<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
include("DFJQUERY.inc");

//function cambioCelda(celda){
//echo "hola";
//}
?>

<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script type="text/javascript">
/*function(datos){
		//	document.getElementById(arrData.idLayer).style.display='';
		//	if(typeof arrData.width!='undefined' && typeof arrData.height!='undefined')
		//		resLay(arrData);
		//	document.getElementById(arrData.idLayer).innerHTML=datos;
		//}
	});

function getAjaxSource(){
	return "rec_checkin_PR-SRV.php";	
}

	
	   
	    function cambVCVia_color(celda){
	ajaxRequest("rec_checkin_PR-SRV.php",{
		g1:'1',
		celda2:celda
		
	},{
		okLoad:function(ceCVlda2){
			alert("Asignando......");
			
		celda.style.backgroundColor="#FF00CC";
		//return "rec_checkin_PR-SRV.php";	
		document.form1.submit();
        
		}
		}

});
*/


function cambia_color(celda){
	
		//url: "rec_checkin_PR-SRV.php";
		//okLoad.('rec_checkin_NU.php');	
		celda.style.backgroundColor="#FF00CC"
		//return "rec_checkin_PR-SRV.php";	
		//document.form1.submit();
        openpage('rec_checkin_PR-SRV.php','_self');
}







/*ajaxRequest(
		getAjaxSourcee()
	,{ 
		cancelaPedido:1
	},{
		async:false,
		okLoad:function(datos) {
			document.mainForm.submit();				
		}
	});

/*		
	
	ajaxRequest(
		getAjaxSource(),{
			agp:'A'
		},{
			async:true,
			okLoad:function(datos){
				
				ge('bot').value=datos;	
			}
	});	*/
		
	

</script>

	


  
 	
<body>
<div align="left">

</div>
<div align="center">
  <form name="form1" method="post" action="">
    <table width="486" border="0" align="center">
	    <tr>
        <th colspan="2"><span class="Estilo5">CHART DE OCUPACI&Oacute;N X CUARTO</span></th>
      </tr>
      <tr>
        <th width="344"> <input name="r1" type="radio" value="ffecllegada" tabindex="1">
        PERIODO</th>
        <th width="132"><input name="r1" type="radio" value="ncto" tabindex="2">
        HABITACI&Oacute;N</th>
      </tr>
      <tr>
        <td><div align="center">
          <input name="t1" type="text" class="thcons" id="t1" size="15"  readonly onBlur="valFecha(this)"
			  <?php
 
			  if(isset($_POST['t1'])){
			  	echo 'value="'.$_POST['t1'].'"'; 
			  }else{
			  	echo 'value="'.date('d/m/Y').'"'; 
			  }
			  ?>
			  >
		      &nbsp;
		      <input name="reset2"  value=" ... " id="bot1" type="image" src="logos/cal4.jpg"/>
		      <span class="Estilo16">/</span>
		      <script type="text/javascript">
				  	Calendar.setup(
    					{
      						inputField  : "t1",        // ID of the input field
      						ifFormat    : "%d/%m/%Y",    // the date format
      						button      : "bot1"      // ID of the button
    					}
  					);
				</script>
       
          <input name="t2" type="text" class="thcons" id="t2" size="15" readonly onBlur="valFecha(this)" value="<? $tmt = mktime($mes, $dia, $anio); $eft = $tmt + 604800 ; // Eso me dar�a el timestamp de la fecha sumada 120 minutos. 
		   $fecha = date("d/m/Y", $eft); 
           echo $fecha;?>"			 				
		  <?php
 
			  	
			if(isset($_POST['t2'])){
			echo 'value="'.$fecha.'"'; 
			}else{
			echo 'value="'.$fecha.'"'; 
			}?>>
		         &nbsp;
		    <input name="reset" value=" ... " id="bot2" type="image" src="logos/cal4.jpg"/>
				<script type="text/javascript">
				  	Calendar.setup(
    					{
      						inputField  : "t2",        // ID of the input field
      						ifFormat    : "%d/%m/%Y",    // the date format
      						button      : "bot2"      // ID of the button
    					}
  					);
				</script>
        </div></td>
        <td><div align="center">
          <input name="s3" type="text" id="s3" onBlur="may(this)" size="15"/>
        </div></td>
      </tr>
      <tr>
        <td colspan="2"><div align="center">
		<?php

		include("DE10000.php");
		?>
		<?php

		 $inicio=$_POST['t1'];
		 $final=$_POST['t2'];
         ?> 
		  <input name="Submit" type="submit" class="original" value="Buscar" />
		  <input name="bot4" type="button" class="bot_WsW" onClick="openpage('valeryus69000_IM.php?fec= <?php
 echo "".$inicio."";?>&fec2=<? echo "".$final."";?>','_self')" value="Pdf"/>
		  <!--input name="imprimir" type="button" class="original" value="Imprimir" onClick="openpage('rec_disponibilidad_IM.php?fec=<? //echo "".$inicio."";?>&fec2=<? //echo "".$final."";?>','_self')"/>
		  <input name="bot4" type="button" class="bot_WsW" onClick="openpage('valeryus69000_IME.php?fec=<? //echo "".$inicio."";?>&fec2=<? //echo "".$final."";?>','_self')" value="Excel"/-->
        </div></td>
		<?php

		$f=mysqli_query($con ,"select n_reg,ffecllegada,ffecsalida,fnumcto,cancelado,status,fmuncto from valeryus19 where chart='0'");
	         while ($r=mysqli_fetch_array($f)){
	              $d=mysqli_query($con ,"insert into chart set n_reg='".$r['n_reg']."', ffecllegada='".$r['ffecllegada']."', ffecsalida='".$r['ffecsalida']."', fnumcto='".$r['fnumcto']."', cancelado='".$r['cancelado']."', status='".$r['status']."', fmuncto='".$r['fmuncto']."'");
				        $s=mysqli_query($con ,"update valeryus19 set chart='1' where n_reg='".$r['n_reg']."'");
	}
	       $i=mysqli_query($con ,"SELECT n_reg,ffecllegada,ffecsalida,fnumcto,cancelado,status,fmuncto,extra1 from valeryus19 where chart='1'");
		      while ($y=mysqli_fetch_array($i)){
			          $u=mysqli_query($con ,"UPDATE chart set ffecllegada='".$y['ffecllegada']."', ffecsalida='".$y['ffecsalida']."', fnumcto='".$y['fnumcto']."', cancelado='".$y['cancelado']."', status='".$y['status']."', fmuncto='".$y['fmuncto']."', extra1='".$y['extra1']."' where n_reg='".$y['n_reg']."'");
			  }   
		?>
      </tr>
    </table>
  </form>
</div>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="" >
  <input name="botf1" type="hidden" value="
  <?php
 
  if(!isset($_POST['t1'])){
  	echo date('d/m/Y');
  }else{
  	echo $_POST['t1'];
  }
  ?>">
      <input name="botf2" type="hidden" value="
  <?php
 
  if(!isset($_POST['t1'])){
  	echo date('d/m/Y');
  }else{
  	echo $_POST['t2'];
  }
  ?>">
  <?php

	if(isset($_POST['t1'])){
		$fec = $_POST['t1'];
		include('DF20000.php');
			$ffecllegada = $f_m;
		$fec = $_POST['t2'];
		include('DF20000.php');
			$ffecsalida = $f_m;
		
	}
	?>
  	  <table width="713" border='1' bordercolor="#FFFFFF" bordercolordark="#FFFFFF">
      <tr>
        <th  colspan="61"><span class="Estilo2 Estilo3">CHART DE OCUPACI&Oacute;N X CUARTO</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><div class='Estilo13'> ".whatDay($ffecllegada)." ".chfecha($ffecllegada,'Y-m-d','dd')."</div></td>";
	 
	 	$ffecllegada=addDay($ffecllegada,1); 
		
	 	 }
		 }
	 ?>        
        </tr>
<?php
	$sql=mysqli_query($con ,$sq1="SELECT * FROM valeryus08 where ntipo!='MAESTRA' 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>";
				echo "<td style='background-color:".$reg['ocupado'].";  ;'><div align='center'>" . $reg["ncto"] ." | ".$reg['ntipo']. "&nbsp</div></td>";
				
		 while ( dateCmp($ffecllegada,$ffecsalida)<=0)
		 {
		 $sqb=mysqli_query($con ,"SELECT n_reg,status,cancelado FROM chart where ffecllegada <= '$ffecllegada' and  ffecsalida>'$ffecllegada' and (fnumcto= '".$reg['ncto']."' or fmuncto='".$reg['ncto']."') and cancelado='0' and extra1='0' and ffecllegada>'2014-01-01'");
	 
	 echo "<td onclick='cambia_color(this)'>&nbsp";
			while ($reb= mysqli_fetch_array($sqb)) {
				
				if ($reb['status']=='HISTORICO'){
				echo "<div style='background:#FF6600; color:#000000; font-size:12px'>Folio:". $reb["n_reg"] ."</div>";
				}else{
				echo "<div style='background:#FFFFFF; color:#000000; font-size:12px'>Folio:". $reb["n_reg"] ."". $reb["status"] ."". $reb["cancelado"] ."</div>";
					}
			}
	
	///out
		 //$sqb2=mysqli_query($con ,"SELECT n_reg FROM chart where ffecllegada <= '$ffecllegada' and  fecha_real>'$ffecllegada' and fmuncto= '".$reg['ncto']."'and cancelado='0' and ffecllegada>'2013-04-01'");
	
			//while ($reb2= mysqli_fetch_array($sqb2)) {
				//echo "<div style='background:#FF9933; color:#000000; font-size:12px'>Folio:". $reb2["n_reg"] ."</div>";
			//}
			$ffecllegada=addDay($ffecllegada,1); 
			}	 	 
			echo "</td>";
						echo "</tr>";	
		}
	mysqli_close($con);	
}
	?>    
  </table>
  </form>
  </div>
</body>
</html>