<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("JQUERY.inc");
$tohb1=0;
$nr=0;
$f_f="";
$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>

</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 PLAN</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>
          <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)"//solo fechas   
		/>
          </td>
      </tr>
	  <tr> <td width="33%"><div align="right" class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" />  <strong>PLAN</strong></div></td>
	     <td width="67%"><select name="fplan" id="fplan" tabindex="11">
          <option value="T">---TODOS---</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM pplan");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['fplan']==$reg['pdescrip'] ){
		echo '<option value="' . $reg['pdescrip'] . '" selected>' . $reg['pdescrip'] . '</option>';
	}else{
		echo '<option value="' . $reg['pdescrip'] . '">' . $reg['pdescrip'] . '</option>';
	}
}
?>
        </select></td>
	</tr>
      <tr>
        <td colspan="2">
            <div align="center">
              
              <input name="Submit" type="button" class="boton" onClick="openpage('cat_plan_PR.php','_self')" value="Buscar"/>
			  <input name="bot4" type="button" class="boton" onClick="openpage('cat_plan_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 fplan<>'' order by ffecllegada");
	//echo "".$_POST['smerf']."";
	?>
    
	<table width="104%" align="center" cellpadding="0" cellspacing="0">
      <tr> 
		<th width="6%"><div align="center">FOLIO</div></th>
		<th width="7%"><div align="center">PLAN</div></th>
        <th width="16%"><div align="center">HUESPED</div></th>
		<th width="10%"><div align="center">STATUS</div></th>
		<th width="10%"><div align="center">FECHA DE LLEGADA</div></th>
		<th width="10%"><div align="center">FECHA DE SALIDA</div></th>
		<th width="11%"><div align="center">TOTAL CARGO HAB</div></th>
		<th width="11%"><div align="center">SEGMENTO</div></th>
		<th width="8%"><div align="center">AGENCIA</div></th>
		<th width="8%"><div align="center">GRUPO</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['fplan']) && $_POST['fplan']=="T"){
		echo '<input name="tbusqueda" type="hidden" value="f">';
		$result = mysqli_query($con ,"SELECT * FROM valeryus19 where fplan<>'' and cancelado='0' and ffecllegada between '$fecha_inicial' and '$fecha_final' order by ffecllegada");  
	}else{
            $var1=(isset($_POST['fplan']))?$_POST['fplan']:"";
	$result = mysqli_query($con ,"SELECT * FROM valeryus19 where fplan='".$var1."' and cancelado='0' and ffecllegada between '$fecha_inicial' and '$fecha_final' order by ffecllegada");
	}
	 if(isset($tothb)){
$tohb1= mysqli_num_rows($tothb);
} 
/*mysqli_num_rows($tothb);*/
	include("DE10000.php");
	$nocuarto=0;
	while($reg = mysqli_fetch_array($result))
	{
		$nr = $nr + 1;
			$v1 = $nr / 2;
			$v2 = (int) ($nr / 2);
			if($v1 == $v2){
				$col ="#3399FF";
			}else{
				$col ="#66CCFF";
			}
			
		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["fplan"] . "&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["status"] . "&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>";
		$cargo=mysqli_fetch_array(mysqli_query($con ,"select sum(costo) as hab from valeryus030 where nparte1='".$reg['n_reg']."' and nparte1_det='1' and (cancelado='0' or cancelado='2')"));
		echo "<td style='".$col."'> <div align='center'><strong>$" . number_format($cargo['hab'],2,'.',',') . "&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["fcodagen"] . "&nbsp;</strong></div></td>";
		echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fcodgrupo"] . "&nbsp;</strong></div></td>";
		//echo "<td style='".$col."'> <div align='center'><strong>" . $reg["fempresa"] . "&nbsp;</strong></div></td>";
		//echo "<td style='#3399FF'> <div align='center'><strong>" . $reg["fcodagen"] . "&nbsp;</strong></div></td>";
		//echo "<td style='#3399FF'> <div align='center'><strong>" . $reg["fcodagen"] . "&nbsp;</strong></div></td>";
		echo "</tr>";
	  	
		
	    	}
	    
	mysqli_close($con);
	?>
    </table>
  </form>
</div>
</body>
</html><?php
// 100 LISTO ULTIMA ACTUALIACION 21/AGOSTO/2012 ?>