@extends('layouts.dashboard') @section('content')
@if(session('success'))
✅ {{ session('success') }}
@endif

Van Box Management

Organize van stock by shelf, box, barcode label, and product location.

@if(auth()->user()->isAdmin())
@endif
@if($selectedUser)
Selected Van
{{ $selectedUser->name }}
Latest stock: {{ $latestImport ? $latestImport->original_file : 'No completed stock import yet' }}
Boxes
{{ number_format($boxes->count()) }}
Assigned Items
{{ number_format($boxes->sum(fn($b) => $b->items->count())) }}
Unassigned
{{ number_format($unassignedItems->count()) }}
@if(auth()->user()->isAdmin())

➕ Create / Update Box

@csrf
@endif

📍 Van Layout Idea

Use shelves like A/B/C and boxes like A01, A02, B01.

@foreach(['A' => 'Top Shelf', 'B' => 'Middle Shelf', 'C' => 'Bottom Shelf'] as $shelf => $label)
{{ $label }}
@for($i = 1; $i <= 3; $i++) @php $code = $shelf . str_pad($i, 2, '0', STR_PAD_LEFT); $exists = $boxes->firstWhere('box_code', $code); @endphp
{{ $code }}
@endfor
@endforeach

📦 Boxes

Click a box to view contents and print label.

@if($boxes->count()) @else
📦

No boxes yet

Create A01, A02, B01 boxes to start organizing the van.

@endif
@if(auth()->user()->isAdmin())

🧩 Unassigned Van Stock Items

Assign products from the latest van stock to a box.

@if(!$latestImport)
No completed stock import found for this salesman.
@elseif(!$boxes->count())
Create boxes first, then assign products.
@elseif($unassignedItems->count())
@foreach($unassignedItems as $item)
@if($item->main_image) @else 🖼 @endif
{{ $item->display_name }}
SKU: {{ $item->sku ?: '-' }} | Barcode: {{ $item->barcode ?: '-' }} | Qty: {{ number_format($item->qty) }}
@csrf
@endforeach
@else
✅ All latest van stock items are assigned to boxes.
@endif
@endif
@endif
@endsection