@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']) }} |
|
|
|
| {{ __('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']) }} |
|
|
|
| {{ __('Published Reports') }} |
{{ $published['current_label'] }} {{ number_format((int)$published['current_month']) }} |
{{ $published['previous_label'] }} {{ number_format((int)$published['previous_month']) }} |
|
|
|
{{-- Row 2 --}}
| {{ __('Sector-wise Visit Distribution') }} |
@if (($sectorPie['total'] ?? 0) > 0)
@foreach ($sectorPie['items'] ?? [] as $item)
| {{ Str::limit($item['label'], 22) }} | {{ $item['pct'] }}% |
@endforeach
@else
{{ __('No sector data') }}
@endif
|
|
| {{ __('Status of 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
|
{{ $bar['regular'] }}
{{ $bar['compliance'] }}
{{ $bar['special'] }}
{{ $bar['published'] }}
{{ Str::limit($bar['region'], 10) }}
|
@endforeach
@else
{{ __('No regional data') }}
@endif
|
|
{{-- Row 3 --}}
| {{ __('Monthly Visits Progress') }} |
@if (count($monthlyTrend['labels'] ?? []) > 0)
@foreach ($monthlyTrend['labels'] as $label)
| {{ Str::limit($label, 8) }} |
@endforeach
@else
{{ __('No monthly trend data') }}
@endif
|
|
| {{ __('Visit Region Map') }} |
|
@if ($mapPoints !== [])
{{ __('Visit route (plan month order)') }} · {{ count($mapPoints) }} {{ __('points') }}
| # | {{ __('ADP') }} | {{ __('Region') }} | {{ __('Status') }} |
@foreach ($mapPreview as $pt)
| {{ $pt['visit_order'] ?? '' }} |
{{ Str::limit($pt['adp'] ?? '—', 10) }} |
{{ Str::limit($pt['region'] ?? '—', 12) }} |
{{ Str::limit($pt['published_status'] ?? '', 10) }} |
@endforeach
@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 !== [])
| # | {{ __('Department') }} | {{ __('Visits') }} |
@foreach ($topDepartments as $dept)
| {{ $dept['rank'] }} | {{ Str::limit($dept['name'], 28) }} | {{ $dept['visits'] }} |
@endforeach
@else
{{ __('No department data') }}
@endif
|
|
| {{ __('Visit Media Wise Progress') }} |
{{ __('Coming soon') }} |
|
| {{ __('Top Visit Categories') }} |
@if (($categoryPie['total'] ?? 0) > 0)
@foreach ($categoryPie['items'] ?? [] as $item)
| {{ Str::limit($item['label'], 20) }} | {{ $item['pct'] }}% |
@endforeach
@else
{{ __('No scheme type data') }}
@endif
|
|
{{-- Row 5 --}}
| {{ __('Overall Compliance by Region') }} |
| {{ __('Region') }} | {{ __('Planned') }} | {{ __('Conducted') }} | {{ __('Compliance %') }} |
@forelse ($complianceRows as $row)
@php $pct = (int) $row['compliance_pct']; @endphp
| {{ Str::limit($row['region'], 18) }} |
{{ $row['planned'] }} |
{{ $row['conducted'] }} |
{{ $pct }}% |
@empty
| {{ __('No data') }} |
@endforelse
@if ($complianceRows !== [])
| {{ __('Total') }} |
{{ $complianceTotals['planned'] }} |
{{ $complianceTotals['conducted'] }} |
{{ $complianceTotals['compliance_pct'] }}% |
@endif
|
|
| {{ __('Key Issues / Remarks') }} |
{{ __('Coming soon') }} |
|
|