@once @push('stylesheets') @endpush @endonce @php use App\Helpers\PC\AmountMillionHelper; use App\Services\ReportPreviewPresenter; $pciIiiBPhysicalDisplayQty = function (mixed $raw) use ($pciIiiBEdit): string { if ($raw === null || $raw === '') { return ''; } $digits = preg_replace('/\D+/', '', (string) $raw) ?? ''; if ($digits === '') { return ''; } if ($pciIiiBEdit) { return $digits; } return number_format((int) $digits, 0, '.', ','); }; $pciIiiBPhysicalDisplayPct = function (mixed $raw) use ($pciIiiBEdit): string { if ($raw === null || $raw === '') { return ''; } $plain = AmountMillionHelper::normalizePlanProvisionAmountInput( is_string($raw) ? str_replace('%', '', $raw) : $raw ); if ($plain === null || $plain === '' || ! is_numeric($plain)) { return (string) $raw; } $n = min(100, max(0, (float) $plain)); if ($pciIiiBEdit) { return number_format($n, 2, '.', ''); } return number_format($n, 2).'%'; }; $pciIiiBPhysicalFormatMillionForDisplay = static function (string $plain): string { $plain = trim($plain); if ($plain === '' || $plain === '0') { return '0'; } if (! preg_match('/^(\d+)(\.\d+)?$/', $plain, $m)) { return $plain; } $intPart = ltrim($m[1], '0') ?: '0'; $len = strlen($intPart); $buf = ''; for ($i = 0; $i < $len; $i++) { if ($i > 0 && ($len - $i) % 3 === 0) { $buf .= ','; } $buf .= $intPart[$i]; } if (isset($m[2]) && $m[2] !== '' && $m[2] !== '.') { $buf .= $m[2]; } return $buf; }; $pciIiiBPhysicalDisplayAmt = function (mixed $raw) use ($pciIiiBEdit, $pciIiiBPhysicalFormatMillionForDisplay): string { if ($raw === null || $raw === '') { return ''; } $plain = AmountMillionHelper::normalizePlanProvisionAmountInput($raw); if ($plain === null || $plain === '' || ! is_numeric($plain)) { return ''; } if (! $pciIiiBEdit) { return ReportPreviewPresenter::amountMillionDisplay($raw); } $n = (float) $plain; if ($n <= 0) { return $n === 0.0 ? '0' : ''; } $trimmed = rtrim(rtrim(sprintf('%.6F', $n), '0'), '.'); return $pciIiiBPhysicalFormatMillionForDisplay($trimmed === '' ? '0' : $trimmed); }; $pciIiiBPhysicalSections = is_array($pciIiiBPhysicalSections ?? null) ? $pciIiiBPhysicalSections : []; $pciIiiBPhysByDistrict = []; foreach ($pciIiiBPhysicalSections as $si => $section) { if (! is_array($section)) { continue; } $dName = trim((string) ($section['district'] ?? '')); $dKey = $dName !== '' ? $dName : '—'; if (! isset($pciIiiBPhysByDistrict[$dKey])) { $pciIiiBPhysByDistrict[$dKey] = [ 'district' => $dName, 'sections' => [], ]; } $pciIiiBPhysByDistrict[$dKey]['sections'][] = [ 'index' => $si, 'section' => $section, ]; } @endphp {{-- Step 4: Physical Status --}}

Physical achievements by location (from Location step). Add component rows under each Taluka / UC / Unit / Contractor / Consultant group.

@if($pciIiiBPhysByDistrict === [])

No districts found on Location yet. Add district rows on the Location step first.

@else @foreach($pciIiiBPhysByDistrict as $districtKey => $districtGroup)
District: {{ $districtGroup['district'] !== '' ? $districtGroup['district'] : '—' }}
@foreach($districtGroup['sections'] as $entry) @php $sec = $entry['section']; @endphp @endforeach
Taluka U.C Unit Contractor Consultant
{{ $sec['taluka'] !== '' ? $sec['taluka'] : '—' }} {{ $sec['union_council'] !== '' ? $sec['union_council'] : '—' }} {{ $sec['unit'] !== '' ? $sec['unit'] : '—' }} {{ $sec['contractor'] !== '' ? $sec['contractor'] : '—' }} {{ $sec['consultant'] !== '' ? $sec['consultant'] : '—' }}
@foreach($districtGroup['sections'] as $entry) @php $si = (int) $entry['index']; $sec = $entry['section']; $components = is_array($sec['components'] ?? null) ? $sec['components'] : []; if ($components === []) { $components = [[ 'component' => '', 'unit' => '', 'total_qty_pc_i' => '', 'qty_completed_cumulative' => '', 'qty_completed_current_month' => '', 'physical_progress_pct' => '', 'expenditure_rs_m' => '', 'remarks' => '', ]]; } @endphp
@if($pciIiiBEdit)
@endif
@if($pciIiiBEdit)@endif @foreach($components as $ci => $pRow) @if($pciIiiBEdit) @endif @endforeach
S.No. Major Units / Components (As per PC-I) Unit (Per PC-I) Total Qty As per PC-I Qty Completed (Cumul.) Qty Completed Current Month Physical Progress % Expenditure (Rs. M) Remarks
{{ $ci + 1 }}
@endforeach
@endforeach @endif