@php use Carbon\Carbon; // Fetch project from dp_project using request $project = null; $district = request('district'); $project_id = request('dp_project'); if($project_id) { $project = \App\Models\DpProject::find($project_id); } if (!$project && $district) { $project = \App\Models\DpProject::where('district', $district)->first(); } // Get the start year from the project $startYear = $project ? (Carbon::parse($project->start_date)->year ?? null) : null; // Prepare years for columns $years = []; if ($startYear) { $years = [$startYear, $startYear + 1, $startYear + 2]; } else { $years = [null, null, null]; } if($project){ $year_wise_results = \App\Helpers\ProjectHelper :: getDpConsolidatedResults($district, $project->start_date, $project->end_date); } // echo '
'; print_r($year_wise_results); echo ''; die(); $project_types = ['al', 'asc', 'ict', 'overall']; // Prepare results $results = [ ['label' => 'Decisions', 'field' => 'decisions'], ['label' => 'New Life Members', 'field' => 'new_life_members'], ['label' => 'Hope Cells', 'field' => 'hope_cells'], ['label' => 'Villages Reached', 'field' => 'worship_groups'], ]; @endphp @php $table_colors = [ 'al' => '#ffe0b2', // Soft Orange 'asc' => '#b9f6ca', // Soft Green 'ict' => '#fff9b2', // Soft Yellow 'overall' => '#ef1f7276', // Soft Purple ]; $plannedFieldMap = [ 'al' => ['al_first_year_villages', 'al_second_year_villages', 'al_third_year_villages'], 'asc' => ['asc_first_year_villages', 'asc_second_year_villages', 'asc_third_year_villages'], 'ict' => ['ict_first_year_villages', 'ict_second_year_villages', 'ict_third_year_villages'], 'overall' => ['first_year_villages', 'second_year_villages', 'third_year_villages'], ]; $actualFieldMap = [ 'al' => ['actual_al_first_year_villages', 'actual_al_second_year_villages', 'actual_al_third_year_villages'], 'asc' => ['actual_asc_first_year_villages', 'actual_asc_second_year_villages', 'actual_asc_third_year_villages'], 'ict' => ['actual_ict_first_year_villages', 'actual_ict_second_year_villages', 'actual_ict_third_year_villages'], 'overall' => ['actual_first_year_villages', 'actual_second_year_villages', 'actual_third_year_villages'], ]; @endphp
| {{ strtoupper($type) }} Year Wise Results | |||||
|---|---|---|---|---|---|
| S. No | Results | @if($years[0]) {{ $years[0] }} @else Year 1 @endif | @if($years[1]) {{ $years[1] }} @else Year 2 @endif | @if($years[2]) {{ $years[2] }} @else Year 3 @endif | Total |
| {{ $i + 1 }} | {{ $result['label'] }} | {{ $y1 }} | {{ $y2 }} | {{ $y3 }} | {{ $total }} |
| {{ count($results) + 1 }} | Actual Villages Reached | {{ $actualY1 }} | {{ $actualY2 }} | {{ $actualY3 }} | {{ $actualTotal }} |
| {{ count($results) + 2 }} | Actual Deviation | {{ $actualDevY1 }} | {{ $actualDevY2 }} | {{ $actualDevY3 }} | {{ $actualDevTotal }} |