@extends('layouts.app')
@section('title','Trips')
@section('page_title','Trips & Dispatch')
@section('content')
<div class="page-head"><div><h1>Trips & Dispatch</h1><p>Vehicle, driver, vendor, timing and trip-rate control.</p></div><a class="btn btn-primary" href="{{ route('trips.create') }}">+ New Trip</a></div>
<div class="card"><div class="toolbar"><form class="search"><input class="control" name="search" value="{{ request('search') }}" placeholder="Trip, job, vehicle"><select class="control" name="status"><option value="">All statuses</option>@foreach(['scheduled','vehicle_assigned','driver_assigned','in_transit','reached_destination','delivered','cancelled'] as $s)<option value="{{ $s }}" @selected(request('status')===$s)>{{ ucwords(str_replace('_',' ',$s)) }}</option>@endforeach</select><button class="btn btn-secondary">Filter</button></form><span class="muted">{{ $trips->total() }} trips</span></div><div class="table-wrap"><table class="table"><thead><tr><th>Trip</th><th>Job / Customer</th><th>Pickup</th><th>Vehicle</th><th>Driver</th><th>Vendor</th><th>Rates</th><th>Status</th><th></th></tr></thead><tbody>@forelse($trips as $trip)<tr><td><strong>{{ $trip->trip_number }}</strong></td><td>{{ $trip->job?->job_number }}<div class="muted">{{ $trip->job?->customer?->legal_name }}</div></td><td>{{ optional($trip->pickup_at)->format('d M Y H:i') }}</td><td>{{ $trip->vehicle?->plate_number ?? '—' }}</td><td>{{ $trip->driver?->name ?? '—' }}</td><td>{{ $trip->vendor?->legal_name ?? 'Own vehicle' }}</td><td>C {{ number_format((float)$trip->customer_rate,2) }} / V {{ number_format((float)$trip->vendor_rate,2) }}</td><td><span class="badge status-{{ $trip->status }}">{{ ucwords(str_replace('_',' ',$trip->status)) }}</span></td><td><a class="btn btn-secondary btn-sm" href="{{ route('trips.show',$trip) }}">Open</a></td></tr>@empty<tr><td colspan="9" class="empty">No trips found.</td></tr>@endforelse</tbody></table></div>{{ $trips->links() }}</div>
@endsection
