From ecf96252b94607e22893cd1878817a558a1182d6 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 8 Jul 2018 15:16:24 +0200 Subject: [PATCH] Add possibility to filter products by location (references #10) --- controllers/StockController.php | 1 + localization/de.php | 1 + public/viewjs/stockoverview.js | 42 ++++++++++++++++++++++++++++++--- version.json | 4 ++-- views/stockoverview.blade.php | 4 ++++ 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/controllers/StockController.php b/controllers/StockController.php index 72d8d74a..504eb7a7 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -24,6 +24,7 @@ class StockController extends BaseController return $this->AppContainer->view->render($response, 'stockoverview', [ 'products' => $this->Database->products()->orderBy('name'), 'quantityunits' => $this->Database->quantity_units()->orderBy('name'), + 'locations' => $this->Database->locations()->orderBy('name'), 'currentStock' => $currentStock, 'missingProducts' => $this->StockService->GetMissingProducts(), 'nextXDays' => $nextXDays, diff --git a/localization/de.php b/localization/de.php index 630ed2d7..e95237ed 100644 --- a/localization/de.php +++ b/localization/de.php @@ -129,6 +129,7 @@ return array( 'All' => 'Alle', 'Track charge cycle of battery #1' => 'Erfasse einen Ladezyklus für Batterie #1', 'Track execution of habit #1' => 'Erfasse eine Ausführung von #1', + 'Filter by location' => 'Nach Standort filtern', //Constants 'manually' => 'Manuell', diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index 98c22481..c4ec4e87 100644 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -1,10 +1,46 @@ -$('#stock-overview-table').DataTable({ +var stockOverviewTable = $('#stock-overview-table').DataTable({ 'bPaginate': false, 'order': [[3, 'asc']], 'columnDefs': [ - { 'orderable': false, 'targets': 0 } + { 'orderable': false, 'targets': 0 }, + { 'visible': false, 'targets': 4 } ], - 'language': JSON.parse(L('datatables_localization')) + 'language': JSON.parse(L('datatables_localization')), + "dom": '<"filter-by-location">f' +}); + +$("div.filter-by-location").html('