@extends('layouts.app') @section('content')

📄 Reports

{{-- Export button --}}
⬇️ Export All Reports
@if($reports->isEmpty())
No reports found for your center or county.
@else {{-- Summary badges --}}
Approved: {{ $reports->where('status','Approved')->count() }} Pending: {{ $reports->where('status','Pending')->count() }} Rejected: {{ $reports->where('status','Rejected')->count() }} Total Reports: {{ $reports->count() }}
@php // Group reports by center name $groupedReports = $reports->groupBy(function($report) { return $report->user->center->name ?? 'Unknown Center'; }); @endphp
@foreach($groupedReports as $centerName => $centerReports) @php // Count statuses for this center $approvedCount = $centerReports->where('status','Approved')->count(); $pendingCount = $centerReports->where('status','Pending')->count(); $rejectedCount = $centerReports->where('status','Rejected')->count(); @endphp

@php // Group by user role then by user $reportsByRole = $centerReports->groupBy('user.role'); @endphp @foreach($reportsByRole as $role => $roleReports)
{{ strtoupper($role ?? 'Trainer') }}
@php // Group by individual user $reportsByUser = $roleReports->groupBy('user.name'); @endphp @foreach($reportsByUser as $userName => $userReports)
{{ $userName }} ({{ $userReports->count() }})
@foreach($userReports as $report) @endforeach
#ID Title Type Status Date Actions
{{ $report->id }} {{ $report->title }} {{ ucfirst($report->type ?? '-') }} @switch($report->status) @case('Approved') {{ $report->status }} @break @case('Pending') {{ $report->status }} @break @case('Rejected') {{ $report->status }} @break @default {{ $report->status ?? '-' }} @endswitch {{ $report->created_at->format('d M, Y') }} View @if($report->attachment) Download @endif
@endforeach
@endforeach
@endforeach
@endif
← Back to Dashboard
@section('scripts') {{-- Bootstrap tooltips --}} {{-- DataTables --}} @endsection @endsection