@php $kpis = $ageing['kpis'] ?? []; $register = $ageing['exception_register'] ?? []; $modal = $ageing['modal'] ?? ['alarm' => 'red', 'rows' => [], 'total' => 0]; $matrixRows = $ageing['stage_bottleneck_matrix'] ?? []; $nonWithdrawalMatrix = $ageing['non_withdrawal_matrix'] ?? ['yellow' => 0, 'orange' => 0, 'red' => 0]; $alarmCardCounts = [ 'yellow' => (int) ($nonWithdrawalMatrix['yellow'] ?? 0), 'orange' => (int) ($nonWithdrawalMatrix['orange'] ?? 0), 'red' => (int) ($nonWithdrawalMatrix['red'] ?? 0), ]; if (($alarmCardCounts['yellow'] + $alarmCardCounts['orange'] + $alarmCardCounts['red']) === 0) { // Fallback for tenants where w_* precompute is not available yet. $alarmCardCounts['yellow'] = (int) ($kpis['yellow_population'] ?? 0); $alarmCardCounts['orange'] = (int) ($kpis['orange_population'] ?? 0); $alarmCardCounts['red'] = (int) ($kpis['red_population'] ?? 0); } $stageNameOverrides = [ 'tranche_1_to_plinth' => 'First Installment Released', 'plinth_to_tranche_2' => 'Plinth Completed', 'tranche_2_to_lintel' => 'Second Installment Released', 'lintel_to_tranche_3' => 'Lintel Completed', 'tranche_3_to_roof' => 'Third Installment Released', 'roof_to_tranche_4' => 'Roof Completed', 'overall_1st_to_roof' => 'Overall', ]; $stageDelayChart = $ageing['charts']['stage_delay_trend'] ?? []; $delayFiscalYears = $stageDelayChart['fiscal_years'] ?? []; $delaySelectedFY = (string) ($stageDelayChart['selected_fiscal_year'] ?? request('fiscal_year', '')); $total = (int) ($register['total'] ?? 0); $currentPage = (int) ($register['current_page'] ?? 1); $lastPage = (int) ($register['last_page'] ?? 1); $from = (int) ($register['from'] ?? 0); $to = (int) ($register['to'] ?? 0); $baseQuery = request()->except('page', 'ajax', 'per_page'); $pageUrl = fn(int $p) => url()->current() . '?' . http_build_query(array_merge($baseQuery, ['page' => $p])); @endphp @if(!empty($pageMessages ?? []))
{{ implode(' ', $pageMessages) }}
@endif

Total Cases

{{ number_format((int) ($kpis['total_population'] ?? 0)) }}

Normal

{{ number_format((int) ($kpis['green_population'] ?? 0)) }}

Yellow

{{ number_format((int) ($kpis['yellow_population'] ?? 0)) }}

Orange

{{ number_format((int) ($kpis['orange_population'] ?? 0)) }}

Red

{{ number_format((int) ($kpis['red_population'] ?? 0)) }}

Stage Bottleneck Matrix

Under-progress only
@forelse($matrixRows as $row) @php $displayStage = $stageNameOverrides[(string) ($row['key'] ?? '')] ?? ($row['stage'] ?? '-'); @endphp @empty @endforelse
Stage Live Cases Avg Days Green Yellow Amber Red Escalation
{{ $displayStage }} {{ number_format((int) ($row['live_cases'] ?? 0)) }} {{ number_format((int) ($row['avg_days'] ?? 0)) }} {{ $row['escalation'] ?? '-' }}
No stage bottleneck data found for selected filters.

Stage Red Alert Share

Non Withdrawal Matrix

{{-- ===== MONTH WISE PROGRESS CHART ===== --}} {{--

Month Wise Progress

--}} {{-- ===== STAGE-WISE SEVERITY BREAKDOWN CHART ===== --}}

Stage-wise severity breakdown

Withdrawal stages · Construction stages

{{-- Custom legend --}}
Green
Yellow
Amber
Red
Withdrawal
Construction

Beneficiary Drill-down: Current Stage Delays

@forelse(($register['rows'] ?? []) as $row) @php $statusClass = match (strtolower((string) ($row['alarm_level'] ?? 'green'))) { 'red' => 'is-red', 'orange' => 'is-orange', 'yellow' => 'is-yellow', default => 'is-green', }; $alarmLabel = ucfirst((string) ($row['alarm_level'] ?? 'Green')); @endphp @empty @endforelse
UUID Beneficiary CNIC IP District IFI Current Stage Elapsed Days Status Owner Level
{{ $row['uuid'] ?? '-' }} {{ $row['beneficiary_name'] ?? '-' }} {{ $row['beneficiary_cnic'] ?? '-' }} {{ $row['ip'] ?? '-' }} {{ $row['district'] ?? '-' }} {{ $row['ifi'] ?? '-' }} {{ $row['pending_stage'] ?? '-' }} {{ (int) ($row['ageing_days'] ?? 0) }} {{ $alarmLabel }} {{ $row['owner_level'] ?? 'Normal' }}
No exception rows found for selected filters.
@if($lastPage > 1) @elseif($total > 0) @endif