@php use App\Support\MonthlyReportSummaryPdfSvg; $dash = is_array($summary ?? null) ? $summary : []; $kpis = $dash['kpis'] ?? []; $planned = $kpis['planned'] ?? ['regular' => 0, 'compliance' => 0, 'special' => 0, 'pmu' => 0, 'total' => 0]; $conducted = $kpis['conducted'] ?? ['regular' => 0, 'compliance' => 0, 'special' => 0, 'pmu' => 0, 'total' => 0]; $published = $kpis['published'] ?? ['current_month' => 0, 'previous_month' => 0, 'total' => 0, 'current_label' => '—', 'previous_label' => '—']; $visitStatus = $dash['visit_status'] ?? ['total' => 0, 'completed' => 0, 'pending' => 0, 'completed_pct' => 0, 'pending_pct' => 0]; $sectorPie = $dash['sector_distribution'] ?? ['items' => [], 'total' => 0]; $categoryPie = $dash['visit_categories'] ?? ['items' => [], 'total' => 0]; $regionBars = is_array($dash['region_bars'] ?? null) ? $dash['region_bars'] : []; $monthlyTrend = $dash['monthly_trend'] ?? ['labels' => [], 'planned' => [], 'conducted' => [], 'pending' => [], 'max' => 1]; $topDepartments = is_array($dash['top_departments'] ?? null) ? $dash['top_departments'] : []; $complianceRows = is_array($dash['compliance_rows'] ?? null) ? $dash['compliance_rows'] : []; $complianceTotals = $dash['compliance_totals'] ?? ['planned' => 0, 'conducted' => 0, 'pending' => 0, 'compliance_pct' => 0]; $mapPoints = is_array($dash['map_points'] ?? null) ? $dash['map_points'] : []; $titlePeriod = $dash['title_period'] ?? ''; $generatedAt = $dash['generated_at'] ?? now()->format('d M Y'); $rowCount = (int) ($dash['row_count'] ?? 0); $mecLogoPath = public_path('assets/mec logo.jpg'); $gosLogoPath = public_path('assets/dist/img/gos.png'); $mecLogoSrc = is_file($mecLogoPath) ? 'file:///'.str_replace('\\', '/', $mecLogoPath) : ''; $gosLogoSrc = is_file($gosLogoPath) ? 'file:///'.str_replace('\\', '/', $gosLogoPath) : ''; $sectorSlices = MonthlyReportSummaryPdfSvg::pieSlices($sectorPie['items'] ?? [], 50, 50, 45); $categorySlices = MonthlyReportSummaryPdfSvg::pieSlices($categoryPie['items'] ?? [], 50, 50, 45); $trendMax = max(1, (int) ($monthlyTrend['max'] ?? 1)); $trendPlanned = MonthlyReportSummaryPdfSvg::polylinePoints($monthlyTrend['planned'] ?? [], $trendMax, 520, 150, 20, 10); $trendConducted = MonthlyReportSummaryPdfSvg::polylinePoints($monthlyTrend['conducted'] ?? [], $trendMax, 520, 150, 20, 10); $trendPending = MonthlyReportSummaryPdfSvg::polylinePoints($monthlyTrend['pending'] ?? [], $trendMax, 520, 150, 20, 10); $mapPreview = array_slice($mapPoints, 0, 12); $mapExtra = max(0, count($mapPoints) - count($mapPreview)); $donutSlices = MonthlyReportSummaryPdfSvg::donutSlices((float) ($visitStatus['completed_pct'] ?? 0)); @endphp {{ __('Monthly M&E Report Summary') }} — {{ $titlePeriod }}
{{-- Row 1: KPI cards --}}
{{ __('Monitoring Visits Planned') }}
{{ __('Regular') }}
{{ number_format((int)$planned['regular']) }}
{{ __('Compliance') }}
{{ number_format((int)$planned['compliance']) }}
{{ __('Special') }}
{{ number_format((int)$planned['special']) }}
{{ __('PMU') }}
{{ number_format((int)$planned['pmu']) }}
{{ __('Total') }}: {{ number_format((int)$planned['total']) }}
{{ __('Visits Conducted') }}
{{ __('Regular') }}
{{ number_format((int)$conducted['regular']) }}
{{ __('Compliance') }}
{{ number_format((int)$conducted['compliance']) }}
{{ __('Special') }}
{{ number_format((int)$conducted['special']) }}
{{ __('PMU') }}
{{ number_format((int)$conducted['pmu']) }}
{{ __('Total') }}: {{ number_format((int)$conducted['total']) }}
{{ __('Published Reports') }}
{{ $published['current_label'] }}
{{ number_format((int)$published['current_month']) }}
{{ $published['previous_label'] }}
{{ number_format((int)$published['previous_month']) }}
{{ __('Total') }}: {{ number_format((int)$published['total']) }}
{{-- Row 2 --}}
{{ __('Sector-wise Visit Distribution') }}
@if (($sectorPie['total'] ?? 0) > 0) @foreach ($sectorSlices as $slice) @endforeach @foreach ($sectorPie['items'] ?? [] as $item) @endforeach
{{ Str::limit($item['label'], 22) }}{{ $item['pct'] }}%
@else
{{ __('No sector data') }}
@endif
{{ __('Status of Visits') }}
@foreach ($donutSlices as $slice) @endforeach {{ number_format((int)$visitStatus['total']) }} {{ __('TOTAL VISITS') }}
{{ __('Completed') }}{{ $visitStatus['completed_pct'] }}% ({{ number_format((int)$visitStatus['completed']) }})
{{ __('Pending') }}{{ $visitStatus['pending_pct'] }}% ({{ number_format((int)$visitStatus['pending']) }})
{{ __('MEC Region Wise Visits Status') }}
@if ($regionBars !== [])
{{ __('Regular') }} {{ __('Compliance') }} {{ __('Special') }} {{ __('Published') }}
@foreach ($regionBars as $bar) @php $axis = max(1, (int) ($bar['max'] ?? 1)); $hR = max(2, (int) round(100 * ((int) ($bar['regular'] ?? 0)) / $axis)); $hC = max(2, (int) round(100 * ((int) ($bar['compliance'] ?? 0)) / $axis)); $hS = max(2, (int) round(100 * ((int) ($bar['special'] ?? 0)) / $axis)); $hP = max(2, (int) round(100 * ((int) ($bar['published'] ?? 0)) / $axis)); @endphp @endforeach
{{ $bar['regular'] }}
{{ $bar['compliance'] }}
{{ $bar['special'] }}
{{ $bar['published'] }}
{{ Str::limit($bar['region'], 10) }}
@else
{{ __('No regional data') }}
@endif
{{-- Row 3 --}}
{{ __('Monthly Visits Progress') }}
@if (count($monthlyTrend['labels'] ?? []) > 0) @foreach ([0, 0.25, 0.5, 0.75, 1] as $ratio) @endforeach @if ($trendPlanned !== '')@endif @if ($trendConducted !== '')@endif @if ($trendPending !== '')@endif @foreach ($monthlyTrend['labels'] as $label) @endforeach
{{ Str::limit($label, 8) }}
@else
{{ __('No monthly trend data') }}
@endif
{{ __('Visit Region Map') }}
@if ($mapPoints !== [])

{{ __('Visit route (plan month order)') }} · {{ count($mapPoints) }} {{ __('points') }}

@foreach ($mapPreview as $pt) @endforeach
#{{ __('ADP') }}{{ __('Region') }}{{ __('Status') }}
{{ $pt['visit_order'] ?? '' }} {{ Str::limit($pt['adp'] ?? '—', 10) }} {{ Str::limit($pt['region'] ?? '—', 12) }} {{ Str::limit($pt['published_status'] ?? '', 10) }}
@if ($mapExtra > 0)

{{ __('and :count more visit points', ['count' => $mapExtra]) }}

@endif @else
{{ __('No schemes with coordinates') }}
@endif
{{-- Row 4 --}}
{{ __('Top 10 Departments Visited') }}
@if ($topDepartments !== []) @foreach ($topDepartments as $dept) @endforeach
#{{ __('Department') }}{{ __('Visits') }}
{{ $dept['rank'] }}{{ Str::limit($dept['name'], 28) }}{{ $dept['visits'] }}
@else
{{ __('No department data') }}
@endif
{{ __('Visit Media Wise Progress') }}
{{ __('Coming soon') }}
{{ __('Top Visit Categories') }}
@if (($categoryPie['total'] ?? 0) > 0) @foreach ($categorySlices as $slice) @endforeach @foreach ($categoryPie['items'] ?? [] as $item) @endforeach
{{ Str::limit($item['label'], 20) }}{{ $item['pct'] }}%
@else
{{ __('No scheme type data') }}
@endif
{{-- Row 5 --}}
{{ __('Overall Compliance by Region') }}
@forelse ($complianceRows as $row) @php $pct = (int) $row['compliance_pct']; @endphp @empty @endforelse @if ($complianceRows !== []) @endif
{{ __('Region') }}{{ __('Planned') }}{{ __('Conducted') }}{{ __('Compliance %') }}
{{ Str::limit($row['region'], 18) }} {{ $row['planned'] }} {{ $row['conducted'] }} {{ $pct }}%
{{ __('No data') }}
{{ __('Total') }} {{ $complianceTotals['planned'] }} {{ $complianceTotals['conducted'] }} {{ $complianceTotals['compliance_pct'] }}%
{{ __('Key Issues / Remarks') }}
{{ __('Coming soon') }}