{{-- Chart.js — loaded synchronously so it's ready before any x-init --}} {{-- ═══════════════════════════════════════════════════════════════════════ --}} {{-- FILTER BAR --}} {{-- ═══════════════════════════════════════════════════════════════════════ --}}

From

To

@foreach([['today','Today'],['this_week','This Week'],['this_month','This Month'],['last_month','Last Month'],['last_90','90 Days'],['all_time','All Time']] as [$k,$l]) @endforeach
{{-- ═══════════════════════════════════════════════════════════════════════ --}} {{-- KPI CARDS --}} {{-- ═══════════════════════════════════════════════════════════════════════ --}} @php $kpis = [ ['Trips Posted', $summary['trips_posted'] ?? 0, '#3b82f6', 'M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7'], ['Completed Rides', $summary['trips_completed'] ?? 0, '#10b981', 'M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'], ['Total Bookings', $summary['bookings_total'] ?? 0, '#f59e0b', 'M15 5v2m0 4v2m0 4v2M5 5a2 2 0 00-2 2v3a2 2 0 110 4v3a2 2 0 002 2h14a2 2 0 002-2v-3a2 2 0 110-4V7a2 2 0 00-2-2H5z'], ['Confirmed Bookings',$summary['bookings_confirmed'] ?? 0, '#14b8a6', 'M5 13l4 4L19 7'], ['Cancellations', $summary['trips_cancelled'] ?? 0, '#ef4444', 'M6 18L18 6M6 6l12 12'], ['New Drivers', $summary['new_drivers'] ?? 0, '#8b5cf6', 'M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z'], ['New Riders', $summary['new_riders'] ?? 0, '#06b6d4', 'M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z'], ['Completion Rate', ($summary['trips_posted'] ?? 0) > 0 ? round(($summary['trips_completed'] ?? 0) / $summary['trips_posted'] * 100) . '%' : '—', '#0ea5e9', 'M13 7h8m0 0v8m0-8l-8 8-4-4-6 6'], ]; @endphp
@foreach($kpis as [$label, $value, $color, $path])

{{ $label }}

{{ is_numeric($value) ? number_format($value) : $value }}

@endforeach
{{-- ═══════════════════════════════════════════════════════════════════════ --}} {{-- TABS --}} {{-- ═══════════════════════════════════════════════════════════════════════ --}}
@foreach([['overview','Overview'],['trips','Trips & Routes'],['revenue','Revenue'],['drivers','Top Drivers']] as [$id,$name]) @endforeach
{{-- ─── OVERVIEW TAB ─────────────────────────────────────────────── --}}
{{-- Activity line chart --}}

Daily Activity

Trips posted, completed rides, and bookings per day

{{ count($dailyActivity) }} days
{{-- Status donut + breakdown --}}

Bookings by Status

Status Breakdown

@php $total = array_sum(array_column($bookingsByStatus, 'total')) ?: 1; @endphp
@forelse($bookingsByStatus as $row) @php $pct = round($row['total'] / $total * 100); @endphp
{{ $row['status'] }} {{ number_format($row['total']) }}  ({{ $pct }}%)
@empty

No bookings in this period

@endforelse
{{-- ─── TRIPS & ROUTES TAB ───────────────────────────────────────── --}}

Top Corridors

Corridor Leaderboard

@forelse($topCorridors as $i => $row)
{{ $i+1 }} {{ $row['route'] }} {{ $row['total'] }}
@empty

No completed trips in this period

@endforelse

Daily Breakdown

@forelse($dailyActivity as $day) @empty @endforelse
Date Posted Completed Bookings Rate
{{ $day['date'] }} {{ $day['posted'] }} {{ $day['completed'] }} {{ $day['bookings'] }} {{ $day['posted'] > 0 ? round($day['completed'] / $day['posted'] * 100) . '%' : '—' }}
No data for this period
{{-- ─── REVENUE TAB ──────────────────────────────────────────────── --}}

Revenue Summary — Completed Rides Only

@if($revenueTotals && $revenueTotals->rides > 0)

Paid Rides

{{ number_format($revenueTotals->rides) }}

Gross Fare Volume

{{ number_format($revenueTotals->gross) }}

TZS

Your Commission (9%)

{{ number_format($revenueTotals->commission) }}

TZS

@else

No completed paid rides in this period.

@endif

Revenue by Route (top 10, completed rides)

@foreach(['Route','Rides','Gross (TZS)','Commission (TZS)','Margin'] as $h) @endforeach @forelse($revenueByRoute as $row) @empty @endforelse
{{ $h }}
{{ $row['route'] }} {{ $row['rides'] }} {{ number_format($row['gross']) }} {{ number_format($row['commission']) }} {{ $row['gross'] > 0 ? number_format($row['commission'] / $row['gross'] * 100, 1) . '%' : '—' }}
No completed rides in this period
{{-- ─── TOP DRIVERS TAB ─────────────────────────────────────────── --}}

Top 15 Drivers by Completed Trips

@forelse($topDrivers as $i => $row) @empty @endforelse
# Driver Phone Trips Rating
@if($i === 0)🥇@elseif($i === 1)🥈@elseif($i === 2)🥉 @else{{ $i+1 }}@endif {{ $row['driver'] }} {{ $row['phone'] }} {{ $row['trips_completed'] }} ★ {{ $row['rating'] }}
No completed trips in this period
{{-- /tabs --}} {{-- ═══════════════════════════════════════════════════════════════════════ --}} {{-- CHART MANAGEMENT — single script, no defer, no race conditions --}} {{-- ═══════════════════════════════════════════════════════════════════════ --}}