<?php
 
session_start();
include("DMMYSQLG.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
include("DFJQUERY.inc");
$q=$_GET['num'];
//echo $q;
?>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script language="JavaScript">
function cambia_color(celda){
		//celda = document.getElementById("celda" + document.fcolor.celda.value)
		celda.style.backgroundColor="#FF00CC"
		
	}
function cambiar_color_over(celda){
		celda.style.backgroundColor=""
	}	
</script>	
<?php

    if (isset($_POST['bt8'])){
      $mirror=mysqli_query($con ,"insert into valeryus29 set fnumcto='24'");
	  echo "<script language='javascript'>
				
					document.getElementById('form1').submit()
					
				 </script>";
}
	
	if (isset($_POST['asignado'])){
$fecha_llegada = chfecha($_POST['a1'],'d/m/Y','Y-m-d');
	$fecha_salida = chfecha($_POST['a2'],'d/m/Y','Y-m-d');
@$ss = mysqli_query($con ,"insert into valeryus29 SET ffecllegada='$fecha_llegada', ffecsalida='$fecha_salida', fnumcto='".$_POST['a3']."', fnombre='".$_POST['a4']."'");

}elseif (isset($_POST['denegar'])){
$fecha_llegad = chfecha($_POST['b1'],'d/m/Y','Y-m-d');
	
@$ss = mysqli_query($con ,"delete from valeryus29 where ffecllegada='$fecha_llegad' and fnumcto='".$_POST['b3']."'");
}
?>

	  <table width="713" border='1'>
     <tr>
	 <?php

	 $array=mysqli_query($con ,"select * from valeryus05 where descripcion!='MAESTRA' AND n_reg!='$q'");
	   while ($cuartos=mysqli_fetch_array($array)){
	     echo "<td><div align='center'><span id='bot1'><a href='rec_checkin_CH".$cuartos['n_reg'].".php?num=".$cuartos['n_reg']."'>  "         .$cuartos['descripcion']."</a></span></div></td>";  }		  
	 ?>
	 </tr>
	  <tr>
	      <th  colspan="60"> <div align="center">
        </div></th>
      </tr>
      <tr>
	  <?php

	  $room=mysqli_fetch_array(mysqli_query($con ,"select * from valeryus05 where n_reg='$q'"));
	  ?>
        <th  colspan="60"><span class="Estilo2 Estilo3">CHART DE OCUPACI&Oacute;N X NOMBRE <?php
echo "(".$room['descripcion'].")";?></span></th>
	  </tr>
	
	     <tr>
        <th   width="104"><div align="center">HABITACI&Oacute;N</div>          </th>        <div align="center"></div>                
      <th width="593" colspan="60">FECHA
	     </tr>
	     <tr>
		 <th>&nbsp; </th>
	       
	           <?php

			   if(isset($_POST['t1'])){
		$fec = $_POST['t1'];
		include('DF20000.php');
			$ffecllegada = $f_m;
		$fec = $_POST['t2'];
		include('DF20000.php');
			$ffecsalida = $f_m;
			
	 while ( dateCmp($ffecllegada,$ffecsalida)<=0)
	 {
	 echo "<td> ".chfecha($ffecllegada,'Y-m-d','dd')." </td>";
	 
	 	$ffecllegada=addDay($ffecllegada,1); 
		
	 	 }
		 }
	 ?>        
        </tr>
<?php

		$sql=mysqli_query($con ,$sq1="SELECT * FROM valeryus08 where ntipo='".$room['descripcion']."'order by ncto");
?>		
        
	<?php

	 if(isset($_POST['t1'])){
	while($reg = mysqli_fetch_array($sql))
	{
	$fec = $_POST['t1'];
		include('DF20000.php');
			$ffecllegada = $f_m;
		$fec = $_POST['t2'];
		include('DF20000.php');
			$ffecsalida = $f_m;
		    echo "<tr>";
			?>
			<td style='background-color:<?php
echo "".$reg['ocupado']."" ?>;' onClick="openpage('valeryus60100.php?ncto=<?php
echo $reg['ncto'] ?>&&tipo=<?php
 echo $reg['ntipo']?>','_self')"><div align='center' style=' '><?php
echo "" . $reg["ncto"] ." | ".$reg["ntipo"]. ""; ?></div></td>
			<?php

	$i ++;
	 while ( dateCmp($ffecllegada,$ffecsalida)<=0)
	 {

	 $sqb=mysqli_query($con ,"SELECT * FROM valeryus19 where ffecllegada <= '$ffecllegada' and  ffecsalida>='$ffecllegada' and fnumcto= '".$reg['ncto']."'");
	 echo "<td onclick='$varible_clase->agregar();' onDblClick='cambiar_color_over(this)' id='mirror'>&nbsp";
		while ($reb= mysqli_fetch_array($sqb)) {
	 		echo "<div style='background:#b1d8ff; color:#000000; font-size:12px'>". $reb["fapellido"] ."|</div>";
	 	}
		
	$sqb3=mysqli_query($con ,"SELECT * FROM valeryus29 where ffecllegada <= '$ffecllegada' and  ffecsalida>='$ffecllegada' and fnumcto= '".$reg['ncto']."'");
	 
		while ($reb3= mysqli_fetch_array($sqb3)) {
	 		?>
			<div style='background:#FF00CC;  ; font-size:12px'><?php
echo "".$reb3["fnombre"]."";?></div>
	 	<?php

		}	
	 //	$ffecllegada=addDay($ffecllegada,1); 
	//	}	 	 
//		echo "</td>";
	//				echo "</tr>";	
	//}
	
	 $sqb2=mysqli_query($con ,"SELECT * FROM valeryus19 where ffecllegada <= '$ffecllegada' and  fecha_real>='$ffecllegada' and fmuncto= '".$reg['ncto']."'");
// echo "<td>&nbsp";
		while ($reb2= mysqli_fetch_array($sqb2)) {
	 		echo "<div style='background:#FF9933; color:#000000; font-size:12px'>". $reb2["fapellido"] ."|</div>";
	 	}
	 	$ffecllegada=addDay($ffecllegada,1); 
		}	 	 
		echo "</td>";
					echo "</tr>";	
	}

	
	//	echo "<td> <div align='center'>kak3</div></td>";

	mysqli_close($con);
	
}


	?>  
	<td onClick=""  
  </table> 
  
   </table>
  </form>
</div>
</body>
</html>