<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include ("varfun.php");
include("DFJQUERY.inc");
?>
<html>
<HEAD> 
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">

</HEAD>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>

 	
	
<body>
<div align="left">

</div>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="441" border="0">
	<tr>
	  <th colspan="2"><span class="Estilo23">REPORTE DE HUESPEDES</span></th>
	  </tr>
	<tr>
	  <td><div align="right" class="Estilo31"><span class="Estilo29"><span class="Estilo30"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" />FECHA</span></span></div></td>
	  <td><span class="Estilo31">
	    <input name="r2" type="checkbox" value="f" tabindex="5" <?php
if($_POST['r2']=='f') echo 'checked';?>/>
	    De:
        <input name="fec" type="text" class="emplea" id="fec" size="9" maxlength="20"
			<?php

				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
        <input name="bot" id="bot" type="image" value=" ... " src="logos/cal4.jpg"/>
        <script type="text/javascript">
  Calendar.setup(
    {
      inputField  : "fec",        // ID of the input field
      ifFormat    : "%d/%m/%Y",    // the date format
      button      : "bot"      // ID of the button
    }
  );
            </script>
        
        </span></td>
	  </tr>
	  <tr>
	  <td colspan="2" height="25">	  </td>
	  </tr>
      <tr>
        <td colspan="2">
            <div align="center">
              <a style="text-decoration:underline;cursor:pointer;" href="menu_PR.php"/></a>
              <input name="Submit" type="button" class="original" onClick="openpage('ger_huespedes_PR.php','_self')" value="Buscar"/>
			  <input name="bot4" type="button" class="bot_WsW" onClick="openpage('ger_huespedes_IM.php','_self')" value="Imprimir "/>
		  </div></td>  </tr>  
    </table>  
  </form> </div>
<div align="center">
  <form method="post" action="" >
     <div style="height:450px; overflow:scroll; width:1150;" align="center">
	<table>
	<tr><th colspan="15"><span class="Estilo23">
	<?php
if ($_POST['r2']=='f'){ 
	echo "HUESPEDES DEL ".$_POST['fec']."";
	}else{
	echo "TODOS LOS HUESPEDES";
	}
	?> </span></th></tr>
      <tr>
		<th><div align="center">HAB</div></th>
		<th><div align="center">TIPO</div></th>
		<th><div align="center">HUESPED</div></th>
		<th><div align="center">FOLIO</div></th>
		<th><div align="center">ADUL</div></th>
		<th><div align="center">MEN</div></th>
		<th><div align="center">FECHA DE LLEGADA</div></th>
		<th><div align="center">FECHA DE SALIDA</div></th>
		<th><div align="center">FORMA DE PAGO</div></th>
		<th><div align="center">TARIFA</div></th>
		<th><div align="center">TAR-XTRA</div></th>
		<th><div align="center">MERCADO</div></th>		
		<th><div align="center">SEGMENTO</div></th>		
		<th><div align="center">NOTAS</div></th>
	  </tr>
	  <?php

	  
	  $walk=mysqli_query($con ,"select n_reg,fnumcto from valeryus19 where status='HUESPED'");
	  while($mun=mysqli_fetch_array($walk)){
	  $fmuncto=mysqli_query($con ,"UPDATE valeryus19 set fmuncto='".$mun['fnumcto']."' where n_reg='".$mun['n_reg']."'");
	  }
	 // --->
	  	$fec = $_POST['fec'];
		include('DF20000.php');
		$fecha_inicial = $f_m;
	  // -->
           if($_POST['r2']=='f'){
		  
   	      @$huesped=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total, SUM(fnumadu) AS adultos, SUM(fnummenor) AS menores from valeryus19 WHERE ffecllegada <= '$fecha_inicial' and ffecsalida >= '$fecha_inicial' and cancelado='0'"));

	      }else{
		  
	      @$huesped=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total, SUM(fnumadu) AS adultos, SUM(fnummenor) AS menores from valeryus19 where (status='HUESPED' or status='MISCELANEOS')"));
		  
		  }
	
	$d=0;
	
		$seccion=mysqli_query($con ,"select distinct(seccion) from valeryus08 order by seccion");
	
	while($secciones=mysqli_fetch_array($seccion)){
	
		echo "<tr>";
		echo "<td style='#C60636' colspan='14'> <div align='left'><strong>SECCION: " . $secciones["seccion"] ." &nbsp;</strong></div></td>";
		echo "</tr>";
		 if($_POST['r2']=='f'){
	  	    $result = mysqli_query($con ,"SELECT * FROM valeryus19 inner join valeryus08 on valeryus19.fmuncto=valeryus08.ncto WHERE  (valeryus19.ffecllegada <= '$fecha_inicial' AND valeryus19.ffecsalida >= '$fecha_inicial' and valeryus19.cancelado='0') and valeryus08.seccion='".$secciones['seccion']."' order by valeryus08.ncto");
		}else{
		    $result=mysqli_query($con ,"select * from valeryus19 left join valeryus08 on valeryus19.fnumcto=valeryus08.ncto where valeryus08.seccion = '".$secciones['seccion']."' and (valeryus19.status='HUESPED' or  valeryus19.status='MISCELANEOS') order by valeryus08.ncto");
		}
		
	    while($reg=mysqli_fetch_array($result)){
	    	
		$nr = $nr + 1;
		$v1 = $nr / 2;
		$v2 = (int) ($nr / 2);
		  if($v1 == $v2){
			$col ="";
		   }else{
			$col =" ";
		   }
	  	echo "<tr>";
		if ($reg["fnumcto"]==''){
		$reg["fnumcto"]=$reg["fmuncto"];
		}
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fnumcto"] . "&nbsp;</strong></div></td>";
		if ($reg["ftipocto"]!='MAESTRA'){
		echo "<td style='#C60636'> <div align='center'><strong>" . $reg["ftipocto"] . "&nbsp;</strong></div></td>";
		}else{
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["ftipocto"] . "&nbsp;</strong></div></td>";
		}
		echo "<td style='".$col."'> <div align='left'><strong> &nbsp;". $reg["fapellido"] . ' '. $reg["fnombre"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fnumadu"] . "&nbsp;</strong></div></td>";
		$adultos+= $reg["fnumadu"];
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fnummenor"] . "&nbsp;</strong></div></td>";
		$fec1=$reg["ffecllegada"];
		include('DF20000.php');
		echo "<td style='".$col."'> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
		$fec1=$reg["ffecsalida"];
		include('DF20000.php');
		echo "<td style='".$col."'> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fformpago"] . "&nbsp;</strong></div></td>";
		$tarext=$reg["fmonmen"]+$reg["fmonadu"];
		echo "<td style='".$col."'> <div align='center'><strong>$" .  number_format($reg['tex4'], 2, '.', ',') . "</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>$" .number_format($tarext,2,'.', ','). "</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fcodmeca"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["codseg"] . "&nbsp;</strong></div></td>";	
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fnorasvip"] . "&nbsp;</strong></div></td>";					
		if ($reg["ftipocto"]!='MAESTRA'){
		$d++;
		}
		}
	    	}
	    echo "<tr><th><div align='center' style=' '><strong>HABS :</strong></div></th>
				  <th><div align=\"center\" style=' '><strong>".$d."</strong></div></th>
                  <th colspan='2'><div align='center' style=' '><strong>PERSONAS :</strong></div></th>
	              <th><div align=\"center\" style=' '><strong>".$huesped["adultos"]."</strong></div></th>
	              <th><div align=\"center\" style=' '><strong>".$huesped["menores"]."</strong></div></th>
				  <th colspan='8'><div align=\"center\" style=' '><strong> &nbsp;".$tohb1."</strong></div></th>   	 				
	          </tr>";	
	mysqli_close($con);
	?>
    </table></div> </form>  </div>  </body>  </html>
<?php
//252 --> 300  ULTIMA ACTUALIZACION 6/ENERO/2012 AGRUPAR POR ORDENADOR ?>