@php $pdfLocale = app()->getLocale(); $isRtl = $pdfLocale === 'ar'; $rtlLabelSuffix = $isRtl ? '' : ':'; @endphp Stock Transfer - {{$transfer['Ref']}}
@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.stock_transfer') }}
{{$transfer['Ref']}}
{{ __('pdf.date') }}{{ $isRtl ? '' : ':' }} @php $dateFormat = $setting['date_format'] ?? 'YYYY-MM-DD'; $dateTime = \Carbon\Carbon::parse($transfer['date']); $phpDateFormat = str_replace(['YYYY', 'MM', 'DD'], ['Y', 'm', 'd'], $dateFormat); // Check if original date string contains time $hasTime = strpos($transfer['date'], ' ') !== false && preg_match('/\d{1,2}:\d{2}/', $transfer['date']); if ($hasTime) { $formattedDate = $dateTime->format($phpDateFormat . ' H:i'); // Preserve seconds if they exist if (preg_match('/:\d{2}:\d{2}/', $transfer['date'])) { $formattedDate = $dateTime->format($phpDateFormat . ' H:i:s'); } } else { $formattedDate = $dateTime->format($phpDateFormat); } @endphp {{$formattedDate}}
{{ __('pdf.transfer_no') }}{{ $isRtl ? '' : ':' }} {{$transfer['Ref']}}
{{ __('pdf.status') }}{{ $isRtl ? '' : ':' }} @php $statusColors = [ 'completed' => ['bg' => '#d1fae5', 'color' => '#065f46'], 'sent' => ['bg' => '#d1fae5', 'color' => '#065f46'], 'pending' => ['bg' => '#fef3c7', 'color' => '#92400e'], ]; $statusKey = strtolower($transfer['statut']); $statusStyle = $statusColors[$statusKey] ?? ['bg' => '#e5e7eb', 'color' => '#374151']; @endphp {{$transfer['statut']}}
{{ __('pdf.from_warehouse') }}
{{$transfer['from_warehouse']}}
{{ __('pdf.to_warehouse') }}
{{$transfer['to_warehouse']}}
@php $rowIndex = 0; $totalQty = 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) @php $rowIndex++; $totalQty += (int)$detail['quantity']; @endphp @if(!empty($detail['is_batch_tracked']) && !empty($detail['batches'])) @endif @endforeach
{{ __('pdf.product') }} {{ __('pdf.quantity') }}
{{$detail['name']}}
{{ __('pdf.code') }} {{$detail['code']}}
{{$detail['quantity']}} {{$detail['unit_purchase']}}
{{ __('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, '.', ''); $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') }}
@if(!empty($b['batch_no'])) {{ $b['batch_no'] }} @else — @endif @if($mfgFormatted) {{ $mfgFormatted }} @else — @endif @if($expFormatted) {{ $expFormatted }} @else — @endif {{ $qtyStr }} {{ $detail['unit_purchase'] }}
@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
{{$rowIndex}} {{ __('pdf.total_items') }}{!! $rtlLabelSuffix !!}
{{$totalQty}} {{ __('pdf.total_quantity') }}{!! $rtlLabelSuffix !!}
{{ __('pdf.total_items') }} {{$rowIndex}}
{{ __('pdf.total_quantity') }} {{$totalQty}}
@if($setting['is_invoice_footer'] && $setting['invoice_footer'] !==null)

{{$setting['invoice_footer']}}

@endif

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