diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index cb4fa5fa5b32..e5446477cf4f 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -621,9 +621,25 @@ public function showCheckout() : View { $this->authorize('checkout', Asset::class); + $alreadyAssigned = collect(); + + if (old('selected_assets') && is_array(old('selected_assets'))) { + $assets = Asset::findMany(old('selected_assets')); + + [$assignable, $alreadyAssigned] = $assets->partition(function (Asset $asset) { + return !$asset->assigned_to; + }); + + session()->flashInput(['selected_assets' => $assignable->pluck('id')->values()->toArray()]); + } + $do_not_change = ['' => trans('general.do_not_change')]; $status_label_list = $do_not_change + Helper::deployableStatusLabelList(); - return view('hardware/bulk-checkout')->with('statusLabel_list', $status_label_list); + + return view('hardware/bulk-checkout', [ + 'statusLabel_list' => $status_label_list, + 'removed_assets' => $alreadyAssigned, + ]); } /** diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 3d7b8ca6bf82..630442c90fff 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -522,6 +522,7 @@ 'error_user_company_multiple' => 'One or more of the checkout target company and asset company do not match', 'error_user_company_accept_view' => 'An Asset assigned to you belongs to a different company so you can\'t accept nor deny it, please check with your manager', 'error_assets_already_checked_out' => 'One or more of the assets are already checked out', + 'assigned_assets_removed' => 'The following were removed from the selected assets because they are already checked out', 'importer' => [ 'checked_out_to_fullname' => 'Checked Out to: Full Name', 'checked_out_to_first_name' => 'Checked Out to: First Name', diff --git a/resources/views/hardware/bulk-checkout.blade.php b/resources/views/hardware/bulk-checkout.blade.php index 4b6d26b02741..7fbcbee39b36 100644 --- a/resources/views/hardware/bulk-checkout.blade.php +++ b/resources/views/hardware/bulk-checkout.blade.php @@ -27,6 +27,26 @@