<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DFJQUERY.inc");
include("JQUERY.inc");
$f_m="";
$nr=0;
$f_f="";
?>
<html>
<HEAD> 
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">

</HEAD>

<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 ¿CÒMO SE ENTERO?</span> </th>
	  </tr>
	  
      <tr>
        <td> <div align="right" class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> <strong>PERIODO</strong> </div></td>
        <td>
          <strong>De:</strong>
         <?php $varf=(isset($_POST['fec']))?$_POST['fec']:date('d/m/Y');  ?>
                 <input name="fec" type="text" class="emplea datefrom" id="fec" size="9" maxlength="20" value="<?=$varf?>"
			<?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
		/>
          
            <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 width="33%"><div align="right" class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /><strong>¿CÓMO SE ENTERO? </strong></div></td>
	     <td width="67%"><select name="entero" id="entero" tabindex="11">
          <option value="T">---TODOS---</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM tiphuesped");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['entero']==$reg['tpdescrip'] ){
		echo '<option value="' . $reg['tpdescrip'] . '" selected>' . $reg['tpdescrip'] . '</option>';
	}else{
		echo '<option value="' . $reg['tpdescrip'] . '">' . $reg['tpdescrip'] . '</option>';
	}
}
?>
        </select></td>
	</tr>
      <tr>
        <td colspan="2">
            <div align="center">
              <input name="Submit" type="button" class="original" onClick="openpage('aud_ente_PR.php','_self')" value="Buscar"/>
			  <input name="bot4" type="button" class="bot_WsW" onClick="openpage('aud_ente_IM.php','_self')" value="PDF"/>        
		  </div></td>
      </tr>
    </table>   
  </form>
</div>
<div align="center">
  <form method="post" action="" >
    <?php

	@$result = mysqli_query($con ,"SELECT * FROM valeryus19 where cancelado='0' and ftiphuesped<>'' order by ffecllegada");
	?>
	<table width="87%" align="center" bordercolor=" " bordercolordark=" ">
      <tr> 
		<th width="6%"><div align="center">FOLIO</div></th>
		<th width="18%"><div align="center">¿COMO SE ENTERO?</div></th>
        <th width="18%"><div align="center">HUESPED</div></th>
		<th width="12%"><div align="center">TELEFONO</div></th>
		<th width="12%"><div align="center">E-MAIL</div></th>
		<th width="11%"><div align="center">FEC. DE LLEGADA</div></th>
		<th width="12%"><div align="center">FEC. DE SALIDA</div></th>
		<th width="11%"><div align="center">SEGMENTO</div></th>
	  </tr>
	<?php

	$fec = (isset($_POST['fec']))?$_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['entero']) && $_POST['entero']!="T"){
		$result = mysqli_query($con ,"SELECT * FROM valeryus19 where ftiphuesped='".$_POST['entero']."' and cancelado='0' and ffecsalida between '$fecha_inicial' and '$fecha_final' and status='HISTORICO' order by ffecllegada"); 
		$nocuarto=0;
		while($reg = mysqli_fetch_array($result))
	{
		$nr = $nr + 1;
			$v1 = $nr / 2;
			$v2 = (int) ($nr / 2);
			if($v1 == $v2){
				$col ="";
			}else{
				$col =" ";
			}
		
		$nocuarto++;	
		echo "<tr>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["ftiphuesped"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='left'><strong>".$reg["fapellido"] . ' '. $reg["fnombre"]."</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["ftelefono"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fmail"] . "&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["fecha_real"];
		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["codseg"] . "&nbsp;</strong></div></td>";
		echo "</tr>";
	    	}
			
		echo "<tr>";
		echo "<td style='#990066' colspan='3'><div align='left'><strong> TOTAL DE FOLIOS DE ".$_POST['entero'].": </strong></div></td>";
		echo "<td style='#990066'> <div align='center'><strong> $nocuarto </strong></div></td>";
		echo "<td style='#990066' colspan='4'><div align='center'></div></td>";
		echo "</tr>";
			 
	}else{
	echo '<input name="tbusqueda" type="hidden" value="f">';
	    
		$como=mysqli_query($con ,"select distinct(ftiphuesped) from valeryus19 where cancelado='0' and ffecsalida between '$fecha_inicial' and '$fecha_final' and status='HISTORICO' order by ftiphuesped");
		
		while ($entero=mysqli_fetch_array($como)){
		
		@$result = mysqli_query($con ,"SELECT * FROM valeryus19 where cancelado='0' and ffecsalida between '$fecha_inicial' and '$fecha_final' and status='HISTORICO' and ftiphuesped='".$entero['ftiphuesped']."' order by n_reg");
		
	$nocuarto=0;
	while($reg = mysqli_fetch_array($result))
	{
		$nr = $nr + 1;
			$v1 = $nr / 2;
			$v2 = (int) ($nr / 2);
			if($v1 == $v2){
				$col ="";
			}else{
				$col =" ";
			}
		
		$nocuarto++;	
		echo "<tr>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["ftiphuesped"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='left'><strong>".$reg["fapellido"] . ' '. $reg["fnombre"]."</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["ftelefono"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fmail"] . "&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["fecha_real"];
		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["codseg"] . "&nbsp;</strong></div></td>";
		echo "</tr>";
	    	}
			
		echo "<tr>";
		echo "<td style='#990066' colspan='3'><div align='left'><strong> TOTAL DE FOLIOS DE ".$entero['ftiphuesped'].": </strong></div></td>";
		echo "<td style='#990066'> <div align='center'><strong> $nocuarto </strong></div></td>";
		echo "<td style='#990066' colspan='4'><div align='center'></div></td>";
		echo "</tr>";
		}
		
	}
		
			
	mysqli_close($con);
	?>
    </table>
  </form>
</div>
</body>
</html><?php
// 100 LISTO ULTIMA ACTUALIACION 21/AGOSTO/2012 ?>