@php $pdfLocale = app()->getLocale(); $isRtl = $pdfLocale === 'ar'; $rtlLabelSuffix = $isRtl ? '' : ':'; @endphp Sales Return - {{$return_sale['Ref']}} @php $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
@php $logoSrc = null; if (!empty($setting['logo'])) { $logoPath = public_path('images/'.$setting['logo']); if (file_exists($logoPath) && is_readable($logoPath)) { $logoData = @file_get_contents($logoPath); if ($logoData !== false) { $logoB64 = base64_encode($logoData); $logoExt = strtolower(pathinfo($logoPath, PATHINFO_EXTENSION)); $logoMime = $logoExt === 'svg' ? 'image/svg+xml' : (in_array($logoExt, ['png','jpeg','jpg','gif','webp'], true) ? 'image/'.$logoExt : 'image/png'); if ($logoExt === 'jpg') { $logoMime = 'image/jpeg'; } $logoSrc = 'data:'.$logoMime.';base64,'.$logoB64; } } } @endphp @if($logoSrc) Logo @endif
{{ __('pdf.sales_return') }}
{{$return_sale['Ref']}}
{{ __('pdf.date') }}{{ $isRtl ? '' : ':' }} @php $dateFormat = $setting['date_format'] ?? 'YYYY-MM-DD'; $dateTime = \Carbon\Carbon::parse($return_sale['date']); $phpDateFormat = str_replace(['YYYY', 'MM', 'DD'], ['Y', 'm', 'd'], $dateFormat); // Check if original date string contains time $hasTime = strpos($return_sale['date'], ' ') !== false && preg_match('/\d{1,2}:\d{2}/', $return_sale['date']); if ($hasTime) { $formattedDate = $dateTime->format($phpDateFormat . ' H:i'); // Preserve seconds if they exist if (preg_match('/:\d{2}:\d{2}/', $return_sale['date'])) { $formattedDate = $dateTime->format($phpDateFormat . ' H:i:s'); } } else { $formattedDate = $dateTime->format($phpDateFormat); } @endphp {{$formattedDate}}
Return #: {{$return_sale['Ref']}}
Sale Ref: {{$return_sale['sale_ref']}}
Status: @php $statusColors = [ 'completed' => ['bg' => '#d1fae5', 'color' => '#065f46'], 'received' => ['bg' => '#d1fae5', 'color' => '#065f46'], 'pending' => ['bg' => '#fef3c7', 'color' => '#92400e'], ]; $statusKey = strtolower($return_sale['statut']); $statusStyle = $statusColors[$statusKey] ?? ['bg' => '#e5e7eb', 'color' => '#374151']; @endphp {{$return_sale['statut']}}
{{ __('pdf.payment') }}{{ $isRtl ? '' : ':' }} @php $paymentKey = strtolower($return_sale['payment_status']); $paymentStyle = $statusColors[$paymentKey] ?? ['bg' => '#e5e7eb', 'color' => '#374151']; @endphp {{$return_sale['payment_status']}}
{{ __('pdf.customer_info') }}
{{$return_sale['client_name']}}
@if($isRtl) @if($return_sale['client_tax']) @endif @else @if($return_sale['client_tax']) @endif @endif
{{$return_sale['client_phone']}}{{ __('pdf.phone') }}
{{$return_sale['client_email']}}{{ __('pdf.email') }}
{{$return_sale['client_adr']}}{{ __('pdf.address') }}
{{$return_sale['client_tax']}}{{ __('pdf.tax_no') }}
{{ __('pdf.phone') }}:{{$return_sale['client_phone']}}
{{ __('pdf.email') }}:{{$return_sale['client_email']}}
{{ __('pdf.address') }}:{{$return_sale['client_adr']}}
{{ __('pdf.tax_no') }}:{{$return_sale['client_tax']}}
{{ __('pdf.company_info') }}
{{$setting['CompanyName']}}
@if($isRtl) @else @endif
{{$setting['CompanyPhone']}}{{ __('pdf.phone') }}
{{$setting['email']}}{{ __('pdf.email') }}
{{$setting['CompanyAdress']}}{{ __('pdf.address') }}
{{ __('pdf.phone') }}:{{$setting['CompanyPhone']}}
{{ __('pdf.email') }}:{{$setting['email']}}
{{ __('pdf.address') }}:{{$setting['CompanyAdress']}}
@php $rowIndex = 0; $pdfDateFormat = $setting['date_format'] ?? 'YYYY-MM-DD'; $phpBatchDateFormat = str_replace(['YYYY', 'MM', 'DD'], ['Y', 'm', 'd'], $pdfDateFormat); $formatBatchDate = function ($d) use ($phpBatchDateFormat) { if (empty($d)) return null; try { return \Carbon\Carbon::parse($d)->format($phpBatchDateFormat); } catch (\Exception $e) { return (string) $d; } }; @endphp @foreach ($details as $detail) @if(!empty($detail['is_batch_tracked']) && !empty($detail['batches'])) @endif @php $rowIndex++; @endphp @endforeach
{{ __('pdf.product') }} {{ __('pdf.price') }} {{ __('pdf.qty') }} {{ __('pdf.disc') }} {{ __('pdf.tax') }} {{ __('pdf.total') }}
{{$detail['name']}}
{{ __('pdf.code') }} {{$detail['code']}}
@if($detail['is_imei'] && $detail['imei_number'] !==null)
{{ __('pdf.sn') }} {{$detail['imei_number']}}
@endif
{{$detail['price']}} {{$detail['quantity']}} {{$detail['unitSale']}} {{$detail['DiscountNet']}} {{$detail['taxe']}} {{$detail['total']}}
{{ __('pdf.batches') }} {{ count($detail['batches']) }}
@foreach($detail['batches'] as $bIdx => $b) @php $expiryStyle = 'background: #f3f4f6; color: #6b7280;'; if (!empty($b['expiry_date'])) { try { $expDate = \Carbon\Carbon::parse($b['expiry_date'])->startOfDay(); $today = \Carbon\Carbon::now()->startOfDay(); $diffDays = $today->diffInDays($expDate, false); if ($diffDays < 0) { $expiryStyle = 'background: #fee2e2; color: #991b1b;'; } elseif ($diffDays <= 30) { $expiryStyle = 'background: #fef3c7; color: #92400e;'; } else { $expiryStyle = 'background: #d1fae5; color: #065f46;'; } } catch (\Exception $e) {} } $qtyStr = number_format((float)($b['qty'] ?? 0), 2, '.', ''); $unitPrice = isset($b['unit_price']) && $b['unit_price'] !== null ? $symbol.' '.formatPrice((float)$b['unit_price'], 2, $priceFormat) : '—'; $rowBg = $bIdx % 2 === 1 ? '#f8faff' : '#ffffff'; $mfgFormatted = $formatBatchDate($b['mfg_date'] ?? null); $expFormatted = $formatBatchDate($b['expiry_date'] ?? null); @endphp @endforeach
{{ __('pdf.batch_no') }} {{ __('pdf.mfg') }} {{ __('pdf.exp') }} {{ __('pdf.qty') }} {{ __('pdf.price') }}
@if(!empty($b['batch_no'])) {{ $b['batch_no'] }} @else @endif @if($mfgFormatted) {{ $mfgFormatted }} @else @endif @if($expFormatted) {{ $expFormatted }} @else @endif {{ $qtyStr }} {{ $detail['unitSale'] }} {{ $unitPrice }}
@php $tdAmountLeft = 'padding: 5px 10px; font-size: 8.5pt; font-weight: 600; text-align: left; direction: ltr;'; $tdLabelRight = 'padding: 5px 10px; font-size: 8pt; font-weight: 600; text-align: right; direction: rtl;'; @endphp
@if($isRtl) @else @endif
{{$symbol}} {{formatPrice((float)($return_sale['GrandTotal'] - $return_sale['TaxNet'] + $return_sale['discount'] - $return_sale['shipping']), 2, $priceFormat)}}{{ __('pdf.subtotal') }}{!! $rtlLabelSuffix !!}
{{$symbol}} {{formatPrice((float)$return_sale['TaxNet'], 2, $priceFormat)}}{{ __('pdf.order_tax') }}{!! $rtlLabelSuffix !!}
- {{$symbol}} {{formatPrice((float)$return_sale['discount'], 2, $priceFormat)}}{{ __('pdf.discount') }}{!! $rtlLabelSuffix !!}
{{$symbol}} {{formatPrice((float)$return_sale['shipping'], 2, $priceFormat)}}{{ __('pdf.shipping') }}{!! $rtlLabelSuffix !!}
{{$symbol}} {{formatPrice((float)$return_sale['GrandTotal'], 2, $priceFormat)}}{{ __('pdf.total_return') }}{!! $rtlLabelSuffix !!}
{{$symbol}} {{formatPrice((float)$return_sale['paid_amount'], 2, $priceFormat)}}{{ __('pdf.refunded') }}{!! $rtlLabelSuffix !!}
{{$symbol}} {{formatPrice((float)$return_sale['due'], 2, $priceFormat)}}{{ __('pdf.amount_due') }}{!! $rtlLabelSuffix !!}
{{ __('pdf.subtotal') }}{{$symbol}} {{formatPrice((float)($return_sale['GrandTotal'] - $return_sale['TaxNet'] + $return_sale['discount'] - $return_sale['shipping']), 2, $priceFormat)}}
{{ __('pdf.order_tax') }}{{$symbol}} {{formatPrice((float)$return_sale['TaxNet'], 2, $priceFormat)}}
{{ __('pdf.discount') }}- {{$symbol}} {{formatPrice((float)$return_sale['discount'], 2, $priceFormat)}}
{{ __('pdf.shipping') }}{{$symbol}} {{formatPrice((float)$return_sale['shipping'], 2, $priceFormat)}}
{{ __('pdf.total_return') }}{{$symbol}} {{formatPrice((float)$return_sale['GrandTotal'], 2, $priceFormat)}}
{{ __('pdf.refunded') }}{{$symbol}} {{formatPrice((float)$return_sale['paid_amount'], 2, $priceFormat)}}
{{ __('pdf.amount_due') }}{{$symbol}} {{formatPrice((float)$return_sale['due'], 2, $priceFormat)}}
@if($setting['is_invoice_footer'] && $setting['invoice_footer'] !==null)

{{$setting['invoice_footer']}}

@endif

{{ __('pdf.thank_you') }}