<?php
 
session_start();
include("DMMYSQLG.php");
include("JQUERY.inc");
$oc1=0;
$oc2=0;
$oc3=0;
$f_m="";
?> 
<html>
    <head>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="javascript">
function cpyValText(arrData){
	var id;

      
      for(id in arrData)  
        window.parent.$("#"+id).val(arrData[id]);
        parent.$.fancybox.close();
}
</script>
<script type="text/javascript" language="JavaScript1.2" src="js/searchtable.js"></script>
<script>
    $(function() {
		  theTable = $("#latabla");
		  $("#q").keyup(function() {
			$.uiTableFilter(theTable, this.value);
		  });
		});
</script>
<script language="javascript">
<!--
	//--> ABRIR EN OTRA PANTALLA
  function sendValueOV(va1,va2,va3,va4){
	var sv = va1;
	cs = sv.split("|");
	var va = cs[0];
	if (va1 != "") {
		window.opener.document.frm1.tncli.value = va1;
		window.opener.document.frm1.tnom_alt.value = va2 + " " + va3 + " " + va4;
		window.opener.document.frm1.tncli.focus();
	} else {
		alert("EL CLIENTE NO EXISTE" + comple + " \n. POR FAVOR VERIFIQUELO!");
		window.opener.document.frm1.tncli.value = "";
		window.opener.document.frm1.tncli.focus();
	}
	window.close();
}
  //-->FIN
-->
</script>
<style type="text/css">
    td{
        padding:0px !important;
    }
</style>

</head>
<body>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="458"  align="center" bordercolor=" " bordercolordark=" ">
      <tr> 
        <th width="594" colspan="2">AGREGAR NUMERO Y TIPO DE HABITACION. </th>
      </tr>
    </table>
  </form>
</div>
     <div id="busqueda" align="center" style="color:#000">
          <input type="text" style="width: 70%" id="q" name="q" value="" placeholder="una palabra del tipo o num" />
		</div>
<form id="pp" name="pp" action="">
     
<table width="354" align="center"  id='latabla'>
    <thead>
<tr>
	  <th width="32"><div align="center">SEL</div></th>
      <th width="54"><div align="center">NUMERO</div></th>
  	  <th><div align="center">HABITACION</div></th>
	  <th><div align="center">STATUS</div></th>
    </tr>
</thead>
<tbody>
<?php

//busqueda de habitaciones ya ocupadas 
		$fec = (isset($_GET['feclle']))?$_GET['feclle']:"";
		include('DF20000.php');
		 $fini = $f_m;
		$fec = (isset($_GET['fecsal']))?$_GET['fecsal']:"";
		include('DF20000.php');
		$fsal = $f_m;
                
              
                
//$sql = mysqli_query($con ,"SELECT * FROM valeryus08 order by ncto");
//$sql = mysqli_query($con ,"SELECT * FROM valeryus08 WHERE ntipo != 'MAESTRA' AND nstaamalla != 'BLOQUEADO' AND nstaamalla!='FUERA' order by ncto");
$q="select valeryus08.*,COALESCE(table1.num1, 0) as canceled,COALESCE(table2.num2, 0) as bloked FROM valeryus08
                    left outer join
                    (
                    select count(*)as num1,fnumcto as id from valeryus19
                     WHERE  ((valeryus19.ffecllegada <= '$fini' AND valeryus19.ffecsalida > '$fini' )
                     OR(valeryus19.ffecllegada < '$fsal'  AND valeryus19.ffecsalida > '$fsal')
                     OR((valeryus19.ffecllegada >= '$fini' AND valeryus19.ffecsalida < '$fsal')
                     OR((valeryus19.ffecllegada < '$fsal'  AND valeryus19.ffecsalida >= '$fsal')))) and valeryus19.cancelado='0' 
                     group by valeryus19.fnumcto
                     )as table1
                     on  table1.id=valeryus08.ncto

                     left outer join

                     ( select count(*)as num2, fnumcto as id from valeryusst08 where  ((valeryusst08.fec_ini < '$fsal' AND valeryusst08.fec_fin > '$fsal') 
                      or (valeryusst08.fec_ini >= '$fini' AND valeryusst08.fec_fin < '$fsal')
                      or (valeryusst08.fec_ini <= '$fini' AND valeryusst08.fec_fin > '$fini') 
                      or (valeryusst08.fec_ini < '$fsal' AND valeryusst08.fec_fin >= '$fsal')) group by valeryusst08.fnumcto
                     )as table2
                     on table2.id=valeryus08.ncto
                     WHERE ntipo <> 'MAESTRA' 
                    order by valeryus08.n_reg; ";
$sql = mysqli_query($con ,$q);
//if(!isset($_POST['r1']))$_POST['r1']="";
if(isset($_POST['r1']) && $_POST['r1']=="clave")
{
	@$sql = mysqli_query($con ,"SELECT * FROM dxbascps WHERE codigo like '%".$_POST['tbus']."%' and act1 = '1'");
        
        
      
        
        
        
}elseif(isset($_POST['r1']) && $_POST['r1']=="nombre"){
	@$sql = mysqli_query($con ,"SELECT * FROM dxbascps WHERE nombre  like '%".$_POST['tbus']."%' or ap_paterno  like '%".$_POST['tbus']."%' or ap_materno  like '%".$_POST['tbus']."%' and act1 = '1'");
}
while(@$reg = mysqli_fetch_array($sql))
	{
 	  	echo "<tr>";
//COMPARACION DE FECHAS PARA LA rec_ocupacion DE CUARTOS
  	//	$dt_user=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto,ffecllegada FROM valeryus19 WHERE fnumcto='".$reg['ncto']."'  AND ((ffecllegada <= '$fini' AND ffecsalida > '$fini' )OR(ffecllegada < '$fsal' AND ffecsalida > '$fsal')OR((ffecllegada >= '".$fini."' AND ffecsalida < '$fsal')OR((ffecllegada < '$fsal' AND ffecsalida >= '$fsal')))) and cancelado='0' "));
          //  echo "SELECT  count(*) as numRows, fnumcto,ffecllegada FROM valeryus19 WHERE fnumcto='".$reg['ncto']."'  AND ((ffecllegada <= '$fini' AND ffecsalida > '$fini' )OR(ffecllegada < '$fsal' AND ffecsalida > '$fsal')OR((ffecllegada >= '".$fini."' AND ffecsalida < '$fsal')OR((ffecllegada < '$fsal' AND ffecsalida >= '$fsal')))) and cancelado='0' group by fnumcto<br>";
            //    echo mysqli_error($con);
     
 //  $bl_uper=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto, fec_ini FROM valeryusst08 WHERE fnumcto='".$reg['ncto']."' AND	((fec_ini < '$fsal' AND fec_fin > '$fsal') or (fec_ini >= '$fini' AND fec_fin < '$fsal')or (fec_ini <= '$fini' AND fec_fin > '$fini') or (fec_ini < '$fsal' AND fec_fin >= '$fsal')) "));
 // echo "SELECT  count(*) as numRows, fnumcto, fec_ini FROM valeryusst08 WHERE fnumcto='".$reg['ncto']."' AND	((fec_ini < '$fsal' AND fec_fin > '$fsal') or (fec_ini >= '$fini' AND fec_fin < '$fsal')or (fec_ini <= '$fini' AND fec_fin > '$fini') or (fec_ini < '$fsal' AND fec_fin >= '$fsal')) group by fnumcto<br>";
   //echo mysqli_error($con);

   
 

  		
  		if($reg['canceled']!=0){ 
		   	$oc1=1;
			}else{
	 		$oc1=0;
	 		$oc2=0; 
			$oc3=0;
			$oc4=0;
				}
		
		
  		if($reg['bloked']!=0){
                    $oc5=1;
 		   }else{
	 		$oc5=0;
	 		$oc6=0;
			$oc7=0;
			$oc8=0;
				}
				
		if( ($oc1==1) || ($oc2==1) || ($oc3==1) || ($oc4==1)){  ?>
		<td> <div align='center' style="font-size:22px; color:#FF0000"> X </div>
		<?php
//echo //"".$oc1."".$oc2."".$oc3."".$oc4."";?>
		</td>
			<?php
	}elseif( ($oc5==1) || ($oc6==1) || ($oc7==1) || ($oc8==1)){
			?>
			<td> <div align='center' style="font-size:22px; color:#FF0000"> B </div>
			<?php //echo "".$oc5."-".$oc6."-".$oc7."-".$oc8."";?>
			</td>			
			<?php

			}else{?>
		<td> <div align="center"><input type="button" name="button" value="OK" onClick="
			cpyValText({
				<?php
 echo $_REQUEST['val'];?>:'<?php
 echo $reg['ncto'] ?>',
				<?php
 echo $_REQUEST['des'];?>:'<?php
 echo $reg['ntipo'] ?>'
			});
			
			"></div></td>
		<?php
	} 
		echo "<td> <div align='center'>'" . $reg["ncto"] . "'</div></td>";
		echo "<td> <div align='center'>'" . $reg["ntipo"] . "'</div></td>";
		echo "<td> <div align='center' style='background-color:".$reg["ocupado"].";'>&nbsp;</div></td>";
		echo "</tr>";
	}
?>
                        </tbody>
</table>
</form>
</body>
</html>
<?php

//151 ultima actualizacion 23/Noviembre/2011 regresar valores tarifa alta y baja
?> 
