@php $items = collect($order->items ?? []); $printedDate = $printedAt ?? now(); $customerName = trim((string) ($order->customer_name ?? optional($order->customer)->name ?? 'INSTANSI')); $invoiceNumber = trim((string) ($order->invoice_number ?? '-')); $suratJalanNumber = 'SJ/' . $printedDate->format('d') . '/' . preg_replace('/[^A-Za-z0-9]/', '', strtoupper(substr($customerName, 0, 12))) . '/' . $printedDate->format('m/Y'); $prNo = $order->pr_number ?? '-'; $poNo = $order->po_number ?? '-'; $vehicleName = $order->vehicle_name ?? ''; $plateNo = $order->plate_number ?? ''; $preparedBy = optional($order->designer)->name ?: 'Admin'; $rows = []; foreach ($items as $item) { $qty = (float) ($item->qty ?? 0); $qtyText = $qty > 0 ? rtrim(rtrim(number_format($qty, 2, ',', '.'), '0'), ',') : '-'; $productName = trim((string) ($item->product_name ?? '')); $fileName = trim((string) ($item->file_name ?? '')); $sizeDesc = trim((string) ($item->size_description ?? '')); $finishing = trim((string) ($item->finishing_note ?? '')); $descParts = array_filter([ $productName !== '' ? $productName : null, $fileName !== '' && $fileName !== $productName ? 'File: ' . $fileName : null, $sizeDesc !== '' ? 'Ukuran: ' . $sizeDesc : null, $finishing !== '' ? 'Finishing: ' . $finishing : null, ]); $rows[] = [ 'qty' => $qtyText, 'desc' => !empty($descParts) ? implode(' | ', $descParts) : '-', ]; } $minRows = 10; $blankRows = max($minRows - count($rows), 0); @endphp
@if(!empty($shopLogo)) Logo @else
{{ $shopName ?? 'Nama Perusahaan' }}
{{ $shopAddress ?? '' }}
{{ $shopPhone ?? '' }}
@endif
Kepada : {{ $customerName !== '' ? $customerName : 'INSTANSI' }}
PR No. : {{ $prNo }}
PO No. : {{ $poNo }}
SURAT JALAN No. {{ $suratJalanNumber }}
Kami kirimkan barang - barang tersebut dibawah ini dengan kendaraan {{ $vehicleName !== '' ? $vehicleName : 'Kendaraan' }} No. {{ $plateNo !== '' ? $plateNo : 'Plat No' }}
@forelse($rows as $row) @empty @endforelse @for($i = 0; $i < $blankRows; $i++) @endfor
QUANTITY RINCIAN
{{ $row['qty'] }} {{ $row['desc'] }}
   
   
Tanda Terima Hormat Kami,
  {{ $preparedBy }}
@if(!empty($shopAddress) || !empty($shopPhone)) @endif