<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DF30000.inc");
include('JQUERY.inc');
$Totaf=0;
$f_m="";
?>
<html>
<HEAD> <meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">

</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="Estilo23">REPORTE DE COLGADOS.</span> </th>
	  </tr>
	<tr>
	  <td width="142"><div align="right" class="Estilo24"><span class="Estilo25"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" />  FOLIO.</span></div></td>
	  <td width="289"><input name="r1" type="radio" value="no" tabindex="3"/></td>
	</tr>
	<tr>
	  <td> <div align="right" class="Estilo24"><span class="Estilo25"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> APELLIDO.</span></div></td>
	  <td><input name="r1" type="radio" value="p" tabindex="4"/></td>
	</tr>
	<tr >
	  <td><div align="right" class="Estilo24"><span class="Estilo25"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> HABITACION. </span></div></td>
	  <td>&nbsp;<input name="r1" type="radio" value="hb" tabindex="4"/><input type="hidden" name="cto" id="cto" size="12" <?php

				if(isset($_POST['cto'])){ //este es el truco
					echo 'value="' . $_POST['cto'] .  '"';
				}else{
					echo 'value=""';
				}
			?>/></td>
	  </tr>
	<tr style="display:none">
	  <td> <div align="right"class="Estilo24"><span class="Estilo25"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> PERIODO. </span></div></td>
	  <td><input name="r1" type="radio" value="f" tabindex="5"/>
	    <strong>De:</strong>
          <input name="fec" type="text" class="emplea datefrom" 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)"
		/>
            
            <strong>            A:</strong>
          <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)"
		/>
             </td>
	</tr>
      <tr>
        <td colspan="2">
            <div align="center">
              
              <input name="Submit" type="button" class="boton" onClick="openpage('aud_colgados_PR.php','_self')" value="Buscar"/>
			  <input name="bot4" type="button" class="boton" onClick="openpage('aud_colgados_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 = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."'");
	@$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where status = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."'"));
    @$tothb=mysqli_query($con ,"select * from valeryus19 where status = 'HUESPED' and ffecsalida='".$dt_empres['fec_alta']."' ");
	@$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."'"));
	@$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."'"));
	?>
    <table width="100%"   align="center" cellpadding="0" cellspacing="0">
      <tr>
        
		<th><div align="center">FOLIO.</div></th>
        <th><div align="center">CLIENTE.</div></th>
		<th><div align="center">AGENCIA.</div></th>
		<th><div align="center">ADUL.</div></th>
		<th><div align="center">MEN.</div></th>
		<th><div align="center">HAB.</div></th>
		<th><div align="center">TIPO.</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">SALDO</div></th>
		<th><div align="center">MERCADO</div></th>		
		<th><div align="center">SEGMENTO</div></th>				

	  </tr>
	<?php

	 // --->
	  	$fec = ( (isset($_POST['fec']))?$_POST['fec']:"" );/*$_POST['fec'];*/
		include('DF20000.php');
		$fecha_inicial = $f_m;
		//$pdf->Cell(15,5,$fecha_inicial,1,0,'C');
		$fec = ( (isset($_POST['fec2']))?$_POST['fec2']:"" );/*$_POST['fec2'];*/
		include('DF20000.php');
		$fecha_final = $f_m;
                
	  // -->

                $varr=(isset($_POST['r1']))?$_POST['r1']:"";
                $vars=(isset($_POST['Submit']))?$_POST['Submit']:"";
                          print_r($_POST);
	if($vars=="" && $varr=="no"){
            
		echo '<input name="tbusqueda" type="hidden" value="no">';
                 $var2=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."' order by n_reg");
   	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where status = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."'"));
	    @$tothb=mysqli_query($con ,"select * from valeryus19 where status = 'huesped' and ffecsalida='".$var2."' ");		
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$dt_empres['fec_alta']."'"));
		
	}elseif($vars=="" && $varr=="f"){
		//$fec = $_POST['tt'];
		//include("DF20000.php");
		//echo $f_m;
		echo '<input name="tbusqueda" type="hidden" value="f">';
                $var2=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
		$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'huesped' and ffecsalida='".$var2."'");
		@$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'huesped' and ffecsalida='".$var2."'"));
	    @$tothb=mysqli_query($con ,"select * from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'huesped' and ffecsalida='".$var2."' ");
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'huesped' and ffecsalida='".$var2."'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'huesped' and ffecsalida='".$var2."'"));
		
   	}elseif($vars=="" && $varr=="p"){
		echo '<input name="tbusqueda" type="hidden" value="p">';
                $var2=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$var2."' order by fapellido");
	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where status = 'huesped' and ffecsalida='".$var2."'"));
	    @$tothb=mysqli_query($con ,"select * from valeryus19 where status = 'huesped' and ffecsalida='".$var2."' ");		
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$var2."'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$var2."'"));
	
            
        }elseif($vars=="" && $varr=="hb"){
		echo '<input name="tbusqueda" type="hidden" value="hb">';
                 $var2=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	  	$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'huesped'  and ffecsalida='".$var2."' order by fnumcto");
	    @$tot=mysqli_fetch_array(mysqli_query($con ,"select count(*) as total from valeryus19 where status = 'huesped' and ffecsalida='".$var2."' "));
	    @$tothb=mysqli_query($con ,"select * from valeryus19 where status = 'huesped' and ffecsalida='".$var2."' ");		
	    @$jso=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$var2."'"));
	    @$ahj=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status = 'huesped' and ffecsalida='".$var2."' "));
	}
	
	$tohb1=mysqli_num_rows($tothb);
	include("DE10000.php");
	$nocuarto=0;
	while($reg = mysqli_fetch_array($result))
	{
			

		
	  	echo "<tr>";
		//echo '<td><div align="center"><input name="bot" type="radio" value="'. $reg["n_reg"].'">&nbsp</div></td>';
		echo "<td> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='left'><strong> &nbsp;". $reg["fapellido"] . ' '. $reg["fnombre"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fcodagen"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fnumadu"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fnummenor"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fnumcto"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["ftipocto"] . "&nbsp;</strong></div></td>";
		$fec1=$reg["ffecllegada"];
		include('DF20000.php');
		echo "<td> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
		$fec1=$reg["ffecsalida"];
		include('DF20000.php');
		echo "<td> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fformpago"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>$" .  number_format($reg['suma'], 2, '.', ',') . "</strong></div></td>";
		$Totaf+=$reg['suma'];
		echo "<td> <div align='center'><strong>" . $reg["fcodmeca"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["codseg"] . "&nbsp;</strong></div></td>";				
		echo "</tr>";
		echo "<tr>";
		echo "<th><div align='center'><strong>NOTAS&nbsp;</strong></div></th>";				
		echo "<td colspan='13'> <div align='left'><strong>&nbsp;" . $reg["fnorasvip"] . "&nbsp;</strong></div></td></tr>";
		echo "<tr><td  colspan='13'  height='5' style='background:#000099'></td></tr>";
		
	    	}
	    echo "<tr><th><div align='center' style=' '><strong>FOLIOS :</strong></div></th>
                  <th><div align=\"center\" style=' '><strong>".$tot['total']."</strong></div></th>
                  <th><div align='center' style=' '><strong>PERSONAS :</strong></div></th>
	              <th><div align=\"center\" style=' '><strong>".$jso['total']."</strong></div></th>
	              <th><div align=\"center\" style=' '><strong>".$ahj['total']."</strong></div></th>
				 <th><div align=\"center\" style=' '><strong> &nbsp;".$tohb1."</strong></div></th>
 				 <th><div align=\"center\" style=' '><strong> &nbsp;</strong></div></th>				 

				 <th><div align=\"center\" style=' '><strong>&nbsp; </strong></div></th>
				 <th><div align=\"center\" style=' '><strong> &nbsp;</strong></div></th>
				 <th><div align=\"center\" style=' '><strong> &nbsp;</strong></div></th>		 
				 <th><div align=\"center\" style=' '><strong>".number_format($Totaf, 2, '.', ',')."</strong></div></th>								
				 <th><div align=\"center\" style=' '><strong> &nbsp;</strong></div></th>  
 				 <th><div align=\"center\" style=' '><strong> &nbsp;</strong></div></th>		 				  
				 
	          </tr>";
	mysqli_close($con);
	?>
    </table>
  </form>
</div>
</body>
</html>