@extends('layouts.regent') @section('title', 'Revenue Report') @push('styles') @endpush @section('content') @php // Process revenue data if($month === 'all') { $rooms = []; $monthlyRevenue = []; foreach($revenueData as $monthName => $data) { foreach($data as $record) { $rooms[$record->Room] = true; if(!isset($monthlyRevenue[$record->Room][$monthName])) { $monthlyRevenue[$record->Room][$monthName] = 0; } $monthlyRevenue[$record->Room][$monthName] += $record->Amount_1; } } $rooms = array_keys($rooms); sort($rooms); $monthlyTotals = []; foreach(['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as $monthName) { $monthlyTotals[$monthName] = 0; foreach($rooms as $room) { $monthlyTotals[$monthName] += $monthlyRevenue[$room][$monthName] ?? 0; } } $grandTotal = array_sum($monthlyTotals); } else { $rooms = []; $roomRevenue = []; $roomDays = []; foreach($revenueData as $record) { $rooms[$record->Room] = true; if(!isset($roomRevenue[$record->Room])) { $roomRevenue[$record->Room] = 0; $roomDays[$record->Room] = []; } $roomRevenue[$record->Room] += $record->Amount_1; $day = date('Y-m-d', strtotime($record->Posting_Date)); $roomDays[$record->Room][$day] = true; } $rooms = array_keys($rooms); sort($rooms); $totalRevenue = array_sum($roomRevenue); } @endphp

Revenue Report

Analyze revenue performance by room and month

Total Revenue
Rp {{ number_format($month === 'all' ? $grandTotal : $totalRevenue, 0, ',', '.') }}
Average/Room
Rp {{ count($rooms) > 0 ? number_format(($month === 'all' ? $grandTotal : $totalRevenue) / count($rooms), 0, ',', '.') : 0 }}
Rooms
{{ count($rooms) }}
Period
{{ $month === 'all' ? '12 Months' : ucfirst($month) }}
@if(count($rooms) === 0)

No Revenue Data

No revenue data found for this period.

@else
@if($month === 'all') {{-- All Months View --}} @foreach(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] as $monthName) @endforeach @foreach($rooms as $room) @php $roomTotal = 0; $roomCount = 0; @endphp @foreach(['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as $monthName) @php $amount = $monthlyRevenue[$room][$monthName] ?? 0; $roomTotal += $amount; if($amount > 0) $roomCount++; @endphp @endforeach @endforeach {{-- Total Row --}} @foreach(['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as $monthName) @endforeach {{-- Average Row --}} @foreach(['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as $monthName) @endforeach
Room{{ $monthName }}Total Average
Room {{ $room }}Rp {{ number_format($amount, 0, ',', '.') }}Rp {{ number_format($roomTotal, 0, ',', '.') }} Rp {{ $roomCount > 0 ? number_format($roomTotal / $roomCount, 0, ',', '.') : 0 }}
TOTALRp {{ number_format($monthlyTotals[$monthName], 0, ',', '.') }}Rp {{ number_format($grandTotal, 0, ',', '.') }} -
AVERAGERp {{ count($rooms) > 0 ? number_format($monthlyTotals[$monthName] / count($rooms), 0, ',', '.') : 0 }}Rp {{ count($rooms) > 0 ? number_format($grandTotal / count($rooms), 0, ',', '.') : 0 }} -
@else {{-- Single Month View --}} @foreach($rooms as $room) @php $revenue = $roomRevenue[$room]; $days = count($roomDays[$room]); $adr = $days > 0 ? $revenue / $days : 0; @endphp @endforeach {{-- Total Row --}}
Room Revenue Days Occupied ADR
Room {{ $room }} Rp {{ number_format($revenue, 0, ',', '.') }} {{ $days }} days Rp {{ number_format($adr, 0, ',', '.') }}
TOTAL Rp {{ number_format($totalRevenue, 0, ',', '.') }} -
@endif
@endif
@endsection @push('scripts') @endpush