Overview @if (auth()->user()->isAdmin()) Register Meter @endif @if (session('status'))
{{ session('status') }}
@endif

Total Meters

{{ $totalMeters }}

Read Today

{{ $readToday }}

Pending Today

{{ $pendingToday }}

@if ($totalMeters > 0)
@if ($buildings->count() > 1) @endif
@endif @forelse ($buildings as $building)
{{ $building->name }} @if ($building->address) {{ $building->address }} @endif @if (auth()->user()->isAdmin()) Add Floors @endif
@forelse ($building->floors as $floor) @php $floorRead = $floor->meters->filter(fn ($m) => $m->latestReadingRecord?->reading_date?->isToday())->count(); $floorTotal = $floor->meters->count(); $floorPending = $floorTotal - $floorRead; @endphp {{-- Floors with meters still to read start open; fully-read floors start collapsed. --}}
0) open @endif> {{ $floor->name }} @if ($floorTotal > 0) {{ $floorRead }}/{{ $floorTotal }} read today @endif {{ $floorTotal }} {{ \Illuminate\Support\Str::plural('meter', $floorTotal) }} @if ($floor->meters->isEmpty())

No meters registered on this floor yet.

@endif @foreach (['water', 'electricity'] as $groupType) @php $group = $floor->meters->where('type', $groupType); @endphp @if ($group->isNotEmpty())
{{ $groupType === 'water' ? 'Water meters' : 'Electricity meters' }} {{ $group->count() }}
@foreach ($group as $meter) @php $latest = $meter->latestReadingRecord; $isRead = (bool) $latest?->reading_date?->isToday(); $rows = $recentReadings[$meter->id] ?? collect(); @endphp

{{ $meter->name }} @if ($meter->apartment_no){{ $meter->apartment_label }}@endif {{ $meter->code }}

@if ($latest) Last: {{ $latest->reading_value }} {{ $meter->unit }} on {{ $latest->reading_date->format('d M Y') }} @else No readings yet @endif

@if (auth()->user()->canAddToFloor($floor)) Reading @endif QR
@if ($rows->isNotEmpty()) {{-- Recent readings are tucked away until asked for. --}}
Recent readings View all @foreach ($rows->take(3) as $i => $reading) @php $older = $rows->get($i + 1); $usage = $older ? round($reading->reading_value - $older->reading_value, 2) : ($i === $rows->count() - 1 && (float) $meter->initial_reading > 0 ? round($reading->reading_value - $meter->initial_reading, 2) : null); @endphp
{{ $reading->reading_date->format('d M Y') }} {{ $reading->reading_value }} {{ $meter->unit }} {{ $usage !== null ? '+'.number_format($usage, 2).' used' : '' }}
@endforeach
@endif
@endforeach
@endif @endforeach
@empty

No floors in this building yet.

@endforelse
@empty
@if (auth()->user()->isAdmin())

No buildings yet. Add your first building.

@else

You haven't been given access to any buildings yet. Please ask an administrator.

@endif
@endforelse