{{-- Tab "Doanh thu" của /statistics (nạp bằng AJAX khi bấm tab / lọc): so sánh chi nhánh, top dịch vụ theo doanh thu, giờ & thứ cao điểm. Dữ liệu từ StatisticReportService, cùng bộ lọc ngày / chi nhánh / cụm khu vực. --}} @php $branchTotalIncome = max(1, $branches->sum('income')); $serviceMax = max(1, (float) $topServices->max('revenue')); $branchChart = [ 'labels' => $branches->pluck('name')->values(), 'sales' => $branches->pluck('sales')->values(), 'income' => $branches->pluck('income')->values(), ]; // Ô đông nhất để gợi ý xếp ca $peak = null; foreach ($heatmap['cells'] as $d => $hours) { foreach ($hours as $h => $cell) { if (!$peak || $cell['orders'] > $peak['orders']) { $peak = ['day' => $heatmap['days'][$d], 'hour' => $h] + $cell; } } } @endphp
| Chi nhánh | Khách mới | Số đơn | Doanh số | Thực thu | Tỷ trọng thực thu |
|---|---|---|---|---|---|
| {{ $branch->name }} | {{ number_format($branch->customers) }} | {{ number_format($branch->orders) }} | {{ number_format($branch->sales) }} | {{ number_format($branch->income) }} |
{{ number_format($share, 1) }}%
|
| Tổng | {{ number_format($branches->sum('customers')) }} | {{ number_format($branches->sum('orders')) }} | {{ number_format($branches->sum('sales')) }} | {{ number_format($branches->sum('income')) }} |
| # | Dịch vụ / sản phẩm | Loại | Số lượng | Số đơn | Doanh thu |
|---|---|---|---|---|---|
| {{ $i + 1 }} | {{ $service->name }} | {{ $service->type_text }} | {{ number_format($service->quantity) }} | {{ number_format($service->orders) }} |
{{ number_format($service->revenue) }}
|
| @foreach($heatmap['hours'] as $hour) | {{ $hour }}h | @endforeach
|---|---|
| {{ $dayName }} | @foreach($heatmap['hours'] as $hour) @php($cell = $heatmap['cells'][$d][$hour] ?? null) @php($level = $cell ? max(0.12, $cell['orders'] / $heatmap['max']) : 0){{ $cell ? $cell['orders'] : '' }} | @endforeach