@extends('layouts.regent')
@section('title', 'Room ' . $room . ' Matrix')
@push('styles')
@endpush
@section('content')
@php
$monthNames = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
$daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Process data per day
$dailyRevenue = [];
$monthlyTotals = array_fill(0, 12, 0);
$monthlyCounts = array_fill(0, 12, 0);
foreach($monthNames as $idx => $monthName) {
$monthData = $monthlyData[$monthName] ?? collect();
// Group by day
$grouped = $monthData->groupBy(function($item) {
return (int) date('d', strtotime($item->Posting_Date));
});
foreach($grouped as $day => $records) {
$dailyTotal = $records->sum('Amount_1');
$dailyRevenue[$day][$idx] = $dailyTotal;
$monthlyTotals[$idx] += $dailyTotal;
if($dailyTotal > 0) $monthlyCounts[$idx]++;
}
}
@endphp
| Day |
Jan |
Feb |
Mar |
Apr |
May |
Jun |
Jul |
Aug |
Sep |
Oct |
Nov |
Dec |
{{-- Day rows --}}
@for($day = 1; $day <= 31; $day++)
| {{ $day }} |
@for($monthIdx = 0; $monthIdx < 12; $monthIdx++)
@if($day <= $daysInMonth[$monthIdx])
@php
$amount = $dailyRevenue[$day][$monthIdx] ?? 0;
@endphp
@if($amount > 0)
{{ number_format($amount, 0, ',', '.') }} |
@else
- |
@endif
@else
- |
@endif
@endfor
@endfor
{{-- Total Row --}}
| TOTAL |
@foreach($monthlyTotals as $total)
{{ number_format($total, 0, ',', '.') }} |
@endforeach
{{-- Average Row --}}
| AVERAGE |
@foreach($monthlyTotals as $idx => $total)
@php
$avg = $monthlyCounts[$idx] > 0 ? $total / $monthlyCounts[$idx] : 0;
@endphp
{{ number_format($avg, 0, ',', '.') }} |
@endforeach
@endsection