@php $dir = $direction ?? 'rtl'; $isRtl = $dir === 'rtl'; $start = $isRtl ? 'right' : 'left'; $end = $isRtl ? 'left' : 'right'; // ── Logo (fallback to first company if not provided) ── $logoImg = $logoSrc ?? null; if (!$logoImg) { $logoImgRaw = data_get($company ?? [], 'invoice_logo') ?: null; if (!$logoImgRaw && isset($companies) && $companies->count()) { $logoImgRaw = data_get($companies->first(), 'invoice_logo') ?: null; } $isHtml = request()->query('view') === 'html'; if ($logoImgRaw) { $logoImg = $isHtml ? asset($logoImgRaw) : public_path($logoImgRaw); if (!$isHtml && !file_exists($logoImg)) $logoImg = null; } } // ── Company information ── $companyVat = $company_vat ?? data_get($company ?? [], 'company_vat') ?? data_get($company ?? [], 'tax_number') ?? (isset($companies) && $companies->count() ? ($companies->first()->company_vat ?? $companies->first()->tax_number ?? null) : null) ?? '---'; $companyName = $company_name ?? data_get($company ?? [], 'company_name') ?? data_get($company ?? [], 'name_company') ?? (isset($companies) && $companies->count() ? ($companies->first()->name_company ?? $companies->first()->company_name ?? null) : null) ?? 'Azora'; $companyCurrency = $currency ?? data_get($company ?? [], 'currency', null); // ── Report title (language‑specific) ── // Map supports both short keys (from controller) and full keys $typeTitleMap = [ 'Daily' => 'التقرير اليومي', 'Daily ' => 'التقرير اليومي', 'Daily Report' => 'التقرير اليومي', 'General Ledger' => 'ميزان المراجعة', 'General Ledger Report' => 'ميزان المراجعة', 'Ledger' => 'دفتر الأستاذ', 'Ledger Report' => 'دفتر الأستاذ', 'Bank Statement' => 'كشف حساب بنكي', 'Bank Statement Report' => 'كشف حساب بنكي', 'Cost Center' => 'تقرير مركز التكلفة', 'Cost Center Report' => 'تقرير مركز التكلفة', 'balance' => 'الميزانية العمومية', 'Balance Sheet' => 'الميزانية العمومية', 'Balance Sheet Report' => 'الميزانية العمومية', 'income' => 'قائمة الدخل', 'Income Statement' => 'قائمة الدخل', 'Income Statement Report' => 'قائمة الدخل', ]; $rawType = (isset($type) && $type) ? trim($type) : null; $arTitle = $title_ar ?? ($rawType ? ($typeTitleMap[$rawType] ?? $rawType) : 'تقرير'); $enTitle = $title_en ?? ($rawType ? $rawType : 'Report'); if (!str_contains(strtolower($enTitle), 'report')) { $enTitle = trim($enTitle) . ' Report'; } $reportTitle = $isRtl ? $arTitle : $enTitle; // Full title — for RTL just show Arabic name, for LTR show English $fullReportTitle = $reportTitle; $rawStatus = $status ?? null; $statusLabel = null; if ($rawStatus) { $isApproved = in_array(strtolower($rawStatus), ['approved', 'معتمد', 'posted']); $statusLabel = $isApproved ? 'معتمد / Approved' : 'مسودة / Draft'; } // ── Report number & issue date ── $reportNumber = $report_number ?? null; $issueDate = $issue_date ?? null; @endphp
{{-- ROW 1 – Company name, VAT and Logo – alignment depends on direction --}}
@if($isRtl) {{-- Arabic layout: company name on the right, VAT on the left, logo on the right (above) --}}
{{ $companyName }}
الرقم الضريبي: {{ $companyVat }} @if($companyCurrency)
العملة: {{ $companyCurrency }} @endif
@if($logoImg) @endif @else {{-- English layout: logo on the left, company info on the right --}} @if($logoImg) @endif
{{ $companyName }}
Tax ID: {{ $companyVat }} @if($companyCurrency)
Currency: {{ $companyCurrency }} @endif
@endif
{{-- ROW 2 – Title and Period – right‑aligned for RTL, left‑aligned for LTR --}}
{{ $fullReportTitle }}
@if(!empty($date_from) && !empty($date_to))
{{ $isRtl ? 'الفترة:' : 'Period:' }} {{ $date_from }} - {{ $date_to }}
@endif
{{-- OPTIONAL: Details bar (Status | Issue Date | Report No.) – kept same for both directions --}} @if($reportNumber || $issueDate || $statusLabel)
@if($statusLabel)
{{ $isRtl ? 'الحالة' : 'Status' }}
{{ $statusLabel }}
@endif
@if($issueDate)
{{ $isRtl ? 'إصدار' : 'Issue Date' }}
{{ $issueDate }}
@endif
@if($reportNumber)
{{ $isRtl ? 'رقم التقرير' : 'Report No.' }}
{{ $reportNumber }}
@endif
@endif {{-- ROW 4 – Companies table when more than one company – headers bilingual based on direction --}} @if(isset($companies) && $companies->count() > 1)
@foreach($companies as $comp) @endforeach
{{ $isRtl ? 'اسم الفرع' : 'Branch Name' }} {{ $isRtl ? 'الرقم الضريبي' : 'Company VAT' }}
{{ $comp->name_company ?? $comp->company_name ?? '' }} {{ $comp->company_vat ?? $comp->tax_number ?? '' }}
@endif