Skip to content

Commit 426c81a

Browse files
committed
prevents bulk checkout of undeployable assets
1 parent 5e61a81 commit 426c81a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

app/Http/Controllers/Assets/BulkAssetsController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ public function edit(Request $request) : View | RedirectResponse
5353

5454
$asset_ids = $request->input('ids');
5555
if ($request->input('bulk_actions') === 'checkout') {
56+
$undeployable_assets = Asset::whereIn('id', $asset_ids)
57+
->whereHas('assetStatus', function ($query){
58+
$query->where('deployable', 0);
59+
})
60+
->get();
61+
if($undeployable_assets->count() > 0) {
62+
return redirect()->back()->with('error', trans_choice('admin/hardware/form.bulk_asset_undeployable', $undeployable_assets->count()));
63+
}
5664
$request->session()->flashInput(['selected_assets' => $asset_ids]);
5765
return redirect()->route('hardware.bulkcheckout.show');
5866
}

resources/lang/en-US/admin/hardware/form.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
'asset_location_update_actual' => 'Update only actual location',
5757
'asset_not_deployable' => 'That asset status is not deployable. This asset cannot be checked out.',
5858
'asset_not_deployable_checkin' => 'That asset status is not deployable. Using this status label will checkin the asset.',
59+
'bulk_asset_undeployable' => 'Asset in this bulk checkout request is undeployable.|[2,*]Assets in this bulk checkout request are undeployable.',
5960
'asset_deployable' => 'This asset can be checked out.',
6061
'processing_spinner' => 'Processing... (This might take a bit of time on large files)',
6162
'optional_infos' => 'Optional Information',

0 commit comments

Comments
 (0)