@extends('layouts.app')
@section('title','Transport Jobs')
@section('page_title','Transport Jobs')
@section('content')
<div class="page-head"><div><h1>Transport Jobs</h1><p>Plan dispatch, track delivery, POD, revenue, cost and profit.</p></div>@if(auth()->user()->hasPermission('transport_jobs.create'))<a class="btn btn-primary" href="{{ route('jobs.create') }}">+ New Job</a>@endif</div>
<div class="card"><div class="toolbar"><form class="search"><input class="control" name="search" value="{{ request('search') }}" placeholder="Job, customer, PO, location"><select class="control" name="status"><option value="">All statuses</option>@foreach(['enquiry','confirmed','scheduled','in_transit','delivered','pod_received','ready_to_invoice','invoiced','closed','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">{{ $jobs->total() }} jobs</span></div>
<div class="table-wrap"><table class="table"><thead><tr><th>Job</th><th>Date</th><th>Customer</th><th>Route / Service</th><th>Trips</th><th>Revenue</th><th>Cost</th><th>Profit</th><th>Status</th><th></th></tr></thead><tbody>@forelse($jobs as $job)<tr><td><strong>{{ $job->job_number }}</strong><div class="muted">{{ $job->customer_po }}</div></td><td>{{ $job->job_date->format('d M Y') }}</td><td>{{ $job->customer?->legal_name }}</td><td>{{ $job->route?->name ?? ($job->pickup_location.' → '.$job->delivery_location) }}<div class="muted">{{ $job->serviceType?->name }}</div></td><td>{{ $job->number_of_trips }}</td><td>AED {{ number_format((float)$job->actual_revenue,2) }}</td><td>AED {{ number_format((float)$job->actual_cost,2) }}</td><td class="{{ (float)$job->profit<0?'badge-red':'' }}">AED {{ number_format((float)$job->profit,2) }}</td><td><span class="badge status-{{ $job->status }}">{{ ucwords(str_replace('_',' ',$job->status)) }}</span></td><td><a class="btn btn-secondary btn-sm" href="{{ route('jobs.show',$job) }}">Open</a></td></tr>@empty<tr><td colspan="10" class="empty">No jobs found.</td></tr>@endforelse</tbody></table></div>{{ $jobs->links() }}</div>
@endsection
