Merge branch 'develop' into company_tests

This commit is contained in:
Marcus Moore 2024-09-09 12:18:02 -07:00
commit 35533c39d5
No known key found for this signature in database
4 changed files with 20 additions and 2 deletions

View file

@ -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;

View file

@ -118,6 +118,7 @@ class BulkUsersController extends Controller
->conditionallyAddItem('activated')
->conditionallyAddItem('start_date')
->conditionallyAddItem('end_date')
->conditionallyAddItem('city')
->conditionallyAddItem('autoassign_licenses');

View file

@ -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
*

View file

@ -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,
], [