From 5344ef4a1a51dec92413c78218083489bcb20542 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 26 Feb 2025 10:46:38 +0000 Subject: [PATCH] Allow pending as an asset status that does not automatically check the asset in Signed-off-by: snipe --- app/Http/Controllers/Api/StatuslabelsController.php | 8 +++++--- app/Http/Controllers/Assets/AssetsController.php | 9 ++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php index 7e4851ff5..b3503ff15 100644 --- a/app/Http/Controllers/Api/StatuslabelsController.php +++ b/app/Http/Controllers/Api/StatuslabelsController.php @@ -290,10 +290,12 @@ class StatuslabelsController extends Controller /** * Returns a boolean response based on whether the status label - * is one that is deployable. + * is one that is deployable or pending. * * This is used by the hardware create/edit view to determine whether - * we should provide a dropdown of users for them to check the asset out to. + * we should provide a dropdown of users for them to check the asset out to, + * and whether we show a warning that the asset will be checked in if it's already + * assigned but the status is changed to one that isn't pending or deployable * * @author [A. Gianotto] [] * @since [v4.0] @@ -301,7 +303,7 @@ class StatuslabelsController extends Controller public function checkIfDeployable($id) : string { $statuslabel = Statuslabel::findOrFail($id); - if ($statuslabel->getStatuslabelType() == 'deployable') { + if (($statuslabel->getStatuslabelType() == 'pending') || ($statuslabel->getStatuslabelType() == 'deployable')) { return '1'; } diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index f3b2de3e7..c8b936425 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -340,15 +340,14 @@ class AssetsController extends Controller $status = Statuslabel::find($request->input('status_id')); - // This is a non-deployable status label - we should check the asset back in. - if (($status && $status->getStatuslabelType() != 'deployable') && ($target = $asset->assignedTo)) { - + // This is an archived or undeployable - we should check the asset back in. + // Pending is allowed here + if (($status) && (($status->getStatuslabelType() != 'pending') || ($status->getStatuslabelType() != 'deployable')) && ($target = $asset->assignedTo)) { $originalValues = $asset->getRawOriginal(); $asset->assigned_to = null; $asset->assigned_type = null; $asset->accepted = null; - - event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update', date('Y-m-d H:i:s'), $originalValues)); + event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update with '.$status->getStatuslabelType().' status', date('Y-m-d H:i:s'), $originalValues)); } if ($asset->assigned_to == '') {