mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-25 12:41:16 -08:00
Additional filters on maintenances UI
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
bfec0059c5
commit
a33276cb3d
|
@ -35,7 +35,8 @@ class AssetMaintenancesController extends Controller
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->authorize('view', Asset::class);
|
$this->authorize('view', Asset::class);
|
||||||
$maintenances = AssetMaintenance::with('asset', 'asset.model', 'asset.location', 'supplier', 'asset.company', 'admin');
|
|
||||||
|
$maintenances = AssetMaintenance::select('asset_maintenances.*')->with('asset', 'asset.model', 'asset.location', 'supplier', 'asset.company', 'admin');
|
||||||
|
|
||||||
if ($request->filled('search')) {
|
if ($request->filled('search')) {
|
||||||
$maintenances = $maintenances->TextSearch($request->input('search'));
|
$maintenances = $maintenances->TextSearch($request->input('search'));
|
||||||
|
@ -45,6 +46,15 @@ class AssetMaintenancesController extends Controller
|
||||||
$maintenances->where('asset_id', '=', $request->input('asset_id'));
|
$maintenances->where('asset_id', '=', $request->input('asset_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->filled('supplier_id')) {
|
||||||
|
$maintenances->where('supplier_id', '=', $request->input('supplier_id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('asset_maintenance_type')) {
|
||||||
|
$maintenances->where('asset_maintenance_type', '=', $request->input('asset_maintenance_type'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which
|
// Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which
|
||||||
// case we override with the actual count, so we should return 0 items.
|
// case we override with the actual count, so we should return 0 items.
|
||||||
$offset = (($maintenances) && ($request->get('offset') > $maintenances->count())) ? $maintenances->count() : $request->get('offset', 0);
|
$offset = (($maintenances) && ($request->get('offset') > $maintenances->count())) ? $maintenances->count() : $request->get('offset', 0);
|
||||||
|
@ -64,6 +74,7 @@ class AssetMaintenancesController extends Controller
|
||||||
'asset_tag',
|
'asset_tag',
|
||||||
'asset_name',
|
'asset_name',
|
||||||
'user_id',
|
'user_id',
|
||||||
|
'supplier'
|
||||||
];
|
];
|
||||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||||
|
@ -72,6 +83,9 @@ class AssetMaintenancesController extends Controller
|
||||||
case 'user_id':
|
case 'user_id':
|
||||||
$maintenances = $maintenances->OrderAdmin($order);
|
$maintenances = $maintenances->OrderAdmin($order);
|
||||||
break;
|
break;
|
||||||
|
case 'supplier':
|
||||||
|
$maintenances = $maintenances->OrderBySupplier($order);
|
||||||
|
break;
|
||||||
case 'asset_tag':
|
case 'asset_tag':
|
||||||
$maintenances = $maintenances->OrderByTag($order);
|
$maintenances = $maintenances->OrderByTag($order);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue