@extends('layouts.print') @section('title', 'Maintenance Backlog — ' . \Carbon\Carbon::parse($from)->format('M j') . '–' . \Carbon\Carbon::parse($to)->format('M j, Y')) @section('content') @php $propName = \App\Models\Setting::get('property_name', config('app.name', 'Parkview Hotel')); $periodLabel = \Carbon\Carbon::parse($from)->format('M j') . ' – ' . \Carbon\Carbon::parse($to)->format('M j, Y'); $fmtHours = fn($h) => $h === null ? '—' : ($h >= 48 ? round($h / 24, 1) . 'd' : $h . 'h'); @endphp
@include('reports.print._letterhead', [ 'reportTitle' => 'Maintenance Backlog & MTTR', 'periodLabel' => $periodLabel, 'backUrl' => route('reports.maintenance-backlog', ['from' => $from, 'to' => $to]), ])
@foreach([ ['Open Backlog', $openCount + $inProgressCount, $openCount . ' open · ' . $inProgressCount . ' in prog.'], ['Overdue', $overdueCount, 'past target'], ['Oldest Open', $oldestAge . 'd', 'since reported'], ['Avg Resolve', $fmtHours($mttrHours), $resolvedCount . ' resolved'], ] as [$label, $value, $sub])

{{ $label }}

{{ $value }}

{{ $sub }}

@endforeach

Open Backlog

@if($backlogRows->isEmpty())

No open work orders — backlog is clear.

@else @foreach($backlogRows as $r) @endforeach
Location Category Priority Status Issue Age
{{ $r['room_no'] ? 'Room ' . $r['room_no'] : ($r['location'] ?: 'Common area') }} {{ $r['category'] }} {{ ucfirst($r['priority']) }} {{ \Illuminate\Support\Str::headline($r['status']) }} {{ \Illuminate\Support\Str::limit($r['description'], 48) }} {{ $r['age_days'] }}d{{ $r['overdue'] ? ' ⚠' : '' }}
@endif

Resolve Time by Category ({{ $resolvedCount }} resolved)

@if($mttrByCategory->isEmpty())

No work orders resolved in this range.

@else @foreach($mttrByCategory as $cat => $m) @endforeach
Category Resolved Avg Time
{{ $cat }} {{ $m['count'] }} {{ $fmtHours($m['hours']) }}
@endif
{{ $propName }} · Maintenance Backlog & MTTR Printed {{ now()->format('M j, Y g:i A') }}
@endsection