<?php
require_once('startinclude.php');
include "lib_form.php";
require_once "util_db.php";
include "lecturadb_slow.php";

// aaaaaaaaaaaaa
$camara=parametro('camara',-1);
$ventanan=parametro('ventanan',0);
$iuniquev=$_SERVER['REMOTE_ADDR']."_pf_".$ventanan;
if ($camara==-1) {
	$camara=@apc_fetch($iuniquev);
} else {
	
	apc_store($iuniquev,$camara);
}
if ($camara==0) {
	$anterior_num=apc_fetch('numero_de_camaras');
} else {
	$anterior_num=$camara-1;
}
if ($camara==apc_fetch('numero_de_camaras')) {
	$despues_num=0;
} else {
	$despues_num=$camara+1;
}
$anterior_c="<a href='$phporigen?camara=".$anterior_num."&ventanan=$ventanan'>&lt;&lt;&lt;</a>&nbsp;&nbsp;&nbsp;";
$despues_c="&nbsp;&nbsp;&nbsp;<a href='$phporigen?camara=".($despues_num)."&ventanan=$ventanan'>&gt;&gt;&gt;</a>";


// aaaaaaaaaaaaaa


$botontag=parametro('boton_tag',"");
$pagina=parametro('pagina',0);
$proceso=parametro('proceso',@$proceso);
$buscar=parametro('buscar',"");
$camara_buscar=parametro('camara_buscar',@$camara+1);
$tipo_buscar=parametro('tipo_buscar',"1");


switch ($botontag) {
	case "PGUP":
		$pagina=$pagina+1;
		break;
	case "PGDOWN":
		$pagina=$pagina-1;
		break;
	case "OK":
		break;		
}





$totalcamaras=0;
$num_temp=0;

$titulowin=array();
$id_camara=array();
$nsensores=array();





?>
<head>
<title> No title</title>


<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> 
<META NAME="ROBOTS" CONTENT="NOARCHIVE"> 
<script type='text/javascript' src='ajaxlib/dhtmlwindow.js'></script>
<script type='text/javascript' src='ajaxlib/cookies.js'></script>
<script type='text/javascript' src='ajaxlib/utils/southprojects.js'></script>
<script type='text/javascript' src='jscriptrpc.js'></script>
<script type='text/javascript' src='ajaxlib/utils/progress.js'></script>

<link href='ajaxlib/dhtmlwindow.css' rel='stylesheet' type='text/css'>
<!--<link rel="stylesheet" type="text/css" href="style2.css" />-->
<?php
//echo headerform(0);
 echo cabecera("titulo",1);
?>



<script type="text/javascript">
	var loader;


		loader = new southprojects.Progress({
			theme: 'default',
			themePath: "ajaxlib/spextra/themes/progress/"
		});



	function showespere() {
		loader.start('espere..');
		//setTimeout("loader.stop();", 4000);
	}

	function clickcheck(direccion) {
		fetchUrl(direccion, 'transportdiv')
		loader.start('espere..');
	}
	


</script>

<script type="text/javascript">
phprpc='wsensor_rpc.php';
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

</script>


<style type="text/css">

/*
USAGE: All you have to do is include this one line in your CSS file, with the
tag names to which you want the script applied:
*/

 { behavior: url(iepngfix.htc) }

/*
Alternatively, you can specify that this will apply to all tags like so:
* { behavior: url(iepngfix.htc) }
*/

</style>
</head>


<body background=#ffffcc>
<div id="transportdiv" name='transportdiv' style="border-width:1px; border-color:rgb(0,0,240); border-style:solid; display: none;"></div>            



<?php






$temp=array();

$tabla=array();
$tabla_leyenda=array();
$limites=array();

// leer_temperatura($temp,$camara,$maxima,$minima,);

//leer_temperatura2($temp,$camara);
if ($buscar!=="") {
	leer_tarja($tabla,$camara_buscar,$buscar,$tipo_buscar,$pagina) ;
}



$scr="";
$scr.= "<div id='divscroll'>";


$anchocadasensor=800/$camaras[$camara]["nsensores"];
$anchocadasensor=($anchocadasensor<40)?40:$anchocadasensor;
$anchotabla=$camaras[$camara]["nsensores"]*$anchocadasensor+80;

$scr.= "<table border='0' id='table_2' cellspacing='0' bordercolordark='white' bordercolorlight='blue' width=$anchotabla >\n";
$scr.= "<thead>";
$scr.= "<td width=70  align='center'>Tarja</td>\n";
$scr.= "<td width=30  align='center'>Proceso</td>\n";
$scr.= "<td width=70  align='center'>Camara</td>\n";
$scr.= "<td width=70  align='center'>Fecha Creacion</td>\n";
$scr.= "</thead><tbody>";



$num=@count($tabla[0]);
$nums=count($tabla); // incluyendo fecha que es el campo 0



for ($i=0;$i<$num;$i++) {
	$scr.= "<tr>";
for ($e=0;$e<$nums;$e++) {
		
		if ($i % 2) 
			$clase="odd";
		else
			$clase="even";
		$valor=$tabla[$e][$i];
		

		
		$scr.= "<td  class='$clase' align='center'>".$valor."</td>\n";
}
$scr.= "</tr></tbody>";
}
$scr.= "</table>\n";
$scr.= "</div>";



		//$titulo=$camaras[$camara]["nombre_camara"];
		$titulo="<h2 align='left'>$anterior_c".$camaras[$camara]["nombre_camara"]."$despues_c</h2>\n";
		$leyenda="Busqueda de Tarja";
		$descripcion="desc";
		$campos="";
		$camposhidden="";
		$contador=0;
		$boton=array();
		if ($pagina>0) {
			$boton[]="<<";
			$boton[]="PGDOWN";
			$boton[]="";
		}
			$boton[]="Actualizar";
			$boton[]="OK";
			$boton[]="";
		if ($num>1) {
			$boton[]=">>";
			$boton[]="PGUP";
			$boton[]="";
		}
		leerarreglo(&$c);
		$resultado="";
		
	$camposhidden.=campohidden("pagina",$pagina);
	$camposhidden.=campohidden("camara",$camara);
	$camposhidden.=campohidden("ventanan",@$ventanan);
	
	
	
	
	
	
	
	@$campos[0][0]=  campoformulario("buscar","Tarja :",30,$buscar,"spformNoRequired",0);	
	$arr=array("1","Inicia Con","2","Finaliza Con","3","En Cualquier Posicion","4","Busqueda Exacta");
	
	@$campos[1][0]= campocombo("tipo_buscar","Tipo de Busqueda :",30,$tipo_buscar,$arr,"spformNoRequired",0,$camposhidden,"");	
	$arr=array();
	$arr[]="TODA";
	$arr[]="-Todas las camaras-";				
	for ($i=0;$i<count($camaras);$i++) {
		$arr[]=$camaras[$i]["id_camara"];				
		$arr[]=$camaras[$i]["nombre_camara"];				
	}
	
	@$campos[0][1]= campocombo("camara_buscar","Camara :",30,$camara_buscar,$arr,"spformNoRequired",0,$camposhidden,"submit();");	
	$resultadotitulo="Pagina ".($pagina+1);
	
		
		echo "<TABLE cellSpacing=0 cellPadding=0 width=98% border=0>";
		echo  "<tr><td><table width=850 height=0 border=0></table></td></tr>\n";
		echo "<tr><td>";


/*
$extracampo[0]=array();
@$extracampo[0][0][0].=campoformulario("c12","Inicio Vuelta 1",20,$c[12],"",1);
@$extracampo[0][1][0].=campoformulario("c13","Fin Vuelta 1",20,$c[13],"",1);
@$extracampo[0][0][1].=campoformulario("c14","Inicio Vuelta 2",20,$c[14],"",1);
@$extracampo[0][1][1].=campoformulario("c15","Fin Vuelta 2",20,$c[15],"",1);
@$extracampo[0][0][2].=campoformulario("c16","Inicio Vuelta 3",20,$c[16],"",1);
@$extracampo[0][1][2].=campoformulario("c17","Fin Vuelta 3",20,$c[17],"",1);
$extracampo["titulo0"]="Giros";
$extracampo[1]=array();
@$extracampo[1][0][0].=campoformulario("c12","Inicio Vuelta 1",20,$c[12],"",1);
@$extracampo[1][1][0].=campoformulario("c13","Fin Vuelta 1",20,$c[13],"",1);
@$extracampo[1][0][1].=campoformulario("c14","Inicio Vuelta 2",20,$c[14],"",1);
@$extracampo[1][1][1].=campoformulario("c15","Fin Vuelta 2",20,$c[15],"",1);
@$extracampo[1][0][2].=campoformulario("c16","Inicio Vuelta 3",20,$c[16],"",1);
@$extracampo[1][1][2].=campoformulario("c17","Fin Vuelta 3",20,$c[17],"",1);
$extracampo["titulo1"]="Giros";
*/		
$extracampo="";		
		
		echo mostrarformulario($titulo,$leyenda,$descripcion,$campos,$camposhidden,$boton,$numform=1,$resultadotitulo,$scr,$extracampo);
		echo "</td></tr></table>";





?>

<script type="text/javascript">
//document.getElementById('valor0').className='alerta';

//window.parent.window.parent.document.getElementById('spWin0Container').className='spWinRedxpContainer';



</script>
</BODY>
