<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
//include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
include("JQUERY.inc");
$f_m=0;
include("DFJQUERY.inc");
include("JQUERY.inc");
$totpax=0;
$fila=array();
?>
<html>
<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="form1" id="form1" method="post" action="">
    <table width="331" align="center">
      <tr>
	  <th width="323" colspan="2">ROOMING LIST </th>
	  </tr>
      <tr>
      <th align="center"><div align="center">GRUPO</div></th>
      </tr>
		  <tr><td align="center"><select name="fcodgrupo" id="fcodgrupo" tabindex="6">
		  <!--<td align="center"><select name="fcodgrupo" id="fcodgrupo" onChange="javascript: document.getElementById('form1').submit()" tabindex="6">-->
            <option value="">----------SELECCIONE----------</option>
            <?php
 $hoy = date("Y-m-d");
			include("DMMYSQLG.php");
$resultado = mysqli_query($con ,'SELECT valeryus04.n_reg, valeryus04.*, valeryus19.ffecllegada FROM valeryus04 
                   inner JOIN valeryus19 on TRIM(valeryus04.gdescrip)=TRIM(valeryus19.fcodgrupo)
                     where ffecllegada = date(now())
                    		group by gdescrip 
                    order by ffecllegada desc');
//  $resultado = mysqli_query($con ,'SELECT distinct(valeryus04.n_reg), valeryus04.*, valeryus19.ffecllegada FROM valeryus04 
//                    INNER JOIN valeryus19 on valeryus04.gdescrip=valeryus19.fcodgrupo  where YEAR(ffecllegada) = YEAR(now())
//						   group by gdescrip ');
while($reg=mysqli_fetch_array( $resultado)){
//    echo '<option value="' . $reg['gdescrip'] . '">' . $reg['gdescrip'] . '</option>';
	if(isset($_POST['fcodgrupo'])&&$_POST['fcodgrupo']==$reg['gdescrip'] ){
		echo '<option value="' . $reg['gdescrip'] . '" selected>' . $reg['gdescrip'] . '</option>';
	}else{
             if($reg['ffecllegada']>=$hoy and $reg['ffecsalida']<=$hoy){
      //$hoy>=fecchallegada and hoy<=fehcasalida
         echo '<option style="color:red"  value="' . $reg['gdescrip'] . '">' . $reg['gdescrip'] . '</option>';
            }else{
                        echo '<option value="' . $reg['gdescrip'] .$hoy. '">' . $reg['gdescrip'] . '</option>';
                }
        }
}
//			include("DMMYSQLG.php");
//$sql = mysqli_query($con ,"SELECT * FROM valeryus04 ORDER BY gdescrip");
//while($reg=mysqli_fetch_array($sql)){
//	if($_POST['fcodgrupo']==$reg['gdescrip'] ){
//		echo '<option value="' . $reg['gdescrip'] . '" selected>' . $reg['gdescrip'] . '</option>';
//	}else{
//		echo '<option value="' . $reg['gdescrip'] . '">' . $reg['gdescrip'] . '</option>';
//	}
//}
            
include("DMMYSQLG.php");
?>
          </select></td>
		  </tr>
		  <tr>
		  <th align="center">FECHA</th>
		  </tr>
		  <tr>
		  <td align="center"><input name="ffecllegada" type="text" class="emplea date" id="ffecllegada" size="10" maxlength="20" 
			<?php

				if(isset($_POST['ffecllegada'])) //este es el truco
					echo 'value="' . $_POST['ffecllegada'] .  '"';
				else
			  		echo 'value="'.date('d/m/Y').'"'; 
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
           <!-- <input name="bot1" id="bot1" type="image" value="Cal" src="logos/cal4.jpg"/>
        --> 
        <input name="ffecsalida" type="text" class="emplea" id="ffecsalida" size="10" maxlength="20"
		<?php

		
		$fecha_llegada = (isset($_POST['ffecllegada']))?$_POST['ffecllegada']:"";
		$nueva_fecha = chfecha($fecha_llegada,'d/m/Y','Y-m-d');
		$vart=(isset($_POST['fcodgrupo']))?$_POST['fcodgrupo']:"";
		$fec_salida = mysqli_query($con ,"select * from valeryus19 where ffecllegada = '".$nueva_fecha."' and status = 'RESERVA GRUPO' and fcodgrupo = '".$vart."' limit 1");
		$salida = mysqli_fetch_array($fec_salida);
		$salida_fecha = $salida['ffecsalida'];
		$nueva_fecha_salida = chfecha($salida_fecha,'Y-m-d','d/m/Y');
		echo 'value="'.$nueva_fecha_salida.'"';
		?> READONLY/>
		</td></tr>
      <tr>
        <td colspan="2"></td>
      </tr>
      <tr>
        <td colspan="2"><div align="center"><input name="Submit" type="submit" class="form" value="Buscar" />
        </div></td>
      </tr>
    </table>
  </form>
</div> 
<div align="center">    
<form action="" method="post" name="frm1"> 
<input type="hidden" name="r1" value="<?php
echo $_POST['r1'];?>">
<input type="hidden" name="select1" value=" <?php
echo $vars;?>">
<?php

   $ssql=mysqli_query($con ,"select * from valeryus19 WHERE status = 'RESERVA GRUPO' and cancelado='0'"); 
   //$result=mysqli_query($con ,$ssql); 
?>
  <table width="778" align=center> 
  <tr>
        <th colspan="7"> <div align="center">
          <input type="submit" class="form"  value="Limpiar" />
          <input name="Submit" type="button" class="form" onClick="openpage('res_rooming_MC.php','_self')" value="Guardar"/>
        </div></th>
      </tr>
    <tr>
        <th width="54"><div align="center">FOLIO</div></th>
        <th width="170"><div align="center">NOMBRE</div></th>
        <th width="181"><div align="center">APELLIDO</div></th>
		<th width="181"><div align="center">PAX</div></th>
		<th width="269"><div align="center">TIPO DE HABITACION</div></th>
		<th width="80"><div align="center">HABITACION</div></th>
  <th width="80"><div align="center">AGENCIA</div></th>
      </tr>
   <?php

   
$fec =(isset( $_POST['ffecllegada']))? $_POST['ffecllegada']:"";
		include('DF20000.php');
		$fecha_final = $f_m;
//$vart=(isset($_POST['fcodgrupo']))?$_POST['fcodgrupo']:"";		
echo '<input name="txt_bus" type="hidden" value="'.$vart.'">';
	$vars=(isset($_POST['submit']))?$_POST['submit']:"";
	if($vars=="")
	{
		echo '<input name="tip_bus" type="hidden" value="clave">';
	  	@$ssql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fcodgrupo = '".$vart."' AND ffecllegada = '".$f_m."' AND status = 'reserva grupo' AND cancelado = '0'");
		 }
	$i = 1; 
	$var3=(isset($fila["ffecsalida"]))?$fila["ffecsalida"]:"";
      echo "<td><h5 align='center'>" . $var3 . "</h5></td>";
        while ($fila=mysqli_fetch_array($ssql)){ 
		
		$nr = $nr + 1;
		$v1 = $nr / 2;
		$v2 = (int) ($nr / 2);
		  if($v1 == $v2){
			$col ="";
		   }else{
			$col =" ";
		   }
		
      echo "\n<div align='center'><input type=hidden name='id$i' value='" . $fila["n_reg"] . "'></div>"; 
      echo "<tr>"; 
      echo "<td align = 'center' style=\"$col\"><span class='Estilo16' style=' '>'" . $fila["n_reg"] . "'</span></td>"; 
      echo "<td style=\"$col\"><input type=text name='telefono$i' value='" . $fila["fnombre"] . "'></td>"; 
	  echo "<td style=\"$col\"><input type=text size='30' name='paxdia$i' value='" . $fila["fapellido"] . "'></td>";
	  $personas=$fila["fnumadu"]+$fila["fnummenor"];
	  echo "<td align = 'center' style=\"$col\"><span class='Estilo16' style=' '>" . $personas . "</span></td>";
	  $totpax+=$personas;
	  echo "<td align = 'center' style=\"$col\"><span class='Estilo16' style=' '>" . $fila["ftipocto"] . "</span></td>";
	  echo "<td align = 'center' style=\"$col\"><span class='Estilo16' style=' '>" . $fila["fnumcto"] . "</span></td>";
	 echo "<td align = 'center' style=\"$col\"><span class='Estilo16' style=' '>" . $fila["fcodagen"] . "</span></td>";
          echo "</tr>"; 
      $i++; 
      $ultimo_mostrado = $fila["n_reg"]; 
   } 
      
	  echo "<tr>"; 
      echo "<th align = 'right' colspan='3'>TOTALES: </th>"; 
      echo "<th align = 'center'><span class='Estilo16'>" . $totpax . "</span></th>"; 
	  echo "<th align = 'center' colspan='2'></th>";
          echo "<th align = 'center' colspan='2'></th>";
	  echo "</tr>"; 
?>
   </table>
  </form>
   </div>
   
</table>
</body> 
</html> 