Вы должны ограничить использование класса $ semaforo, используя возможности css
Измените атрибуцию диапазона, то, что у вас сейчас, немного сбивает с толку:
function semColor($p) {
$semValues = array('rojo','berde','amarillo','naranja','rojo');
$ranges = array(-1,50,70,100);
for ($i=0; $i<4;$i++)
if ($ranges[$i]>$p['desv']) break;
return $semValues[$i];
}
используйте шаблон для созданиястрока
/* use any other method to create the template string */
$templ = '<div class="%s %s"><ul><li class="thmas"> <a href="#" class="trigger2"> </a></li>'
. '<li class="'
. join('">%s </li><li class="',
array_merge(array('','th1','th2','th3','th5','th4','th6'),
array_fill(0,12,'thmes'),
array('thtotal','thtotal)
)).'">%s </li></ul></div>';
ваш код для внутреннего цикла становится:
foreach ( $aTareak as $a ) {
if (($a['proyecto_id']==$h['proyecto_id']) && ($a['hito_id']==$h['hito_id'])) {
printf($templ,
'divtrtarea',
semColor($a['desv'])
$a['categoria_nombre'],
$a['coordinador_nombre'],
$a['tarea_nombre'],
$a['total_prev'],
$a['total_horas'],
round($a['desv'], 2),
$a['1'], $a['2'], $a['3'], $a['4'], $a['5'], $a['6'],
$a['7'], $a['8'], $a['9'], $a['10'], $a['11'], $a['12'],
array_sum(array_slice($a,1,12)), /* assuming they are consecutive */
$html->link('Selec.',array(
'controller'=>'lineas',
'action'=>'addhoras',
$a['proyecto_id'],
$a['hito_id'],
$a['tarea_id'])
)
);
}
}
внешние должны измениться соответственно