@extends('layouts.app') @section('title','Dashboard') @section('crumbs','Dashboard · Operations command centre') @section('content') @if(count($alerts))
@foreach($alerts as [$tone,$msg])
{{ $tone==='bad' ? '✕' : ($tone==='warn' ? '⚠' : 'ℹ') }}  {{ $msg }}
@endforeach
@endif
Production today
{{ qty($k['prod_today']) }} t
{{ qty($k['prod_month']) }} t this month (approved)
Dispatched today
{{ qty($k['dispatch_today']) }} t
Across all quarries & customers
Revenue this month
{{ cmoney($k['revenue_month'],0) }}
Invoiced (excl. draft/cancelled)
Receivables outstanding
{{ cmoney($k['ar_out'],0) }}
Payables: {{ cmoney($k['ap_out'],0) }}
Attendance today
{{ $present }} / {{ $empTotal }}
Present of active staff
Fleet available
{{ $eqAvail }} / {{ $eqTotal }}
Machines ready for work
Fuel cost (month)
{{ cmoney($k['fuel_month'],0) }}
All equipment
Net payroll (month)
{{ cmoney($k['payroll_month'],0) }}
Last computed run

Production — last 14 days (tonnes)

@php $mx = max(1, max($labels14)); @endphp
@foreach($labels14 as $d=>$v)
{{ $v>0? round($v):'' }}
@endforeach
@foreach($labels14 as $d=>$v){{ date('d/m',strtotime($d)) }}@endforeach

Revenue — last 6 months

@php $mx2 = max(1, $sales6->max() ?? 1); @endphp
@for($i=5;$i>=0;$i--) @php $m = date('Y-m', strtotime("-$i months")); $v = (float)($sales6[$m] ?? 0); @endphp
{{ $v>0? round($v/1000).'k':'' }}
@endfor
@for($i=5;$i>=0;$i--){{ date('M', strtotime("-$i months")) }}@endfor

Dispatch by product (this month)

@php $mx3 = max(1, $byProduct->max('t') ?? 1); @endphp @forelse($byProduct as $bp)
{{ $bp->product->name ?? '—' }}
{{ qty($bp->t) }}
@empty

No dispatches this month yet.

@endforelse

Stockpiles (lowest first)

@forelse($stockpiles as $s)@empty@endforelse
PileProductStock (t)
{{ $s->code }}
{{ $s->quarry->name ?? '' }}
{{ $s->product->name ?? '' }}{{ qty($s->current_qty) }}
No stockpiles.

Low stock alerts

@forelse($lowStock as $i)@empty@endforelse
ItemOn handReorder
{{ $i->code }} {{ $i->name }}{{ qty($i->current_qty) }}{{ qty($i->reorder_level) }}
All stocked up. ✓

Overdue invoices

@forelse($overdue as $o)@empty@endforelse
InvoiceCustomerDue
{{ $o->invoice_no }}
{{ fdate($o->due_date) }}
{{ $o->customer->name ?? '' }}{{ money($o->balance_due) }}
Nothing overdue. ✓

Expiring equipment documents

@forelse($expiring as $e)@empty@endforelse
EquipmentTypeExpiry
{{ $e->equipment->display_name ?? '' }}{{ $e->doc_type }}{{ fdate($e->expiry_date) }}
No expiries in 30 days. ✓

Open work orders (critical first)

@forelse($openWOs as $w)@empty@endforelse
WOEquipmentPriorityStatus
{{ $w->wo_no }}{{ $w->equipment->display_name ?? '' }}{{ $w->priority }}{{ $w->status }}
Workshop clear. ✓

Latest invoices

@forelse($recentInvoices as $i)@empty@endforelse
InvoiceCustomerTotalStatus
{{ $i->invoice_no }}{{ $i->customer->name ?? '' }}{{ money($i->grand_total) }}{{ $i->status }}
No invoices yet.

Latest dispatches

@forelse($recentDeliveries as $d)@empty@endforelse
DNCustomerVehicleStatus
{{ $d->dn_no }}{{ $d->customer->name ?? '' }}{{ $d->vehicle_no }}{{ $d->status }}
No dispatches yet.
@endsection