@php /** * colorVRtoM($key,$value): * Aplica color <70 => rojo, >=90 => verde, else => blanco * SOLO si $key está en [VRC,VRP,VPS,VPA,M]. */ function colorVRtoM($key,$val){ if(is_null($val)) return ''; if(!in_array($key,['VRC','VRP','VPS','VPA','M'])) return ''; if($val<=70) return 'bg-danger text-white'; return ''; } /** * colorPerformance($perf): * < -10 => rojo * > +10 => verde * else => sin color */ function colorPerformance($perf){ if(is_null($perf)) return ''; if($perf<=-10) return 'bg-danger text-white'; return ''; } /** * Determina si una métrica es del tipo ERROR o NOT VALUE * para los cuales la lógica de colores se invierte */ function isErrorOrNotValue($key) { return in_array(strtoupper($key), ['ERROR', 'NOT_VALUE', 'SIN_VALOR']); } /** * Determina la clase CSS para la píldora de rendimiento * según el tipo de métrica y el valor de rendimiento */ function getPerformancePillClass($key, $perf) { if (isErrorOrNotValue($key)) { // Para ERROR y NOT VALUE, la lógica se invierte return $perf < 0 ? 'positive' : 'negative'; } else { // Para el resto de métricas, comportamiento normal return $perf >= 0 ? 'positive' : 'negative'; } } /** * Calcula el número de bolas negras basado en el valor de darkness Z1 y Z1/Z2 * @param float $darknessZ1 Valor de darkness Z1 * @param float $z1z2 Valor de Z1/Z2 * @return int|string Número de bolas (1-6) o 'n/a' si no aplica */ function calculateDarkCircles($darknessZ1, $z1z2) { if (is_null($darknessZ1) || is_null($z1z2) || !is_numeric($darknessZ1) || !is_numeric($z1z2)) { return 'n/a'; } if ($darknessZ1 < 0) { // Para valores negativos (origen negativo) if ($z1z2 >= 0 && $z1z2 <= 9.99) return 6; if ($z1z2 >= 10 && $z1z2 <= 19.99) return 5; if ($z1z2 >= 20 && $z1z2 <= 29.99) return 4; if ($z1z2 >= 30 && $z1z2 <= 39.99) return 3; if ($z1z2 >= 40 && $z1z2 <= 49.99) return 2; if ($z1z2 >= 50) return 1; } else { // Para valores positivos (origen positivo) if ($z1z2 >= 0 && $z1z2 <= 9.99) return 1; if ($z1z2 >= 10 && $z1z2 <= 14.99) return 2; if ($z1z2 >= 15 && $z1z2 <= 19.99) return 3; if ($z1z2 >= 20 && $z1z2 <= 29.99) return 4; if ($z1z2 >= 30 && $z1z2 <= 39.99) return 5; if ($z1z2 >= 40) return 6; } return 'n/a'; } /** * Genera el HTML para mostrar las bolas negras * @param int|string $count Número de bolas a mostrar o 'n/a' * @return string HTML con las bolas */ function renderDarkCircles($count) { if ($count === 'n/a') { return 'n/a'; } $html = '
'; for ($i = 0; $i < $count; $i++) { $html .= ''; } $html .= '
'; return $html; } @endphp