@extends('layouts.app') @section('title', 'Dashboard') @section('content') @php $kes = fn ($v) => 'KES ' . number_format((float) $v); $day = $shifts['day'] ?? ['cash'=>0,'mpesa'=>0,'insurance'=>0,'card'=>0,'total'=>0]; $night = $shifts['night'] ?? ['cash'=>0,'mpesa'=>0,'insurance'=>0,'card'=>0,'total'=>0]; $maxVisits = max(1, collect($visitsByDay)->max('total') ?? 1); @endphp

Dashboard

Today · {{ $today->format('l, d M Y') }}

Today only
{{-- ── FINANCIALS ─────────────────────────────────────────────────────── --}}

Patients Today

{{ number_format($row1['patientsToday']) }}

Revenue Today

{{ $kes($row1['revenueToday']) }}

Collections Today

{{ $kes($row1['collectionsToday']) }}

ARPP

{{ $kes($row1['arpp']) }}

Avg revenue per patient

Cash

{{ $kes($row1['cashToday']) }}

Mobile / Bank

{{ $kes($row1['mobileToday']) }}

Insurance

{{ $kes($row1['insuranceToday']) }}

SHA{{ $kes($insSha) }}
Private Insurers{{ $kes($insPrivate) }}
{{-- ── OPERATIONS ─────────────────────────────────────────────────────── --}}

Appointments

{{ number_format($ops['appointments']) }}

Bed Occupancy

{{ number_format($ops['bedOccupancy']) }}%

{{ $ops['occupiedBeds'] }} of {{ $ops['totalBeds'] }} beds

Active ANC Clients

{{ number_format($ops['activeAnc']) }}

New vs Returning

{{ number_format($ops['newCount']) }} / {{ number_format($ops['returningCount']) }}

New / Returning today

{{-- ── DAILY VISITS (7 days) ──────────────────────────────────────────── --}}

Daily Visits (7 days ending {{ $rangeEnd->format('d M Y') }})

@foreach($visitsByDay as $d) @php $w = round(((int) $d->total / $maxVisits) * 100); @endphp
{{ \Carbon\Carbon::parse($d->date)->format('d M') }}
{{ $d->total }}
@endforeach
{{-- ── SHIFT BREAKDOWN ────────────────────────────────────────────────── --}}
@foreach([['Day Shift','8:00 AM – 8:00 PM',$day],['Night Shift','8:00 PM – 8:00 AM',$night]] as [$label,$window,$s])

{{ $label }}

{{ $window }}
Cash{{ $kes($s['cash']) }}
M-Pesa / Mobile{{ $kes($s['mpesa']) }}
Insurance{{ $kes($s['insurance']) }}
Card / Bank{{ $kes($s['card']) }}
Shift Total{{ $kes($s['total']) }}
@endforeach
@endsection