@php $reportB2PmrLayout = ! empty($reportB2PmrLayout); $reportPayload = is_array($report ?? null) ? $report : []; if ($reportPayload === [] && is_array(old('report'))) { $reportPayload = old('report'); } $unitMode = old( 'report.part_b.scheme_progress_capital.reporting_mode', report_section_reporting_mode($reportPayload, 'part_b.scheme_progress_capital.reporting_mode') ); if (! in_array((string) $unitMode, ['single', 'unit_wise'], true)) { $unitMode = 'single'; } $defaultSpRow = [ 'major_unit_component' => '', 'activity_sub_activity' => '', 'unit' => '', 'qty_pc_i' => '', 'qty_ts' => '', 'total_cost' => '', 'amount_pc_i' => '', 'amount_ts' => '', 'qty_mb' => '', 'payment_mb' => '', 'pp_pct' => '', 'fp_pct' => '', 'variance_pp_fp' => '', ]; $defaultSpRowExtended = [ 'major_unit_component' => '', 'qty_pc_i' => '', 'amount_pc_i' => '', 'qty_ts' => '', 'amount_ts' => '', 'qty_mb' => '', 'payment_mb' => '', 'pp_pct' => '', 'fp_pct' => '', 'variance_pp_fp' => '', ]; $normalizeSpRowExtended = static function ($row) use ($defaultSpRowExtended): array { if (! is_array($row)) { return $defaultSpRowExtended; } $out = []; foreach ($defaultSpRowExtended as $key => $default) { $val = $row[$key] ?? $default; $out[$key] = $val === null ? '' : (is_scalar($val) ? (string) $val : $default); } if ($out['amount_pc_i'] === '' && trim((string) ($row['total_cost'] ?? '')) !== '') { $out['amount_pc_i'] = (string) $row['total_cost']; } return $out; }; $normalizeSpRow = static function ($row) use ($defaultSpRow): array { if (! is_array($row)) { return $defaultSpRow; } $out = []; foreach ($defaultSpRow as $key => $default) { $val = $row[$key] ?? $default; $out[$key] = $val === null ? '' : (is_scalar($val) ? (string) $val : $default); } return $out; }; $b2ExtendedAvailable = ! $reportB2PmrLayout; $tableFormat = old('report.part_b.scheme_progress_capital.table_format', data_get($reportPayload, 'part_b.scheme_progress_capital.table_format', 'standard')); if (! in_array((string) $tableFormat, ['standard', 'extended'], true)) { $tableFormat = 'standard'; } if (! $b2ExtendedAvailable) { $tableFormat = 'standard'; } $spRows = data_get($reportPayload, 'part_b.scheme_progress_capital.rows', []); if (! is_array($spRows)) { $spRows = []; } $oldSpRows = old('report.part_b.scheme_progress_capital.rows'); if (is_array($oldSpRows) && count($oldSpRows) > 0) { $spRows = $oldSpRows; } if (count($spRows) === 0) { $spRows = [$defaultSpRow]; } $spRows = array_map($normalizeSpRow, array_values($spRows)); $spRowsExt = array_map($normalizeSpRowExtended, array_values($spRows)); $spUnits = data_get($reportPayload, 'part_b.scheme_progress_capital.units', []); if (! is_array($spUnits)) { $spUnits = []; } $oldSpUnits = old('report.part_b.scheme_progress_capital.units'); if (is_array($oldSpUnits) && count($oldSpUnits) > 0) { $spUnits = $oldSpUnits; } if (count($spUnits) === 0) { $spUnits = [['unit_name' => '', 'rows' => [$defaultSpRow]]]; } foreach ($spUnits as $ui => $unit) { if (! is_array($unit)) { $spUnits[$ui] = ['unit_name' => '', 'rows' => [$defaultSpRow]]; continue; } $unitRows = $unit['rows'] ?? []; if (! is_array($unitRows) || count($unitRows) === 0) { $unitRows = [$defaultSpRow]; } $spUnits[$ui]['unit_name'] = (string) ($unit['unit_name'] ?? ''); $spUnits[$ui]['rows'] = array_map($normalizeSpRow, array_values($unitRows)); $unitTotals = is_array($unit['totals'] ?? null) ? $unit['totals'] : []; $spUnits[$ui]['totals'] = [ 'pp_pct' => (string) ($unitTotals['pp_pct'] ?? ''), 'fp_pct' => (string) ($unitTotals['fp_pct'] ?? ''), ]; } $spUnitsExt = $spUnits; foreach ($spUnitsExt as $ui => $unit) { $unitRows = $unit['rows'] ?? []; if (! is_array($unitRows)) { $unitRows = []; } $spUnitsExt[$ui]['rows'] = array_map($normalizeSpRowExtended, array_values($unitRows)); } $spTotalsRaw = old('report.part_b.scheme_progress_capital.totals'); if (! is_array($spTotalsRaw)) { $spTotalsRaw = data_get($reportPayload, 'part_b.scheme_progress_capital.totals', []); } if (! is_array($spTotalsRaw)) { $spTotalsRaw = []; } $spTotalPp = \App\Services\ReportPreviewPresenter::schemeProgressPctInputValue((string) ($spTotalsRaw['pp_pct'] ?? '')); $spTotalFp = \App\Services\ReportPreviewPresenter::schemeProgressPctInputValue((string) ($spTotalsRaw['fp_pct'] ?? '')); @endphp {{-- Part B §2 — Scheme Progress / Component-wise (CAPITAL); same green card chrome as Part A --}}
| S# | {{ __('Major Unit / Component (As per PC-I)') }} | {{ __('Unit') }} | {{ __('Qty') }} ({{ __('PC-I') }}) | {{ __('Qty') }} ({{ __('T.S') }}) | {{ __('Total cost') }} | {{ __('Payment') }} ({{ __('As per MB') }}) | PP (%) | FP (%) | {{ __('Variance') }} | |
|---|---|---|---|---|---|---|---|---|---|---|
| {{ __('TOTAL (THIS UNIT)') }} | — | — | — | — | — | |||||