@php if (!function_exists('getChunks')) { function getChunks($data, $size) { return array_chunk($data, $size); } } if (!function_exists('getColorByProgressKeyName')) { function getColorByProgressKeyName($progressKeys, $keyName) { return collect($progressKeys) ->firstWhere('name', $keyName)['color'] ?? '#ccc'; } } if (!function_exists('getCustomChunks')) { function getCustomChunks($data) { $chunks = []; $index = 0; $page = 0; while ($index < count($data)) { if ($page < 2) { $chunkSize = 2; // First two pages } else { $chunkSize = 3; // Subsequent pages } $chunks[] = array_slice($data, $index, $chunkSize); $index += $chunkSize; $page++; } return $chunks; } } @endphp @foreach(getCustomChunks($milestoneReport['progressData'] ?? []) as $chunkIndex => $chunk) @php $chunks = getCustomChunks($milestoneReport['progressData'] ?? []); $isFirst = $chunkIndex === 0; $isLast = $chunkIndex === count($chunks) - 1; @endphp @if(!$isFirst)
@endif
{{-- Header and Learner Info --}} @if($isFirst)

Progress Review

Academic Term 2024-2025

Learner’s Name: {{ $milestoneReport['student']['name'] ?? '' }}

{{ $milestoneReport['ageString'] ?? '' }}

Grade: {{ $milestoneReport['student']->classSection->name ?? '' }}

Attendance: {{ $milestoneReport['totalDaysPresent'] ?? '' }} Out Of {{ $milestoneReport['totalWorkingDays'] ?? '' }}

Facilitators: @foreach($milestoneReport['classSectionTeacher'] ?? [] as $i => $teacher) {{ $teacher['name'] }}@if($i + 1 < count($milestoneReport['classSectionTeacher'])){{ ', ' }}@endif @endforeach

Date: {{ $milestoneReport['currentDate'] ?? '' }}

  • Progress key:

  • @foreach($milestoneReport['progressKeys'] ?? [] as $key)
  • {{ $key['name'] }}
  • @endforeach
@endif {{-- Domain + Subdomain Sections --}}
@foreach($chunk as $domain)

{{ $domain['name'] }}

@if($milestoneReport['student']->classSection->class_id == 1) @foreach($domain['sub_domains'] ?? [] as $subdomain) @php $strands = $subdomain['strands'] ?? []; $strandCount = count($strands); $splitStrands = $strandCount >= 9 ? [array_slice($strands, 0, 5), array_slice($strands, 5, 4)] : [$strands, []]; @endphp @if($strandCount >= 9) {{-- When strands >= 9: Split into two equal cols --}}

{{ $subdomain['name'] }}

@foreach($splitStrands[0] as $strand) @endforeach
{{ $strand['strand'] ?? '' }} @if(!empty($strand['progress_key'])) @endif
@foreach($splitStrands[1] as $strand) @endforeach {{-- If exactly 9 strands, add one empty row --}} @if($strandCount == 9) @endif
{{ $strand['strand'] ?? '' }} @if(!empty($strand['progress_key'])) @endif
 
@else {{-- Default rendering for subdomains with < 9 strands --}}

{{ $subdomain['name'] }}

@php $maxStrandCount = $domain['maxStrandCount'] ?? count($strands); $strands = array_pad($strands, $maxStrandCount, null); @endphp @foreach($strands as $strand) @endforeach
{{ $strand['strand'] ?? '' }} @if(!empty($strand) && !empty($strand['progress_key'])) @endif
@endif @endforeach @else @foreach($domain['sub_domains'] ?? [] as $subdomain)

{{ $subdomain['name'] }}

@php $strands = $subdomain['strands'] ?? []; $maxStrandCount = $domain['maxStrandCount'] ?? count($strands); $strands = array_pad($strands, $maxStrandCount, null); @endphp @foreach($strands as $strand) @endforeach
{{ $strand['strand'] ?? '' }} @if(!empty($strand) && !empty($strand['progress_key'])) @endif
@endforeach @endif
@endforeach
{{-- Custom Text Box --}} @if($isLast && trim($milestoneReport['customTextBox']['title'] ?? '') && trim($milestoneReport['customTextBox']['value'] ?? ''))

{{ $milestoneReport['customTextBox']['title'] }}

{{ $milestoneReport['customTextBox']['value'] }}
@endif
@endforeach