@php use App\Helpers\PC\AmountMillionHelper; use App\Services\ReportPreviewPresenter as ReportPercentDisplay; $fpPrefix = 'report.part_a.financial_progress'; $fundingAmountKeys = ['funding_gos_amount', 'funding_gop_amount', 'funding_fpa_amount']; $costAutoTotalPrefixes = ['approved_cost', 'revised_cost', 'unit_cost']; $fpName = 'report[part_a][financial_progress]'; $pa4 = array_merge([ 'funding_gos_share' => '', 'funding_gop_share' => '', 'funding_fpa_share' => '', 'funding_gos_amount' => '', 'funding_gop_amount' => '', 'funding_fpa_amount' => '', 'funding_fields_readonly' => false, 'approved_capital' => '', 'approved_revenue' => '', 'approved_total' => '', 'approved_fields_readonly' => false, 'revised_capital' => '', 'revised_revenue' => '', 'revised_total' => '', 'revised_fields_readonly' => false, 'overall_progress_auto' => false, 'overall_progress_baseline_total' => '', ], $reportPartA4FinancialPrefill ?? []); $pA4Payload = $reportPayload ?? report_wizard_payload_array(is_array($report ?? null) ? $report : null); $fpYearCols = \App\Support\PlanSchemeAdpDisplay::mecReportFinancialProgressYearColumns(); $yearColumns = array_merge($fpYearCols, [ ['suffix' => 'total', 'head' => 'TOTAL', 'chart_head' => 'TOTAL'], ]); $timelineRows = [ ['label' => 'Allocation', 'prefix' => 'allocation'], ['label' => 'Releases (as per F.D. Data)', 'prefix' => 'releases'], ['label' => 'Expenditure (as per F.D/E.A Data)', 'prefix' => 'expenditure'], ]; $tripleBlocks = [ [ 'label' => 'Funding Agency Share (%)', 'readonly' => false, 'fields' => [ ['key' => 'funding_gos_share', 'sub' => 'GoS Share %', 'prefill' => $pa4['funding_gos_share']], ['key' => 'funding_gop_share', 'sub' => 'GoP Share %', 'prefill' => $pa4['funding_gop_share']], ['key' => 'funding_fpa_share', 'sub' => 'FPA Share %', 'prefill' => $pa4['funding_fpa_share']], ], ], [ 'label' => 'Funding Source Amount (M)', 'readonly' => false, 'fields' => [ ['key' => 'funding_gos_amount', 'sub' => 'GoS Amount', 'prefill' => $pa4['funding_gos_amount']], ['key' => 'funding_gop_amount', 'sub' => 'GoP Amount', 'prefill' => $pa4['funding_gop_amount']], ['key' => 'funding_fpa_amount', 'sub' => 'FPA Amount', 'prefill' => $pa4['funding_fpa_amount']], ], ], [ 'label' => 'Approved Cost of the Scheme (M)', 'readonly' => $pa4['approved_fields_readonly'], 'fields' => [ ['key' => 'approved_cost_capital', 'sub' => 'Capital', 'prefill' => $pa4['approved_capital']], ['key' => 'approved_cost_revenue', 'sub' => 'Revenue', 'prefill' => $pa4['approved_revenue']], ['key' => 'approved_cost_total', 'sub' => 'Total', 'prefill' => $pa4['approved_total']], ], ], [ 'label' => 'Revised Cost of the Scheme (if any)', 'readonly' => $pa4['revised_fields_readonly'], 'fields' => [ ['key' => 'revised_cost_capital', 'sub' => 'Capital', 'prefill' => $pa4['revised_capital']], ['key' => 'revised_cost_revenue', 'sub' => 'Revenue', 'prefill' => $pa4['revised_revenue']], ['key' => 'revised_cost_total', 'sub' => 'Total', 'prefill' => $pa4['revised_total']], ], ], [ 'label' => 'Units Cost within the Scheme (if applicable)', 'readonly' => false, 'fields' => [ ['key' => 'unit_cost_capital', 'sub' => 'Capital', 'prefill' => ''], ['key' => 'unit_cost_revenue', 'sub' => 'Revenue', 'prefill' => ''], ['key' => 'unit_cost_total', 'sub' => 'Total', 'prefill' => ''], ], ], ]; @endphp {{-- Part A §4 — Financial Progress FP (PKR million); title from collapsible only --}}
@foreach ($tripleBlocks as $block) @endforeach
{{ $block['label'] }}
@foreach ($block['fields'] as $field) @php $dotKey = $fpPrefix.'.'.$field['key']; $ro = $block['readonly']; $rawDisp = report_wizard_old('part_a.financial_progress.'.$field['key'], $field['prefill'] ?? '', $pA4Payload); $rawDisp = is_scalar($rawDisp) ? (string) $rawDisp : ''; $disp = in_array($field['key'], $fundingAmountKeys, true) ? AmountMillionHelper::reportFundingAmountMillionDisplay($rawDisp) : (str_ends_with($field['key'], '_share') ? ReportPercentDisplay::reportPercentInputDisplay($rawDisp) : $rawDisp); $fundingAgency = ''; if (str_starts_with($field['key'], 'funding_') && str_ends_with($field['key'], '_share')) { $fundingAgency = substr($field['key'], 8, -6); } elseif (in_array($field['key'], $fundingAmountKeys, true)) { $fundingAgency = substr($field['key'], 8, -7); } $fpInputClass = 'form-control form-control-sm pms-report-numeric-field'; if ($fundingAgency !== '') { $fpInputClass .= str_ends_with($field['key'], '_share') ? ' report-a4-funding-share' : ' report-a4-funding-amount'; } $costGroup = ''; foreach ($costAutoTotalPrefixes as $costPrefix) { if (str_starts_with($field['key'], $costPrefix.'_')) { $costGroup = $costPrefix; break; } } $isCostTotal = $costGroup !== '' && str_ends_with($field['key'], '_total'); $isCostPart = $costGroup !== '' && ! $isCostTotal; if ($isCostPart) { $fpInputClass .= ' report-a4-cost-part'; } if ($isCostTotal) { $fpInputClass .= ' report-a4-cost-total report-a1-identity-readonly'; } @endphp
@if ($ro) @else @endif @error($dotKey) {{ $message }} @enderror
@endforeach
@foreach ($yearColumns as $yc) @endforeach @foreach ($timelineRows as $tRow) @foreach ($yearColumns as $yc) @php $cellKey = $tRow['prefix'].'_'.$yc['suffix']; $dotKey = $fpPrefix.'.'.$cellKey; $cellVal = report_wizard_old('part_a.financial_progress.'.$cellKey, '', $pA4Payload); $cellVal = is_scalar($cellVal) ? (string) $cellVal : ''; $isTotalCol = $yc['suffix'] === 'total'; @endphp @endforeach @endforeach
Financial Progress (Up to 5 Years) of Scheme
{{ $yc['head'] }}
{{ $tRow['label'] }} @if ($isTotalCol) @else @endif @error($dotKey) {{ $message }} @enderror
Overall Financial Progress in % @php $overallDot = $fpPrefix.'.overall_fp_pct'; $overallVal = ReportPercentDisplay::reportPercentInputDisplay( report_wizard_old('part_a.financial_progress.overall_fp_pct', '', $pA4Payload) ); @endphp @error($overallDot) {{ $message }} @enderror Overall PP % @php $ppDot = $fpPrefix.'.overall_physical_pct'; $ppVal = ReportPercentDisplay::reportPercentInputDisplay( report_wizard_old('part_a.financial_progress.overall_physical_pct', '', $pA4Payload) ); @endphp @error($ppDot) {{ $message }} @enderror FP variance vs PP @php $varDot = $fpPrefix.'.fp_variance_vs_pp'; $varVal = ReportPercentDisplay::reportPercentInputDisplay( report_wizard_old('part_a.financial_progress.fp_variance_vs_pp', '', $pA4Payload) ); @endphp {{-- Auto: Overall PP % − Overall FP % (§4). Readonly; JS syncs when §4 overall inputs change. --}} @error($varDot) {{ $message }} @enderror
@push('scripts') @endpush