@extends('layouts.staff') @section('content') {{-- MAIN CONTAINER with ID for Alpine Scope --}}
{{-- === HEADER === --}}
{{-- LEFT: Brand & Model ONLY --}}

{{ $vehicle->brand }} {{ $vehicle->model }}

{{-- RIGHT: Actions (Your Original Button Styles) --}}
{{-- Edit Button --}} Edit {{-- Delete Button --}}
@csrf @method('DELETE')
{{-- LEFT COL --}}
{{-- 1. VEHICLE DETAILS --}}
@if($vehicle->availability) Available @else Unavailable @endif
@if($vehicle->image) @else @endif
Owner Details
{{ substr($vehicle->owner_name ?? 'H', 0, 1) }}

{{ $vehicle->owner_name ?? 'Hasta Travel & Tours' }}

{{ $vehicle->owner_phone ?? 'No Phone' }}
{{ $vehicle->owner_nric ?? 'No ID' }}
{{-- RIGHT: Info & Docs --}}
{{-- GRID: 2 Columns, 3 Rows --}}
{{-- Row 1 --}}
Plate Number {{ $vehicle->plateNo }}
Manufacture Year {{ $vehicle->year }}
{{-- Row 2 --}}
Color {{ $vehicle->color }}
{{-- Changed 'Capacity/Transmission' to 'Fuel Type' --}} Fuel Type {{ $vehicle->fuel_type ?? 'Petrol' }}
{{-- Row 3 --}}
Body Type {{ $vehicle->type }}
Current Mileage {{ number_format($currentMileage) }} km
Documents Preview
{{-- Road Tax --}}
road_tax_image) @click="openViewer('Road Tax', '{{ asset('storage/'.$vehicle->road_tax_image) }}')" @endif> @if($vehicle->road_tax_image) @php $rtExt = pathinfo($vehicle->road_tax_image, PATHINFO_EXTENSION); @endphp @if(in_array(strtolower($rtExt), ['jpg', 'jpeg', 'png', 'gif', 'webp'])) @else
@endif
{{ basename($vehicle->road_tax_image) }}
@else
Not Available
@endif
Road Tax
{{-- Grant --}}
grant_image) @click="openViewer('Grant', '{{ asset('storage/'.$vehicle->grant_image) }}')" @endif> @if($vehicle->grant_image) @php $gExt = pathinfo($vehicle->grant_image, PATHINFO_EXTENSION); @endphp @if(in_array(strtolower($gExt), ['jpg', 'jpeg', 'png', 'gif', 'webp'])) @else
@endif
{{ basename($vehicle->grant_image) }}
@else
Not Available
@endif
Grant
{{-- Insurance --}}
insurance_image) @click="openViewer('Insurance', '{{ asset('storage/'.$vehicle->insurance_image) }}')" @endif> @if($vehicle->insurance_image) @php $iExt = pathinfo($vehicle->insurance_image, PATHINFO_EXTENSION); @endphp @if(in_array(strtolower($iExt), ['jpg', 'jpeg', 'png', 'gif', 'webp'])) @else
@endif
{{ basename($vehicle->insurance_image) }}
@else
Not Available
@endif
Insurance
@if($vehicle->hourly_rates)
Rental Rates (Hourly Tiers)
@foreach($vehicle->hourly_rates as $hour => $rate)
{{ $hour }}H RM{{ $rate }}
@endforeach
@endif
{{-- 2. CALENDAR SECTION --}}

Manage Availability

Booked
Maintenance
Delivery
Holiday
Blocked
{{-- RIGHT COL: Financials & Bookings --}}
{{-- 1. Financial Card (Fixed Top) --}}

Net Profit

RM {{ number_format($netProfit, 2) }}
RM {{ number_format($totalEarnings, 2) }} Earnings
RM {{ number_format($totalMaintenanceCost, 2) }} Cost
{{-- 2. Tabbed List Card (Fixed Height & Scrollable) --}} {{-- Added 'h-[600px]' to force a fixed size matching roughly the calendar height --}}
{{-- Tabs Header (Fixed at top of card) --}}
{{-- Scrollable List Area --}} {{-- 'flex-1' fills the rest of the 600px, 'overflow-y-auto' enables scroll --}}
{{-- Booking List --}} {{-- Service List --}}
@forelse($vehicle->maintenances->whereIn('type', ['maintenance', null])->sortByDesc('start_time') as $maint)
{{ \Carbon\Carbon::parse($maint->start_time)->format('d M Y') }} Ref: #{{ $maint->MaintenanceID }}
RM {{ number_format($maint->cost, 2) }}

{{ $maint->description }}

@empty

No service records.

@endforelse
{{-- VIEWER MODAL --}}

{{ $vehicle->plateNo }}

{{-- BLOCK SCHEDULE MODAL --}}
@csrf {{-- Header --}}

Block Schedule

{{-- Time & Toggle Section --}}
{{-- Time Selectors --}}
{{-- All Day Toggle --}}
Block Entire Day
{{-- Reason Selection Grid --}}
@foreach(['maintenance' => ['red', 'Maintenance', 'fa-tools'], 'delivery' => ['blue', 'Delivery', 'fa-truck'], 'holiday' => ['purple', 'Holiday', 'fa-umbrella-beach'], 'other' => ['gray', 'Other', 'fa-comment-alt']] as $key => $details) @endforeach
{{-- Dynamic Inputs --}}
{{-- Maintenance Inputs --}}
RM
{{-- Delivery Inputs --}}
{{-- Other/Holiday Inputs --}}
{{-- HISTORY MODAL --}}
{{-- Header --}}

History Log

Maintenance & block records

{{-- Content --}}
@forelse($vehicle->maintenances->sortByDesc('updated_at') as $log)
{{-- Unblocked Status Strip --}} @if($log->type === 'unblocked')
@endif
@php $badgeStyle = match($log->type) { 'maintenance' => 'bg-red-50 text-red-600 border-red-100', 'delivery' => 'bg-blue-50 text-blue-600 border-blue-100', 'holiday' => 'bg-purple-50 text-purple-600 border-purple-100', 'unblocked' => 'bg-emerald-50 text-emerald-600 border-emerald-100', // Green style for unblocked default => 'bg-gray-50 text-gray-600 border-gray-200' }; $icon = match($log->type) { 'maintenance' => 'fa-tools', 'delivery' => 'fa-truck', 'holiday' => 'fa-umbrella-beach', 'unblocked' => 'fa-history', default => 'fa-info-circle' }; @endphp
{{ $log->type === 'unblocked' ? 'Unblocked' : ucfirst($log->type) }}
{{ $log->created_at->format('d M, h:i A') }}
{{-- Description Logic --}} @php $parts = explode('| [UNBLOCKED]', $log->description); $cleanDesc = $parts[0]; $unblockInfo = isset($parts[1]) ? trim($parts[1]) : null; @endphp

{{ $cleanDesc ?? 'No Description' }}

Created By {{ $log->staff->name ?? 'System' }}
{{-- Unblock Info Box --}} @if($unblockInfo)

Unblocked

{{ str_replace('by ', '', $unblockInfo) }}

@endif {{-- Footer Date Range --}}
{{ \Carbon\Carbon::parse($log->start_time)->format('d M') }} {{ \Carbon\Carbon::parse($log->end_time)->format('d M') }}
{{-- Duration pill --}} @php $duration = \Carbon\Carbon::parse($log->start_time)->diffInDays(\Carbon\Carbon::parse($log->end_time)); @endphp {{ $duration == 0 ? 'Same Day' : $duration . ' Days' }}
@empty

No records found

Activity will appear here.

@endforelse
@endsection