@if($fromDate && $toDate && count($data) > 0)
| Customer |
Currency |
@foreach($months as $month)
{{ $month['label'] }} |
@endforeach
Total |
@php
$columnTotals = [];
$grandTotal = 0;
@endphp
@foreach($data as $row)
| {{ $row['customer_name'] }} |
{{ $showBaseCurrency ? 'GBP' : $row['currency'] }} |
@foreach($months as $month)
@php
// Display value (customer or base depending on toggle)
$displayValue = $showBaseCurrency
? ($row['months_base'][$month['key']] ?? 0)
: ($row['months'][$month['key']] ?? 0);
// Always use base for totals
$baseValue = $row['months_base'][$month['key']] ?? 0;
if (!isset($columnTotals[$month['key']])) {
$columnTotals[$month['key']] = 0;
}
$columnTotals[$month['key']] += $baseValue;
@endphp
@if($displayValue > 0)
@if($metric === 'sales_value')
{{ number_format($displayValue, 2) }}
@else
{{ number_format($displayValue, 0) }}
@endif
@else
-
@endif
|
@endforeach
@php
// Display total (customer or base depending on toggle)
$displayTotal = $showBaseCurrency ? $row['total_base'] : $row['total'];
// Always use base for grand total
$grandTotal += $row['total_base'];
@endphp
@if($metric === 'sales_value')
{{ number_format($displayTotal, 2) }}
@else
{{ number_format($displayTotal, 0) }}
@endif
|
@endforeach
| GRAND TOTAL |
GBP |
@foreach($months as $month)
@if($metric === 'sales_value')
{{ number_format($columnTotals[$month['key']] ?? 0, 2) }}
@else
{{ number_format($columnTotals[$month['key']] ?? 0, 0) }}
@endif
|
@endforeach
@if($metric === 'sales_value')
{{ number_format($grandTotal, 2) }}
@else
{{ number_format($grandTotal, 0) }}
@endif
|
@elseif($fromDate && $toDate)
No data found for the selected date range and filters.
@else
Please select a date range and click "Go" to view the report.
@endif