@php use App\Support\MonthlyReportSummaryChartSvg; $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]; $publishedReportStatus = $dash['published_report_status'] ?? ['total' => 0, 'satisfactory' => 0, 'unsatisfactory' => 0, 'satisfactory_pct' => 0, 'unsatisfactory_pct' => 0]; $sectorPie = $dash['sector_distribution'] ?? ['items' => [], 'conic_gradient' => '#e2e8f0 0deg 360deg', 'total' => 0]; $subSectorPie = $dash['sub_sector_distribution'] ?? ['items' => [], 'conic_gradient' => '#e2e8f0 0deg 360deg', 'total' => 0]; $costPie = $dash['cost_distribution'] ?? ['items' => [], 'conic_gradient' => '#e2e8f0 0deg 360deg', 'total' => 0]; $typeWisePie = $dash['type_wise_distribution'] ?? ['items' => [], 'conic_gradient' => '#e2e8f0 0deg 360deg', 'total' => 0]; $pcReceiving = $dash['pc_receiving'] ?? ['rows' => [], 'total_adp' => 0]; $pcReceivingRows = is_array($pcReceiving['rows'] ?? null) ? $pcReceiving['rows'] : []; $regionBars = is_array($dash['region_bars'] ?? null) ? $dash['region_bars'] : []; $monthWiseProgress = $dash['month_wise_progress'] ?? ['labels' => [], 'assigned' => [], 'visited' => [], 'published' => [], 'satisfactory' => [], 'unsatisfactory' => [], 'max' => 1]; $pmuMonthProgress = $dash['pmu_month_progress'] ?? ['labels' => [], 'assigned' => [], 'visited' => [], 'published' => [], 'max' => 1]; $topDepartments = is_array($dash['top_departments'] ?? null) ? $dash['top_departments'] : []; $mapPoints = is_array($dash['map_points'] ?? null) ? $dash['map_points'] : []; $majorObservations = is_array($dash['major_observations'] ?? null) ? $dash['major_observations'] : []; $titlePeriod = $dash['title_period'] ?? now()->format('F Y'); $generatedAt = $dash['generated_at'] ?? now()->format('d M Y'); $rowCount = (int) ($dash['row_count'] ?? 0); $donutSatisfactoryDeg = max(0, min(360, (int) round(((float) ($publishedReportStatus['satisfactory_pct'] ?? 0) / 100) * 360))); $monthWiseCount = count($monthWiseProgress['labels'] ?? []); $pmuMonthCount = count($pmuMonthProgress['labels'] ?? []); $regionAxisMax = (int) ($regionBars[0]['max'] ?? 10); $sectorPieSvg = (($sectorPie['total'] ?? 0) > 0) ? MonthlyReportSummaryChartSvg::isometricPie($sectorPie['items'] ?? [], 'sector') : ''; $subSectorPieSvg = (($subSectorPie['total'] ?? 0) > 0) ? MonthlyReportSummaryChartSvg::isometricPie($subSectorPie['items'] ?? [], 'subsector') : ''; $costPieSvg = (($costPie['total'] ?? 0) > 0) ? MonthlyReportSummaryChartSvg::isometricPie($costPie['items'] ?? [], 'cost') : ''; $typeWisePieSvg = (($typeWisePie['total'] ?? 0) > 0) ? MonthlyReportSummaryChartSvg::isometricPie($typeWisePie['items'] ?? [], 'typewise') : ''; $monthWiseChartSvg = $monthWiseCount > 0 ? MonthlyReportSummaryChartSvg::monthWiseProgress($monthWiseProgress) : ''; $pmuMonthChartSvg = $pmuMonthCount > 0 ? MonthlyReportSummaryChartSvg::pmuMonthWiseProgress($pmuMonthProgress) : ''; /** Compact A4 layout only when explicitly requested — print preview uses full Summary design. */ $printMode = ! empty($printMode); $compactLayout = ! empty($compactLayout); $enableMapSnapshot = ! empty($enableMapSnapshot) || $printMode; $barChartHeight = $compactLayout ? 108 : ($printMode ? 88 : 144); $topDepartmentsDisplay = $printMode ? array_slice($topDepartments, 0, 6) : $topDepartments; $majorObservationsDisplay = array_slice($majorObservations, 0, 5); $topDepartmentsHidden = $printMode ? max(0, count($topDepartments) - count($topDepartmentsDisplay)) : 0; $majorObservationsHidden = max(0, count($majorObservations) - count($majorObservationsDisplay)); $mecLogo = asset('assets/mec logo.jpg'); $gosLogo = asset('assets/dist/img/gos.png'); @endphp
{{ __('MEC Logo') }}

{{ __('Monthly') }} {{ __('M&E') }} {{ __('Report') }}

{{ $titlePeriod }} @if ($rowCount > 0) · {{ number_format($rowCount) }} {{ __('schemes') }} @endif
{{ __('Government of Sindh') }}
{{-- 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['label'] ?? ($published['current_label'] ?? __('Current Month')) }}
{{ number_format((int) ($published['count'] ?? $published['current_month'] ?? 0)) }}
{{-- Row 2: Distribution pies --}}
{{ __('Sector @ Wise Distribution') }}
@if ($sectorPieSvg !== '')
{!! $sectorPieSvg !!}
@foreach ($sectorPie['items'] ?? [] as $item)
{{ Str::limit($item['label'], 18) }} {{ number_format((int) $item['count']) }} · {{ $item['pct'] }}%
@endforeach
@else
{{ __('No MEC sector data for current filters.') }}
@endif
{{ __('Sub-Sector @ Wise Distribution') }}
@if ($subSectorPieSvg !== '')
{!! $subSectorPieSvg !!}
@foreach ($subSectorPie['items'] ?? [] as $item)
{{ Str::limit($item['label'], 18) }} {{ number_format((int) $item['count']) }} · {{ $item['pct'] }}%
@endforeach
@else
{{ __('No sub-sector data for current filters.') }}
@endif
{{ __('Published Report Status') }}
{{ number_format((int) $publishedReportStatus['total']) }} {{ __('Assessed') }}
{{ __('Satisfactory') }} {{ $publishedReportStatus['satisfactory_pct'] }}% ({{ number_format((int) $publishedReportStatus['satisfactory']) }})
{{ __('Un-Satisfactory') }} {{ $publishedReportStatus['unsatisfactory_pct'] }}% ({{ number_format((int) $publishedReportStatus['unsatisfactory']) }})
{{-- Row 3: Region bars + Month Wise Progress --}}
{{ __('MEC Region Wise Visits Status') }}
@if ($regionBars !== [])
{{ __('Regular') }} {{ __('Compliance') }} {{ __('Special') }} {{ __('Report Published') }}
@for ($tick = $regionAxisMax; $tick >= 0; $tick -= max(1, (int) round($regionAxisMax / 6))) {{ $tick }} @endfor
@for ($g = 0; $g <= 6; $g++)
@endfor @foreach ($regionBars as $bar) @php $axis = max(1, (int) ($bar['max'] ?? $regionAxisMax)); $regularH = max(2, (int) round($barChartHeight * ((int) $bar['regular']) / $axis)); $complianceH = max(2, (int) round($barChartHeight * ((int) $bar['compliance']) / $axis)); $specialH = max(2, (int) round($barChartHeight * ((int) $bar['special']) / $axis)); $publishedH = max(2, (int) round($barChartHeight * ((int) $bar['published']) / $axis)); @endphp
{{ $bar['regular'] }}
{{ $bar['compliance'] }}
{{ $bar['special'] }}
{{ $bar['published'] }}
{{ Str::limit($bar['region'], 14) }}
@endforeach
@else
{{ __('No regional data for current filters.') }}
@endif
{{ __('Month Wise Progress') }}
@if ($monthWiseChartSvg !== '')
{{ __('Assigned') }} {{ __('Visited') }} {{ __('Published') }} {{ __('Satisfactory') }} {{ __('Un-Satisfactory') }}
{!! $monthWiseChartSvg !!}
@else
{{ __('No month-wise progress data for current filters.') }}
@endif
@if ($compactLayout) {{-- Print preview: map alone, then type + cost distributions --}}
{{ __('Visited Schemes Map') }}
@if ($enableMapSnapshot) @endif

@if ($mapPoints === []) {{ __('Sindh province · no scheme coordinates in current filters · zoom out for country view') }} @else {{ __('Sindh province · :count visited schemes · zoom out for country view', ['count' => count($mapPoints)]) }} @endif

@include('reports.partials.monthly-report-summary-type-wise-card')
@include('reports.partials.monthly-report-summary-cost-wise-card')
@else {{-- Summary tab: map + type wise side by side --}}
{{ __('Visited Schemes Map') }}
@if ($enableMapSnapshot) @endif

@if ($mapPoints === []) {{ __('Sindh province · no scheme coordinates in current filters · zoom out for country view') }} @else {{ __('Sindh province · :count visited schemes · zoom out for country view', ['count' => count($mapPoints)]) }} @endif

@include('reports.partials.monthly-report-summary-type-wise-card')
@endif {{-- Row 5: Major Observations + PC Receiving — print page 2 --}}
{{ __('Major Observations') }} @if (count($majorObservationsDisplay) > 0) {{ count($majorObservationsDisplay) }} @endif
@if ($majorObservationsDisplay !== [])
@foreach ($majorObservationsDisplay as $observation) @endforeach
{{ __('S#') }} {{ __('Observations') }}
{{ $observation['rank'] }} {{ $observation['observation'] }}
@if ($majorObservationsHidden > 0)
{{ __('+:count more observations on screen view', ['count' => $majorObservationsHidden]) }}
@endif @else
{{ __('No major observations for current filters.') }}
@endif
{{ __('PC(s) Receiving / Dept. Enquiries') }}
@if ($pcReceivingRows !== []) @foreach ($pcReceivingRows as $pcRow) @endforeach
{{ __('S#') }} {{ __('Description') }} {{ __('No.') }} {{ __('%') }}
{{ $pcRow['rank'] }} {{ Str::limit($pcRow['description'], $printMode ? 42 : 120) }} {{ number_format((int) $pcRow['count']) }} {{ $pcRow['pct_label'] ?? '—' }}
@else
{{ __('No PC receiving data for current filters.') }}
@endif
{{-- Row 6 --}}
{{ __('Top 10 Departments Visited') }}
@if ($topDepartmentsDisplay !== []) @foreach ($topDepartmentsDisplay as $dept) @endforeach
# {{ __('Department') }} {{ __('Visits') }}
{{ $dept['rank'] }} {{ Str::limit($dept['name'], $printMode ? 22 : 28) }} {{ $dept['visits'] }}
@if ($topDepartmentsHidden > 0)
{{ __('+:count more departments on screen view', ['count' => $topDepartmentsHidden]) }}
@endif @else
{{ __('No department data.') }}
@endif
{{ __('PMU Month Wise Progress') }}
@if ($pmuMonthChartSvg !== '')
{{ __('Assigned') }} {{ __('Visited') }} {{ __('Published') }}
{!! $pmuMonthChartSvg !!}
@else
{{ __('No PMU month-wise data for current filters.') }}
@endif
@if (! $compactLayout)
@include('reports.partials.monthly-report-summary-cost-wise-card')
@endif