2019-05-05 19:32:52 -07:00
|
|
|
<?php
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2019-05-05 19:32:52 -07:00
|
|
|
namespace App\Presenters;
|
|
|
|
|
|
|
|
use App\Models\CustomField;
|
|
|
|
use DateTime;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AssetPresenter
|
|
|
|
*/
|
|
|
|
class AssetAuditPresenter extends Presenter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Json Column Layout for bootstrap table
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function dataTableLayout()
|
|
|
|
{
|
|
|
|
$layout = [
|
|
|
|
[
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'id',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.id'),
|
|
|
|
'visible' => false,
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'company',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('general.company'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'assetCompanyObjFilterFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'name',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/form.name'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'hardwareLinkFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'image',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => trans('admin/hardware/table.image'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'imageFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'asset_tag',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/table.asset_tag'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'hardwareLinkFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'serial',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/form.serial'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'hardwareLinkFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'model',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/form.model'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'modelsLinkObjFormatter',
|
|
|
|
], [
|
|
|
|
'field' => 'model_number',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/models/table.modelnumber'),
|
|
|
|
'visible' => false,
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'category',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('general.category'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'categoriesLinkObjFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'status_label',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/table.status'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'statuslabelsLinkObjFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'assigned_to',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/form.checkedout_to'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'polymorphicItemFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'location',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/table.location'),
|
|
|
|
'visible' => true,
|
|
|
|
'formatter' => 'deployedLocationFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'rtd_location',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('admin/hardware/form.default_location'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'deployedLocationFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'manufacturer',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'title' => trans('general.manufacturer'),
|
|
|
|
'visible' => false,
|
|
|
|
'formatter' => 'manufacturersLinkObjFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'purchase_date',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.purchase_date'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'purchase_cost',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.purchase_cost'),
|
|
|
|
'footerFormatter' => 'sumFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'order_number',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.order_number'),
|
|
|
|
'formatter' => 'orderNumberObjFilterFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'eol',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => false,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.eol'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'warranty_months',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('admin/hardware/form.warranty'),
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'warranty_expires',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => false,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('admin/hardware/form.warranty_expires'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
|
|
|
], [
|
|
|
|
'field' => 'notes',
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.notes'),
|
2019-05-05 19:32:52 -07:00
|
|
|
|
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'checkout_counter',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.checkouts_count'),
|
2019-05-05 19:32:52 -07:00
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
], [
|
|
|
|
'field' => 'checkin_counter',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.checkins_count'),
|
2019-05-05 19:32:52 -07:00
|
|
|
|
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'requests_counter',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.user_requests_count'),
|
2019-05-05 19:32:52 -07:00
|
|
|
|
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'created_at',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.created_at'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'updated_at',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('general.updated_at'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'last_checkout',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('admin/hardware/table.checkout_date'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'expected_checkin',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'title' => trans('admin/hardware/form.expected_checkin'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'last_audit_date',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => true,
|
|
|
|
'title' => trans('general.last_audit'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
], [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'next_audit_date',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => true,
|
|
|
|
'title' => trans('general.next_audit_date'),
|
|
|
|
'formatter' => 'dateDisplayFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
// This looks complicated, but we have to confirm that the custom fields exist in custom fieldsets
|
|
|
|
// *and* those fieldsets are associated with models, otherwise we'll trigger
|
|
|
|
// javascript errors on the bootstrap tables side of things, since we're asking for properties
|
|
|
|
// on fields that will never be passed through the REST API since they're not associated with
|
|
|
|
// models. We only pass the fieldsets that pertain to each asset (via their model) so that we
|
|
|
|
// don't junk up the REST API with tons of custom fields that don't apply
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
$fields = CustomField::whereHas('fieldset', function ($query) {
|
2019-05-05 19:32:52 -07:00
|
|
|
$query->whereHas('models');
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
foreach ($fields as $field) {
|
|
|
|
$layout[] = [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'custom_fields.'.$field->convertUnicodeDbSlug(),
|
|
|
|
'searchable' => true,
|
|
|
|
'sortable' => true,
|
|
|
|
'visible' => false,
|
|
|
|
'switchable' => true,
|
|
|
|
'title' => ($field->field_encrypted == '1') ? '<i class="fa fa-lock"></i> '.e($field->name) : e($field->name),
|
|
|
|
'formatter' => 'customFieldsFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$layout[] = [
|
2021-06-10 13:15:52 -07:00
|
|
|
'field' => 'actions',
|
|
|
|
'searchable' => false,
|
|
|
|
'sortable' => false,
|
|
|
|
'switchable' => false,
|
|
|
|
'title' => trans('table.actions'),
|
|
|
|
'formatter' => 'hardwareAuditFormatter',
|
2019-05-05 19:32:52 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
return json_encode($layout);
|
|
|
|
}
|
|
|
|
}
|