{{-- Badge نوع الفاتورة --}} @php $invoiceTypeText = match ($invoice->type) { 'sale' => 'فاتورة بيع', 'purchase' => 'فاتورة شراء', 'refund' => 'فاتورة استرجاع', default => 'فاتورة', }; @endphp
{{ $invoiceTypeText }}
{{--
{!! $qrCode !!}
--}}
@php $companyKeys = [ 'company_name_en', 'company_name_ar', 'company_address_en', 'company_address_ar', 'tax_number', 'commercial_register', 'tourism_license', 'building_no', 'street', 'district', 'city', 'postal_code', 'additional_no', 'other_info', ]; $company = \App\Models\Setting::whereIn('key', $companyKeys)->pluck('value', 'key'); // Determine first reservation (supports unified invoices with multiple reservations) $firstReservation = (isset($reservations) && $reservations instanceof \Illuminate\Support\Collection && $reservations->isNotEmpty()) ? $reservations->first() : $reservation; // Related entity from reservation morph $related = $firstReservation?->related; $relatedName = $related->company_name ?? ($related->name ?? ''); // Passenger on reservation (first one if unified) $passengerName = $firstReservation?->passenger?->first_name; // Build items collection robustly if ($invoice->items_ids) { $items_ids = json_decode($invoice->items_ids, true) ?: []; if (isset($reservations) && $reservations instanceof \Illuminate\Support\Collection && $reservations->isNotEmpty()) { $items = $reservations->flatMap(function ($res) use ($items_ids) { return $res->items()->with('supplier')->whereIn('id', $items_ids)->get(); }); } else { $items = $firstReservation ? $firstReservation->items()->with('supplier')->whereIn('id', $items_ids)->get() : collect(); } } else { if (isset($reservations) && $reservations instanceof \Illuminate\Support\Collection && $reservations->isNotEmpty()) { $items = $reservations->flatMap(function ($res) { return $res->items()->with('supplier')->get(); }); } else { $items = $firstReservation ? $firstReservation->items()->with('supplier')->get() : collect(); } } // Service type: prefer item's service_type; fallback to mapped Arabic by reservation_type or raw $reservationTypes = [ 'hotel' => 'فندق', 'car' => 'سيارة', 'tourism' => 'سياحة', 'visa' => 'تأشيرات', 'international_license' => 'رخصة قيادة دولية', 'train' => 'حجز قطار', 'meeting_room' => 'حجز قاعة إجتماعات', 'internal_transport' => 'تنقلات داخلية ', 'other' => 'أخرى', ]; @endphp
Invoice Number: {{ $invoice->invoice_number }} :رقم الفاتورة
Issue Time: {{ $invoice->created_at->format('Y-m-d H:i:s') }} :وقت الإصدار
Supply Date: {{ $invoice->created_at->format('Y-m-d') }} :تاريخ التوريد
Supply (Hijri): - :تاريخ التوريد (هجري)
Due Date: {{ $invoice->due_date ? $invoice->due_date->format('Y-m-d') : $invoice->created_at->format('Y-m-d') }} :تاريخ الاستحقاق
حالة الدفع: استحقت الدفع - مسجلة
عملة الفاتورة: SAR
@if ($invoice->type === 'refund' && $invoice->reference_num)
الفاتورة المرجعية: {{ $invoice->reference_num }}
@endif
{{-- المشتري --}}
المشتري - Buyer
:الاسم {{ $relatedName }}
:رقم المبنى {{ $related->contactInfo->building_number ?? '-' }}
:العنوان (الشارع) {{ $related->address ?? ($related->contactInfo->address ?? '-') }}
:المنطقة {{ $related->contactInfo->region ?? '-' }}
:المدينة {{ $related->contactInfo->city ?? '-' }}
:الدولة SA - المملكة العربية السعودية
:الرمز البريدي {{ $related->contactInfo->postal_code ?? '-' }}
:الرقم الإضافي {{ $related->contactInfo->additional_number ?? '-' }}
:الرقم الضريبي {{ $related->tax_number ?? '-' }}
:بطاقة تجارية -
{{-- البائع --}}
البائع - Seller
:الاسم {{ $company['company_name_ar'] ?? ($company['company_name_en'] ?? '') }}
:رقم المبنى {{ $company['building_no'] ?? '-' }}
:العنوان (الشارع) {{ $company['street'] ?? ($company['company_address_ar'] ?? '-') }}
:المنطقة {{ $company['district'] ?? '-' }}
:المدينة {{ $company['city'] ?? 'جدة' }}
:الدولة SA - المملكة العربية السعودية
:الرمز البريدي {{ $company['postal_code'] ?? '-' }}
:الرقم الإضافي {{ $company['additional_no'] ?? '-' }}
:الرقم الضريبي {{ $company['tax_number'] ?? '' }}
:السجل التجاري {{ $company['commercial_register'] ?? '' }}
@php $row = 1; @endphp @forelse($items as $item) @php $serviceType = $item->service_type ?: $reservationTypes[$item->reservation_type] ?? $item->reservation_type; $supplierName = $item->supplier->name ?? '-'; @endphp @empty @endforelse
# نوع الخدمة المورد التفاصيل المبلغ
{{ $row++ }} {{ $serviceType }} {{ $supplierName }} @if ($item->isHotel())
حجز فندق
اسم الفندق: {{ $item->hotel_name }} / نوع الغرفة: {{ $item->room_type }} / عدد الليالي: {{ $item->nights_count }}
@else
{{ $serviceType }}
تفاصيل الخدمة: {{ $item->service_details ?? '-' }}
@endif
{{ number_format((float) $item->total_amount, 2) }}
لا توجد عناصر
الضرائب (Taxes): {{ number_format((float) $invoice->total_amount - $items->sum('total_amount'), 2) }} SAR
الإجمالي النهائي (Total): {{ number_format((float) $invoice->total_amount, 2) }} SAR
@if (!empty($invoice->notes))

ملاحظات

{{ $invoice->notes }}

@endif @if (!empty($company['other_info']))
ملاحظات:

{{ $company['other_info'] }}

@endif