@extends('layouts.demo10.base')
@section('content')
@php
$rbmsNumberValue = static function ($value) {
return ($value !== null && $value !== '' && is_numeric($value)) ? (float) $value : null;
};
$formatRbmsValue = static function ($value) {
if ($value === null || $value === '') {
return '-';
}
if (!is_numeric($value)) {
return $value;
}
$raw = trim((string) $value);
$decimals = 0;
if (str_contains($raw, '.')) {
$fraction = rtrim(substr($raw, strpos($raw, '.') + 1), '0');
$decimals = min(strlen($fraction), 4);
}
return number_format((float) $value, $decimals);
};
@endphp
{{-- ── Page Header ── --}}
@forelse($pdo as $indicator)
@php
$num = str_pad($loop->iteration, 2, '0', STR_PAD_LEFT);
$current = $rbmsNumberValue($indicator->computed_result);
$baseline = is_numeric($indicator->baseline_value) ? (float) $indicator->baseline_value : null;
$target = is_numeric($indicator->end_target) ? (float) $indicator->end_target : null;
$rawPct = ($current !== null && $target !== null && $target > 0) ? min(100, ($current / $target) * 100) : 0;
$pct = rtrim(rtrim(number_format($rawPct, 2, '.', ''), '0'), '.');
@endphp
{{-- Badge row --}}
PDO-{{ $num }}
{{ strtoupper($indicator->donor?->name ?? 'NO DONOR') }}
{{-- Title --}}
{{ $indicator->name ?: ($indicator->definition ?: 'No title provided.') }}
{{-- Current + Target --}}
CURRENT
{{ $formatRbmsValue($indicator->computed_result) }}
TARGET
{{ $formatRbmsValue($indicator->end_target) }}
{{-- Progress bar --}}
{{ $pct }}% achieved
{{-- Baseline + Freq --}}
BASELINE
{{ $formatRbmsValue($indicator->baseline_value) }}
FREQ.
{{ $indicator->reporting_frequency ?? '-' }}
@empty
No PDO indicators found.
@endforelse
@if($pdo->isNotEmpty())
No PDO indicators found for selected donor.
@endif
{{-- ══════════════════════════════════════════
IRI Tab (hidden by default)
══════════════════════════════════════════ --}}
@forelse($iri as $indicator)
@php
$num = str_pad($loop->iteration, 2, '0', STR_PAD_LEFT);
$current = $rbmsNumberValue($indicator->computed_result);
$baseline = is_numeric($indicator->baseline_value) ? (float) $indicator->baseline_value : null;
$target = is_numeric($indicator->end_target) ? (float) $indicator->end_target : null;
$rawPct = ($current !== null && $target !== null && $target > 0) ? min(100, ($current / $target) * 100) : 0;
$pct = rtrim(rtrim(number_format($rawPct, 2, '.', ''), '0'), '.');
@endphp
{{-- Badge row --}}
IRI-{{ $num }}
{{ strtoupper($indicator->donor?->name ?? 'NO DONOR') }}
{{-- Title --}}
{{ $indicator->name ?: ($indicator->definition ?: 'No title provided.') }}
{{-- Current + Target --}}
CURRENT
{{ $formatRbmsValue($indicator->computed_result) }}
TARGET
{{ $formatRbmsValue($indicator->end_target) }}
{{-- Progress bar --}}
{{ $pct }}% achieved
{{-- Baseline + Freq --}}
BASELINE
{{ $formatRbmsValue($indicator->baseline_value) }}
FREQ.
{{ $indicator->reporting_frequency ?? '-' }}
@empty
No IRI indicators found.
@endforelse
@if($iri->isNotEmpty())
No IRI indicators found for selected donor.
@endif
{{-- ══════════════════════════════════════════════════════════
Detail Modal
══════════════════════════════════════════════════════════ --}}