mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Added additional permissions for checkin/checkout buttons
This commit is contained in:
parent
00aa06882c
commit
8dbd9fb299
|
@ -42,11 +42,17 @@ class AccessoriesTransformer
|
|||
|
||||
$permissions_array['available_actions'] = [
|
||||
'checkout' => Gate::allows('checkout', Accessory::class) ? true : false,
|
||||
'checkin' => Gate::allows('checkin', Accessory::class) ? true : false,
|
||||
'checkin' => false,
|
||||
'update' => Gate::allows('update', Accessory::class) ? true : false,
|
||||
'delete' => Gate::allows('delete', Accessory::class) ? true : false,
|
||||
];
|
||||
|
||||
$permissions_array['user_can_checkout'] = false;
|
||||
|
||||
if ($accessory->numRemaining() > 0) {
|
||||
$permissions_array['user_can_checkout'] = true;
|
||||
}
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
return $array;
|
||||
|
|
|
@ -49,7 +49,7 @@ class AssetsTransformer
|
|||
'last_checkout' => Helper::getFormattedDateObject($asset->last_checkout, 'datetime'),
|
||||
'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'),
|
||||
'purchase_cost' => $asset->purchase_cost,
|
||||
'can_checkout' => $asset->availableForCheckout(),
|
||||
'user_can_checkout' => $asset->availableForCheckout(),
|
||||
|
||||
];
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class ComponentsAssetsTransformer
|
|||
'name' => e($asset->name),
|
||||
'created_at' => $asset->created_at->format('Y-m-d'),
|
||||
'qty' => $asset->components()->count(),
|
||||
'can_checkout' => $asset->availableForCheckout(),
|
||||
'user_can_checkout' => $asset->availableForCheckout(),
|
||||
];
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
|
@ -36,6 +36,8 @@ class ComponentsAssetsTransformer
|
|||
'delete' => Gate::allows('delete', Asset::class) ? true : false,
|
||||
];
|
||||
|
||||
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
if ($asset->model->fieldset) {
|
||||
|
|
|
@ -39,6 +39,12 @@ class ConsumablesTransformer
|
|||
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
|
||||
];
|
||||
|
||||
$permissions_array['user_can_checkout'] = false;
|
||||
|
||||
if ($consumable->numRemaining() > 0) {
|
||||
$permissions_array['user_can_checkout'] = true;
|
||||
}
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'checkout' => Gate::allows('checkout', Consumable::class) ? true : false,
|
||||
'checkin' => Gate::allows('checkin', Consumable::class) ? true : false,
|
||||
|
|
|
@ -102,6 +102,13 @@ class AccessoryPresenter extends Presenter
|
|||
"sortable" => true,
|
||||
"visible" => false,
|
||||
"title" => trans('general.order_number'),
|
||||
],[
|
||||
"field" => "change",
|
||||
"searchable" => false,
|
||||
"sortable" => false,
|
||||
"visible" => true,
|
||||
"title" => trans('general.change'),
|
||||
"formatter" => "accessoriesInOutFormatter",
|
||||
], [
|
||||
"field" => "actions",
|
||||
"searchable" => false,
|
||||
|
|
123
app/Presenters/ConsumablePresenter.php
Normal file
123
app/Presenters/ConsumablePresenter.php
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
/**
|
||||
* Class ComponentPresenter
|
||||
* @package App\Presenters
|
||||
*/
|
||||
class ConsumablePresenter extends Presenter
|
||||
{
|
||||
|
||||
/**
|
||||
* Json Column Layout for bootstrap table
|
||||
* @return string
|
||||
*/
|
||||
public static function dataTableLayout()
|
||||
{
|
||||
$layout = [
|
||||
[
|
||||
"field" => "id",
|
||||
"searchable" => false,
|
||||
"sortable" => true,
|
||||
"switchable" => true,
|
||||
"title" => trans('general.id'),
|
||||
"visible" => false
|
||||
],
|
||||
[
|
||||
"field" => "company",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"switchable" => true,
|
||||
"title" => trans('general.company'),
|
||||
"visible" => false,
|
||||
"formatter" => 'companiesLinkObjFormatter',
|
||||
],
|
||||
[
|
||||
"field" => "name",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.name'),
|
||||
"visible" => true,
|
||||
"formatter" => 'componentsLinkFormatter',
|
||||
], [
|
||||
"field" => "category",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.category'),
|
||||
"formatter" => "categoriesLinkObjFormatter"
|
||||
],[
|
||||
"field" => "item_no",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('admin/consumables/general.item_no')
|
||||
], [
|
||||
"field" => "qty",
|
||||
"searchable" => false,
|
||||
"sortable" => false,
|
||||
"title" => trans('admin/components/general.total'),
|
||||
"visible" => true,
|
||||
], [
|
||||
"field" => "remaining",
|
||||
"searchable" => false,
|
||||
"sortable" => false,
|
||||
"title" => trans('admin/components/general.remaining'),
|
||||
"visible" => true,
|
||||
], [
|
||||
"field" => "min_amt",
|
||||
"searchable" => false,
|
||||
"sortable" => false,
|
||||
"title" => trans('general.min_amt'),
|
||||
"visible" => true,
|
||||
], [
|
||||
"field" => "order_number",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.order_number'),
|
||||
"visible" => true,
|
||||
],[
|
||||
"field" => "purchase_date",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.purchase_date'),
|
||||
"visible" => true,
|
||||
"formatter" => "dateDisplayFormatter",
|
||||
],[
|
||||
"field" => "purchase_cost",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.purchase_cost'),
|
||||
"visible" => true,
|
||||
],[
|
||||
"field" => "change",
|
||||
"searchable" => false,
|
||||
"sortable" => false,
|
||||
"visible" => true,
|
||||
"title" => trans('general.change'),
|
||||
"formatter" => "consumablesInOutFormatter",
|
||||
], [
|
||||
"field" => "actions",
|
||||
"searchable" => false,
|
||||
"sortable" => false,
|
||||
"switchable" => false,
|
||||
"title" => trans('table.actions'),
|
||||
"visible" => true,
|
||||
"formatter" => "consumablesActionsFormatter",
|
||||
]
|
||||
];
|
||||
|
||||
return json_encode($layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Url to view this item.
|
||||
* @return string
|
||||
*/
|
||||
public function viewUrl()
|
||||
{
|
||||
return route('consumables.show', $this->id);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue