mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Fixed #5151 - added asset tag to maintenances
This commit is contained in:
parent
9effa3d2ab
commit
36cd63836e
|
@ -56,6 +56,8 @@ class AssetMaintenancesController extends Controller
|
||||||
'start_date',
|
'start_date',
|
||||||
'completion_date',
|
'completion_date',
|
||||||
'notes',
|
'notes',
|
||||||
|
'asset_tag',
|
||||||
|
'asset_name',
|
||||||
'user_id'
|
'user_id'
|
||||||
];
|
];
|
||||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||||
|
@ -65,6 +67,12 @@ class AssetMaintenancesController extends Controller
|
||||||
case 'user_id':
|
case 'user_id':
|
||||||
$maintenances = $maintenances->OrderAdmin($order);
|
$maintenances = $maintenances->OrderAdmin($order);
|
||||||
break;
|
break;
|
||||||
|
case 'asset_tag':
|
||||||
|
$maintenances = $maintenances->OrderByTag($order);
|
||||||
|
break;
|
||||||
|
case 'asset_name':
|
||||||
|
$maintenances = $maintenances->OrderByAssetName($order);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$maintenances = $maintenances->orderBy($sort, $order);
|
$maintenances = $maintenances->orderBy($sort, $order);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -22,8 +22,19 @@ class AssetMaintenancesTransformer
|
||||||
{
|
{
|
||||||
$array = [
|
$array = [
|
||||||
'id' => (int) $assetmaintenance->id,
|
'id' => (int) $assetmaintenance->id,
|
||||||
'asset_name' => ($assetmaintenance->asset) ? ['id' => $assetmaintenance->asset->id,'name'=> e($assetmaintenance->asset->name)] : null,
|
|
||||||
|
'asset' => ($assetmaintenance->asset) ? [
|
||||||
|
'id' => (int) $assetmaintenance->asset->id,
|
||||||
|
'name'=> ($assetmaintenance->asset->name) ? e($assetmaintenance->asset->name) : null,
|
||||||
|
'asset_tag'=> e($assetmaintenance->asset->asset_tag)
|
||||||
|
|
||||||
|
] : null,
|
||||||
'title' => ($assetmaintenance->title) ? e($assetmaintenance->title) : null,
|
'title' => ($assetmaintenance->title) ? e($assetmaintenance->title) : null,
|
||||||
|
'location' => ($assetmaintenance->asset->location) ? [
|
||||||
|
'id' => (int) $assetmaintenance->asset->location->id,
|
||||||
|
'name'=> e($assetmaintenance->asset->location->name),
|
||||||
|
|
||||||
|
] : null,
|
||||||
'notes' => ($assetmaintenance->notes) ? e($assetmaintenance->notes) : null,
|
'notes' => ($assetmaintenance->notes) ? e($assetmaintenance->notes) : null,
|
||||||
'supplier' => ($assetmaintenance->supplier) ? ['id' => $assetmaintenance->supplier->id,'name'=> e($assetmaintenance->supplier->name)] : null,
|
'supplier' => ($assetmaintenance->supplier) ? ['id' => $assetmaintenance->supplier->id,'name'=> e($assetmaintenance->supplier->name)] : null,
|
||||||
'cost' => Helper::formatCurrencyOutput($assetmaintenance->cost),
|
'cost' => Helper::formatCurrencyOutput($assetmaintenance->cost),
|
||||||
|
|
|
@ -177,4 +177,32 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||||
->orderBy('users.first_name', $order)
|
->orderBy('users.first_name', $order)
|
||||||
->orderBy('users.last_name', $order);
|
->orderBy('users.last_name', $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query builder scope to order on asset tag
|
||||||
|
*
|
||||||
|
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||||
|
* @param text $order Order
|
||||||
|
*
|
||||||
|
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||||
|
*/
|
||||||
|
public function scopeOrderByTag($query, $order)
|
||||||
|
{
|
||||||
|
return $query->leftJoin('assets', 'asset_maintenances.asset_id', '=', 'assets.id')
|
||||||
|
->orderBy('assets.asset_tag', $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query builder scope to order on asset tag
|
||||||
|
*
|
||||||
|
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||||
|
* @param text $order Order
|
||||||
|
*
|
||||||
|
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||||
|
*/
|
||||||
|
public function scopeOrderByAssetName($query, $order)
|
||||||
|
{
|
||||||
|
return $query->leftJoin('assets', 'asset_maintenances.asset_id', '=', 'assets.id')
|
||||||
|
->orderBy('assets.name', $order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,9 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th data-sortable="true" data-field="id" data-visible="true">{{ trans('general.id') }}</th>
|
<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-field="company" data-sortable="false" data-visible="true">{{ trans('admin/companies/table.title') }}</th>
|
||||||
<th data-sortable="false" data-visible="true" data-field="asset_name" data-formatter="hardwareLinkObjFormatter">{{ trans('admin/asset_maintenances/table.asset_name') }}</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-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="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="title">{{ trans('admin/asset_maintenances/form.title') }}</th>
|
||||||
|
|
|
@ -413,6 +413,17 @@
|
||||||
return '<a href="{{ url('/') }}/admin/groups/' + row.id + '"> ' + value + '</a>';
|
return '<a href="{{ url('/') }}/admin/groups/' + row.id + '"> ' + value + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assetTagLinkFormatter(value, row) {
|
||||||
|
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.asset_tag + '</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function assetNameLinkFormatter(value, row) {
|
||||||
|
if ((row.asset) && (row.asset.name)) {
|
||||||
|
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.name + '</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function trueFalseFormatter(value, row) {
|
function trueFalseFormatter(value, row) {
|
||||||
if ((value) && ((value == 'true') || (value == '1'))) {
|
if ((value) && ((value == 'true') || (value == '1'))) {
|
||||||
return '<i class="fa fa-check text-success"></i>';
|
return '<i class="fa fa-check text-success"></i>';
|
||||||
|
|
Loading…
Reference in a new issue