OLIVIA                      NOTA PEMBELIAN
  Kepada Yth.
  {{ str_pad($purchaseInvoice->suppliers->supplier_name ?? 'N/A', 35) }}No. Invoice : {{ $purchaseInvoice->purchase_invoice_number }}
  {{ str_pad($purchaseInvoice->suppliers->address ?? 'N/A', 35) }}Tanggal     : {{ \Carbon\Carbon::parse($purchaseInvoice->document_date)->format('d M Y') }}

 ———————————————————————————————————————————————————————————————————————————————————————
 |NO.|NAMA BARANG                              |         QTY|      HARGA |       JUMLAH|
 ———————————————————————————————————————————————————————————————————————————————————————
@foreach($purchaseInvoice->details as $index => $detail)
@php
    $maxLength = 35; // Max length for item name
    $itemName = $detail->items->item_name;
    $lines = explode("\n", wordwrap($itemName, $maxLength, "\n", false)); // Word-based wrapping
@endphp
@foreach($lines as $lineIndex => $line)
@if($lineIndex == 0)
 |{{ str_pad($loop->parent->iteration . '.', 3) }}|{{ str_pad($line, 41) }}|{{ str_pad(number_format($detail->qty, 2, ',', '.') . ' ' . $detail->baseUnit->unit_name, 12, ' ', STR_PAD_LEFT) }}|{{ str_pad(number_format($detail->price, 0, ',', '.'), 12, ' ', STR_PAD_LEFT) }}|{{ str_pad(number_format(($detail->qty*$detail->price), 0, ',', '.'), 13, ' ', STR_PAD_LEFT) }}|
@else
 |{{ str_pad('', 3) }}|{{ str_pad($line, 41) }}|{{ str_pad('', 12) }}|{{ str_pad('', 12) }}|{{ str_pad('', 13) }}|
@endif
@endforeach
@endforeach
 ———————————————————————————————————————————————————————————————————————————————————————
@php
    $maxLength = 35; // Max length for Terbilang
    $terbilang = "Terbilang: " . $totalHuruf;
    $terbilangLines = explode("\n", wordwrap($terbilang, $maxLength, "\n", false));
    // Ensure at least 3 lines for Terbilang, padding with empty strings if needed
    while (count($terbilangLines) < 3) {
        $terbilangLines[] = '';
    }
@endphp
  {{ str_pad($terbilangLines[0], 35) }}                    Sub Total    : {{ str_pad(number_format($purchaseInvoice->subtotal+$totalDiscount, 0, ',', '.'), 15, ' ', STR_PAD_LEFT) }}
  {{ str_pad($terbilangLines[1], 35) }}                    Discount     : {{ str_pad(number_format(+$totalDiscount, 0, ',', '.'), 15, ' ', STR_PAD_LEFT) }}
  {{ str_pad($terbilangLines[2], 35) }}                    Total Invoice: {{ str_pad(number_format($purchaseInvoice->total, 0, ',', '.'), 15, ' ', STR_PAD_LEFT) }}
@if(isset($terbilangLines[3]))
@foreach(array_slice($terbilangLines, 3) as $extraLine)
  {{ str_pad($extraLine, 35) }}
@endforeach
@endif


        
Kembali