Disallow checkout asset to itself

This commit is contained in:
snipe 2018-02-23 05:52:19 -08:00
parent 103974cae4
commit 5e5ba54c3e

View file

@ -460,8 +460,14 @@ class AssetsController extends Controller
$asset->location_id = ($target) ? $target->id : ''; $asset->location_id = ($target) ? $target->id : '';
} elseif (request('checkout_to_type')=='asset') { } elseif (request('checkout_to_type')=='asset') {
if (request('assigned_asset') == $assetId) {
return redirect()->back()->with('error', 'You cannot check an asset out to itself.');
}
$target = Asset::where('id','!=',$assetId)->find(request('assigned_asset')); $target = Asset::where('id','!=',$assetId)->find(request('assigned_asset'));
$asset->location_id = $target->rtd_location_id; $asset->location_id = $target->rtd_location_id;
// Override with the asset's location_id if it has one // Override with the asset's location_id if it has one
if ($target->location_id!='') { if ($target->location_id!='') {
$asset->location_id = ($target) ? $target->location_id : ''; $asset->location_id = ($target) ? $target->location_id : '';