Merge pull request #12242 from inietov/features/add_purchase_cost_column

Added `purchase_cost` to user's default view [sc-19680]
This commit is contained in:
snipe 2022-12-15 12:42:29 -08:00 committed by GitHub
commit d0c5ba70f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 9 deletions

View file

@ -159,6 +159,10 @@ class AuthServiceProvider extends ServiceProvider
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
// in the left-side navigation
Gate::define('backend.interact', function ($user) {

View file

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

View file

@ -387,6 +387,7 @@
data-side-pagination="client"
data-show-columns="true"
data-show-export="true"
data-show-footer="true"
data-show-refresh="true"
data-sort-order="asc"
id="userAssets"
@ -404,7 +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('admin/hardware/table.asset_model') }}</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>
@endcan
@foreach ($field_array as $db_column => $field_name)
<th class="col-md-1" data-switchable="true" data-visible="true">{{ $field_name }}</th>
@endforeach
@ -440,6 +443,12 @@
</td>
<td>{{ $asset->serial }}</td>
@can('self.view_purchase_cost')
<td>
{!! Helper::formatCurrencyOutput($asset->purchase_cost) !!}
</td>
@endcan
@foreach ($field_array as $db_column => $field_value)
<td>
{{ $asset->{$db_column} }}
@ -527,7 +536,9 @@
<thead>
<tr>
<th class="col-md-5">{{ trans('general.name') }}</th>
<th class="col-md-6" data-footer-formatter="sumFormatter" data-fieldname="purchase_cost">{{ trans('general.purchase_cost') }}</th>
@can('self.view_purchase_cost')
<th class="col-md-6" data-footer-formatter="sumFormatter" data-fieldname="purchase_cost">{{ trans('general.purchase_cost') }}</th>
@endcan
<th class="col-md-1 hidden-print">{{ trans('general.action') }}</th>
</tr>
</thead>
@ -535,9 +546,11 @@
@foreach ($user->accessories as $accessory)
<tr>
<td>{{ $accessory->name }}</td>
<td>
{!! Helper::formatCurrencyOutput($accessory->purchase_cost) !!}
</td>
@can('self.view_purchase_cost')
<td>
{!! Helper::formatCurrencyOutput($accessory->purchase_cost) !!}
</td>
@endcan
<td class="hidden-print">
@can('checkin', $accessory)
<a href="{{ route('accessories.checkin.show', array('accessoryID'=> $accessory->pivot->id, 'backto'=>'user')) }}" class="btn btn-primary btn-sm hidden-print">{{ trans('general.checkin') }}</a>
@ -574,7 +587,9 @@
<thead>
<tr>
<th class="col-md-3">{{ trans('general.name') }}</th>
<th class="col-md-2" data-footer-formatter="sumFormatter" data-fieldname="purchase_cost">{{ trans('general.purchase_cost') }}</th>
@can('self.view_purchase_cost')
<th class="col-md-2" data-footer-formatter="sumFormatter" data-fieldname="purchase_cost">{{ trans('general.purchase_cost') }}</th>
@endcan
<th class="col-md-2">{{ trans('general.date') }}</th>
<th class="col-md-5">{{ trans('general.notes') }}</th>
</tr>
@ -583,9 +598,11 @@
@foreach ($user->consumables as $consumable)
<tr>
<td>{{ $consumable->name }}</td>
<td>
{!! Helper::formatCurrencyOutput($consumable->purchase_cost) !!}
</td>
@can('self.view_purchase_cost')
<td>
{!! Helper::formatCurrencyOutput($consumable->purchase_cost) !!}
</td>
@endcan
<td>{{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}</td>
<td>{{ $consumable->pivot->note }}</td>
</tr>