@extends('layouts.app') @section('content') {{-- 1. FIXED BACKGROUND --}}
{{-- 2. MAIN CONTENT --}}
{{-- HEADER WITH FILTERS --}}

My Bookings

Manage your active and past rentals.

{{-- SERVER-SIDE FILTER BAR (MODERN STATUS DROPDOWN) --}}
@php $currentStatus = request('status', 'all'); // Comprehensive list of booking and payment statuses $statuses = [ 'all' => 'All Bookings', 'Submitted' => 'Submitted', 'Deposit Paid' => 'Deposit Paid', 'Paid' => 'Paid (Full)', 'Confirmed' => 'Confirmed', 'Active' => 'Active', 'Completed' => 'Completed', 'Cancelled' => 'Cancelled', 'Rejected' => 'Rejected' ]; $currentLabel = $statuses[$currentStatus] ?? 'Select Status'; @endphp {{-- CUSTOM GLASS DROPDOWN --}}
{{-- TRIGGER BUTTON --}} {{-- DROPDOWN MENU --}}
{{-- LOOP: CARDS --}} @forelse($bookings as $booking)
{{-- Clickable Area for Details --}}
{{-- Card Header --}}
{{-- Numbering Badge --}}
{{ $loop->iteration }}
{{-- BOOKING DATE --}}

Your booking starts:

{{ \Carbon\Carbon::parse($booking->originalDate)->format('d M Y') }}

{{-- Status Badge --}} {{ $booking->bookingStatus }}
{{-- [UPDATED] Vehicle Info with IMAGE --}}
{{-- Car Image Container --}}
@if($booking->vehicle->image) {{ $booking->vehicle->model }} @else
@endif

{{ $booking->vehicle->model }}

{{-- CONDITIONAL PLATE DISPLAY --}} @if($booking->bookingStatus == 'Confirmed' || $booking->bookingStatus == 'Active' || $booking->bookingStatus == 'Completed')

PLATE: {{ $booking->vehicle->plateNo }}

@else

Plate No. pending confirmation

@endif
{{-- AGENT INFO ON CARD --}} @if($booking->staff)

Agent: {{ $booking->staff->name }}

@endif
Click to view full details
{{-- ACTIONS: INSPECTION & FEEDBACK --}} {{-- 1. INSPECTION BUTTON --}} @php // Check if customer has already uploaded for the current stage $isReturn = ($booking->bookingStatus == 'Active'); $typeCheck = $isReturn ? 'Return' : 'Pickup'; $alreadySubmitted = $booking->inspections ->where('inspectionType', $typeCheck) ->whereNull('staffID') ->isNotEmpty(); @endphp @if(($booking->bookingStatus == 'Confirmed' || $booking->bookingStatus == 'Active') && !$alreadySubmitted)
@elseif($alreadySubmitted)
{{ $typeCheck }} Inspection Submitted
@endif {{-- 2. FEEDBACK BUTTON --}} @if($booking->bookingStatus == 'Completed' && !$booking->feedback)
@endif {{-- 3. INVOICE BUTTON (NEW) --}} @if($booking->bookingStatus == 'Completed')
{{-- Existing Agreement/Receipt Buttons... --}} {{-- NEW: View Invoice Button --}} @if($booking->bookingStatus == 'Completed' && $booking->invoiceLink) View Invoice @elseif($booking->bookingStatus == 'Completed') {{-- Fallback if generation failed (or for old bookings) --}} Generate Invoice @endif
@endif
@empty {{-- Empty State --}}

No bookings found

@if(request('status') && request('status') != 'all') No {{ request('status') }} bookings found. @else You haven't rented any cars yet. @endif

@if(request('status') && request('status') != 'all') Clear Filter @endif
@endforelse
{{-- 3. INSPECTION MODALS (LOOP 2) --}} @foreach($bookings as $booking) @if($booking->bookingStatus == 'Confirmed' || $booking->bookingStatus == 'Active') {{-- Determine Required Count --}} @php $requiredCount = ($booking->bookingStatus == 'Confirmed') ? 5 : 6; @endphp @endif @endforeach {{-- 4. FEEDBACK MODALS (LOOP 3) --}} @foreach($bookings as $booking) @if($booking->bookingStatus == 'Completed' && !$booking->feedback) @endif @endforeach {{-- 5. DETAILS MODALS (LOOP 4) --}} @foreach($bookings as $booking) @endforeach {{-- STYLES --}} @endsection