diff --git a/controllers/StockController.php b/controllers/StockController.php index efd67b87..3e9052cc 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -161,7 +161,8 @@ class StockController extends BaseController return $this->renderPage($response, 'stockoverview', [ 'currentStock' => $this->getDatabase()->uihelper_stock_current_overview()->where($where), - 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations_hierarchy()->where('active = 1')->orderBy('location_path', 'COLLATE NOCASE'), + 'locationsResolved' => $this->getDatabase()->locations_resolved(), 'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(), 'nextXDays' => $nextXDays, 'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 74a33488..9b053e6d 100755 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -112,7 +112,7 @@ id="location-filter"> @foreach($locations as $location) - + @endforeach @@ -377,7 +377,14 @@ @foreach(FindAllObjectsInArrayByPropertyValue($currentStockLocations, 'product_id', $currentStockEntry->product_id) as $locationsForProduct) - xx{{ FindObjectInArrayByPropertyValue($locations, 'id', $locationsForProduct->location_id)->name }}xx + @php + // Include all ancestor locations for hierarchical filtering + $ancestorMappings = FindAllObjectsInArrayByPropertyValue($locationsResolved, 'location_id', $locationsForProduct->location_id); + @endphp + @foreach($ancestorMappings as $ancestorMapping) + @php $ancestorLocation = FindObjectInArrayByPropertyValue($locations, 'id', $ancestorMapping->ancestor_location_id); @endphp + @if($ancestorLocation)xx{{ $ancestorLocation->name }}xx @endif + @endforeach @endforeach