<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DF80000.php");
include ("varfun.php");
include("JQUERY.inc");
$f_m="";
$f_f="";
$nr=0;
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="js/searchtable.js"></script>
<script>
    $(function() {
		  theTable = $("#latabla");
		  $("#q").keyup(function() {
			$.uiTableFilter(theTable, this.value);
		  });
		  
		<?php if(!isset($_SESSION['open'])){  $_SESSION['open']=1;?>
		  $.ajax({
    url: "alerta_otas.php",
    success: function(data){
		
       var a= JSON.parse(data);
	   
		$.each(a, function( index, value ) {
			  $("#fechas").append(value); 
			  $("#fechas").append("<BR/>");
			});
			
			$( "#dialog-confirm" ).dialog('open');
			}   
});

 
  $( "#dialog-confirm" ).dialog({
				  resizable: false,
				  height: "auto",
				  width: 400,
				  modal: true,
				  buttons: {
					"Abrir disponibilidad": function() {
					  $( this ).dialog( "close" );
					  openpage('detalle_otas.php','_self');
					},
					"Cerrar": function() {
					  $( this ).dialog( "close" );
					}
				  }
				});
				<?php }?>	
		});

</script>
<body>
<div id="dialog-confirm" title="Fechas con cierre proximo" style="display:none"> 
  <p><span class="ui-icon ui-icon-alert" 
  style="float:left; margin:12px 12px 20px 0;">
  </span>Las siguientea fechas estan por agotarse, revise el modulo de disponibilidad para no sobre vender</p>
<p id="fechas">

</p>
</div>
<div align="center">
  <form name="form1" method="post" action="">
    <table width="433" border="0" align="center" bordercolor=" " bordercolordark=" ">
      <tr>
        <th colspan="2"><span class="Estilo3">REGISTRO DE RESERVACIONES INDIVIDUALES</span> </th>
      </tr>
      <tr>
        <th>FECHA DE LLEGADA </th>
        <th><div align="left">
          <input name="r1" type="radio" value="fecha" tabindex="2">
          <?php $fec3=(isset($_POST['fec']))?$_POST['fec']:date('d/m/Y'); ?>
        <input name="fec" type="text" class="emplea date" id="fec" size="9" maxlength="20" value="<?=$fec3?>"
			
			<?php

			
				$fecha = (isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	            $fechita = chfecha($fecha,'Y-m-d','d/m/Y');
				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}else{
					echo 'value="'.$fechita.'"';
				}
			?> onkeypress="return soloNumeros(event)"
		/>
        <!--    <input name="bot" id="bot" type="image" value=" ... " src="logos/cal4.jpg"/>
        --></div></th>
      </tr>
      <tr>
        <th> APELLIDO DEL CLIENTE</th>
        <th><div align="left">
          <input name="r1" type="radio" value="nombre" tabindex="2">
        </div></th>
      </tr>
       <tr>
        <th width="204">          NUMERO DE FOLIO </th>
        <th width="219"><div align="left">
          <input name="r1" type="radio" value="folio" tabindex="1">
        </div></th>
      </tr>
	  <tr>
        <th width="204">          NUMERO DE HABITACION </th>
        <th width="219"><div align="left">
          <input name="r1" type="radio" value="clave" tabindex="1">
        </div></th>
      </tr>
      <tr>
        <td colspan="2">
		<img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" />
		<input name="tbus" type="text" onBlur="may(this)" size="55"/></td></tr>
      <tr>
        <td colspan="2"><div align="center"><input name="Submit" type="submit" class="bot_WsW" value="Buscar" />
        </div></td></tr> 
    </table>
  </form>
</div>
<div align="center">
  <form name="frm1" method="post" action="" >
	<?php
 
	
	//$duplicada=mysqli_query($con ,"select * from valeryus19 where status='RESERVA INDIVIDUAL' and cancelado='0' ORDER BY fnumcto limit 1");
	//while ($sdf=mysqli_fetch_array($duplicada)){
	 //echo alert_js("".$sdf['fnombre']."");
	//}
	//echo alert_js("hola");
	
	//if(isset($_POST['Submit'])){
	//$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'RESERVA INDIVIDUAL' ORDER BY fnumcto");
	//include("DE10000.php");
	//}else{
	$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status='RESERVA INDIVIDUAL' and cancelado='0' ORDER BY fnumcto");
	include("DE10000.php");
	//}
	?>
          
         <div id="busqueda" style="color:#000">
             Busqueda Rapida <input type="text" style="width: 70%" id="q" name="q" value=""  placeholder="cualquier texto de la busqueda actual(nombre, folio, hab.)"/>
		</div>
      
    <table width="1024" border='1' id="latabla" bordercolor=" " bordercolordark=" ">
        <thead>
      <tr>
        <th colspan="12"> <div align="center">
          <input name="Submit6" type="button" class="original" onClick="openpage('res_registro_AG.php','_self')" value="Agregar"/>
          <input name="bot3" type="Submit" class="bot_WsW"  onClick="openpage('res_registro_CO.php','_self')" value="Consultar"/>
          <input name="bot2" type="button" class="original" onClick="openpage('res_registro_ACEX.php','_self')" value="Modificar"/> 
          <input name="bot1" type="button" class="bot_RjR" onClick="openpage('res_registro_EL.php','_self')" value="Cancelar"/>
          <input name="Submit" type="submit" class="bot_WsW" id="Submit" onClick="openpage('res_registro_PR.php','_self')" value="Mostrar Todas"/>
		  <input name="bot4" type="button" class="original" onClick="openpage('res_registro_IM.php','_self')" value="Papeleta Reservas"/>
		  <input name="bot44" type="button" class="bot_WsW" onClick="openpage('rec_checkin_IM.php','_self')" value="Tarjeta de Registro"/>
		  <input name="bot44" type="button" class="original" onClick="openpage('valeryus69200_IM.php','_self')" value="Tarjetas de Registro x Fecha De Llegada"/>
          <input name="bot22" type="button" class="bot_WsW" onClick="openpage('res_registro_AG.php?multiplo=true','_self')" value="Multiplo"/>
        </div></th>
      </tr>
      <tr>
        <th colspan="12" ><strong>REGISTRO DE RESERVACIONES INDIVIDUALES </strong></th>
      </tr>
      <tr>
        <th width="40" height="32"></th>
		<th width="40" height="32"><div align="center">SEL</div></th>
        <th width="55"><div align="center">FOLIO </div></th>
        <th width="103"><div align="center">HABITACION</div></th>
        <th width="161"><div align="center">STATUS </div></th>
		<th width="240"><div align="center">CLIENTE </div></th>
		<th width="100"><div align="center">MERCADO </div></th>
		<th width="100"><div align="center">AGENCIA </div></th>
		<th width="86"><div align="center">FECHA DE ENTRADA</div></th>
		<th width="91"><div align="center">FECHA DE SALIDA</div></th>
		<th width="98"><div align="center">STATUS</div></th>
		<th width="130"><div align="center"></div></th>
      </tr>
      </thead>   
      <tbody>
      <?php

	 
	$fec = (isset($_POST['fec']))?$_POST['fec']:"";
		include('DF20000.php');
		$fecha_inicial = $f_m;
		$vart=(isset($_POST['tbus']))?$_POST['tbus']:"";
	echo '<input name="txt_bus" type="hidden" value="'.$vart.'">';
	
	if(isset($_POST['r1']) && $_POST['r1']=="clave"){
		echo '<input name="tip_bus" type="hidden" value="clave">';
	  	@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto = '".$vart."' and status = 'RESERVA INDIVIDUAL' ORDER BY cancelado desc,ffecllegada");
		
	}elseif(isset($_POST['r1']) && $_POST['r1']=="nombre"){
		echo '<input name="tip_bus" type="hidden" value="nombre">';
		@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fapellido like '%".$vart."%' AND status = 'RESERVA INDIVIDUAL' ORDER BY cancelado asc");
	
	}elseif(isset($_POST['r1']) &&$_POST['r1']=="fecha"){
		echo '<input name="tip_bus" type="hidden" value="fecha">';
		@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada = '$fecha_inicial' AND status = 'RESERVA INDIVIDUAL' ORDER BY cancelado asc");
	
	}elseif(isset($_POST['r1']) &&$_POST['r1']=="folio"){
		echo '<input name="tip_bus" type="hidden" value="folio">';
		@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE n_reg='".$vart."' AND (status='RESERVA INDIVIDUAL' or status='RESERVA GRUPO') ORDER BY n_reg");
	
	}
	while($reg = mysqli_fetch_array($sql))
	{
	  	echo "<tr>";
		
		$nr = $nr + 1;
		$v1 = $nr / 2;
		$v2 = (int) ($nr / 2);
		  if($v1 == $v2){
			$col =" ";
		   }else{
			$col ="";
		   }
		
		if ($reg['online'] == 1){
		echo'<td><img src="img/new.gif" height="40" width="40" alt="Nueva Reserva Online"/></td>';
		}else{
		echo '<td> </td>';
		}
		if ($reg['cancelado'] == 1){
		echo'<td style="#FF3300"><div align="center"><input name="bot" type="radio" value="'. $reg["n_reg"].'" disabled></div></td>';
		}else{
		echo '<td style="'.$col.'"> <div align="center"><input name="bot" type="radio" value="'. $reg["n_reg"].'"></div></td>';
		}
		if ($reg['cancelado'] == 1){
		echo "<td style='#FF3300'> <div align='center'><h5>" . $reg["n_reg"] . "&nbsp;</h5></div></td>";
		}else{
		echo "<td style='".$col."'> <div align='center' style=' '><h5>" . $reg["n_reg"] . "&nbsp;</h5></div></td>";}
		
		if ($reg['cancelado'] == 1){
		echo "<td style='#FF3300'> <div align='center'><h5>" . $reg["fnumcto"] . "&nbsp;</h5></div></td>";
		}else{
		echo "<td style='".$col."'> <div align='center' style=' '><h5>" . $reg["fnumcto"] . "&nbsp;</h5></div></td>";}
		
		if ($reg['cancelado'] == 1){
		echo "<td style='#FF3300'> <div align='center'><h5>" . $reg["status"] . "&nbsp;</h5></div></td>";}
		else{
		echo "<td style='".$col."'> <div align='center' style=' '><h5>" . $reg["status"] . "&nbsp;</h5></div></td>";}
		
		if ($reg['cancelado'] == 1){
		echo "<td style='#FF3300'> <div align='center'><h5>" . $reg["fnombre"] . ' '. $reg["fapellido"] . "&nbsp;</h5></div></td>";
		echo "<td style='#FF3300'> <div align='center'><h5>" .$reg["fcodmeca"]   . "&nbsp;</h5></div></td>";
		echo "<td style='#FF3300'> <div align='center'><h5>" .$reg["fcodagen"]   . "&nbsp;</h5></div></td>";
		}else{
		echo "<td style='".$col."'><div align='center' style=' '><a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"openpage('res_registro_ACEX.php?bot=".$reg['n_reg']." ','_self')\"><h5>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "</h5></div></a></td>";
		echo "<td style='#FF3300'> <div align='center'><h5>" .$reg["fcodmeca"]. "&nbsp;</h5></div></td>";
		echo "<td style='#FF3300'> <div align='center'><h5>" .$reg["fcodagen"]. "&nbsp;</h5></div></td>";
		
		}
		$fec1=$reg["ffecllegada"];
		
		include('DF20000.php');
		if ($reg['cancelado'] == 1){
		echo "<td style='#FF3300'> <div align='center'><h5>" . $f_f . "&nbsp</h5></div></td>";
		}else{ 
		echo "<td style='".$col."'> <div align='center' style=' '><h5>" . $f_f . "&nbsp</h5></div></td>";}
		
		$fec1=$reg["ffecsalida"];
		include('DF20000.php');
		if ($reg['cancelado'] == 1){
		echo "<td style='#FF3300'> <div align='center'><h5>" . $f_f . "&nbsp</h5></div></td>";
		}else{ 
		echo "<td style='".$col."'> <div align='center' style=' '><h5>" . $f_f . "&nbsp</h5></div></td>";}
				
		if ($reg['cancelado'] == 1){
		echo '<td  style="#FF3300"> <div align="center"><h5>CANCELADO</h5></div></td>';
		}else{
		echo '<td style="'.$col.'"> <div align="center"></div></td>';
		}
		if ($reg['cancelado'] == 1){
		echo '<td> <div align="center"></div></td>';
		}else{
		?> 
		<td style="<?php
 echo "".$col.""; ?>">
		<img src="img/consultar.png" height="40" width="40" alt="Consultar" onClick="openpage('sendmail_recep.php?bot=<?php
 echo "".$reg["n_reg"]."";?>','_self')"/>
		<img src="img/delete.png" height="40" width="40" alt="Cancelar" onClick="openpage('res_registro_EL.php?bot=<?php
 echo "".$reg["n_reg"]."";?>','_self')"/>
		<img src="img/impresora.png" height="40" width="40" alt="Tarjeta De Registro" onClick="openpage('rec_checkin_IM.php?bot=<?php
 echo "".$reg["n_reg"]."";?>','_self')"/>
		</td>
		<?php

		}
		if ($reg['cancelado']=='1'){
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"4\" style=\"#FF3300\" style=\"font-size:12px; font:Arial, Helvetica, sans-serif\"><strong>USUARIO: ".$reg['fusucancela']."</strong></td>";
		echo "<td colspan=\"2\" style=\"#FF3300\" style=\"font-size:12px; font:Arial, Helvetica, sans-serif\"><strong>FECHA CANCELACIÓN: ".$reg['fec_cancela']."</strong></td>";
		echo "<td colspan=\"3\" style=\"#FF3300\" style=\"font-size:12px; font:Arial, Helvetica, sans-serif\"><strong>HORA CANCELACIÓN: ".$reg['hor_cancela']."</strong></td>";
		echo "</tr>";
		}
		
		echo "</tr>";
	}
	mysqli_close($con);
	?>
                </tbody>
    </table>
  </form>
  </div>
</body>
</html>
