mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-23 12:44:12 -08:00
Added ability to sort on qty and remaining for consumables
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
e1fcfc8dc1
commit
7d9a0eba04
|
@ -86,6 +86,9 @@ class ConsumablesController extends Controller
|
|||
case 'company':
|
||||
$consumables = $consumables->OrderCompany($order);
|
||||
break;
|
||||
case 'remaining':
|
||||
$consumables = $consumables->OrderRemaining($order);
|
||||
break;
|
||||
case 'supplier':
|
||||
$consumables = $consumables->OrderSupplier($order);
|
||||
break;
|
||||
|
|
|
@ -425,6 +425,20 @@ class Consumable extends SnipeModel
|
|||
return $query->leftJoin('companies', 'consumables.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on remaining
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param string $order Order
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeOrderRemaining($query, $order)
|
||||
{
|
||||
$order_by = 'consumables.qty - consumables_users_count ' . $order;
|
||||
return $query->orderByRaw($order_by);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on supplier
|
||||
*
|
||||
|
|
|
@ -75,13 +75,13 @@ class ConsumablePresenter extends Presenter
|
|||
], [
|
||||
'field' => 'qty',
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/components/general.total'),
|
||||
'visible' => true,
|
||||
], [
|
||||
'field' => 'remaining',
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('admin/components/general.remaining'),
|
||||
'visible' => true,
|
||||
], [
|
||||
|
|
Loading…
Reference in a new issue