<?php
 
session_start();
include("DMYSQLR.php");
include("DMMYSQLG.php");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="javascript">
function cpyValText(arrData){
	var id;
	if(arguments[1]!='undefined'){
	for(id in arrData)
		window.opener.document.getElementById(id).value=arrData['id'];		
	}
	else{
		for(id in arrData)
			document.getElementById(id).value=arrData['id'];
	}
}
</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>

<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>
<form id="pp" name="pp" action="">
<table width="354" align="center">
<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>
<?php
 
//busqueda de habitaciones ya ocupadas 
		$fec = $_GET['feclle'];
		include('DF20000.php');
		 $fini = $f_m;
		$fec = $_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 ocupado != '#0000CC' order by ncto");
if($_POST['r1']=="clave")
{
	@$sql = mysqli_query($con ,"SELECT * FROM dxbascps WHERE codigo like '%".$_POST['tbus']."%' and act1 = '1'");
}elseif($_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
include("DMMYSQLG.php");
include("DMMYSQLG.php");

  		$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' and cancelado='0' "));
  echo mysqli_error($con);

   $dt_uper=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto,ffecllegada FROM valeryus19 WHERE fnumcto='".$reg['ncto']."' AND 
		ffecllegada < '$fsal' AND ffecsalida > '$fsal' and cancelado='0' "));
  echo mysqli_error($con);

   $dt_uwer=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto,ffecllegada FROM valeryus19 WHERE fnumcto='".$reg['ncto']."' AND 
		ffecllegada >= '$fini' AND ffecsalida < '$fsal' and cancelado='0' "));
  echo mysqli_error($con);

  		$dt_user2=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto,ffecllegada FROM valeryus19 WHERE fnumcto='".$reg['ncto']."'  AND ffecllegada < '$fsal' AND ffecsalida >= '$fsal' and cancelado='0' "));
  echo mysqli_error($con);

  		if($dt_user2['numRows']!=0){
		   	$oc1=1;
				}else  
  		if($dt_user['numRows']!=0){
		   	$oc1=1;
				}else  
  		if($dt_uper['numRows']!=0){
 		   	$oc2=1;
				} else
  		if($dt_uwer['numRows']!=0){
	 		$oc3=1;
				}else{
	 		$oc1=0;
	 		$oc2=0;
			$oc3=0;
				}
		if( ($oc1==1) || ($oc2==1) || ($oc3==1)){  ?>
		<td> <div align='center' style="font-size:22px; color:#FF0000"> X </div></td>
			<?php
	}else {?>
		<td> <div align="center"><input type="button" name="button" value="OK" onClick="
			cpyValText({
				<? echo $_REQUEST['val'];?>:'<?php
 echo $reg['ncto'] ?>',
				<? echo $_REQUEST['des'];?>:'<?php
 echo $reg['ntipo'] ?>'
			});
			window.close();
			"></div></td>
		<?	} 
		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>";
	}
?>
</table>
</form>
</body>
</html>
<?php

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