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 @@
{{ Form::label('name', trans('admin/hardware/form.name'), array('class' => 'col-md-3 control-label')) }}
- + {!! $errors->first('name', ' :message') !!}
+ @include ('partials.forms.checkout-selector') - @include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_user']) + @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_user', 'required'=>'true']) @if ($asset->requireAcceptance())
@@ -57,11 +58,10 @@
@else + + @include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.asset'), 'fieldname' => 'assigned_asset', 'unselect' => 'true', 'style' => 'display:none;', 'required'=>'true']) - @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_asset']) - - @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location']) - + @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required'=>'true']) @endif @@ -99,7 +99,7 @@ @if ($asset->requireAcceptance() || $asset->getEula()) -
+
diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index aea6192893..8a2d7d89ed 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -47,11 +47,13 @@ @include ('partials.forms.edit.status') @if (!$item->id) - @include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_user']) + @include ('partials.forms.checkout-selector', ['style' => 'display:none;']) - @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_asset']) + @include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_user', 'style' => 'display:none;']) - @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location']) + @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_asset', 'style' => 'display:none;']) + + @include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location', 'style' => 'display:none;']) @endif @include ('partials.forms.edit.serial', ['translated_serial' => trans('admin/hardware/form.serial')]) @@ -140,15 +142,21 @@ }, success: function (data) { $(".status_spinner").css("display", "none"); + $("#selected_status_status").fadeIn(); if (data == true) { - $("#assigned_user").css("display", "block"); - $("#assigned_location").css("display", "block"); - $("#assigned_asset").css("display", "block"); + $("#assignto_selector").show(); + + $("#selected_status_status").removeClass('text-danger'); + $("#selected_status_status").addClass('text-success'); + $("#selected_status_status").html(' That status is deployable. This asset can be checked out.'); + + } else { - $("#assigned_user").css("display", "none"); - $("#assigned_location").css("display", "none"); - $("#assigned_asset").css("display", "none"); + $("#assignto_selector").hide(); + $("#selected_status_status").removeClass('text-success'); + $("#selected_status_status").addClass('text-danger'); + $("#selected_status_status").html(' That asset status is not deployable. This asset cannot be checked out. '); } } }); diff --git a/resources/views/partials/forms/checkout-selector.blade.php b/resources/views/partials/forms/checkout-selector.blade.php new file mode 100644 index 0000000000..b51a5d09b8 --- /dev/null +++ b/resources/views/partials/forms/checkout-selector.blade.php @@ -0,0 +1,16 @@ +
+ {{ Form::label('name', trans('admin/hardware/form.checkout_to'), array('class' => 'col-md-3 control-label')) }} +
+
+ + + +
+
+
diff --git a/resources/views/partials/forms/edit/asset-select.blade.php b/resources/views/partials/forms/edit/asset-select.blade.php index 5c9e671992..acaff7a345 100644 --- a/resources/views/partials/forms/edit/asset-select.blade.php +++ b/resources/views/partials/forms/edit/asset-select.blade.php @@ -1,10 +1,10 @@ -
+
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }} -
+