mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Narrowed down the accessories, consumables, etc APIs for manufacturer filtering
This commit is contained in:
parent
c511073bc2
commit
d799ab2a9c
|
@ -29,6 +29,14 @@ class AccessoriesController extends Controller
|
|||
$accessories = $accessories->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$accessories->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer_id')) {
|
||||
$accessories->where('manufacturer_id','=',$request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
$offset = $request->input('offset', 0);
|
||||
$limit = $request->input('limit', 50);
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
|
|
@ -32,12 +32,22 @@ class ConsumablesController extends Controller
|
|||
$consumables = $consumables->TextSearch(e($request->input('search')));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$consumables->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer_id')) {
|
||||
$consumables->where('manufacturer_id','=',$request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
$allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','company','category','model_number', 'item_no', 'manufacturer','location','qty'];
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
|
||||
|
||||
switch ($sort) {
|
||||
case 'category':
|
||||
$consumables = $consumables->OrderCategory($order);
|
||||
|
@ -56,6 +66,8 @@ class ConsumablesController extends Controller
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$total = $consumables->count();
|
||||
$consumables = $consumables->skip($offset)->take($limit)->get();
|
||||
return (new ConsumablesTransformer)->transformConsumables($consumables, $total);
|
||||
|
|
|
@ -26,6 +26,19 @@ class LicensesController extends Controller
|
|||
if ($request->has('search')) {
|
||||
$licenses = $licenses->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$licenses->where('company_id','=',$request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('manufacturer_id')) {
|
||||
$licenses->where('manufacturer_id','=',$request->input('manufacturer_id'));
|
||||
}
|
||||
|
||||
if ($request->has('supplier_id')) {
|
||||
$licenses->where('supplier_id','=',$request->input('supplier_id'));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
|
|
|
@ -23,14 +23,14 @@ class AccessoriesTransformer
|
|||
$array = [
|
||||
'id' => $accessory->id,
|
||||
'name' => e($accessory->name),
|
||||
'company' => ($accessory->company) ? $accessory->company : null,
|
||||
'manufacturer' => ($accessory->manufacturer_id) ? $accessory->manufacturer : null,
|
||||
'company' => ($accessory->company) ? ['id' => $accessory->company->id,'name'=> e($accessory->company->name)] : '',
|
||||
'manufacturer' => ($accessory->manufacturer) ? ['id' => $accessory->manufacturer->id,'name'=> e($accessory->manufacturer->name)] : '',
|
||||
'model_number' => ($accessory->model_number) ? e($accessory->model_number) : null,
|
||||
'category' => ($accessory->category_id) ? $accessory->category : null,
|
||||
'location' => ($accessory->location) ? $accessory->location : null,
|
||||
'category' => ($accessory->category) ? ['id' => $accessory->category->id,'name'=> e($accessory->category->name)] : '',
|
||||
'location' => ($accessory->location) ? ['id' => $accessory->location->id,'name'=> e($accessory->location->name)] : '',
|
||||
'notes' => ($accessory->notes) ? e($accessory->notes) : null,
|
||||
'qty' => ($accessory->qty) ? e($accessory->qty) : null,
|
||||
'purchase_date' => ($accessory->purchase_date) ? e($accessory->purchase_date) : null,
|
||||
'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null,
|
||||
'purchase_cost' => ($accessory->purchase_cost) ? e($accessory->purchase_cost) : null,
|
||||
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
|
||||
'min_qty' => ($accessory->min_amt) ? e($accessory->min_amt) : null,
|
||||
|
|
|
@ -76,28 +76,27 @@
|
|||
name="manufacturer_licenses"
|
||||
class="table table-striped bootstrap-table snipe-table"
|
||||
id="licenses-table"
|
||||
data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'licenses']) }}"
|
||||
data-url="{{ route('api.licenses.index', ['manufacturer_id' => $manufacturer->id]) }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="maufacturerLicensesTable-{{config('version.hash_version') }}"
|
||||
>
|
||||
data-cookie-id-table="maufacturerLicensesTable-{{config('version.hash_version') }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||
<th data-field="company" data-sortable="false" data-switchable="true">{{ trans('general.company') }}</th>
|
||||
<th data-field="name" data-sortable="true">{{ trans('admin/licenses/table.title') }}</th>
|
||||
<th data-field="manufacturer" data-sortable="true">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-field="serial" data-sortable="true" >{{ trans('admin/licenses/table.serial') }}</th>
|
||||
<th data-field="company" data-sortable="false" data-switchable="true" data-formatter="companiesLinkObjFormatter">{{ trans('general.company') }}</th>
|
||||
<th data-field="name" data-sortable="true" data-formatter="licensesLinkFormatter">{{ trans('admin/licenses/table.title') }}</th>
|
||||
<th data-field="manufacturer" data-sortable="true" data-formatter="manufacturersLinkObjFormatter">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-field="product_key" data-sortable="true" >{{ trans('admin/licenses/table.serial') }}</th>
|
||||
<th data-field="license_name" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.to_name') }}</th>
|
||||
<th data-field="license_email" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.to_email') }}</th>
|
||||
<th data-field="totalSeats" data-sortable="false">{{ trans('admin/licenses/form.seats') }}</th>
|
||||
<th data-field="remaining" data-sortable="false">{{ trans('admin/licenses/form.remaining_seats') }}</th>
|
||||
<th data-field="purchase_date" data-sortable="true">{{ trans('admin/licenses/table.purchase_date') }}</th>
|
||||
<th data-field="total_seats" data-sortable="false">{{ trans('admin/licenses/form.seats') }}</th>
|
||||
<th data-field="remaining_qty" data-sortable="false">{{ trans('admin/licenses/form.remaining_seats') }}</th>
|
||||
<th data-field="purchase_date" data-sortable="true" data-formatter="dateDisplayFormatter">{{ trans('admin/licenses/table.purchase_date') }}</th>
|
||||
<th data-field="purchase_cost" data-sortable="true">{{ trans('general.purchase_cost') }}</th>
|
||||
<th data-field="purchase_order" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.purchase_order') }}</th>
|
||||
<th data-field="expiration_date" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.expiration') }}</th>
|
||||
<th data-field="notes" data-sortable="true" data-visible="false">{{ trans('admin/licenses/form.notes') }}</th>
|
||||
<th data-field="actions">{{ trans('table.actions') }}</th>
|
||||
<th data-field="expiration_date" data-sortable="true" data-visible="false" data-formatter="dateDisplayFormatter">{{ trans('admin/licenses/form.expiration') }}</th>
|
||||
<th data-field="notes" data-sortable="true" data-visible="false">{{ trans('general.notes') }}</th>
|
||||
<th data-field="actions" data-formatter="licensesActionsFormatter">{{ trans('table.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
@ -105,28 +104,27 @@
|
|||
|
||||
<div class="tab-pane fade" id="accessories">
|
||||
<table
|
||||
name="manufacturer_licenses"
|
||||
name="manufacturer_accessories"
|
||||
class="table table-striped bootstrap-table snipe-table"
|
||||
id="licenses-table"
|
||||
data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'accessories']) }}"
|
||||
data-url="{{ route('api.accessories.index', ['manufacturer_id' => $manufacturer->id]) }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="manufacturerAccessoriesTable-{{config('version.hash_version') }}"
|
||||
>
|
||||
data-cookie-id-table="manufacturerAccessoriesTable-{{config('version.hash_version') }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-switchable="true" data-searchable="true" data-sortable="true" data-field="company" data-visible="false">{{ trans('admin/companies/table.title') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="name">{{ trans('admin/accessories/table.title') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="category">{{ trans('admin/accessories/general.accessory_category') }}</th>
|
||||
<th data-field="manufacturer" data-searchable="true" data-sortable="true">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="location">{{ trans('general.location') }}</th>
|
||||
<th data-switchable="true" data-searchable="true" data-sortable="true" data-field="company" data-visible="false" data-formatter="companiesLinkObjFormatter">{{ trans('admin/companies/table.title') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="name" data-formatter="accessoriesLinkFormatter">{{ trans('admin/accessories/table.title') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="category" data-formatter="categoriesLinkObjFormatter">{{ trans('admin/accessories/general.accessory_category') }}</th>
|
||||
<th data-field="manufacturer" data-searchable="true" data-sortable="true" data-formatter="manufacturersLinkObjFormatter">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="location" data-formatter="locationsLinkObjFormatter">{{ trans('general.location') }}</th>
|
||||
<th data-searchable="false" data-sortable="false" data-field="qty">{{ trans('admin/accessories/general.total') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="purchase_date" data-visible="false">{{ trans('admin/accessories/general.date') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="purchase_date" data-visible="false" data-formatter="dateDisplayFormatter">{{ trans('general.purchase_date') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="purchase_cost">{{ trans('general.purchase_cost') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="order_number" data-visible="false">{{ trans('admin/accessories/general.order') }}</th>
|
||||
<th data-searchable="false" data-sortable="true" data-field="min_amt">{{ trans('general.min_amt') }}</th>
|
||||
<th data-searchable="false" data-sortable="false" data-field="numRemaining">{{ trans('admin/accessories/general.remaining') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions">{{ trans('table.actions') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="order_number" data-visible="false">{{ trans('general.order_number') }}</th>
|
||||
<th data-searchable="false" data-sortable="true" data-field="min_qty">{{ trans('general.min_amt') }}</th>
|
||||
<th data-searchable="false" data-sortable="false" data-field="remaining_qty">{{ trans('admin/accessories/general.remaining') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="accessoriesActionsFormatter">{{ trans('table.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
@ -134,31 +132,30 @@
|
|||
|
||||
<div class="tab-pane fade" id="consumables">
|
||||
<table
|
||||
name="manufacturer_licenses"
|
||||
name="manufacturer_consumables"
|
||||
class="table table-striped bootstrap-table snipe-table"
|
||||
id="licenses-table"
|
||||
data-url="{{ route('api.manufacturers.show', ['manufacturerId' => $manufacturer->id, 'itemtype' => 'consumables']) }}"
|
||||
data-url="{{ route('api.consumables.index', ['manufacturer_id' => $manufacturer->id]) }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="maufacturerLicensesTable-{{config('version.hash_version') }}"
|
||||
>
|
||||
data-cookie-id-table="maufacturerConsumablesTable-{{config('version.hash_version') }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||
<th data-switchable="true" data-searchable="true" data-sortable="true" data-field="company">{{ trans('admin/companies/table.title') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="name">{{ trans('admin/consumables/table.title') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="location">{{ trans('general.location') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="category">{{ trans('general.category') }}</th>
|
||||
<th data-switchable="true" data-searchable="true" data-sortable="true" data-field="company" data-formatter="companiesLinkObjFormatter">{{ trans('admin/companies/table.title') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="name" data-formatter="consumablesLinkFormatter">{{ trans('admin/consumables/table.title') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="location" data-formatter="locationsLinkObjFormatter">{{ trans('general.location') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="category" data-formatter="categoriesLinkObjFormatter">{{ trans('general.category') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="qty"> {{ trans('admin/consumables/general.total') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="numRemaining"> {{ trans('admin/consumables/general.remaining') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="remaining"> {{ trans('admin/consumables/general.remaining') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="true" data-field="min_amt"> {{ trans('general.min_amt') }}</th>
|
||||
<th data-sortable="true" data-field="manufacturer" data-visible="false">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-sortable="true" data-field="manufacturer" data-visible="false" data-formatter="manufacturersLinkObjFormatter">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-sortable="true" data-field="model_number" data-visible="false">{{ trans('general.model_no') }}</th>
|
||||
<th data-sortable="true" data-field="item_no" data-visible="false">{{ trans('admin/consumables/general.item_no') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="order_number" data-visible="false">{{ trans('admin/consumables/general.order') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="purchase_date" data-visible="false">{{ trans('admin/consumables/general.date') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="order_number" data-visible="false">{{ trans('general.order_number') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="purchase_date" data-visible="false" data-formatter="dateDisplayFormatter">{{ trans('general.purchase_date') }}</th>
|
||||
<th data-sortable="true" data-searchable="true" data-field="purchase_cost" data-visible="false">{{ trans('general.purchase_cost') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions"> {{ trans('table.actions') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="consumablesActionsFormatter"> {{ trans('table.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue