@php $q = $q ?? request('q', ''); $type = $type ?? request('type', 'alle'); $from = $from ?? request('from', ''); $to = $to ?? request('to', ''); $isDistrict = auth()->user()->isDistrictUser(); $types = [ 'alle' => 'Alle', 'in' => 'Zugang', 'out' => 'Verbrauch', 'adjust' => 'Korrektur', ]; $typePills = [ 'in' => 'bg-emerald-50 text-emerald-700 border-emerald-200', 'out' => 'bg-red-50 text-red-700 border-red-200', 'adjust' => 'bg-neutral-100 text-rk-slate border-rk', ]; $reasonLabels = [ 'verbrauch_einsatz' => ['label' => 'Verbrauch (Einsatz)', 'hint' => 'Material im Einsatz verbraucht'], 'korrektur' => ['label' => 'Korrektur Lager', 'hint' => 'Bestand wurde auf Inhalt kontrolliert'], 'order_received' => ['label' => 'Bestellung erhalten', 'hint' => 'Wareneingang aus Bestellung'], ]; $prettyReason = function ($m) use ($reasonLabels) { $key = (string) ($m->reason ?? ''); $map = $reasonLabels[$key] ?? null; // Falls reason nicht gemappt ist: Original anzeigen return [ 'label' => $map['label'] ?? ($key !== '' ? $key : '—'), 'hint' => $map['hint'] ?? null, ]; }; $deltaText = fn($d) => ((int) $d > 0 ? '+' : '') . (int) $d; $deltaPill = function ($m) use ($typePills) { // Delta Badge soll primär nach TYPE färben (konstant), nicht nach Vorzeichen. return $typePills[$m->type] ?? 'bg-neutral-100 text-rk-slate border-rk'; }; $typeLabel = [ 'in' => 'Zugang', 'out' => 'Verbrauch', 'adjust' => 'Korrektur', ]; @endphp
{{-- Header --}}
Buchungen
Zugänge, Verbräuche & Korrekturen inkl. Audit-Trail.
Aktualisieren @if (auth()->user()->isStationUser()) Buchung erstellen @endif
{{-- Filter --}}
Schnellfilter: Alle @foreach (['in', 'out', 'adjust'] as $k) {{ $types[$k] }} @endforeach
{{-- Table --}}
Übersicht
{{ $movements->total() }} Buchungen @if ($type !== 'alle') · Filter: {{ $types[$type] ?? $type }} @endif
@if ($isDistrict) @endif @forelse($movements as $m) @php $pill = $deltaPill($m); $tLbl = $typeLabel[$m->type] ?? $m->type; $note = data_get($m->meta, 'note'); @endphp @php $r = $prettyReason($m); $note = data_get($m->meta, 'note'); @endphp @if ($isDistrict) @endif @empty @endforelse
Zeitpunkt Artikel Variante Typ Grund DeltaOrtstelle
{{ optional($m->booked_at)->format('d.m.Y H:i') ?? '—' }} {{ $m->product?->name ?? '—' }} {{ $m->variant?->name ?? '—' }} {{ $tLbl }}
{{ $r['label'] }}
@if (!empty($r['hint']))
{{ $r['hint'] }}
@endif @if (!empty($note))
{{ $note }}
@endif
{{ $deltaText($m->quantity_delta) }} {{ $m->station?->name ?? '—' }}
Keine Buchungen.
{{ $movements->onEachSide(1)->links() }}