@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 --}}
{{-- Tabla de consumo por semanas --}}
@if(!empty($timeKeys) && !empty($table))
@if($reportType === 'daily')
Reporte Diario de Consumo
DISPOSITIVO |
@foreach($timeKeys as $day)
{{ $day }} |
@endforeach
TOTAL |
@foreach($table as $deviceLabel => $row)
{{ $deviceLabel }} |
@foreach($timeKeys as $day)
@php
$val = (float)($row[$day] ?? 0);
$badge = getBadgeClass($val); // Llamada a la función local
@endphp
{{ number_format($val, 2) }}
|
@endforeach
{{ number_format((float)($row['TOTAL'] ?? 0), 2) }} |
@endforeach
Total general |
@foreach($timeKeys as $day)
@php
$sum = collect($table)->sum(fn($r) => (float)($r[$day] ?? 0));
@endphp
{{ number_format($sum, 2) }} |
@endforeach
{{ number_format(collect($table)->sum(fn($r) => (float)($r['TOTAL'] ?? 0)), 2) }}
|
@else
Reporte Semanal de Consumo
DISPOSITIVO |
@foreach($timeKeys as $week)
{{ $week }} |
@endforeach
TOTAL |
@foreach($table as $deviceLabel => $row)
{{ $deviceLabel }} |
@foreach($timeKeys as $week)
@php
$val = (float)($row[$week] ?? 0);
$badge = getBadgeClass($val);
@endphp
{{ number_format($val, 2) }}
|
@endforeach
{{ number_format((float)($row['TOTAL'] ?? 0), 2) }} |
@endforeach
Total general |
@foreach($timeKeys as $week)
@php
$sum = collect($table)->sum(fn($r) => (float)($r[$week] ?? 0));
@endphp
{{ number_format($sum, 2) }} |
@endforeach
{{ 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