Skip to content

Commit 716f508

Browse files
committed
Fixed #15320 - add deployable status to bulk checkout
Signed-off-by: snipe <[email protected]>
1 parent 09b7db5 commit 716f508

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/Http/Controllers/Assets/BulkAssetsController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public function destroy(Request $request) : RedirectResponse
548548
public function showCheckout() : View
549549
{
550550
$this->authorize('checkout', Asset::class);
551-
return view('hardware/bulk-checkout');
551+
return view('hardware/bulk-checkout')->with('statusLabel_list', Helper::deployableStatusLabelList());
552552
}
553553

554554
/**
@@ -577,6 +577,7 @@ public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse
577577
}
578578
}
579579
}
580+
580581
$checkout_at = date('Y-m-d H:i:s');
581582
if (($request->filled('checkout_at')) && ($request->get('checkout_at') != date('Y-m-d'))) {
582583
$checkout_at = e($request->get('checkout_at'));
@@ -589,11 +590,15 @@ public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse
589590
}
590591

591592
$errors = [];
592-
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $asset_ids, $request) { //NOTE: $errors is passsed by reference!
593+
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $asset_ids, $request) { //NOTE: $errors is passed by reference!
593594
foreach ($asset_ids as $asset_id) {
594595
$asset = Asset::findOrFail($asset_id);
595596
$this->authorize('checkout', $asset);
596597

598+
if ($request->filled('status_id')) {
599+
$asset->status_id = $request->input('status_id');
600+
}
601+
597602
$checkout_success = $asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $asset->name, null);
598603

599604
//TODO - I think this logic is duplicated in the checkOut method?

resources/views/hardware/bulk-checkout.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@
4747
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.asset'), 'asset_selector_div_id' => 'assigned_asset', 'fieldname' => 'assigned_asset', 'unselect' => 'true', 'style' => 'display:none;'])
4848
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'style' => 'display:none;'])
4949

50+
<!-- Status -->
51+
<div class="form-group {{ $errors->has('status_id') ? 'error' : '' }}">
52+
<label for="status_id" class="col-md-3 control-label">
53+
{{ trans('admin/hardware/form.status') }}
54+
</label>
55+
<div class="col-md-7">
56+
{{ Form::select('status_id', $statusLabel_list, '', array('class'=>'select2', 'style'=>'width:100%','', 'aria-label'=>'status_id')) }}
57+
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
58+
</div>
59+
</div>
60+
5061
<!-- Checkout/Checkin Date -->
5162
<div class="form-group {{ $errors->has('checkout_at') ? 'error' : '' }}">
5263
<label for="checkout_at" class="col-sm-3 control-label">

0 commit comments

Comments
 (0)