@extends('layouts.app') @section('title', 'Print Invoice') @section('navigation') @endsection @section('content')
{{-- Header --}}

BOOKING INVOICE UMH

Phone: {{ $booking->bookingBranch->contacts ?? '+966XXX-XXXXXXX' }}

{{ $booking->bookingBranch->name ?? 'BMT-Dak' }}

Invoice No: {{ $booking->invoice_id ?? '-' }}
@php $fpLocationValue = $booking->fingerprint_location; if ($fpLocationValue instanceof \BackedEnum) { $fpLocationValue = $fpLocationValue->value; } if ($fpLocationValue === 'home') { $fpLocation = 'Home'; } elseif ($fpLocationValue === 'office') { $fpLocation = $booking->fingerprintBranch?->address ?? '-'; } else { $fpLocation = '-'; } $fingerprintDeadline = $booking->fingerprint?->deadline?->format('d M Y'); $passengerMobileBd = $booking->passengers->first()?->mobile_no ?? '-'; $passengerAddress = $booking->passengers->first()?->address ?? '-'; $addressKsa = $booking->customer->address ?? '-'; @endphp {{-- Customer Information & Invoice Information --}}
{{-- Customer Information --}}
Customer Information
Booking Date : {{ $booking->booking_date ?? ($booking->created_at ? $booking->created_at->format('d M Y') : '-') }} Passenger Mobile (BD) : {{ $passengerMobileBd }}
Customer Name : {{ $booking->customer->name ?? '-' }} Passenger Address : {{ $passengerAddress }}
Iqama Number : {{ $booking->customer->iqama_no ?? '-' }} Fingerprint Deadline : {{ $fingerprintDeadline ?? '-' }}
Customer Mobile : {{ $booking->customer->mobile_no ?? '-' }} Fingerprint Location : {{ $fpLocation ?? '-' }}
Address (KSA) : {{ $addressKsa }}
{{-- Invoice Information --}}
Invoice Information
Invoice Date : {{ $invoiceDate ?? '-' }}
Booking Date : {{ $booking->created_at ? $booking->created_at->format('d M Y') : '-' }}
Booking Branch : {{ $booking->bookingBranch->name ?? '-' }}
Fingerprint Branch : {{ $booking->fingerprintBranch->name ?? '-' }}
Sale Representative : {{ $booking->user->name ?? '-' }}
Remarks : {{ $booking->remarks ?? '-' }}
{{-- Passenger & Flight Details --}}
Passenger & Flight Details
@forelse($booking->passengers as $index => $passenger) @php $_alCode = $passenger->ticketFare?->airline?->code ?? null; $_rt = $passenger->ticketFare?->route?->route_type?->value; $_airIn = 'N/A'; $_airOut = 'N/A'; if ($_alCode) { if ($_rt === 'oneway_inbound') { $_airIn = $_alCode; } elseif ($_rt === 'oneway_outbound') { $_airOut = $_alCode; } else { $_airIn = $_alCode; $_airOut = $_alCode; } } @endphp @php $_routeType = $passenger->ticketFare?->route?->route_type?->value; $_routeTop = 'N/A'; $_routeBottom = 'N/A'; $_isSplit = false; if ($_routeType === 'oneway_inbound') { $_routeTop = $passenger->route_display; $_isSplit = true; } elseif ($_routeType === 'oneway_outbound') { $_routeBottom = $passenger->route_display; $_isSplit = true; } elseif ($_routeType === 'multi_city') { $_segments = $passenger->ticketFare?->route?->multiSegments ?? collect(); $_inSegment = $_segments->first(fn($s) => $s->segment_direction?->value === 'inbound'); $_outSegment = $_segments->first(fn($s) => $s->segment_direction?->value === 'outbound'); if ($_inSegment && $_inSegment->fromCity && $_inSegment->toCity) { $_routeTop = $_inSegment->fromCity->code . ' → ' . $_inSegment->toCity->code; } if ($_outSegment && $_outSegment->fromCity && $_outSegment->toCity) { $_routeBottom = $_outSegment->fromCity->code . ' → ' . $_outSegment->toCity->code; } $_isSplit = true; } @endphp @if($_isSplit) @else @endif @php $_bd = $passenger->baggage_display; $_in = 'N/A'; $_out = 'N/A'; if ($_bd !== '-' && $_bd !== '') { foreach (explode("\n", $_bd) as $_line) { if (str_starts_with($_line, 'In:')) { $_raw = trim(substr($_line, 3)); $_in = preg_replace('/[^0-9]/', '', $_raw) ?: 'N/A'; } elseif (str_starts_with($_line, 'Out:')) { $_raw = trim(substr($_line, 4)); $_out = preg_replace('/[^0-9]/', '', $_raw) ?: 'N/A'; } } } @endphp @php $_cabinVal = $passenger->ticketFare?->airlineClass?->travelClass?->name ?? '-'; $_cabinRt = $passenger->ticketFare?->route?->route_type?->value; $_cabinTop = $_cabinVal; $_cabinBottom = $_cabinVal; $_cabinSplit = false; if ($_cabinRt === 'oneway_inbound') { $_cabinBottom = 'N/A'; $_cabinSplit = true; } elseif ($_cabinRt === 'oneway_outbound') { $_cabinTop = 'N/A'; $_cabinSplit = true; } @endphp @if($_cabinSplit) @else @endif @php $_mealVal = $passenger->meal_display; $_mealRt = $passenger->ticketFare?->route?->route_type?->value; $_mealTop = $_mealVal; $_mealBottom = $_mealVal; $_mealSplit = false; if ($_mealRt === 'oneway_inbound') { $_mealBottom = 'N/A'; $_mealSplit = true; } elseif ($_mealRt === 'oneway_outbound') { $_mealTop = 'N/A'; $_mealSplit = true; } @endphp @if($_mealSplit) @else @endif @php $_ftRt = $passenger->ticketFare?->route?->route_type?->value; $_ftType = $passenger->ticketFare?->route?->flight_type?->value; $_transits = $passenger->ticketFare?->route?->transits ?? collect(); $_inMins = $_transits->filter(fn($t) => $t->route_direction?->value === 'inbound')->sum('transit_time'); $_outMins = $_transits->filter(fn($t) => $t->route_direction?->value === 'outbound')->sum('transit_time'); $_fmt = function($mins) { if (!$mins || $mins <= 0) return 'Direct'; $h = intdiv($mins, 60); $m = $mins % 60; return sprintf('Transit: %02d hr %02d min', $h, $m); }; $_ftTop = 'N/A'; $_ftBottom = 'N/A'; $_ftSplit = false; if ($_ftRt === 'oneway_inbound') { $_ftTop = $_ftType === 'transit' ? $_fmt($_inMins) : 'Direct'; $_ftSplit = true; } elseif ($_ftRt === 'oneway_outbound') { $_ftBottom = $_ftType === 'transit' ? $_fmt($_outMins) : 'Direct'; $_ftSplit = true; } elseif (in_array($_ftRt, ['round', 'multi_city'])) { if ($_ftType === 'transit') { $_ftTop = $_fmt($_inMins); $_ftBottom = $_fmt($_outMins); $_ftSplit = true; } else { $_ftTop = 'Direct'; } } @endphp @if($_ftSplit) @else @endif @empty @endforelse
Pax No. Name of passengers Gender Passport number Package Duration (Days) Package Value Trip Airline Route Est.Flight Date Baggage Cabin Meal Flight Type Remarks
In Out
{{ $index + 1 }} {{ $passenger->first_name ?? '' }} {{ $passenger->last_name ?? '' }} {{ $passenger->gender ?? '-' }} {{ $passenger->passport_no ?? '-' }} {{ $booking->package?->package_name ?? 'Package' }} {{ $passenger->stay_duration ?? '-' }} @currency($passenger->package_value ?? 0, 2, $rate)
In Bound
Out Bound
{{ $_airIn }}
{{ $_airOut }}
{{ $_routeTop }}
{{ $_routeBottom }}
{{ $passenger->route_display }}
{{ $passenger->flight_date_display }}
After {{ $passenger->stay_duration ?? '-' }} Days
{{ $_in }} {{ $_out }}
{{ $_cabinTop }}
{{ $_cabinBottom }}
{{ $_cabinVal }}
{{ $_mealTop }}
{{ $_mealBottom }}
{{ $_mealVal }}
{{ $_ftTop }}
{{ $_ftBottom }}
{{ $_ftTop }}{{ $booking->remarks ?? '-' }}
No passenger data
{{-- Package Calculation, Payment Summary, Important Note --}}
{{-- Package Calculation --}}
Package Calculation
Sub Total: @currency($subTotal, 2, $rate)
Total Pax: {{ $totalPackages ?? 0 }}
Fingerprint Charge: @currency($fingerprintCharge, 2, $rate)
Discount: @currency($discount, 2, $rate)
Grand Total: @currency($grandTotal, 2, $rate)
@if($useBdt)

Exchange Rate: 1 SAR = {{ number_format($displayRate, 4) }} BDT

@endif
{{-- Payment Summary --}}
Payment Summary
Total Amount: @currency($grandTotal, 2, $rate)
Previous Paid Amount: @currency($totalPaid - $currentPaid, 2, $rate)
Current Paid Amount: @currency($currentPaid, 2, $rate)
Total Paid Amount: @currency($totalPaid, 2, $rate)
Due Amount: @currency($dueAmount, 2, $rate)
{{-- Important Note --}}
Important Note / Conditions
    @forelse($conditions as $condition)
  • {{ $condition->title }} @if($condition->description) : {{ $condition->description }} @endif
  • @empty
  • N/A
  • @endforelse
{{-- Signatures --}}

Representative Signature

Customer Signature

This is a computer-generated invoice. No signature is required.

{{-- Print Buttons --}}
Back
@endsection