Add the permission to show purchase cost column to non-admin sessions

This commit is contained in:
Ivan Nieto Vivanco 2022-12-14 23:00:35 -06:00
parent 450ad3dcec
commit b142f8e012
3 changed files with 17 additions and 2 deletions

View file

@ -159,6 +159,10 @@ class AuthServiceProvider extends ServiceProvider
return $user->hasAccess('self.checkout_assets'); return $user->hasAccess('self.checkout_assets');
}); });
Gate::define('self.view_purchase_cost', function ($user) {
return $user->hasAccess('self.view_purchase_cost');
});
// This is largely used to determine whether to display the gear icon sidenav // This is largely used to determine whether to display the gear icon sidenav
// in the left-side navigation // in the left-side navigation
Gate::define('backend.interact', function ($user) { Gate::define('backend.interact', function ($user) {

View file

@ -645,6 +645,13 @@ return [
'display' => true, 'display' => true,
], ],
[
'permission' => 'self.view_purchase_cost',
'label' => 'View Purchase-Cost Column',
'note' => 'This user can see the purchase cost column of assets assigned to them.',
'display' => true,
],
], ],
]; ];

View file

@ -405,8 +405,9 @@
<th class="col-md-2" data-switchable="true" data-visible="true">{{ trans('general.name') }}</th> <th class="col-md-2" data-switchable="true" data-visible="true">{{ trans('general.name') }}</th>
<th class="col-md-2" data-switchable="true" data-visible="true">{{ trans('admin/hardware/table.asset_model') }}</th> <th class="col-md-2" data-switchable="true" data-visible="true">{{ trans('admin/hardware/table.asset_model') }}</th>
<th class="col-md-3" data-switchable="true" data-visible="true">{{ trans('admin/hardware/table.serial') }}</th> <th class="col-md-3" data-switchable="true" data-visible="true">{{ trans('admin/hardware/table.serial') }}</th>
@can('self.view_purchase_cost')
<th class="col-md-6" data-footer-formatter="sumFormatter" data-fieldname="purchase_cost">{{ trans('general.purchase_cost') }}</th> <th class="col-md-6" data-footer-formatter="sumFormatter" data-fieldname="purchase_cost">{{ trans('general.purchase_cost') }}</th>
@endcan
@foreach ($field_array as $db_column => $field_name) @foreach ($field_array as $db_column => $field_name)
<th class="col-md-1" data-switchable="true" data-visible="true">{{ $field_name }}</th> <th class="col-md-1" data-switchable="true" data-visible="true">{{ $field_name }}</th>
@endforeach @endforeach
@ -441,9 +442,12 @@
@endif @endif
</td> </td>
<td>{{ $asset->serial }}</td> <td>{{ $asset->serial }}</td>
@can('self.view_purchase_cost')
<td> <td>
{!! Helper::formatCurrencyOutput($asset->purchase_cost) !!} {!! Helper::formatCurrencyOutput($asset->purchase_cost) !!}
</td> </td>
@endcan
@foreach ($field_array as $db_column => $field_value) @foreach ($field_array as $db_column => $field_value)
<td> <td>