From d5878dbb47d4426149c37e71948326ff41ebc63e Mon Sep 17 00:00:00 2001 From: Micha Date: Sun, 1 Feb 2026 21:28:27 +0100 Subject: [PATCH] #481 - add locations hierarchy to stock overview reports --- controllers/StockController.php | 6 ++- localization/strings.pot | 6 +++ public/viewjs/locationcontentsheet.js | 14 +++++ views/locationcontentsheet.blade.php | 77 +++++++++++++++++++++++++-- 4 files changed, 97 insertions(+), 6 deletions(-) diff --git a/controllers/StockController.php b/controllers/StockController.php index 3e9052cc..cf2011a3 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -92,8 +92,10 @@ class StockController extends BaseController return $this->renderPage($response, 'locationcontentsheet', [ 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), - 'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock'])) + 'locations' => $this->getDatabase()->locations_hierarchy()->orderBy('location_path', 'COLLATE NOCASE'), + 'locationsResolved' => $this->getDatabase()->locations_resolved(), + 'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock'])), + 'showLeafLocationsOnly' => isset($request->getQueryParams()['leaf_locations_only']) ]); } diff --git a/localization/strings.pot b/localization/strings.pot index 2df59b47..1d3c6265 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2476,3 +2476,9 @@ msgstr "" msgid "List actions" msgstr "" + +msgid "Show only leaf locations" +msgstr "" + +msgid "When enabled, only locations without sub-locations are shown. When disabled, parent locations show aggregated content from all sub-locations." +msgstr "" diff --git a/public/viewjs/locationcontentsheet.js b/public/viewjs/locationcontentsheet.js index 2d823d60..8ba9b542 100644 --- a/public/viewjs/locationcontentsheet.js +++ b/public/viewjs/locationcontentsheet.js @@ -31,3 +31,17 @@ if (GetUriParam("include_out_of_stock")) { $("#include-out-of-stock").prop("checked", false); } + +$(document).on("change", "#leaf-locations-only", function() +{ + if (this.checked) + { + UpdateUriParam("leaf_locations_only", true); + } + else + { + RemoveUriParam("leaf_locations_only"); + } + + window.location.reload(); +}); diff --git a/views/locationcontentsheet.blade.php b/views/locationcontentsheet.blade.php index 12337bf0..e0ee6dd4 100644 --- a/views/locationcontentsheet.blade.php +++ b/views/locationcontentsheet.blade.php @@ -50,6 +50,20 @@ title="{{ $__t('Out of stock items will be shown at the products default location') }}"> +
+ + +