@extends('layouts.app') @section('dashboard-title')

PROGRESS DASHBOARD

@endsection @section('content') @php $catLetter = 65; @endphp
{{-- Row 1: Group Headers --}} {{-- Row 2: Sub Headers --}} @forelse($progresses as $progress) @php $letter = chr($catLetter); $normalizeProgressText = function ($value) { $value = strtolower($value ?? ''); return trim(preg_replace('/[^a-z0-9]+/', ' ', $value)); }; $getComponentThreeSummaryField = function ($subCategory) use ($normalizeProgressText) { $normalized = $normalizeProgressText($subCategory); if (str_contains($normalized, 'house') && str_contains($normalized, 'complete')) return 'houses_completed'; if (str_contains($normalized, 'account') && str_contains($normalized, 'open')) return 'accounts_opened'; if (str_contains($normalized, 'work') && str_contains($normalized, 'init')) return 'work_initiated'; if (str_contains($normalized, 'plinth')) return 'plinth_completed'; if (str_contains($normalized, 'lintel')) return 'lintel_completed'; if (str_contains($normalized, 'roof')) return 'roof_completed'; return null; }; $normalizedCategory = $normalizeProgressText($progress->category); $componentThreeMatchCount = collect($progress->details) ->filter(fn ($item) => $getComponentThreeSummaryField($item->sub_categories)) ->count(); $isComponentThree = str_contains($normalizedCategory, 'component 3') || str_contains($normalizedCategory, 'component three') || $componentThreeMatchCount >= 3; @endphp {{-- Component Header Row --}} @for($i=0; $i<8; $i++) @endfor @foreach($progress->details as $detail) @php $isManual = (int) ($detail->is_manual ?? 0); $yearProgress = $detail->year_progress; $currentYearProgress = $detail->current_year_progress; $historicSum = 0; $summaryField = $getComponentThreeSummaryField($detail->sub_categories); // Check logic: Only auto-calculate if Component 3 AND Not Manual if ($isComponentThree && $summaryField && $isManual === 0) { // 1. Current Previous Year Value (2024-25) $prevSummary = $progressSummaryByYear->get('2024-2025'); if ($prevSummary && isset($prevSummary->{$summaryField})) { $yearProgress = $prevSummary->{$summaryField}; } // 2. Sum ALL years BEFORE 2024-25 $historicSum = $progressSummaryByYear->filter(function($val, $key) { return $key !== '2024-2025' && $key !== '2025-2026'; })->sum($summaryField); // 3. Current Year Value (2025-26) $currSummary = $progressSummaryByYear->get('2025-2026'); if ($currSummary && isset($currSummary->{$summaryField})) { $currentYearProgress = $currSummary->{$summaryField}; } } // Cumulative Logic $cumulativeAsOfJune = $isManual ? $detail->comulative_progress : ($historicSum + $yearProgress); $totalCumulative = $cumulativeAsOfJune + $currentYearProgress; @endphp @endforeach @php $catLetter++; @endphp @empty @endforelse
ACTIVITIES: STATUS PROJECT
TARGETS
YEAR (2024-25) CURRENT YEAR (2025-26) CUMULATIVE
2024-25
PROGRESS
CUMULATIVE
PROGRESS
(As on June 2025)
TARGETS PROGRESS PROGRESS
%
PROGRESS PROGRESS
%
{{ $letter }}- {{ $progress->category }}
 
{{ $detail->sub_categories }} {{ $detail->status == "inprogress" ? "IN PROGRESS" : strtoupper($detail->status) }} {{ $detail->project_targets }} {{ $yearProgress }} {{ $cumulativeAsOfJune }} {{ $detail->current_year_targets }} {{ $currentYearProgress }} @php $percent = $detail->current_year_targets > 0 ? round(($currentYearProgress / $detail->current_year_targets) * 100) : 0; @endphp {{ $percent }}% {{ $totalCumulative }} @php $cum_percent = $totalCumulative > 0 ? round(($totalCumulative / $detail->project_targets) * 100) : 0; @endphp {{ $cum_percent }}%
No Data Found
@endsection