@php // Get company information based on system setting (admin or seller) $seller = $order->getCompanyInfo(); // Get Poslaju settings or fallback to seller/config data $poslajuSettings = $seller->poslajuSetting; // Data - Use database settings first, then seller profile, then config $senderName = $poslajuSettings->sender_name ?? $seller->company_name ?? $seller->name; $senderPhone = $poslajuSettings->sender_phone ?? $seller->company_phone ?? ''; $senderAddr = $poslajuSettings->sender_address ?? $seller->company_address ?? ''; $senderPostcode = $poslajuSettings->sender_postcode ?? $seller->company_postcode ?? ''; $senderCity = $poslajuSettings->sender_city ?? $seller->company_city ?? ''; $senderState = $poslajuSettings->sender_state ?? $seller->company_state ?? ''; $poslajuAccountId = $poslajuSettings->poslaju_account_id ?? config('poslaju.credentials.poslaju_account_id', '80000000'); // Poslaju Account ID $companyAccountNo = $poslajuSettings->account_number ?? config('poslaju.credentials.account_number', '8800564892'); // Company Account Number // Support both WooCommerce format (first_name/last_name) and sales page format (name) $recName = $order->shipping['name'] ?? $order->billing['name'] ?? trim(($order->shipping['first_name'] ?? $order->billing['first_name'] ?? '') . ' ' . ($order->shipping['last_name'] ?? $order->billing['last_name'] ?? '')); $recPhone = $order->billing['phone'] ?? ''; $recEmail = $order->billing['email'] ?? ''; // Support both WooCommerce format (address_1) and sales page format (address) $recAddr1 = $order->shipping['address_1'] ?? $order->shipping['address'] ?? $order->billing['address_1'] ?? $order->billing['address'] ?? ''; $recAddr2 = $order->shipping['address_2'] ?? $order->billing['address_2'] ?? ''; $recPostcode = $order->shipping['postcode'] ?? $order->billing['postcode'] ?? ''; $recCity = $order->shipping['city'] ?? $order->billing['city'] ?? ''; $recState = $order->shipping['state'] ?? $order->billing['state'] ?? ''; // State codes $stateCodes = [ 'johor' => 'JHR', 'kedah' => 'KDH', 'kelantan' => 'KEL', 'melaka' => 'MLK', 'negeri sembilan' => 'NSN', 'pahang' => 'PHG', 'penang' => 'PNG', 'perak' => 'PRK', 'perlis' => 'PLS', 'selangor' => 'SGR', 'terengganu' => 'TRG', 'sabah' => 'SBH', 'sarawak' => 'SWK', 'kuala lumpur' => 'KUL', 'labuan' => 'LBN', 'putrajaya' => 'PJY', ]; $stateCode = ''; foreach ($stateCodes as $key => $code) { if (stripos($recState, $key) !== false) { $stateCode = $code; break; } } if (empty($stateCode)) $stateCode = strtoupper(substr($recState, 0, 3)); $destCode = 'TTG--' . $stateCode; $serviceType = $order->isCOD() ? 'C' : 'A2'; // Generate Barcode $generator = new \Picqer\Barcode\BarcodeGeneratorSVG(); $barcodeSvg = $generator->getBarcode($order->tracking_number ?? 'N/A', \Picqer\Barcode\BarcodeGeneratorSVG::TYPE_CODE_128); $barcodeBase64 = base64_encode($barcodeSvg); // QR Data - Format: A2, EC869454334MY, 22102025, MY, 80000000, Mamadil & Slim Beauty Sdn Bhd, +60108840085, 21300, 8800564892, Elisa, Telupid Sabah, , 89320, Sabah, Sabah, +60146024108, ahmadk6097@gmail.com, 0.3 $qrData = implode(', ', [ $serviceType, // 1. Service Type (A2 or C) $order->tracking_number ?? 'N/A', // 2. Tracking Number $order->date_created ? $order->date_created->format('dmY') : now()->format('dmY'), // 3. Date (ddmmyyyy) 'MY', // 4. Country Code $poslajuAccountId, // 5. Poslaju Account ID (80000000) $senderName, // 6. Sender Name $senderPhone, // 7. Sender Phone $senderPostcode, // 8. Sender Postcode $companyAccountNo, // 9. Company Account Number (8800564892) $recName, // 10. Recipient Name $recCity . ' ' . $recState, // 11. Recipient City + State $recAddr2, // 12. Recipient Address 2 $recPostcode, // 13. Recipient Postcode $recState, // 14. Recipient State $recState, // 15. Recipient State (duplicate) $recPhone, // 16. Recipient Phone $recEmail, // 17. Recipient Email $poslajuSettings->default_weight ?? config('poslaju.defaults.weight', '0.3'), // 18. Weight ]); // QR code (30mm = ~113 pixels at 96 DPI, use 220 for better quality) $renderer = new \BaconQrCode\Renderer\ImageRenderer( new \BaconQrCode\Renderer\RendererStyle\RendererStyle(220, 0), new \BaconQrCode\Renderer\Image\SvgImageBackEnd() ); $writer = new \BaconQrCode\Writer($renderer); $qrCodeSvg = $writer->writeString($qrData); $qrCode = base64_encode($qrCodeSvg); // Check for logos - Use database settings first $poslajuLogoPath = null; $companyLogoPath = null; if ($poslajuSettings && $poslajuSettings->poslaju_logo_path) { // Check if it's new public path format (/images/...) if (str_starts_with($poslajuSettings->poslaju_logo_path, '/images/')) { $poslajuLogoPath = public_path($poslajuSettings->poslaju_logo_path); } else { // Old storage path format $poslajuLogoPath = storage_path('app/public/' . $poslajuSettings->poslaju_logo_path); } } elseif (file_exists(public_path('images/logos/poslaju.png'))) { $poslajuLogoPath = public_path('images/logos/poslaju.png'); } if ($poslajuSettings && $poslajuSettings->company_logo_path) { // Check if it's new public path format (/images/...) if (str_starts_with($poslajuSettings->company_logo_path, '/images/')) { $companyLogoPath = public_path($poslajuSettings->company_logo_path); } else { // Old storage path format $companyLogoPath = storage_path('app/public/' . $poslajuSettings->company_logo_path); } } elseif ($seller->company_logo) { // Check if it's new public path format (/images/...) if (str_starts_with($seller->company_logo, '/images/')) { $companyLogoPath = public_path($seller->company_logo); } else { // Absolute path $companyLogoPath = $seller->company_logo; } } elseif (file_exists(public_path('images/logos/company.png'))) { $companyLogoPath = public_path('images/logos/company.png'); } $hasPoslajuLogo = $poslajuLogoPath && file_exists($poslajuLogoPath); $hasCompanyLogo = $companyLogoPath && file_exists($companyLogoPath); @endphp
@if($hasPoslajuLogo) @else
POS Laju
@endif
Barcode
{{ $order->tracking_number ?? 'N/A' }}
{{ $destCode }}
@if($hasCompanyLogo) @else
{{ Str::limit($senderName, 15) }}
@endif
Sender Details (Pengirim)
Name: {{ $senderName }}
Phone: {{ App\Helpers\PhoneHelper::display($senderPhone) }}
Address:
{{ $senderAddr }}, {{ $senderPostcode }} {{ $senderCity }}, {{ $senderState }}.
Account No:
{{ $companyAccountNo }}
Recipient Details (Penerima)
Name: {{ $recName }}
Phone: {{ App\Helpers\PhoneHelper::display($recPhone) }}
Address:
{{ $recAddr1 }}@if($recAddr2), {{ $recAddr2 }}@endif, {{ $recPostcode }} {{ $recCity }}, {{ $recState }}.
QR
{{ $recPostcode }}
Item Details
Order Date: {{ $order->date_created ? $order->date_created->format('d/m/Y') : now()->format('d/m/Y') }}
Order ID: #{{ $order->global_order_id ?? $order->order_number }}
Weight: {{ $poslajuSettings->default_weight ?? config('poslaju.defaults.weight', '0.3') }} Kg ({{ $poslajuSettings->default_dimension_l ?? '1' }}cm X {{ $poslajuSettings->default_dimension_w ?? '1' }}cm X {{ $poslajuSettings->default_dimension_h ?? '1' }}cm)
Notes: {{ $order->customer_note ? Str::limit($order->customer_note, 30) : '-' }}
@if($order->isCOD())
COD: {{ $order->formatCurrency($order->total) }}
@endif @php $hideProductNames = $poslajuSettings->hide_product_names ?? false; @endphp @if(!$hideProductNames && is_array($order->line_items) && count($order->line_items) > 0)
@foreach($order->line_items as $index => $item) @if($index < 3) {{ $item['quantity'] ?? 1 }}x {{ Str::limit($item['name'] ?? 'Item', 40) }}
@endif @endforeach @if(count($order->line_items) > 3) +{{ count($order->line_items) - 3 }} more items @endif
@endif
@if(is_array($order->line_items) && count($order->line_items) > 0)
PACKING LIST (SKU x UNIT)
@foreach($order->getExpandedLineItems() as $expandedItem) @php $item = $expandedItem['item']; $isBundle = $expandedItem['is_bundle']; $bundleDetails = $expandedItem['bundle_details']; $sku = $item['sku'] ?? $item['id'] ?? 'N/A'; $quantity = $item['quantity'] ?? 1; @endphp @if($isBundle && $bundleDetails) @foreach($bundleDetails['items'] as $bundleItem)
{{ $bundleItem['sku'] ?? 'N/A' }} x {{ $bundleItem['quantity'] * $quantity }}
@endforeach @else
{{ $sku }} x {{ $quantity }}
@endif @endforeach
@endif