@extends('layouts.vertical', ['page_title' => 'Datatables']) @section('css') @endsection @section('content')

{{ $title }}

@php // Helper to get all months from July 2025 to current month $start = \Carbon\Carbon::create(2025, 7, 1); $end = \Carbon\Carbon::now()->startOfMonth(); $months = []; while ($start <= $end) { $months[] = $start->format('F Y'); $start->addMonth(); } $selectedMonth = request()->get('month', \Carbon\Carbon::now()->format('F Y')); @endphp
@if (isset($buttons)) @foreach ($buttons as $button) {{ $button['title'] }} @endforeach @endif
@if (session()->has('message'))
{{ session()->get('message') }}
@endif @if (session()->has('error'))
{{ session()->get('error') }}
@endif
1. Monthly Summary ( {{ $selectedMonth }} )
Export
@foreach ($monthsummary as $col) @endforeach @foreach ($monthsummarysubmission as $row) @foreach ($monthsummary as $col) @php $val = $row->{$col['key']} ?? ''; @endphp @endforeach @endforeach @foreach (array_slice($monthsummary, 1) as $col) @php $key = $col['key']; @endphp @endforeach
{{ $col['name'] }}
@php if (is_numeric($val)) { if (floor($val) == $val) { echo number_format($val); } else { echo number_format($val, 2); } } else { echo $val; } @endphp
Total @if ($key === 'percent_ach') {{ $monthTotals['units_plan'] > 0 ? round(($monthTotals['units_ach'] / $monthTotals['units_plan']) * 100) : 0 }}% @else @php $totalVal = $monthTotals[$key] ?? 0; if (floor($totalVal) == $totalVal) { echo number_format($totalVal); } else { echo number_format($totalVal, 2); } @endphp @endif
2. Weekly Summary ( {{ $selectedMonth }} )
Export
@foreach ($weeklysummary as $col) @endforeach @foreach ($weeklysummarysubmission as $row) @foreach ($weeklysummary as $col) @php $val = $row->{$col['key']} ?? ''; @endphp @endforeach @endforeach @if (count($weeklysummarysubmission) > 0) @foreach ($weeklysummary as $col) @if ($col['key'] === 'product_name') @continue @elseif ($col['key'] === 'percent_ach') @else @endif @endforeach @endif
{{ $col['label'] }}
@if (is_numeric($val)) {{ number_format($val) }} @else {{ $val }} @endif
Total {{ $weeklyTotals['month_plan'] > 0 ? number_format(($weeklyTotals['units_ach'] / $weeklyTotals['month_plan']) * 100) : 0 }}% {{ number_format($weeklyTotals[$col['key']] ?? 0) }}
3. Center Summary
Export
@foreach ($centersummary as $col) @endforeach @foreach ($centersummarysubmission as $row) @foreach ($centersummary as $col) @php $val = $row->{$col['key']} ?? ''; @endphp @endforeach @endforeach @if ($centerTotals) @foreach ($centersummary as $index => $col) @if ($index === 0) {{-- Skip the first column since "Total" text already there --}} @continue @endif @php $key = $col['key']; $val = $centerTotals->{$key} ?? 0; @endphp @if ($key === 'percent_ach') @php $plan = $centerTotals->centers_plan ?? 0; $ach = $centerTotals->centers_ach ?? 0; $percent = $plan > 0 ? number_format(($ach / $plan) * 100) : 0; @endphp @else @endif @endforeach @endif
{{ $col['name'] }}
@if ($col['key'] === 'percent_ach') {{ round($val) }} @elseif (is_numeric($val)) {{ number_format($val) }} @else {{ $val }} @endif
Total{{ $percent }}%{{ number_format($val) }}
4. Center Trend Summary
Export
@foreach ($centertrendsummary as $col) @endforeach @foreach ($centertrendsummarysubmission as $row) @foreach ($centertrendsummary as $col) @php $val = $row->{$col['key']} ?? ''; @endphp @endforeach @endforeach @if (count($centertrendsummarysubmission) > 0) @foreach (array_slice($centertrendsummary, 1) as $col) @php $val = $centerTrendTotals[$col['key']] ?? 0; @endphp @endforeach @endif
{{ $col['name'] }}
{{ is_numeric($val) ? number_format($val) : $val }}
Total{{ number_format($val) }}
5. Unit Trend Summary
Export
@foreach ($unittrendsummary as $col) @endforeach @foreach ($unittrendsummarysubmission as $row) @foreach ($unittrendsummary as $col) @php $val = $row->{$col['key']} ?? ''; @endphp @endforeach @endforeach @if (count($unittrendsummarysubmission) > 0) @foreach (array_slice($unittrendsummary, 1) as $col) @endforeach @endif
{{ $col['name'] }}
{{ is_numeric($val) ? number_format($val) : $val }}
Total{{ number_format($unitTrendTotals[$col['key']] ?? 0) }}
@endsection @section('script') @endsection