Added asset presenter, fixed asset maintenances button in asset view

This commit is contained in:
snipe 2018-03-26 14:49:49 -07:00
parent 46f5f21368
commit 0134ec7b04
3 changed files with 121 additions and 37 deletions

View file

@ -0,0 +1,119 @@
<?php
/**
* Created by PhpStorm.
* User: parallelgrapefruit
* Date: 12/23/16
* Time: 12:15 PM
*/
namespace App\Presenters;
use App\Helpers\Helper;
/**
* Class AssetModelPresenter
* @package App\Presenters
*/
class AssetMaintenancesPresenter 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('admin/companies/table.title'),
"visible" => false,
"formatter" => "companiesLinkObjFormatter"
], [
"field" => "asset_name",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/asset_maintenances/table.asset_name'),
"formatter" => "assetNameLinkFormatter"
],[
"field" => "asset_tag",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/hardware/table.asset_tag'),
"formatter" => "assetTagLinkFormatter"
], [
"field" => "supplier",
"searchable" => true,
"sortable" => true,
"switchable" => true,
"title" => trans('general.supplier'),
"visible" => false,
"formatter" => "suppliersLinkObjFormatter"
], [
"field" => "location",
"searchable" => true,
"sortable" => true,
"title" => trans('general.location'),
"formatter" => "locationsLinkObjFormatter",
], [
"field" => "asset_maintenance_type",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/asset_maintenances/form.asset_maintenance_type'),
], [
"field" => "created_at",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/asset_maintenances/form.start_date'),
"formatter" => "dateDisplayFormatter"
], [
"field" => "completion_date",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/asset_maintenances/form.completion_date'),
"formatter" => "dateDisplayFormatter"
], [
"field" => "notes",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/asset_maintenances/form.notes')
],[
"field" => "is_warranty",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/asset_maintenances/table.is_warranty')
], [
"field" => "cost",
"searchable" => true,
"sortable" => true,
"title" => trans('admin/asset_maintenances/form.cost')
], [
"field" => "user_id",
"searchable" => true,
"sortable" => true,
"title" => trans('general.admin'),
"formatter" => "usersLinkObjFormatter"
], [
"field" => "actions",
"searchable" => false,
"sortable" => false,
"switchable" => false,
"title" => trans('table.actions'),
"visible" => true,
"formatter" => "maintenancesActionsFormatter",
]
];
return json_encode($layout);
}
}

View file

@ -22,6 +22,7 @@
<div class="box-body"> <div class="box-body">
<table <table
data-columns="{{ \App\Presenters\AssetMaintenancesPresenter::dataTableLayout() }}"
data-cookie-id-table="maintenancesTable" data-cookie-id-table="maintenancesTable"
data-pagination="true" data-pagination="true"
data-search="true" data-search="true"
@ -38,27 +39,6 @@
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'> }'>
<thead>
<tr>
<th data-sortable="true" data-field="id" data-visible="true">{{ trans('general.id') }}</th>
<th data-field="company" data-sortable="false" data-visible="true">{{ trans('admin/companies/table.title') }}</th>
<th data-sortable="true" data-visible="false" data-field="asset_name" data-formatter="assetNameLinkFormatter">{{ trans('admin/asset_maintenances/table.asset_name') }}</th>
<th data-field="asset_tag" data-sortable="true" data-visible="true" data-formatter="assetTagLinkFormatter">{{ trans('admin/hardware/table.asset_tag') }}</th>
<th data-sortable="false" data-visible="true" data-field="location" data-formatter="locationsLinkObjFormatter">{{ trans('admin/hardware/table.location') }}</th>
<th data-sortable="false" data-visible="true" data-field="supplier" data-formatter="suppliersLinkObjFormatter">{{ trans('general.supplier') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="asset_maintenance_type">{{ trans('admin/asset_maintenances/form.asset_maintenance_type') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="title">{{ trans('admin/asset_maintenances/form.title') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="start_date" data-formatter="dateDisplayFormatter">{{ trans('admin/asset_maintenances/form.start_date') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="completion_date" data-formatter="dateDisplayFormatter">{{ trans('admin/asset_maintenances/form.completion_date') }}</th>
<th class="text-right" data-searchable="true" data-visible="true" data-sortable="true" data-field="asset_maintenance_time" data-footer-formatter="sumFormatter">{{ trans('admin/asset_maintenances/form.asset_maintenance_time') }}</th>
<th data-searchable="true" data-sortable="true" data-field="cost" class="text-right" data-footer-formatter="sumFormatter">{{ trans('admin/asset_maintenances/form.cost') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="user_id" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="notes" data-formatter="notesFormatter">{{ trans('admin/asset_maintenances/form.notes') }}</th>
@can('update', \App\Models\Asset::class)
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="maintenanceActions">{{ trans('table.actions') }}</th>
@endcan
</tr>
</thead>
</table> </table>
</div> </div>

View file

@ -672,6 +672,7 @@
<!-- Asset Maintenance table --> <!-- Asset Maintenance table -->
<table <table
data-columns="{{ \App\Presenters\AssetMaintenancesPresenter::dataTableLayout() }}"
class="table table-striped snipe-table" class="table table-striped snipe-table"
id="assetMaintenancesTable" id="assetMaintenancesTable"
data-pagination="true" data-pagination="true"
@ -688,22 +689,6 @@
}' }'
data-url="{{ route('api.maintenances.index', array('asset_id' => $asset->id)) }}" data-url="{{ route('api.maintenances.index', array('asset_id' => $asset->id)) }}"
data-cookie-id-table="assetMaintenancesTable"> data-cookie-id-table="assetMaintenancesTable">
<thead>
<tr>
<th data-field="supplier" data-formatter="suppliersLinkObjFormatter">{{ trans('general.supplier') }}</th>
<th data-visible="true" data-field="title">{{ trans('admin/asset_maintenances/form.title') }}</th>
<th data-visible="true" data-field="asset_maintenance_type">{{ trans('admin/asset_maintenances/form.asset_maintenance_type') }}</th>
<th data-visible="true" data-field="created_at" data-formatter="dateDisplayFormatter">{{ trans('admin/asset_maintenances/form.start_date') }}</th>
<th data-visible="true" data-field="completion_date" data-formatter="dateDisplayFormatter">{{ trans('admin/asset_maintenances/form.completion_date') }}</th>
<th data-visible="true" data-field="notes">{{ trans('admin/asset_maintenances/form.notes') }}</th>
<th>{{ trans('admin/asset_maintenances/table.is_warranty') }}</th>
<th data-visible="true" data-field="cost">{{ trans('admin/asset_maintenances/form.cost') }}</th>
<th data-visible="true" data-field="user_id" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>
@can('update', \App\Models\Asset::class)
<th data-visible="true" data-formatter="maintenanceActions">{{ trans('table.actions') }}</th>
@endcan
</tr>
</thead>
</table> </table>
</div> <!-- /.col-md-12 --> </div> <!-- /.col-md-12 -->
</div> <!-- /.row --> </div> <!-- /.row -->