diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 59b22b386d..d162b9a98d 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Assets; +use App\Events\CheckoutableCheckedIn; use App\Helpers\Helper; use App\Http\Controllers\Controller; use App\Http\Requests\ImageUploadRequest; @@ -336,8 +337,14 @@ class AssetsController extends Controller $status = Statuslabel::find($asset->status_id); - if ($status && $status->archived) { + // This is a non-deployable status label - we should check the asset back in. + if (($status && $status->getStatuslabelType() != 'deployable') && (is_null($target = $asset->assignedTo))) { + + $originalValues = $asset->getRawOriginal(); $asset->assigned_to = null; + $asset->assigned_type = null; + + event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update', date('Y-m-d H:i:s'), $originalValues)); } if ($asset->assigned_to == '') { diff --git a/resources/lang/en-US/admin/hardware/form.php b/resources/lang/en-US/admin/hardware/form.php index edec543637..03b8f04add 100644 --- a/resources/lang/en-US/admin/hardware/form.php +++ b/resources/lang/en-US/admin/hardware/form.php @@ -55,6 +55,7 @@ return [ 'asset_location_update_default' => 'Update only default location', 'asset_location_update_actual' => 'Update only actual location', 'asset_not_deployable' => 'That asset status is not deployable. This asset cannot be checked out.', + 'asset_not_deployable_checkin' => 'That asset status is not deployable. Using this status label will checkin the asset.', 'asset_deployable' => 'That status is deployable. This asset can be checked out.', 'processing_spinner' => 'Processing... (This might take a bit of time on large files)', 'optional_infos' => 'Optional Information', diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index bdbc3c3c2e..b756187fdd 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -263,7 +263,7 @@ $("#assignto_selector").hide(); $("#selected_status_status").removeClass('text-success'); $("#selected_status_status").addClass('text-danger'); - $("#selected_status_status").html(' {{ trans('admin/hardware/form.asset_not_deployable')}} '); + $("#selected_status_status").html(' {{ (($item->assignedTo) && ($item->deleted_at == '')) ? trans('admin/hardware/form.asset_not_deployable_checkin') : trans('admin/hardware/form.asset_not_deployable') }} '); } } });