<?php

session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("JQUERY.inc"); 
$total=0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es-es">
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<head>

<style type="text/css">
BODY {
scrollbar-face-color:#000000;
scrollbar-highlight-color: ;
scrollbar-shadow-color: ; 
scrollbar-3dlight-color:#000000; 
scrollbar-arrow-color: ; 
scrollbar-track-color: ;
scrollbar-darkshadow-color:#000000;
}

td {/*background-color:#F0FFF0;*/
   /* background-image:url(img/tdn.jpg);*/
   font-family:helvetica;
   font-style:italic;
   font-size:14px;
   color: #FFFFFF;}  

th {background-color:  ;
	/*background-image:url(img/LINE2.jpg);*/
    font-family:helvetica;
    font-size:15px;
	color: #FFFFFF;} 
	
</style> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Registro con AJAX</title>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script language="javascript">
      $(document).ready(function(){
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
	var pagRes='cat_cuartos_AU.php';
	var idObjDes='tbus';
      
        var nomObjRad='tip_bus_ope';
	$("#"+idObjDes).autocomplete({ //Des
	    source:pagRes,	
            minChars: 1,                 //Caracteres Minimos antes de autocompletar
		max:20,                      //maximo de resultados mostrados, se manda como limit en autosugestion
		cacheLength: 0,
		delay: 200,                  //Retardo de autocompletar 
		width: 500,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: true,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 100,           //alto del cuadro para el scroll
		
		 select: function( event, ui ) {
                    
                      $("#"+idObjDes).val(ui.item.descripcion);	
//	
                }
	});	
	
});
//$(document).ready(function(){
//	$("#tbus").autocomplete('cat_cuartos_AU.php',{
//		minChars: 1,                 //Caracteres Minimos antes de autocompletar
//		//max:3                        //maximo de resultados mostrados, se manda como limit en autosugestion
//		selectFirst:false,
//		delay: 200,                  //Retardo de autocompletar 
//		width: 500,                  //ancho del cuadro de despliegue
//		highlight: false,            //Resalta letras coincidentes
//		autoFill: false,             //autocompleta en texto la posible palabra
//		scroll: true,				 //si cuadro tiene barra scroll
//		scrollHeight: 500,           //alto del cuadro para el scroll
//		formatItem:function (row, i, n, value) { //formato de presentacion de las posibles busquedas
//			return "(<strong>"+row[1]+"</strong>)"+row[0];
//		},	     
//		formatResult:function(row){  //formato de seleccion de busqueda
//			return row[0];
//		},
//		extraParams:{tipBus:'d'}     //Parametros Extra a Mandar en autosugestion
//	});
//	$("#tbus").result(function(event, row, formatted){
//		//if(!row && confirm("Articulo:'"+$(this).val()+"'\nDesea AGREGARLO?"))
//			openpage("cat_cuartos_AG.php?tap2="+$(this).val(),'_self');
//		//else if(confirm("Articulo:'" +row[0]+"'\nDesea Consultar/Modificar?"))
//			openpage("cat_cuartos_MO.php?bot="+row[1],'_self');
//	}).keypress (function(){
//    	var evt = (evt) ? evt : event; 
//    	var tecla = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode:((evt.which) ? evt.which : 0)); 
//    	if(tecla==13){
//			$(this).search();
//			return false;	
//		}
//		return true;
//	});	
//
//});
</script>
</head>

<div align="center">
  <form name="form1" id="form1" method="post" action="">
    <table  align="center" bordercolor=" " bordercolordark=" ">
        <tr>  <th>TIPOS DE CUARTOS</th> </tr> 
        <tr>  <th>BUSQUEDA   </th> </tr>
      <tr>
        <td ><input type="submit" name="Submit" value="Buscar" class="bot_WsW" />
          <img src="magnifier.png" onClick="alert('Buscar')" />
        <input name="tbus" id="tbus" type="text" onBlur="may(this)" size="30"/></td>
      </tr>
      <tr>
        <th> TIPOS DE CUARTOS</th>
      </tr>
      <tr>
        <td><div align="center">
          <input name="tbus2" type="text" id="tbus" onBlur="may(this)" size="50"
		<?php

			if(isset($_POST['tbus'])){ 
				echo 'value="' . $_POST['tbus'] .  '"';
			}
	 ?>
		/>
        </div></td>
      </tr>   
    </table>
  </form>
</div>
<form name="frm1" method="post" action="" >
<body>
<div align="center">
<?php
 
	
	
	/*$pagos=mysqli_query($con ,"SELECT nparte1_det, proteina FROM valeryus030 WHERE (cancelado='0' or cancelado='2') AND total<>'0' AND nparte1='544' GROUP BY nparte1_det, proteina ORDER BY id_invend");	
	  while ($abonos=mysqli_fetch_array($pagos)){
		$formas[]=$abonos['nparte1_det'];
		  //echo "--->".$abonos['nparte1_det']."-".$abonos['proteina']."-".$abonos['id_invend']."";
		  if ($abonos['proteina']<>''){
		  $notas[]=$abonos['proteina'];
		  }
		  }	
	    $count=count($formas);
		$count1=count($notas);
		
	          for ($c=0; $c<= $count-1; $c++){
				  $fPago=mysqli_fetch_array(mysqli_query($con ,"SELECT descripcion FROM valeryus09 where n_reg='$formas[$c]'"));	
					$data[]=$fPago['descripcion'];
					  }
	
		      for ($d=0; $d<= $count1-1; $d++){		
				  $dato[] = "$notas[$d]";
					    //echo $notas[$d];
					  }			  
					 
					 $Where = "|".implode(",",$data);
					 $Notes = "|".implode(",",$dato);
					 
					 echo $Where;
					 echo $Notes; */
					 
	
	$sql = mysqli_query($con ,"SELECT * FROM valeryus05 ORDER BY descripcion");
	include("DE10000.php");
	?>
<table width="598" border='1' bordercolor=" " bordercolordark=" ">
      <tr>
        <th colspan="5"> 
          <div align="center">
               <input type="Submit" name="bot3" value="Agregar"  onClick="openpage('cat_cuartos_AG.php','_self')" class="bot_WsW"/>
		  <input type="Submit" name="bot3" value="Consultar"  onClick="openpage('cat_cuartos_CO.php','_self')" class="bot_WsW"/>
          <input type="button" name="bot2" value="Modificar" onClick="openpage('cat_cuartos_MO.php','_self')" class="original"/>
          <input type="button" name="bot1" value="Eliminar" onClick="openpage('cat_cuartos_EL.php','_self')" class="bot_RjR"/>
          <input type="button" name="bot4" value="Imprimir " onClick="openpage('cat_cuartos_IM.php','_self')" class="original"/>
          </div>
   		</th></tr>
<tr>
      <th width="37"  nowrap><div align="center">SEL</div></th>
        <th width="65"  nowrap><div align="center">CODIGO</div></th>
		<th width="161"  nowrap><div align="center">DESCRIPCION</div></th>
		<th width="190"  nowrap>TOTAL DE CUARTOS</th>
	    <th width="111"  nowrap>COLOR</th>
    </tr>
	  <?php

	$vart=(isset($_POST['tbus']))?$_POST['tbus']:"";
	echo '<input name="txt_bus" type="hidden" value="'.$vart.'">';
	$vars=(isset($_POST['submit']))?$_POST['submit']:"";
	if($vars=="")
	{
		echo '<input name="tip_bus" type="hidden" value="nombre">';
		@$sql = mysqli_query($con ,"SELECT * FROM valeryus05 WHERE descripcion like '%".$vart."%'");
	}
	while($reg = mysqli_fetch_array($sql))
	{
	  	echo "<tr>";
		echo '<td> <div align="center"><input name="bot" type="radio" value="'. $reg["n_reg"].'"></div></td>';
		echo "<td> <div align='center'><h5>" . $reg["clavetp"] . "&nbsp;</h5></div></td>";
		echo "<td> <div align='center'><h5>" . $reg["descripcion"] . "&nbsp;</h5></div></td>";
		echo "<td> <div align='center'><h5>" . $reg["totalcuartos"] . "&nbsp;</h5></div></td>";
		echo '<td> <div align="center" style="background-color:'.$reg["color"].';">&nbsp;</div></td>';
		echo "</tr>";
		$total+=$reg["totalcuartos"];
	}
	    echo "<tr>";
		echo "<td colspan='3'> <div align='center'><h5>TOTAL CUARTOS :</h5></div></td>";
		echo "<td> <div align='center'><h5>" . $total . "&nbsp;</h5></div></td>";
	//echo "".$total."";
	mysqli_close($con);
	?>
  </table>
</div>
</body>
</form>
</div> 
</body>
</html>