snipe-it/app/Presenters/LicensePresenter.php

329 lines
11 KiB
PHP
Raw Normal View History

<?php
namespace App\Presenters;
/**
* Class LicensePresenter
*/
class LicensePresenter extends Presenter
{
/**
2017-02-10 18:43:30 -08:00
* Json Column Layout for bootstrap table
* @return string
*/
2017-02-10 18:43:30 -08:00
public static function dataTableLayout()
{
2017-02-10 18:43:30 -08:00
$layout = [
[
'field' => 'id',
'searchable' => false,
'sortable' => true,
'switchable' => true,
'title' => trans('general.id'),
'visible' => false,
2017-02-10 18:43:30 -08:00
], [
'field' => 'company',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('admin/companies/table.title'),
'visible' => false,
'formatter' => 'companiesLinkObjFormatter',
2017-02-10 18:43:30 -08:00
], [
'field' => 'name',
'searchable' => true,
'sortable' => true,
'title' => trans('general.name'),
'formatter' => 'licensesLinkFormatter',
2017-02-10 18:43:30 -08:00
], [
'field' => 'product_key',
'searchable' => true,
'sortable' => true,
'title' => trans('admin/licenses/form.license_key'),
'formatter' => 'licensesLinkFormatter',
2017-02-10 18:43:30 -08:00
], [
'field' => 'expiration_date',
'searchable' => true,
'sortable' => true,
'title' => trans('admin/licenses/form.expiration'),
'formatter' => 'dateDisplayFormatter',
2017-02-10 18:43:30 -08:00
], [
'field' => 'license_email',
'searchable' => true,
'sortable' => true,
'title' => trans('admin/licenses/form.to_email'),
2017-02-10 18:43:30 -08:00
], [
'field' => 'license_name',
'searchable' => true,
'sortable' => true,
'title' => trans('admin/licenses/form.to_name'),
2018-05-04 21:01:38 -07:00
], [
'field' => 'category',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.category'),
'visible' => false,
'formatter' => 'categoriesLinkObjFormatter',
], [
'field' => 'supplier',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.supplier'),
'visible' => false,
'formatter' => 'suppliersLinkObjFormatter',
2017-02-10 18:43:30 -08:00
], [
'field' => 'manufacturer',
'searchable' => true,
'sortable' => true,
'title' => trans('general.manufacturer'),
'formatter' => 'manufacturersLinkObjFormatter',
2017-02-10 18:43:30 -08:00
], [
'field' => 'seats',
'searchable' => false,
'sortable' => true,
'title' => trans('admin/accessories/general.total'),
2017-02-10 18:43:30 -08:00
], [
'field' => 'free_seats_count',
'searchable' => false,
'sortable' => true,
'title' => trans('admin/accessories/general.remaining'),
],
[
'field' => 'min_amt',
'searchable' => false,
'sortable' => true,
'title' => trans('mail.min_QTY'),
'formatter' => 'minAmtFormatter',
],[
'field' => 'purchase_date',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.purchase_date'),
'formatter' => 'dateDisplayFormatter',
],
[
'field' => 'termination_date',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('admin/licenses/form.termination_date'),
'formatter' => 'dateDisplayFormatter',
],
[
'field' => 'depreciation',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('admin/hardware/form.depreciation'),
'visible' => false,
'formatter' => 'depreciationsLinkObjFormatter',
],
[
'field' => 'maintained',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('admin/licenses/form.maintained'),
'formatter' => 'trueFalseFormatter',
], [
'field' => 'reassignable',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('admin/licenses/form.reassignable'),
'formatter' => 'trueFalseFormatter',
],
[
'field' => 'purchase_cost',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.purchase_cost'),
'footerFormatter' => 'sumFormatterQuantity',
'class' => 'text-right',
2017-02-10 18:43:30 -08:00
], [
'field' => 'purchase_order',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('admin/licenses/form.purchase_order'),
2017-02-10 18:43:30 -08:00
], [
'field' => 'order_number',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.order_number'),
2017-10-07 04:42:53 -07:00
], [
2023-04-27 16:19:53 -07:00
'field' => 'created_at',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('general.created_at'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('general.updated_at'),
'formatter' => 'dateDisplayFormatter',
],
[
'field' => 'notes',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.notes'),
'formatter' => 'notesFormatter',
],
];
$layout[] = [
'field' => 'checkincheckout',
'searchable' => false,
'sortable' => false,
'switchable' => true,
'title' => trans('general.checkin').'/'.trans('general.checkout'),
'visible' => true,
'formatter' => 'licensesInOutFormatter',
];
$layout[] = [
'field' => 'actions',
'searchable' => false,
'sortable' => false,
'switchable' => false,
'title' => trans('table.actions'),
'formatter' => 'licensesActionsFormatter',
];
2017-02-10 18:43:30 -08:00
return json_encode($layout);
}
/**
* Json Column Layout for bootstrap table
* @return string
*/
public static function dataTableLayoutSeats()
{
$layout = [
[
'field' => 'id',
'searchable' => false,
'sortable' => true,
'switchable' => true,
'title' => trans('general.id'),
'visible' => false,
],
[
'field' => 'name',
'searchable' => false,
'sortable' => false,
'sorter' => 'numericOnly',
'switchable' => true,
'title' => trans('admin/licenses/general.seat'),
'visible' => true,
], [
'field' => 'assigned_user',
'searchable' => false,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/licenses/general.user'),
'visible' => true,
'formatter' => 'usersLinkObjFormatter',
2023-12-18 15:26:47 -08:00
], [
2023-12-18 17:15:06 -08:00
'field' => 'assigned_user.email',
2023-12-18 15:26:47 -08:00
'searchable' => false,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/users/table.email'),
'visible' => true,
'formatter' => 'emailFormatter',
], [
'field' => 'department',
'searchable' => false,
'sortable' => true,
'switchable' => true,
'title' => trans('general.department'),
'visible' => false,
'formatter' => 'departmentNameLinkFormatter',
2023-12-18 15:26:47 -08:00
], [
'field' => 'assigned_asset',
'searchable' => false,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/licenses/form.asset'),
'visible' => true,
'formatter' => 'hardwareLinkObjFormatter',
], [
'field' => 'location',
'searchable' => false,
'sortable' => false,
'switchable' => true,
'title' => trans('general.location'),
'visible' => true,
'formatter' => 'locationsLinkObjFormatter',
],
[
'field' => 'notes',
'searchable' => false,
'sortable' => false,
'visible' => false,
'title' => trans('general.notes'),
'formatter' => 'notesFormatter'
],
[
'field' => 'checkincheckout',
'searchable' => false,
'sortable' => false,
'switchable' => true,
'title' => trans('general.checkin').'/'.trans('general.checkout'),
'visible' => true,
'formatter' => 'licenseSeatInOutFormatter',
],
];
return json_encode($layout);
}
/**
* Link to this licenses Name
* @return string
*/
public function nameUrl()
{
return (string) link_to_route('licenses.show', $this->name, $this->id);
}
/**
* Link to this licenses Name
* @return string
*/
public function fullName()
{
2017-09-29 12:03:12 -07:00
return $this->name;
}
/**
* Link to this licenses serial
* @return string
*/
public function serialUrl()
{
return (string) link_to('/licenses/'.$this->id, mb_strimwidth($this->serial, 0, 50, '...'));
}
/**
* Url to view this item.
* @return string
*/
public function viewUrl()
{
return route('licenses.show', $this->id);
}
}