@php $kpis = $ageing['kpis'] ?? []; $register = $ageing['exception_register'] ?? []; $modal = $ageing['modal'] ?? ['alarm' => 'red', 'rows' => [], 'total' => 0]; $alarmRules = $ageing['alarm_rules'] ?? []; $total = (int) ($register['total'] ?? 0); $perPage = (int) ($register['per_page'] ?? 5); $currentPage = (int) ($register['current_page'] ?? 1); $lastPage = (int) ($register['last_page'] ?? 1); $from = (int) ($register['from'] ?? 0); $to = (int) ($register['to'] ?? 0); $stageWiseChart = $ageing['charts']['stage_wise_ageing'] ?? []; $completedMatrixRows = $ageing['completed_stage_matrix'] ?? []; $fiscalYears = $stageWiseChart['fiscal_years'] ?? []; $selectedFiscalYear = (string) ($stageWiseChart['selected_fiscal_year'] ?? request('fiscal_year', '')); $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['completed'] ?? 0)) }}

Efficient

THR: ≤ 45

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

Stable

THR: 46-60

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

Delayed

THR: 61-75

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

Severely Delayed

THR: 76+

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

Completed Mode: Stage Threshold Mapping

@forelse($completedMatrixRows as $row) @php $pairKey = (string) ($row['pair_key'] ?? ''); $stageLabelMap = [ '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', ]; $fallbackStage = ucwords(str_replace('_', ' ', (string) ($row['stage'] ?? '-'))); $displayStage = $stageLabelMap[$pairKey] ?? $fallbackStage; @endphp @empty @endforelse
Stage Cases Avg Days Green Yellow Amber Red
{{ $displayStage }} {{ number_format((int) ($row['live_cases'] ?? 0)) }} {{ number_format((int) ($row['avg_days'] ?? 0)) }}
No completed-stage data found for selected filters.

Alarm Distribution

Stage-threshold based distribution of completed cases by alarm color

{{--
Ageing Exception Register
@forelse(($register['rows'] ?? []) as $row) @php $ageClass = $row['ageing_days'] >= 120 ? 'is-critical' : ($row['ageing_days'] >= 60 ? 'is-warning' : 'is-healthy'); $alarmClass = match ($row['alarm_level']) { 'red' => 'is-red', 'orange' => 'is-orange', 'yellow' => 'is-yellow', default => 'is-green', }; @endphp @empty @endforelse
UUID BENEFICIARY/CNIC IP DISTRICT TEHSIL PENDING STAGE AGEING DAYS Performance Thresholds
{{ $row['uuid'] }} {{ $row['beneficiary_name'] }}
{{ $row['beneficiary_cnic'] }}
{{ $row['ip'] }} {{ $row['district'] }} {{ $row['tehsil'] }} {{ $row['stage'] }} {{ (int) $row['ageing_days'] }}
No exception rows found for selected filters.
@if($lastPage > 1) @elseif($total > 0) @endif
--}} {{-- ===== STAGE WISE AGEING COMPARISON CHART ===== --}}
{{-- Header row: title left, stage totals right (pr-12 reserves space for the 3-dot toolbar button) --}}

Month Wise Level Completion

{{--

Monthly completion progress by construction stage · Fiscal Year 2024–25

--}}
{{-- Overall totals pills — populated by renderStageWiseBarChart() in ageing.js --}}
{{-- JS will inject pills here once chart renders --}}
{{-- Chart Controls Toolbar --}}
{{-- Chart rendered by renderStageWiseBarChart() in ageing.js --}}