Add possibility to filter by product group on stock overview page

This commit is contained in:
Bernd Bestel 2018-10-06 18:19:31 +02:00
parent 132999ce36
commit 03eaa6c79f
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
4 changed files with 28 additions and 1 deletions

View File

@ -23,7 +23,8 @@ class StockController extends BaseController
'locations' => $this->Database->locations()->orderBy('name'),
'currentStock' => $this->StockService->GetCurrentStock(),
'missingProducts' => $this->StockService->GetMissingProducts(),
'nextXDays' => 5
'nextXDays' => 5,
'productGroups' => $this->Database->product_groups()->orderBy('name')
]);
}

View File

@ -278,6 +278,7 @@ return array(
'No instruction manual available' => 'Keine Bedienungsanleitung vorhanden',
'The current instruction manual will be deleted when you save the equipment' => 'Die aktuelle Bedienungsanleitung wird beim Speichern des Geräts gelöscht',
'No picture available' => 'Kein Bild vorhanden',
'Filter by product group' => 'Nach Produktgruppe filtern',
//Constants
'manually' => 'Manuell',

View File

@ -31,6 +31,17 @@ $("#location-filter").on("change", function()
stockOverviewTable.column(4).search(value).draw();
});
$("#product-group-filter").on("change", function()
{
var value = $(this).val();
if (value === "all")
{
value = "";
}
stockOverviewTable.column(6).search(value).draw();
});
$("#status-filter").on("change", function()
{
var value = $(this).val();

View File

@ -36,6 +36,15 @@
@endforeach
</select>
</div>
<div class="col-xs-12 col-md-6 col-xl-3">
<label for="location-filter">{{ $L('Filter by product group') }}</label> <i class="fas fa-filter"></i>
<select class="form-control" id="product-group-filter">
<option value="all">{{ $L('All') }}</option>
@foreach($productGroups as $productGroup)
<option value="{{ $productGroup->name }}">{{ $productGroup->name }}</option>
@endforeach
</select>
</div>
<div class="col-xs-12 col-md-6 col-xl-3">
<label for="status-filter">{{ $L('Filter by status') }}</label> <i class="fas fa-filter"></i>
<select class="form-control" id="status-filter">
@ -62,6 +71,7 @@
<th>{{ $L('Next best before date') }}</th>
<th class="d-none">Hidden location</th>
<th class="d-none">Hidden status</th>
<th class="d-none">Hidden product group</th>
</tr>
</thead>
<tbody>
@ -103,6 +113,10 @@
<td class="d-none">
@if($currentStockEntry->best_before_date < date('Y-m-d', strtotime('-1 days')) && $currentStockEntry->amount > 0) expired @elseif($currentStockEntry->best_before_date < date('Y-m-d', strtotime("+$nextXDays days")) && $currentStockEntry->amount > 0) expiring @elseif (FindObjectInArrayByPropertyValue($missingProducts, 'id', $currentStockEntry->product_id) !== null) belowminstockamount @endif
</td>
@php $productGroup = FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->product_group_id) @endphp
<td class="d-none">
@if($productGroup !== null){{ $productGroup->name }}@endif
</td>
</tr>
@endforeach
</tbody>