diff --git a/app/Http/Transformers/LicensesTransformer.php b/app/Http/Transformers/LicensesTransformer.php
index 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.php
index 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.php
index 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 '{{ trans('general.checkout') }}';
+ } 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 '{{ trans('general.checkout') }}';
+ }
+ }
// 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 ID
function licenseSeatInOutFormatter(value, row) {
+ if (row.disabled && (row.assigned_user || row.assigned_asset)) {
+ return '{{ trans('general.checkin') }}';
+ }
if(row.disabled) {
return '{{ trans('general.checkout') }}';
- } 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 '{{ trans('general.checkout') }}';
}
- else {
- return '{{ trans('general.checkin') }}';
- }
+
}
function genericCheckinCheckoutFormatter(destination) {