snipe-it/app/Presenters/LicensePresenter.php

184 lines
5.6 KiB
PHP
Raw Normal View History

<?php
namespace App\Presenters;
use App\Helpers\Helper;
use Illuminate\Support\Facades\Gate;
/**
* Class LicensePresenter
* @package App\Presenters
*/
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
], [
"field" => "company",
"searchable" => true,
"sortable" => true,
"switchable" => true,
"title" => trans('admin/companies/table.title'),
"visible" => false,
"formatter" => "companiesLinkObjFormatter"
], [
"field" => "name",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/licenses/table.title'),
"formatter" => "licensesLinkFormatter"
], [
"field" => "product_key",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/licenses/form.license_key'),
"formatter" => "licensesLinkFormatter"
], [
"field" => "expiration_date",
"searchable" => true,
"sortable" => true,
2017-03-10 22:09:35 -08:00
"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')
], [
"field" => "license_name",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/licenses/form.to_name'),
], [
"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",
], [
"field" => "seats",
2017-02-10 18:43:30 -08:00
"searchable" => false,
"sortable" => true,
2017-02-10 18:43:30 -08:00
"title" => trans('admin/accessories/general.total'),
], [
"field" => "free_seats_count",
2017-02-10 18:43:30 -08:00
"searchable" => false,
"sortable" => true,
2017-02-10 18:43:30 -08:00
"title" => trans('admin/accessories/general.remaining'),
], [
"field" => "purchase_date",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('general.purchase_date'),
2017-03-10 22:09:35 -08:00
'formatter' => 'dateDisplayFormatter'
2017-02-10 18:43:30 -08:00
], [
"field" => "purchase_cost",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('general.purchase_cost'),
"footerFormatter" => 'sumFormatter',
2017-02-10 18:43:30 -08:00
], [
"field" => "purchase_order",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('admin/licenses/form.purchase_order'),
], [
"field" => "order_number",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('general.order_number'),
2017-10-07 04:42:53 -07:00
], [
"field" => "notes",
"searchable" => true,
"sortable" => true,
"visible" => false,
"title" => trans('general.notes'),
2017-02-10 18:43:30 -08:00
]
];
$layout[] = [
"field" => "checkincheckout",
"searchable" => false,
"sortable" => false,
"switchable" => true,
2018-01-23 18:13:55 -08:00
"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);
}
2017-02-10 18:43:30 -08:00
/**
* 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);
}
}