{{-- Part B §3 — Physical / component progress (REVENUE). Independent Single / Unit-wise mode. --}} @php $reportPayload = is_array($report ?? null) ? $report : []; $unitMode = old( 'report.part_b.scheme_progress_revenue.reporting_mode', report_section_reporting_mode($reportPayload, 'part_b.scheme_progress_revenue.reporting_mode') ); if (! in_array((string) $unitMode, ['single', 'unit_wise'], true)) { $unitMode = 'single'; } $defaultRow = [ 'major_unit_component' => '', 'measuring_unit' => '', 'qty_pc_i' => '', 'physical_progress' => '', 'expenditure' => '', 'total_cost' => '', 'pp_pct' => '', 'fp_pct' => '', 'variance_pp_fp' => '', 'remarks' => '', ]; $normalizeRevRow = static function ($row) use ($defaultRow): array { if (! is_array($row)) { return $defaultRow; } $out = []; foreach ($defaultRow as $key => $default) { $val = $row[$key] ?? $default; $out[$key] = $val === null ? '' : (is_scalar($val) ? (string) $val : $default); } if ($out['measuring_unit'] === '' && $out['qty_pc_i'] === '') { $legacy = trim((string) ($row['measuring_unit_qty_pci'] ?? '')); if ($legacy !== '') { $out['qty_pc_i'] = $legacy; } } return $out; }; $rows = old('report.part_b.scheme_progress_revenue.rows'); if (! is_array($rows) || count($rows) === 0) { $rows = data_get($reportPayload, 'part_b.scheme_progress_revenue.rows', []); } if (! is_array($rows) || count($rows) === 0) { $rows = [$defaultRow]; } $rows = array_map($normalizeRevRow, array_values($rows)); $units = old('report.part_b.scheme_progress_revenue.units'); if (! is_array($units) || count($units) === 0) { $units = data_get($reportPayload, 'part_b.scheme_progress_revenue.units', []); } if (! is_array($units) || count($units) === 0) { $units = [['unit_name' => '', 'rows' => [$defaultRow]]]; } foreach ($units as $ui => $unit) { if (! is_array($unit)) { $units[$ui] = ['unit_name' => '', 'rows' => [$defaultRow]]; continue; } $unitRows = $unit['rows'] ?? []; if (! is_array($unitRows) || count($unitRows) === 0) { $unitRows = [$defaultRow]; } $units[$ui]['unit_name'] = (string) ($unit['unit_name'] ?? ''); $units[$ui]['rows'] = array_map($normalizeRevRow, array_values($unitRows)); $unitTotals = is_array($unit['totals'] ?? null) ? $unit['totals'] : []; $units[$ui]['totals'] = [ 'pp_pct' => (string) ($unitTotals['pp_pct'] ?? ''), 'fp_pct' => (string) ($unitTotals['fp_pct'] ?? ''), ]; } $revTotalsRaw = old('report.part_b.scheme_progress_revenue.totals'); if (! is_array($revTotalsRaw)) { $revTotalsRaw = data_get($reportPayload, 'part_b.scheme_progress_revenue.totals', []); } if (! is_array($revTotalsRaw)) { $revTotalsRaw = []; } $revTotalPp = \App\Services\ReportPreviewPresenter::schemeProgressPctInputValue((string) ($revTotalsRaw['pp_pct'] ?? '')); $revTotalFp = \App\Services\ReportPreviewPresenter::schemeProgressPctInputValue((string) ($revTotalsRaw['fp_pct'] ?? '')); @endphp
| S# | {{ __('Major unit/components') }} | {{ __('Measuring unit') }} | {{ __('Qty (PC-I)') }} | {{ __('Phys. progress') }} | {{ __('Expenditure') }} | {{ __('Total cost') }} | PP (%) | FP (%) | {{ __('Variance') }} | {{ __('Remarks') }} | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ __('TOTAL (THIS UNIT)') }} | — | — | — | — | — | — | |||||