A free open source IT asset/license management system
Adds a check to know if the asset is checked out to the logged in user to allow check the state int the view
Ivan Nieto Vivanco35ffe8b90230
diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.phpindex 400a5dd111..bb75b9868c 100644--- a/app/Http/Transformers/AssetsTransformer.php+++ b/app/Http/Transformers/AssetsTransformer.php@@ -185,12 +185,12 @@ class AssetsTransformer'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'),'location' => ($asset->location) ? e($asset->location->name) : null,'status'=> ($asset->assetstatus) ? $asset->present()->statusMeta : null,+ 'assigned_to_self' => ($asset->assigned_to == \Auth::user()->id),];$permissions_array['available_actions'] = ['cancel' => ($asset->isRequestedBy(\Auth::user())) ? true : false,'request' => ($asset->isRequestedBy(\Auth::user())) ? false : true,-];$array += $permissions_array;diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex 13de846d39..60dbd1bece 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -333,7 +333,9 @@// This is only used by the requestable assets sectionfunction assetRequestActionsFormatter (row, value) {- if (value.available_actions.cancel == true) {+ if (value.assigned_to_self == true){+ return '<button class="btn btn-danger btn-sm disabled" data-toggle="tooltip" title="Cancel this item request">{{ trans('button.cancel') }}</button>';+ } else if (value.available_actions.cancel == true) {return '<form action="{{ url('/') }}/account/request-asset/'+ value.id + '" method="GET"><button class="btn btn-danger btn-sm" data-toggle="tooltip" title="Cancel this item request">{{ trans('button.cancel') }}</button></form>';} else if (value.available_actions.request == true) {return '<form action="{{ url('/') }}/account/request-asset/'+ value.id + '" method="GET"><button class="btn btn-primary btn-sm" data-toggle="tooltip" title="Request this item">{{ trans('button.request') }}</button></form>';