@extends('layouts.hirbnd') @section('title', 'Revenue Report - HIRBND') @push('styles') @endpush @section('content') @php $rooms = []; $grandTotal = 0; $totalRevenue = 0; if (isset($revenueData) && !is_null($revenueData)) { if($month === 'all') { $monthlyRevenue = []; foreach($revenueData as $monthName => $data) { if ($data && is_iterable($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 { $roomRevenue = []; $roomDays = []; if (is_iterable($revenueData)) { 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 = isset($roomRevenue) ? array_sum($roomRevenue) : 0; } } @endphp

Revenue Report

Analyze revenue performance by room and month

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

No Revenue Data Found

There are no revenue records for the selected 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 }}{{ number_format($amount, 0, ',', '.') }}{{ number_format($roomTotal, 0, ',', '.') }} {{ $roomCount > 0 ? number_format($roomTotal / $roomCount, 0, ',', '.') : 0 }}
TOTAL{{ number_format($monthlyTotals[$monthName], 0, ',', '.') }}{{ number_format($grandTotal, 0, ',', '.') }} -
AVERAGE{{ count($rooms) > 0 ? number_format($monthlyTotals[$monthName] / count($rooms), 0, ',', '.') : 0 }}{{ count($rooms) > 0 ? number_format($grandTotal / count($rooms), 0, ',', '.') : 0 }} -
@else {{-- Single Month View --}} @foreach($rooms as $room) @php $revenue = $roomRevenue[$room] ?? 0; $days = isset($roomDays[$room]) ? count($roomDays[$room]) : 0; $adr = $days > 0 ? $revenue / $days : 0; @endphp @endforeach {{-- Total Row --}}
Room Revenue Days Occupied ADR (Avg Daily Rate)
Room {{ $room }} {{ number_format($revenue, 0, ',', '.') }} {{ $days }} {{ number_format($adr, 0, ',', '.') }}
TOTAL {{ number_format($totalRevenue, 0, ',', '.') }} -
@endif
@endif
@endsection @push('scripts') @endpush