From 716f5080678a0493fc51d4350f9bcc966532a71a Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 14 Nov 2024 21:38:22 +0000 Subject: [PATCH] Fixed #15320 - add deployable status to bulk checkout Signed-off-by: snipe --- app/Http/Controllers/Assets/BulkAssetsController.php | 9 +++++++-- resources/views/hardware/bulk-checkout.blade.php | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 93f7255c0bf1..90745a4a11c8 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -548,7 +548,7 @@ public function destroy(Request $request) : RedirectResponse public function showCheckout() : View { $this->authorize('checkout', Asset::class); - return view('hardware/bulk-checkout'); + return view('hardware/bulk-checkout')->with('statusLabel_list', Helper::deployableStatusLabelList()); } /** @@ -577,6 +577,7 @@ public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse } } } + $checkout_at = date('Y-m-d H:i:s'); if (($request->filled('checkout_at')) && ($request->get('checkout_at') != date('Y-m-d'))) { $checkout_at = e($request->get('checkout_at')); @@ -589,11 +590,15 @@ public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse } $errors = []; - DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $asset_ids, $request) { //NOTE: $errors is passsed by reference! + DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $asset_ids, $request) { //NOTE: $errors is passed by reference! foreach ($asset_ids as $asset_id) { $asset = Asset::findOrFail($asset_id); $this->authorize('checkout', $asset); + if ($request->filled('status_id')) { + $asset->status_id = $request->input('status_id'); + } + $checkout_success = $asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $asset->name, null); //TODO - I think this logic is duplicated in the checkOut method? diff --git a/resources/views/hardware/bulk-checkout.blade.php b/resources/views/hardware/bulk-checkout.blade.php index 39e2cdf10cbf..bd876bdee095 100644 --- a/resources/views/hardware/bulk-checkout.blade.php +++ b/resources/views/hardware/bulk-checkout.blade.php @@ -47,6 +47,17 @@ @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;']) @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'style' => 'display:none;']) + +
+ +
+ {{ Form::select('status_id', $statusLabel_list, '', array('class'=>'select2', 'style'=>'width:100%','', 'aria-label'=>'status_id')) }} + {!! $errors->first('status_id', '') !!} +
+
+