@php $orderId = 'UF-' . str_pad($order->id, 4, '0', STR_PAD_LEFT); $bookingDate = date('F d, Y', strtotime($order->created_at)); @endphp @foreach($products as $productName => $productData) @php $items = $productData['items']; $activeSizes = $productData['active_sizes'] ?? []; $productTotalQty = $items->sum('quantity'); $uniqueColors = $items->pluck('color')->unique()->filter()->values(); $boxQuantity = (float) ($productData['box_quantity'] ?? 60); if ($boxQuantity <= 0) { $boxQuantity = 60; } $totalBoxes = $productTotalQty > 0 ? (int) ceil($productTotalQty / $boxQuantity) : 0; $fullBoxes = (int) floor($productTotalQty / $boxQuantity); $remainder = (int) ($productTotalQty % $boxQuantity); $productCode = $productData['product_code'] ?? 'N/A'; $sheetNo = $loop->iteration; $matrixCols = 2 + count($activeSizes) + 1; @endphp {{-- Title --}} {{-- Order meta: label | value pairs on separate rows --}} {{-- Shipping --}} {{-- Blank spacer row --}} {{-- Size matrix header --}} @foreach($activeSizes as $size) @endforeach @php $sr = 1; @endphp @foreach($uniqueColors as $color) @foreach($activeSizes as $size) @php $qty = (int) $items->where('color', $color)->where('size', $size)->sum('quantity'); @endphp @endforeach @endforeach {{-- Totals row --}} @foreach($activeSizes as $size) @endforeach {{-- Blank spacer --}} {{-- Box summary: one field per row --}} @if($fullBoxes > 0) @endif @if($remainder > 0) @endif {{-- Packed by --}}
Order Packing Sheet
Sheet No {{ $sheetNo }} / {{ $totalProducts }} Order ID {{ $orderId }}
Booking Date {{ $bookingDate }} Product Code {{ $productCode }}
Product Name {{ $productName }}
Shipping To
Name {{ $order->user->name ?? '' }}
Company {{ $order->user->company_name ?? '' }}
Phone {{ admin_phone($order->user->phone_number ?? '') }}
Address {{ $order->user->complete_address ?? '' }}
 
Color × Size Quantity
Sr. Color{{ $size }}Total
{{ str_pad($sr++, 2, '0', STR_PAD_LEFT) }} {{ $color }}{{ $qty > 0 ? $qty : '-' }}{{ (int) $items->where('color', $color)->sum('quantity') }}
TOTAL{{ (int) $items->where('size', $size)->sum('quantity') }}{{ (int) $productTotalQty }}
 
Order Summary
Total Quantity {{ (int) $productTotalQty }}
Box Capacity (pcs) {{ (int) $boxQuantity }}
Full Boxes (1–{{ $fullBoxes }}) {{ $fullBoxes }} × {{ (int) $boxQuantity }} pcs
Last Box (Box {{ $fullBoxes + 1 }}) {{ $remainder }} pcs
Total Boxes {{ $totalBoxes }}
 
Packed By — Name Sign
@if(!$loop->last)

 

@endif @endforeach