A free open source IT asset/license management system
adds a seperate formatter for checking out on license index, fix interactions
Godfrey Md5175961a41f
diff --git a/app/Http/Transformers/LicensesTransformer.php b/app/Http/Transformers/LicensesTransformer.phpindex e3fa1776e1..39079c6ec5 100644--- a/app/Http/Transformers/LicensesTransformer.php+++ b/app/Http/Transformers/LicensesTransformer.php@@ -58,7 +58,7 @@ class LicensesTransformer];$permissions_array['available_actions'] = [- 'checkout' => Gate::allows('checkout', $license),+ 'checkout' => Gate::allows('checkout', License::class),'checkin' => Gate::allows('checkin', License::class),'clone' => Gate::allows('create', License::class),'update' => Gate::allows('update', License::class),diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.phpindex 6975a58d88..a1edf2cf76 100644--- a/app/Presenters/LicensePresenter.php+++ b/app/Presenters/LicensePresenter.php@@ -202,7 +202,7 @@ class LicensePresenter extends Presenter'switchable' => false,'title' => trans('general.checkin').'/'.trans('general.checkout'),'visible' => true,- 'formatter' => 'licenseSeatInOutFormatter',+ 'formatter' => 'licenseInOutFormatter','printIgnore' => true,];diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex b325e89f1b..7c3468537d 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -556,21 +556,30 @@}}-+ function licenseInOutFormatter(value, row) {+ if(row.disabled || row.user_can_checkout === false) {+ return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-maroon disabled" data-tooltip="true" title="{{ trans('general.checkin_tooltip') }}">{{ trans('general.checkout') }}</a>';+ } else+ // The user is allowed to check the license seat out and it's available+ if ((row.available_actions.checkout === true) && (row.user_can_checkout === true)) {+ return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkout/'+row.id+'" class="btn btn-sm bg-maroon" data-tooltip="true" title="{{ trans('general.checkout_tooltip') }}">{{ trans('general.checkout') }}</a>';+ }+ }// We need a special formatter for license seats, since they don't work exactly the same// Checkouts need the license ID, checkins need the specific seat IDfunction licenseSeatInOutFormatter(value, row) {+ if (row.disabled && (row.assigned_user || row.assigned_asset)) {+ return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="{{ trans('general.checkin_tooltip') }}">{{ trans('general.checkin') }}</a>';+ }if(row.disabled) {return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-maroon disabled" data-tooltip="true" title="{{ trans('general.checkin_tooltip') }}">{{ trans('general.checkout') }}</a>';- } else+ }// The user is allowed to check the license seat out and it's available- if ((row.available_actions.checkout === true) && (row.user_can_checkout === true) && ((!row.asset_id) && (!row.assigned_to))) {+ if ((row.available_actions.checkout === true) && (row.user_can_checkout === true) && ((!row.assigned_asset) && (!row.assigned_user))) {return '<a href="{{ config('app.url') }}/licenses/' + row.license_id + '/checkout/'+row.id+'" class="btn btn-sm bg-maroon" data-tooltip="true" title="{{ trans('general.checkout_tooltip') }}">{{ trans('general.checkout') }}</a>';}- else {- return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="{{ trans('general.checkin_tooltip') }}">{{ trans('general.checkin') }}</a>';- }+}function genericCheckinCheckoutFormatter(destination) {