diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index 056df24aa4..873446d420 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -453,34 +453,31 @@ class AssetsController extends Controller return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available')); } $this->authorize('checkout', $asset); - - - // Fetch the target and set the asset's new location_id - if (request('assigned_user')) { - $target = User::find(request('assigned_user')); - $asset->location_id = ($target) ? $target->location_id : ''; - - } elseif (request('assigned_asset')) { - + $admin = Auth::user(); + + // This item is checked out to a location + if (request('checkout_to_type')=='location') { + $target = Location::find(request('assigned_location')); + $asset->location_id = ($target) ? $target->id : ''; + } elseif (request('checkout_to_type')=='asset') { $target = Asset::where('id','!=',$assetId)->find(request('assigned_asset')); $asset->location_id = $target->rtd_location_id; - // Override with the asset's location_id if it has one if ($target->location_id!='') { $asset->location_id = ($target) ? $target->location_id : ''; } - - } elseif (request('assigned_location')) { - $target = Location::find(request('assigned_location')); - $asset->location_id = ($target) ? $target->id : ''; + } else { + // Fetch the target and set the asset's new location_id + $target = User::find(request('assigned_user')); + $asset->location_id = ($target) ? $target->location_id : ''; } + // No valid target was found - error out if (!$target) { return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($asset->getErrors()); } - $admin = Auth::user(); if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) { $checkout_at = Input::get('checkout_at'); @@ -496,7 +493,6 @@ class AssetsController extends Controller if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), Input::get('name'))) { -// Redirect to the new asset page return redirect()->route("hardware.index")->with('success', trans('admin/hardware/message.checkout.success')); } diff --git a/public/js/build/all.js b/public/js/build/all.js index 3bd9f1d7ad..b35517b1c6 100644 Binary files a/public/js/build/all.js and b/public/js/build/all.js differ diff --git a/public/js/dist/all.js b/public/js/dist/all.js index 3bd9f1d7ad..b35517b1c6 100644 Binary files a/public/js/dist/all.js and b/public/js/dist/all.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 790b857a50..48f752751e 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -8,7 +8,7 @@ "/css/app.css.map": "/css/app.css.map?id=bdbe05e6ecd70ccfac72", "/css/overrides.css.map": "/css/overrides.css.map?id=898c91d4a425b01b589b", "/css/dist/all.css": "/css/dist/all.css?id=7c3842d2639193ac7e88", - "/js/dist/all.js": "/js/dist/all.js?id=0d558c3ed637f4c81a77", + "/js/dist/all.js": "/js/dist/all.js?id=c25f257f81287cafe6a3", "/css/build/all.css": "/css/build/all.css?id=7c3842d2639193ac7e88", - "/js/build/all.js": "/js/build/all.js?id=0d558c3ed637f4c81a77" + "/js/build/all.js": "/js/build/all.js?id=c25f257f81287cafe6a3" } \ No newline at end of file diff --git a/resources/assets/js/snipeit.js b/resources/assets/js/snipeit.js index 02dee1a6be..7119bafc79 100755 --- a/resources/assets/js/snipeit.js +++ b/resources/assets/js/snipeit.js @@ -255,8 +255,37 @@ $(document).ready(function () { return datalist.text; } + $(function() { + $('input[name=checkout_to_type]').on("change",function () { + var assignto_type = $('input[name=checkout_to_type]:checked').val(); + var userid = $('#assigned_user option:selected').val(); - + if (assignto_type == 'asset') { + $('#current_assets_box').fadeOut(); + $('#assigned_asset').show(); + $('#assigned_user').hide(); + $('#assigned_location').hide(); + $('.notification-callout').fadeOut(); + + } else if (assignto_type == 'location') { + $('#current_assets_box').fadeOut(); + $('#assigned_asset').hide(); + $('#assigned_user').hide(); + $('#assigned_location').show(); + $('.notification-callout').fadeOut(); + } else { + $('#assigned_asset').hide(); + $('#assigned_user').show(); + $('#assigned_location').hide(); + if (userid) { + $('#current_assets_box').fadeIn(); + } + $('.notification-callout').fadeIn(); + + } + }); + }); + }); diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index a23016adf5..5a8a7a5746 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -40,12 +40,13 @@