@php if (!function_exists('getBadgeClass')) { function getBadgeClass($value) { if ($value == 0) return 'bg-secondary text-white'; elseif ($value <= 0.25) return 'bg-success text-white'; elseif ($value <= 0.5) return 'bg-warning text-dark'; elseif ($value <= 0.75) return 'bg-danger text-white'; else return 'bg-danger text-white'; } } @endphp
Consumo de dispositivos – {{ $customer->name ?? 'Cliente' }}
{{-- Filtros --}}
Limpiar
{{-- Tabla de consumo por semanas --}}
@if(!empty($timeKeys) && !empty($table)) @if($reportType === 'daily')

Reporte Diario de Consumo

@foreach($timeKeys as $day) @endforeach @foreach($table as $deviceLabel => $row) @foreach($timeKeys as $day) @php $val = (float)($row[$day] ?? 0); $badge = getBadgeClass($val); // Llamada a la función local @endphp @endforeach @endforeach @foreach($timeKeys as $day) @php $sum = collect($table)->sum(fn($r) => (float)($r[$day] ?? 0)); @endphp @endforeach
DISPOSITIVO{{ $day }}TOTAL
{{ $deviceLabel }} {{ number_format($val, 2) }} {{ number_format((float)($row['TOTAL'] ?? 0), 2) }}
Total general{{ number_format($sum, 2) }} {{ number_format(collect($table)->sum(fn($r) => (float)($r['TOTAL'] ?? 0)), 2) }}
@else

Reporte Semanal de Consumo

@foreach($timeKeys as $week) @endforeach @foreach($table as $deviceLabel => $row) @foreach($timeKeys as $week) @php $val = (float)($row[$week] ?? 0); $badge = getBadgeClass($val); @endphp @endforeach @endforeach @foreach($timeKeys as $week) @php $sum = collect($table)->sum(fn($r) => (float)($r[$week] ?? 0)); @endphp @endforeach
DISPOSITIVO{{ $week }}TOTAL
{{ $deviceLabel }} {{ number_format($val, 2) }} {{ number_format((float)($row['TOTAL'] ?? 0), 2) }}
Total general{{ number_format($sum, 2) }} {{ number_format(collect($table)->sum(fn($r) => (float)($r['TOTAL'] ?? 0)), 2) }}
@endif @else
No hay datos de consumo para el rango y servicio seleccionados.
@endif