@php $isAdmin = auth()->check() ? auth()->user()->isDistrictUser() : false; $suggestedItems = $suggestedItems ?? collect(); $prefill = $prefill ?? request('prefill', ''); $priorities = [ 'low' => 'Niedrig', 'medium' => 'Mittel', 'high' => 'Hoch', ]; $urgencies = [ 'normal' => 'Normal', 'urgent' => 'Dringend', 'immediate' => 'Sofort', ]; // Für JS: Produkte+Varianten als Array $productPayload = $products ->map(function ($p) { return [ 'id' => $p->id, 'name' => $p->name, 'has_variants' => (bool) $p->has_variants, 'variants' => $p->variants->map(fn($v) => ['id' => $v->id, 'name' => $v->name])->values(), ]; }) ->values(); // Prefill payload: suggestedItems -> JS $suggestedPayload = $suggestedItems ->map(function ($inv) { return [ 'product_id' => $inv->product_id, 'variant_id' => $inv->variant_id, 'quantity' => (int) ($inv->suggest_qty ?? ($inv->quantity ?? 1)), 'note' => '', 'level' => (string) ($inv->level ?? ''), ]; }) ->values(); // OLD payload (bei Validation-Error): hat Priorität gegenüber Prefill $oldItems = collect(old('items', [])) ->map(function ($it) { return [ 'product_id' => $it['product_id'] ?? null, 'variant_id' => $it['variant_id'] ?? null, 'quantity' => isset($it['quantity']) ? (int) $it['quantity'] : 1, 'note' => $it['note'] ?? '', 'level' => '', // old-items haben kein level ]; }) ->values(); $initialItemsPayload = $oldItems->count() > 0 ? $oldItems : $suggestedPayload; @endphp
{{-- Header --}}
Bestellung erstellen
Artikel auswählen, Mengen definieren, Priorität & Dringlichkeit setzen.
Abbrechen
{{-- Prefill hint --}} @if (!$isAdmin)
Auto-Vorschlag: Unter Mindestbestand
Füllt Positionen automatisch vor, wenn der Bestand unter dem Mindestbestand liegt.
@if ($prefill === 'under_min' && $suggestedItems->count() > 0) Vorbefüllt: {{ $suggestedItems->count() }} Position(en). @elseif ($prefill === 'under_min') Keine Positionen unter Mindestbestand gefunden. @else Klicke rechts, um automatisch vorzubefüllen. @endif @if ($oldItems->count() > 0) · Hinweis: Deine Eingaben wurden wiederhergestellt. @endif
@endif @if ($errors->any())
Bitte prüfe die Eingaben:
    @foreach ($errors->all() as $e)
  • {{ $e }}
  • @endforeach
@endif
@csrf {{-- Left: Items --}}
Positionen
0
Füge Artikel hinzu und setze Mengen. Mindestens 1 Position ist erforderlich.
Tipp: Nutze „Sofort“ nur für echte Notfälle.
{{-- Right: Meta --}}
Details
Nach dem Speichern: Status = Aufgegeben.