@php // Price formatting helper function $priceFormat = $setting['price_format'] ?? null; function formatPrice($number, $decimals = 2, $priceFormat = null) { $number = (float) $number; $decimals = (int) $decimals; if (empty($priceFormat)) { return number_format($number, $decimals, '.', ','); } switch ($priceFormat) { case 'comma_dot': return number_format($number, $decimals, '.', ','); case 'dot_comma': return number_format($number, $decimals, ',', '.'); case 'space_comma': return number_format($number, $decimals, ',', ' '); default: return number_format($number, $decimals, '.', ','); } } @endphp
@if(!empty($setting['logo']) && file_exists(public_path('images/'.$setting['logo']))) Logo @endif
PURCHASE ORDER
{{$purchase['Ref']}}
Date: @php $dateFormat = $setting['date_format'] ?? 'YYYY-MM-DD'; $dateTime = \Carbon\Carbon::parse($purchase['date']); $phpDateFormat = str_replace(['YYYY', 'MM', 'DD'], ['Y', 'm', 'd'], $dateFormat); // Check if original date string contains time $hasTime = strpos($purchase['date'], ' ') !== false && preg_match('/\d{1,2}:\d{2}/', $purchase['date']); if ($hasTime) { $formattedDate = $dateTime->format($phpDateFormat . ' H:i'); // Preserve seconds if they exist if (preg_match('/:\d{2}:\d{2}/', $purchase['date'])) { $formattedDate = $dateTime->format($phpDateFormat . ' H:i:s'); } } else { $formattedDate = $dateTime->format($phpDateFormat); } @endphp {{$formattedDate}}
Order #: {{$purchase['Ref']}}
Status: @php $statusColors = [ 'completed' => ['bg' => '#d1fae5', 'color' => '#065f46'], 'received' => ['bg' => '#d1fae5', 'color' => '#065f46'], 'pending' => ['bg' => '#fef3c7', 'color' => '#92400e'], 'ordered' => ['bg' => '#dbeafe', 'color' => '#1e40af'], ]; $statusKey = strtolower($purchase['statut']); $statusStyle = $statusColors[$statusKey] ?? ['bg' => '#e5e7eb', 'color' => '#374151']; @endphp {{$purchase['statut']}}
Payment: @php $paymentKey = strtolower($purchase['payment_status']); $paymentStyle = $statusColors[$paymentKey] ?? ['bg' => '#e5e7eb', 'color' => '#374151']; @endphp {{$purchase['payment_status']}}
SUPPLIER INFO
{{$purchase['supplier_name']}}
Phone: {{$purchase['supplier_phone']}}
Email: {{$purchase['supplier_email']}}
Address: {{$purchase['supplier_adr']}}
@if($purchase['supplier_tax'])
Tax #: {{$purchase['supplier_tax']}}
@endif
COMPANY INFO
{{$setting['CompanyName']}}
Phone: {{$setting['CompanyPhone']}}
Email: {{$setting['email']}}
Address: {{$setting['CompanyAdress']}}
@php $rowIndex = 0; @endphp @foreach ($details as $detail) @php $rowIndex++; @endphp @endforeach
PRODUCT COST QTY DISC TAX TOTAL
{{$detail['name']}}
Code: {{$detail['code']}}
@if($detail['is_imei'] && $detail['imei_number'] !==null)
SN: {{$detail['imei_number']}}
@endif
{{$detail['cost']}} {{$detail['quantity']}} {{$detail['unit_purchase']}} {{$detail['DiscountNet']}} {{$detail['taxe']}} {{$detail['total']}}
Subtotal: {{$symbol}} {{formatPrice((float)($purchase['GrandTotal'] - $purchase['TaxNet'] + $purchase['discount'] - $purchase['shipping']), 2, $priceFormat)}}
Order Tax: {{$symbol}} {{formatPrice((float)$purchase['TaxNet'], 2, $priceFormat)}}
Discount: - {{$symbol}} {{formatPrice((float)$purchase['discount'], 2, $priceFormat)}}
Shipping: {{$symbol}} {{formatPrice((float)$purchase['shipping'], 2, $priceFormat)}}
TOTAL: {{$symbol}} {{formatPrice((float)$purchase['GrandTotal'], 2, $priceFormat)}}
Paid Amount: {{$symbol}} {{formatPrice((float)$purchase['paid_amount'], 2, $priceFormat)}}
Amount Due: {{$symbol}} {{formatPrice((float)$purchase['due'], 2, $priceFormat)}}
@if($setting['is_invoice_footer'] && $setting['invoice_footer'] !==null)

{{$setting['invoice_footer']}}

@endif

Thank you for your business!