From 6161a0d76dbe023a8a9b839f877c1d4e5a49596c Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 23 Aug 2023 16:22:40 -0600 Subject: [PATCH 1/2] Add condition in LicenseCheckinController:bulkCheckin method to evaluate if the license is reassignable --- app/Http/Controllers/Licenses/LicenseCheckinController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/Licenses/LicenseCheckinController.php b/app/Http/Controllers/Licenses/LicenseCheckinController.php index 50e20c7985..53c9a2f611 100644 --- a/app/Http/Controllers/Licenses/LicenseCheckinController.php +++ b/app/Http/Controllers/Licenses/LicenseCheckinController.php @@ -128,6 +128,13 @@ class LicenseCheckinController extends Controller $license = License::findOrFail($licenseId); $this->authorize('checkin', $license); + if (! $license->reassignable) { + // Not allowed to checkin + Session::flash('error', 'License not reassignable.'); + + return redirect()->back()->withInput(); + } + $licenseSeatsByUser = LicenseSeat::where('license_id', '=', $licenseId) ->whereNotNull('assigned_to') ->with('user') From 7bfb5a0667ba361bcd1f162ea094a456f00af92a Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 23 Aug 2023 16:36:06 -0600 Subject: [PATCH 2/2] Disable the Checkin All Seats button if License is not reassignable --- resources/lang/en/admin/licenses/general.php | 1 + resources/views/licenses/view.blade.php | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/lang/en/admin/licenses/general.php b/resources/lang/en/admin/licenses/general.php index 0187d076a3..b2766d063e 100644 --- a/resources/lang/en/admin/licenses/general.php +++ b/resources/lang/en/admin/licenses/general.php @@ -26,6 +26,7 @@ return array( 'modal' => 'This will action checkin one seat. | This action will checkin all :checkedout_seats_count seats for this license.', 'enabled_tooltip' => 'Checkin ALL seats for this license from both users and assets', 'disabled_tooltip' => 'This is disabled because there are no seats currently checked out', + 'disabled_tooltip_reassignable' => 'This is disabled because the License is not reassignable', 'success' => 'License successfully checked in! | All licenses were successfully checked in!', 'log_msg' => 'Checked in via bulk license checkout in license GUI', ], diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php index 8dcf10caf2..950ba1af2c 100755 --- a/resources/views/licenses/view.blade.php +++ b/resources/views/licenses/view.blade.php @@ -577,17 +577,23 @@ @endcan @can('checkin', $license) - - @if (($license->seats - $license->availCount()->count()) > 0 ) - - {{ trans('admin/licenses/general.bulk.checkin_all.button') }} - - @else + + @if (($license->seats - $license->availCount()->count()) <= 0 ) {{ trans('admin/licenses/general.bulk.checkin_all.button') }} - + + @elseif (! $license->reassignable) + + + {{ trans('admin/licenses/general.bulk.checkin_all.button') }} + + + @else + + {{ trans('admin/licenses/general.bulk.checkin_all.button') }} + @endif @endcan