@extends('layouts.app')
@section('title','Job Profitability')
@section('page_title','Job Profitability')
@section('content')
<div class="page-head"><div><h1>Job Profitability</h1><p>{{ $from }} to {{ $to }}</p></div><a class="btn btn-secondary" href="{{ route('reports.export',['report'=>'jobs','from'=>$from,'to'=>$to]) }}">Export CSV</a></div>@include('reports.partials.date-filter')<div class="card" style="margin-top:18px"><div class="table-wrap"><table class="table"><thead><tr><th>Job</th><th>Date</th><th>Customer</th><th>Route</th><th>Revenue</th><th>Cost</th><th>Profit</th><th>Margin</th><th>Status</th></tr></thead><tbody>@forelse($jobs as $j)<tr><td><a href="{{ route('jobs.show',$j) }}">{{ $j->job_number }}</a></td><td>{{ $j->job_date->format('d M Y') }}</td><td>{{ $j->customer?->legal_name }}</td><td>{{ $j->route?->name ?? ($j->pickup_location.' → '.$j->delivery_location) }}</td><td>{{ number_format((float)$j->actual_revenue,2) }}</td><td>{{ number_format((float)$j->actual_cost,2) }}</td><td>{{ number_format((float)$j->profit,2) }}</td><td>{{ number_format((float)$j->profit_percentage,2) }}%</td><td>{{ ucwords(str_replace('_',' ',$j->status)) }}</td></tr>@empty<tr><td colspan="9" class="empty">No jobs in this period.</td></tr>@endforelse</tbody></table></div>{{ $jobs->links() }}</div>
@endsection
