<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include ("varfun.php");
include("DFJQUERY.inc");
include("JQUERY.inc");
$f_f="";
$f_m="";
?>
<html>
<HEAD> <meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
<style type="text/css">
<!--
.Estilo16 {font-size: 14px}
.Estilo19 {font-family: Verdana, Helvetica; font-weight: bold; font-size: 10px; }
-->
BODY {
SCROLLBAR-FACE-COLOR:#7397A7; 
SCROLLBAR-HIGHLIGHT-COLOR:#5FBEC2;/*sombra izquierda arriba*/ 
SCROLLBAR-SHADOW-COLOR:#5FBEC2;/*sombra derecha abajo*/ 
SCROLLBAR-3DLIGHT-COLOR:#5FBEC2;/*lo mismo que la segunda*/ 
SCROLLBAR-ARROW-COLOR:#5FBEC2;/*flechita*/ 
SCROLLBAR-TRACK-COLOR:#5FBEC2;/*base*/
SCROLLBAR-DARKSHADOW-COLOR:#5FBEC2/*lo mismo que la tercera*/
}
 --> 
</style>
</HEAD>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
 	  	

<body>

<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="441" border="0">
	<tr> <th colspan="2"><span class="Estilo16">REPORTE DE RESERVACIONES</span></th> 
	</tr>
	<tr>
	  <td colspan="2"><div align="center">
	    <select name="status">
		<option value="TODO"<?php
if(isset($_REQUEST['status']) && $_REQUEST['status']=="TODO") echo 'selected';?>>TODO</option>
		<option value="RESERVA GRUPO"<?php
if(isset($_REQUEST['status']) && $_REQUEST['status']=="RESERVA GRUPO") echo 'selected';?>>RESERVA GRUPO</option>
		<option value="RESERVA INDIVIDUAL"<?php
if(isset($_REQUEST['status']) && $_REQUEST['status']=="RESERVA INDIVIDUAL") echo 'selected';?>>RESERVA INDIVIDUAL</option>
	    </select>
	    </div></td>
	  </tr>
	<tr>
	  <td colspan="2"><div align="center"><span class="Estilo19">De:</span>
                   <?php $fec=(isset($_POST['fec']))?$_POST['fec']:date('d/m/Y');?>
	      <input name="fec" type="text" class="emplea datefrom" id="fec" size="9" maxlength="20" value="<?=$fec?>"
			onkeypress="return soloNumeros(event)"
		/>
         <!--   <input name="bot" id="bot" type="image" value=" ... " src="logos/cal4.jpg"/>
            -->
            <span class="Estilo19">A:</span>
             
            <input name="fec2" type="text" class="emplea dateto" id="fec2" size="9" maxlength="20"
			<?php

				if(isset($_POST['fec2'])){ //este es el truco
					echo 'value="' . $_POST['fec2'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?>onkeypress="return soloNumeros(event)"
		/>
        <!--    <input name="bot12" id="bot1" type="image" value="Cal" src="logos/cal4.jpg" />
           --> 
	  </div></td>
	  </tr>
	<tr> <td width="33%"><div align="right" class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" />  FOLIO</div></td>
	     <td width="67%"><input name="r1" type="radio" value="no" tabindex="3" <?php
 if(isset($_POST['r1']) &&$_POST['r1']=='no') echo 'checked';?>/></td>
	</tr>
	<tr>
	  <td><div align="right"><span class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" />CUARTO</span></div></td>
	  <td><input name="r1" type="radio" value="r" tabindex="3" <?php
if(isset($_POST['r1']) &&$_POST['r1']=='r') echo 'checked';?>/></td>
	  </tr>
	<tr>
        <td><div align="right" class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> APELLIDO </div></td>
        <td><input name="r1" type="radio" value="p" tabindex="4" <?php
if(isset($_POST['r1']) &&$_POST['r1']=='p') echo 'checked';?>/></td>
	</tr>
      
      <tr>
        <td colspan="2">
          <div align="center">
            
            <input name="Submit" type="button" class="original" onClick="openpage('res_reservas_PR.php','_self')" value="Buscar"/>
			<input name="bot4" type="button" class="bot_WsW" onClick="openpage('res_reservas_IM.php','_self')" value="Imprimir "/>
		  </div></td>
      </tr>
    </table>
     
  </form>
</div>
<div align="center">
  <form method="post" action="" >
 <?php

	@$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status=''");
	@$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where status=''"));
	@$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status=''"));
	@$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status=''"));
	// --->
	
	?>
	<table width="1057" align="center" bordercolor=" " bordercolordark=" " >
	<tr>
	<?php	if (isset($_POST['r1']) &&$_POST['r1']=="no"){	?>
	
        <th width="50"><div align="center">FOLIO</div></th>
		<th width="190"><div align="center">CLIENTE</div></th>
		<th width="35"><div align="center"> HAB</div></th>
		<th width="49"><div align="center">TIPO</div></th>
		
	<?php
}elseif (isset($_POST['r1']) &&$_POST['r1']=="r"){?>
	
        <th width="35"><div align="center"> HAB</div></th>
		<th width="49"><div align="center">TIPO</div></th>
		<th width="190"><div align="center">CLIENTE</div></th>
		<th width="50"><div align="center">FOLIO</div></th>
				
	<?php	}elseif (isset($_POST['r1']) && $_POST['r1']=="p"){	?>
	
        <th width="190"><div align="center">CLIENTE</div></th>
		<th width="50"><div align="center">FOLIO</div></th>
		<th width="35"><div align="center"> HAB</div></th>
		<th width="49"><div align="center">TIPO</div></th>
	  
	<?php
} ?>
	    <th width="107">STATUS</th>
	    <th width="35"><div align="center">ADUL</div></th>
		<th width="35"><div align="center">MEN</div></th>
	    <th width="70"><div align="center">FEC. DE LLEGADA</div></th>
		<th width="70"><div align="center">FEC. DE SALIDA</div></th>
		<th width="80"><div align="center">FORMA DE PAGO</div></th>
	    <th width="60"><div align="center">TARIFA</div></th>
		
		<th width="100"><div align="center">MERCADO </div></th>
		<th width="100"><div align="center">AGENCIA </div></th>
		<th width="200"><div align="center">NOTAS</div></th>
	    </tr>
	<?php
                
	  	$fec = (isset($_POST['fec']))?$_POST['fec']:"";
		include('DF20000.php');
		$fecha_inicial = $f_m;
		$fec = (isset($_POST['fec2']))?$_POST['fec2']:"";
		include('DF20000.php');
		$fecha_final = $f_m;
	  // -->
	  
	if(isset($_POST['status']) && $_POST['status']=='TODO'){
	if(isset($_POST['r1'])&&$_POST['r1']==''){
	echo alert_JS ("¡¡¡SELECCIONE ORDENADOR!!!");
	}elseif($_POST['r1']=="no"){
		echo '<input name="tbusqueda" type="hidden" value="no">';
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' AND ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0' ORDER BY n_reg");
		@$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' AND ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' AND ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' AND ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
   	}elseif(isset($_POST['r1'])&&$_POST['r1']=="r"){
		echo '<input name="tbusqueda" type="hidden" value="r">';
		$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status = 'RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') and cancelado=0 order by fnumcto");
   	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	}elseif(isset($_POST['r1'])&&$_POST['r1']=="p"){
		echo '<input name="tbusqueda" type="hidden" value="p">';
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') and cancelado='0' ORDER BY fapellido");
	    $tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status = 'RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND (status = 'RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') AND cancelado='0'"));
	}
	}elseif(isset($_POST['status']) && $_POST['status']=='RESERVA GRUPO'){
	if($_POST['r1']==''){
	echo alert_JS ("¡¡¡SELECCIONE ORDENADOR!!!");
	}elseif($_POST['r1']=="no"){
		echo '<input name="tbusqueda" type="hidden" value="no">';
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' and cancelado='0' ORDER BY n_reg");
		@$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
   	}elseif($_POST['r1']=="r"){
		echo '<input name="tbusqueda" type="hidden" value="r">';
		$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' and cancelado=0 order by fnumcto" );
   	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	}elseif($_POST['r1']=="p"){
		echo '<input name="tbusqueda" type="hidden" value="p">';
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' and cancelado='0' ORDER BY fapellido");
	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA GRUPO' AND cancelado='0'"));
	}
	}elseif(isset($_POST['status']) && $_POST['status']=='RESERVA INDIVIDUAL'){
	if($_POST['r1']==''){
	echo alert_JS ("¡¡¡SELECCIONE ORDENADOR!!!");
	}elseif($_POST['r1']=="no"){
		echo '<input name="tbusqueda" type="hidden" value="no">';
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' and cancelado='0' ORDER BY n_reg");
		@$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' AND cancelado='0'"));
   	}elseif($_POST['r1']=="r"){
		echo '<input name="tbusqueda" type="hidden" value="r">';
		$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' and cancelado='0' order by fnumcto");
   	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' AND cancelado='0'"));
	}elseif($_POST['r1']=="p"){
		echo '<input name="tbusqueda" type="hidden" value="p">';
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status='RESERVA INDIVIDUAL' and cancelado='0' ORDER BY fapellido");
	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status = 'RESERVA INDIVIDUAL' AND cancelado='0'"));
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status = 'RESERVA INDIVIDUAL' AND cancelado='0'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecllegada <= '$fecha_final' AND status = 'RESERVA INDIVIDUAL' AND cancelado='0'"));
	} 
	}
	include("DE10000.php");
	
	while($reg = mysqli_fetch_array($result)){
	$DesCripciion=$reg["ftipocto"];
	$CuarTo=mysqli_fetch_array(mysqli_query($con ,"select * from valeryus05 where descripcion='$DesCripciion'"));
	
	if (isset($_POST['r1']) && $_POST['r1']=="no"){  	
		echo "<tr>	 
		<td class=\"DetallePr\"> <div align=\"center\"> '".$reg['n_reg']."' </div></td> 
		<td class=\"DetallePr\"> <div align=\"center\">'". $reg['fapellido']."' '".$reg['fnombre']."'  </div></td> 
		<td class=\"DetallePr\"> <div align=\"center\"> '".$reg['fnumcto']."' </div></td>
	    <td class='DetallePr'> <div align='center'><strong> '".$CuarTo['clavetp']."'  </div></td>";
	}elseif (isset($_POST['r1']) && $_POST['r1']=="r"){
		 echo "<tr>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$reg['fnumcto']." </div></td>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$CuarTo['clavetp']."</strong></div></td>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$reg['fapellido']." ".$reg['fnombre']." </div></td>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$reg['n_reg']." </div></td>";
	}elseif (isset($_POST['r1']) && $_POST['r1']=="p"){
	  	echo "<tr>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$reg['fapellido']." ".$reg['fnombre']." </div></td>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$reg['n_reg']." </div></td>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$reg['fnumcto']." </div></td>
		 <td class=\"DetallePr\"> <div align=\"center\"><strong> ".$CuarTo['clavetp']." </div></td>";
	}
		
		echo "<td class=\"DetallePr\"> <div align=\"center\"> ".$reg['status']." </div></td>
		<td class=\"DetallePr\"> <div align=\"center\"> ".$reg['fnumadu']." </div></td> 
		<td class=\"DetallePr\"> <div align=\"center\"> ".$reg['fnummenor']." </div></td>"; 
		$fec1=$reg["ffecllegada"];
		include('DF20000.php');
		echo "<td class=\"DetallePr\"> <div align=\"center\">" . $f_f . "</div></td>";
		$fec1=$reg["ffecsalida"];
		include('DF20000.php');
		echo "<td class=\"DetallePr\"> <div align=\"center\">" . $f_f . "</div></td>";
		$DesCrIpcioN=$reg["fformpago"];
		$Forma=mysqli_fetch_array(mysqli_query($con ,"select * from valeryus09 where descripcion='$DesCrIpcioN'"));
		echo "<td class=\"DetallePr\"> <div align=\"center\">" . $Forma["pclave"] . "</div></td>";
		echo "<td class=\"DetallePr\"> <div align=\"center\">$" .  number_format($reg['ftotal'], 2, '.', ',') . "</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>";
		
		echo "<td class=\"DetallePr\"> <div align=\"center\">" . $reg["fnorasvip"] . "</div></td></tr>";
	 }
		echo "<tr><td colspan='2'><div align='center' style=' '><strong>FOLIOS :</strong></div></td>
                  <td><div align=\"center\" style=' '><strong>".$tot['total']."</strong></div></td>
                  <td colspan='2'><div align='center' style=' '><strong>PERSONAS :</strong></div></td>
	              <td><div align=\"center\" style=' '><strong>".$jso['total']."</strong></div></td>
	              <td><div align=\"center\" style=' '><strong>".$ahj['total']."</strong></div></td>
	          </tr>";	  		  		  
	mysqli_close($con);
	?>
    </table>
  </form>
</div>
</body>
</html>
<?php

//259--> ultima actualizacion 25/noviembre/2011 ordenar por nombre apellido
//366--> ultima actualizacion 13/diciembre/2011 poner el ordenado a la izquierda, salga todo en un renglon
//377
?>
