#481 - stock overview works with hierarchic locations

This commit is contained in:
Micha 2026-02-01 21:05:44 +01:00
parent 49e134d5fe
commit ea9234eaaf
2 changed files with 11 additions and 3 deletions

View File

@ -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'),

View File

@ -112,7 +112,7 @@
id="location-filter">
<option value="all">{{ $__t('All') }}</option>
@foreach($locations as $location)
<option value="{{ $location->name }}">{{ $location->name }}</option>
<option value="{{ $location->name }}">{{ $location->location_path }}</option>
@endforeach
</select>
</div>
@ -377,7 +377,14 @@
</td>
<td class="d-none">
@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
</td>
<td class="d-none">