<%@ $Language=JScript /* PARA COLORES PHP */ %><% function es_hoja($nodo) { global $arbol; $i=0; $cnt = count($arbol); /*echo "$nodo--
"; echo $cnt; */ while (($arbol[$i][1] != $arbol[$nodo][0]) && ($i < $cnt)) $i++; return ($i == $cnt); } ////////////////////////////////////////////////////////////////////////////////////////////// function dame_hijos($nodo) { global $arbol; $i=0; $h=0; $cnt = count($arbol); while ($i < $cnt ) { if ($arbol[$i][1] <> $arbol[$i][0]) { if ($arbol[$nodo][0] == $arbol[$i][1]) { $result[$h] = $i; $h++; } } $i++; } return $result; } /////////////////////////////////////////////////////////////////////////////////////////// function preorden($nodo=0,$secID) { global $arbol,$conn,$condate; if(!es_hoja($nodo)) { $hijos = dame_hijos($nodo); $h = 0; $cnt = count($hijos); $prueba =0; while($h < $cnt) { $sql = "select count(*) as CANT from upcAcciones where ejeID = '".$arbol[$nodo][0]."' and accActiva='S' and accFechaPub < '$condate' and (accFechaExp > '$condate' or accFechaExp = '0000-00-00 00:00:00' ) and estID='W' "; if($secID!=1) { $sql .= " and secID='$secID' "; } else { $sql .= " and accJerarquia in (1,2) "; } $qry = $conn->execute($sql); $canti = preorden($hijos[$h],$secID);//ojo aca es la parte recursiva $arbol[$nodo][2] = $prueba + $qry->field(CANT) + $canti; $prueba =+ $qry->field(CANT) + $canti; $h++; } }//if else { $sql = "select count(*) as CANT from upcAcciones where ejeID = '".$arbol[$nodo][0]."' and accActiva='S' and accFechaPub < '$condate' and (accFechaExp > '$condate' or accFechaExp = '0000-00-00 00:00:00' ) and estID='W' "; if($secID!=1) { $sql .= " and secID='$secID' "; } else { $sql .= " and accJerarquia in (1,2) "; } $qry = $conn->execute($sql); $arbol[$nodo][2] = $qry->field(CANT); return $qry->field(CANT); } } //////////////////////////////////////////////////////////////////////////////////// function inic($ejeID) { global $arbol,$conn,$condate; $sql="select distinct B.ejeID,B.ejePadre,0 from upcEjes A, upcEjes B where A.ejeID='$ejeID' and A.ejeAncestro =B.ejeAncestro and B.ejeVarios='N' order by B.ejeID"; $qry = $conn->Execute($sql); $rows = $qry->numrows; $i=0; while(!$qry->eof) { $arbol[$i] = $qry->fields_by_index; $i++; $qry->MoveNext(); } } //////////////////////////////////////////////////////////////////////////////////// function cual_muestro($ejeID,$secID) { global $arbol; inic($ejeID); preorden(0,$secID); $j=0; if($arbol[$j]) { $inset = "'".$arbol[$j][0]."'"; } $j++; while ($arbol[$j]) { if($arbol[$j][2]>0) { $inset .= ",'".$arbol[$j][0]."'"; } $j++; } return $inset; } %>