@extends('layouts.staff') @section('content')
{{-- LEFT COLUMN: CUSTOMER, RENTAL, VEHICLE --}}
{{-- 1. [UPDATED] COLLAPSIBLE CUSTOMER INFORMATION --}}
{{-- HEADER: Title & Toggle Button --}}

Customer Info

{{-- COMPACT VIEW (Always Visible) --}}
{{ substr($booking->customer->fullName ?? 'G', 0, 1) }}

{{ $booking->customer->fullName ?? 'Guest User' }}

{{ $booking->customer->phoneNo }}
{{-- EXPANDABLE DETAILS (Hidden by Default) --}}
@if($booking->remarks)

Customer Request

"{{ $booking->remarks }}"

@endif {{-- 2. RENTAL INFORMATION --}}

Rental Information

{{-- PICKUP --}}

Pickup

{{ \Carbon\Carbon::parse($booking->originalDate)->format('d M Y') }} at {{ \Carbon\Carbon::parse($booking->bookingTime)->format('h:i A') }}

{{ $booking->pickupLocation }}
{{-- RETURN --}}

Return

{{ \Carbon\Carbon::parse($booking->returnDate)->format('d M Y') }} at {{ \Carbon\Carbon::parse($booking->returnTime)->format('h:i A') }}

{{ $booking->returnLocation }}
{{-- 3. VEHICLE DETAILS --}}

Vehicle Details

Car {{-- MODIFY VEHICLE FORM --}} @if($booking->bookingStatus == 'Submitted' || $booking->bookingStatus == 'Deposit Paid')
@csrf
@endif

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

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

{{ $booking->vehicle->color }} • {{ $booking->vehicle->fuelType }}

{{-- RIGHT COLUMN: ADMIN & ACTIONS --}}
{{-- NEW TOP GRID: STAFF & PAYMENT --}}
{{-- 0. STAFF ASSIGNMENT CARD --}}
{{ $booking->staff ? substr($booking->staff->name, 0, 1) : '?' }}

Staff In Charge

@if($booking->staff)

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

@else

Unassigned

@endif
{{-- Assignment Form --}}
@csrf
{{-- 4. PAYMENT & DOCUMENTS (MODIFIED SECTION) --}}

Payment & Docs

@if($booking->payment) {{ $booking->payment->depoStatus }} @endif
Total Cost RM {{ number_format($booking->totalCost, 2) }}
{{-- Receipt Link Logic --}} @if($booking->payment && $booking->payment->installmentDetails) @php $receiptUrl = str_contains($booking->payment->installmentDetails, 'drive.google.com') ? $booking->payment->installmentDetails : asset('storage/' . $booking->payment->installmentDetails); @endphp Receipt @else
No Receipt
@endif {{-- Agreement Link Logic --}} @if($booking->aggreementLink) @php $agreementUrl = str_contains($booking->aggreementLink, 'drive.google.com') ? $booking->aggreementLink : asset('storage/' . $booking->aggreementLink); @endphp Agreement @else
No Doc
@endif {{-- Invoice Link Logic --}} @if(!empty($booking->invoiceLink)) {{-- Case 1: Already uploaded to Drive --}} Invoice @elseif($booking->bookingStatus == 'Completed') {{-- Case 2: Completed but not on Drive (Generate Stream) --}} Gen Invoice @else {{-- Case 3: Not Ready --}}
Invoice
@endif
{{-- 5. INSPECTION GALLERY --}}

Inspection Gallery

Pickup: 5 Photos | Return: 6 Photos

{{-- Customer Uploads --}}

Customer Uploads

@forelse($booking->inspections->whereNull('staffID') as $inspection)
{{ $inspection->inspectionType }} Inspection
{{ $inspection->mileageBefore ?? $inspection->mileageAfter }} km {{ $inspection->fuelBefore ?? $inspection->fuelAfter }}
@php $photos = json_decode($inspection->photosBefore ?? $inspection->photosAfter); @endphp @if($photos) @foreach($photos as $photo) @endforeach @endif
@empty
No photos uploaded by customer.
@endforelse
{{-- Staff Uploads --}}

Staff Verifications

@forelse($booking->inspections->whereNotNull('staffID') as $inspection)
{{-- Header with Mileage Logic --}}
@if($inspection->inspectionType == 'Pickup') @else @endif {{ $inspection->inspectionType }} Inspection {{-- MILEAGE DISPLAY LOGIC --}}
@php $currentMileage = $inspection->mileageBefore ?? $inspection->mileageAfter; $fuelLevel = $inspection->fuelBefore ?? $inspection->fuelAfter; @endphp {{-- Fuel Badge --}} {{ $fuelLevel }} {{-- Mileage & Calculation --}} @if($inspection->inspectionType == 'Return') @php // Find the corresponding Pickup inspection to calculate distance $pickupIns = $booking->inspections->where('inspectionType', 'Pickup')->first(); $startMileage = $pickupIns ? ($pickupIns->mileageBefore ?? $pickupIns->mileageAfter) : 0; $distance = $startMileage > 0 ? ($currentMileage - $startMileage) : 0; @endphp @if($startMileage > 0) +{{ $distance }} km @else {{ $currentMileage }} km @endif @else {{-- Just show mileage for Pickup --}} {{ $currentMileage }} km @endif
{{-- Photos Grid --}}
@php $photos = json_decode($inspection->photosBefore ?? $inspection->photosAfter); @endphp @if($photos) @foreach($photos as $photo)
@endforeach @else
No photos uploaded by staff.
@endif
@empty

No staff verification performed yet.

@endforelse
{{-- 6. CUSTOMER FEEDBACK --}} @if($booking->feedback)

Customer Review

@for($i = 1; $i <= 5; $i++) @endfor {{ $booking->feedback->rating }}/5
@if($booking->feedback->comment)

"{{ $booking->feedback->comment }}"

@else

No written comment provided.

@endif

Submitted {{ $booking->feedback->created_at->format('d M Y, h:i A') }}

@endif {{-- 7. WORKFLOW ACTIONS --}}

Manage Booking Status

Current Status: {{ $booking->bookingStatus }}

{{-- GLOBAL VERIFY BUTTON --}} @php $pendingPayments = $booking->payments->where('paymentStatus', 'Pending Verification'); @endphp @if($pendingPayments->count() > 0)
New Payment Received!
@csrf
@endif
{{-- STEP 1: INITIAL PROCESSING --}} @if(in_array($booking->bookingStatus, ['Submitted', 'Deposit Paid', 'Paid'])) @if($pendingPayments->count() > 0)

* Verify payment above to unlock approval.

@else
@csrf
@endif {{-- STEP 2: CONFIRMED --}} @elseif($booking->bookingStatus == 'Confirmed')
@csrf
{{-- STEP 3: ACTIVE --}} @elseif($booking->bookingStatus == 'Active')
@csrf
{{-- STEP 4: CANCELLATIONS --}} @elseif($booking->bookingStatus == 'Cancelled' && $booking->payment && $booking->payment->depoStatus == 'Requested') @endif
{{-- STAFF UPLOAD MODAL --}} {{-- REJECT MODAL --}} {{-- REFUND MODAL --}} @endsection