<?php
 
session_start();
//include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
//include("DF30000.inc");
include("DF80000.php");
include("JQUERY.inc");
$vfa=$dt_empres['fec_alta'];
?>
<html>
<HEAD> <meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
<style type="text/css">
<!--
.Estilo20 {font-size: 18px}
.Estilo22 {font-size: 24px; font-weight: bold; }

-->
</style>
<style type="text/css">
<!--
.estiloFecha {
	font-size: 12px;
	font-weight: bold;
}
.Estilo3 {border: 1px; font-family :urw gothic l; color: #000099; background-color: #dbe0e9;}
.Estilo4 {font-size: 12px}

.granTotL{
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px;
	font-weight:bold;
	text-align:left;
	background-color:#0080FF;
	 ;
}
.granTotR{
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px;
	font-weight:bold;
	text-align:right;
	background-color:#0080FF;
	 ;	
}
.granTotParL{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	text-align:left;
	background-color:#9DCEFF;
	color:#000000;
}
.granTotParR{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	text-align:right;
	background-color:#9DCEFF;
	color:#000000;	
}
.granTotCan{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	text-align:right;
	background-color:#FF0000;
	color:#000000;	
}
.detFacTr{
	font-family:Arial, Helvetica, sans-serif;
	font-size:16px;

}
.detFacL{
	text-align:left;
}
.detFacR{
	text-align:right;
}
-->
</style>

</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="">
  <?php

   $sqltar=mysqli_query($con ,"select * from valeryus19 where status='HUESPED' AND tex NOT IN (select gclave from ftarifas)");
  
  
  

  $numtar=mysqli_num_rows($sqltar);
  
 if ($numtar>0){
     ?>
                <div align="center"><span class="Estilo22" style="color:red">&iexcl;EXISTEN HABITACIONES SIN TARIFA !</span></div> 
          <?php
          while($reg = mysqli_fetch_array($sqltar)){
              echo 'cuarto: <b>'.$reg['fnumcto'].'</b><BR/>';

          }
  echo "<span style='color: red'>Debe Editar esas habitaciones, agregarle una tarifa, Guardar y vuelva a intentarlo </div> ";
 }
 elseif (isset($dt_empres['fec_alta']) && $dt_empres['fec_alta']==date('Y-m-d')){  ?>
  <div align="center"><span class="Estilo22">&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;LA AUDITORIA HA SIDO EJECUTADA !!!!!!!!</span></div> 
  <?php
 }else{ ?>
    <table width="441" border="0">
	<tr> <th colspan="2"><span class="Estilo20">REVISION DE MOVIMIENTOS</span> </th> 
	</tr>	
      <tr>
        <td colspan="2">
          <div align="center">
            
            
			<?php

  if (isset($_POST['buscal'])  or isset($_POST['buscar']) or isset($_POST['buscar2']) or isset($_POST['buscar4']) or isset($_POST['buscar3'])){
  
			}else{
	echo "<input name='buscar' type='submit' class='styTabEspA' onClick='openpage('aud_revision_PR.php','_self')' value='Empezar'/>";
			}
			?>
			<!--input name="bot4" type="button" class="boton" onClick="openpage('aud_revision_IM.php','_self')" value="Imprimir "/-->
           
		  </div></td>
      </tr>
    </table>
     
  </form>
</div>
<div align="center">
  <form method="post" action="" name="frm3" id="frm3" >
 <table border="0" width="100%"> 
 <?php
 if ( isset($_POST["buscar"])){
	$fecIni=chfecha(isset($_POST['fecini'])?$_POST['fecini']:"",'d/m/Y','Y-m-d'); /*($_POST['fecini']*/
	$fecFin=chfecha(isset($_POST['fecfin'])?$_POST['fecfin']:"",'d/m/Y','Y-m-d');
//        if(!isset($dt_empres['fec_alta']))$dt_empres['fec_alta']="";
        $vfa=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	$arrBus[]="dgpemema.fec_ven='".$vfa."' AND dgpemema.cancelado<>1 and cancela<>1 and pagado<>'S'";	
	
 	$WHERE="WHERE ".implode(" AND ",$arrBus);
//CONCAT(dgcatven.nom_ven,' ',dgcatven.ap_pat_ven,' ',dgcatven.ap_mat_ven) as nomVen,			
	@$sql = mysqli_query($con ,"
		SELECT 
			dgpemema.fol_ven,
			dgpemema.con_ven,
			dgpemema.tip_ven,
			dgpemema.fec_ven,
			dgpemema.cod_ven,
			dgpemema.iva_ven,
			ctmeser.np_desc1 as nomVen,
			dgpemema.tot_ven,
			dgpemema.imp_pag,
			dgpemema.sub_ven,
			fpos.mesa as mesa,
			ctmesas.np_desc1 as dmesa,
			ctarea.np_desc1 as  darea,
			ptventa.np_desc1 as dptvta,
			dgger_cajerosj.acc_hor as hora,
			fpropina.tip as propina,
			dgger_cajerosj.tip_mov as tipag,
			dgtippag.desc_pag as descpag,
			dgpemema.cancela as cancela
		FROM 
			dgpemema
			LEFT JOIN fpos ON fpos.fol_ven=dgpemema.fol_ven
			LEFT JOIN ctmesas ON ctmesas.nparte1=fpos.mesa
			LEFT JOIN ctarea ON ctarea.nparte1=ctmesas.area
			LEFT JOIN ctmeser  ON ctmeser.nparte1=dgpemema.cod_ven
			LEFT JOIN ptventa ON ptventa.nparte1=ctmesas.descripcion
			LEFT JOIN dgger_cajerosj ON dgger_cajerosj.pedido=dgpemema.fol_ven		
			LEFT JOIN  fpropina ON fpropina.fol_ven=dgpemema.fol_ven	
			LEFT JOIN  dgtippag ON dgtippag.tip_pag=dgger_cajerosj.tip_mov								
			left JOIN dgcatven ON dgpemema.cod_ven=dgcatven.cod_ven
			
		$WHERE
		ORDER BY 
			dgpemema.con_ven");
	echo mysqli_error($con);
//	".$dt_empres['fec_alta']."
if (mysqli_num_rows($sql)!=0)
{?>
    	<tr>
        	<th colspan="16">
          	<div align="left">
            	<input type="button" name="bot4" value="Imprimir" onClick="envia2('restaurant/AUD10000_IM.php','_self','frm3')">
          	</div>		PUNTOS DE VENTA	</th>
      	</tr>

	 	<tr class="typeagre">
	 	  <td colspan="11" class="granTotCan"><div align="center" style="background:#FFFFFF">¡¡¡¡¡¡EXISTEN CUENTAS ABIERTAS EN LOS PUNTOS DE VENTA!!!!!!</div></td>
	 	</tr>

	 	<tr class="typeagre">
	 	  <td><div align="center">Num. Ord.</div></td>
		  <td>Alimentos</td>
		  <td><div align="center">Extras</div></td>
 		  <td><div align="center">Bebidas</div></td>
		  <td><div align="center">Precio Unitario</div></td>
  		  <td><div align="center">P.U. con Descuento</div></td>
		  <td>Cortesia</td>
		  <td>Propina</td>		  
		  <td>Subtotal</td>
		  <td>Iva</td>
  		  <td>Total</td>
	 	</tr>

<?php
 
	while($reg = mysqli_fetch_array($sql)){
//------suma de productos
	@$s = mysqli_query($con ,"SELECT SUM(dgpememd.pre_bas*dgpememd.can_ref) as sumat FROM dgpememd, dgger_cajerosj, dgpemema WHERE dgpememd.cons_ven='".$reg['fol_ven']."' and dgger_cajerosj.pedido='".$reg['fol_ven']."' and dgpememd.cons_ven=dgpemema.fol_Ven and dgpemema.cancelado=0 and dgger_cajerosj.cancelado=0 and dgpemema.cancelado!=1");
		echo mysqli_error($con);
		while($r = mysqli_fetch_array($s)){
		$suma=$r["sumat"];
		}
////---------------------------------	

//------suma de productos solo cortesia
	@$cr = mysqli_query($con ,"SELECT SUM(dgpememd.pre_bas*dgpememd.can_ref) as sumat FROM dgpememd, dgger_cajerosj, dgger_cajerosd, dgpemema WHERE dgpememd.cons_ven='".$reg['fol_ven']."' and dgpememd.cons_ven=dgger_cajerosj.pedido and dgger_cajerosj.n_rec=dgger_cajerosd.n_rec and dgger_cajerosd.tip_pag=3 and dgger_cajerosj.cancelado=0 and dgpemema.cancelado!=1");
		echo mysqli_error($con);
		while($ccr = mysqli_fetch_array($cr)){
		$sumacr=$ccr["sumat"];
		}
////---------------------------------
		@$sq = mysqli_query($con ,"SELECT dgpememd.*,dginventp.np_desc1 FROM dgpememd INNER JOIN dginventp ON dgpememd.nparte1 = dginventp.nparte1 WHERE dgpememd.cons_ven='".$reg['fol_ven']."' and cancela=0 order by dginventp.np_desc1");
		echo mysqli_error($con);
		while($rg = mysqli_fetch_array($sq)){
			echo '<tr class="detFacTr">';
			echo '<td class="detFacR">'.$reg["con_ven"].'&nbsp;</td>'; //orden
			//echo '<td class="detFacR">'.$rg["can_ref"].'&nbsp;</td>';		//cant	 
		@$al = mysqli_query($con ,"SELECT * from dginventp where np_desc1='".$rg['np_desc1']."' and (linea!=44 and linea!=3)"); //and gpo_basico!=82
		$al1 = mysqli_fetch_array($al);
			echo '<td class="detFacL">'.$al1['np_desc1'].'&nbsp;</td>';  //desc alim
		@$ex = mysqli_query($con ,"SELECT * from dginventp where np_desc1='".$rg['np_desc1']."' and linea=44"); //and gpo_basico=82
		$ex1 = mysqli_fetch_array($ex);
			echo '<td class="detFacL">'.$ex1['np_desc1'].'&nbsp;</td>';  //desc ext
		@$beb = mysqli_query($con ,"SELECT * from dginventp where np_desc1='".$rg['np_desc1']."' and linea=3"); //and gpo_basico=82
		$beb1 = mysqli_fetch_array($beb);
			echo '<td class="detFacL">'.$beb1['np_desc1'].'&nbsp;</td>';  //desc ext			
			echo '<td class="detFacR">'.number_format(($rg["pre_bas"]*$rg["can_ref"]),2,'.',',').'</td>';  //precio unit
			echo '<td class="detFacR">'.number_format(($rg["total_cd"] - $rg["iva_pre"]),2,'.',',').'</td>';  //desceunto 
			echo '<td class="detFacR"></td>';			
			echo '<td class="detFacR"></td>';						
			echo '</tr>';		
			$des=$rg["por_des"];
			$total=$rg["total_cd"];
			$desc=$rg["cancelado"];
		} //una venta
		
		//impresion de reportes cancelados
	if (($reg["imp_pag"]==0.00) && ($reg["cancela"]==1)) {
		echo '<tr class="granTotCan">';
		echo '<td class="granTotCan">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotCan" >'.chfecha($reg['fec_ven'],'Y-m-d','d/m/Y').'&nbsp;</td>';	//fecha		
		echo '<td class="granTotCan" colspan="2" >'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		echo '<td class="granTotCan" colspan="7"><div align="center">   C A N C E L A D O  </div> </td>';  //cortesia
		echo '</tr>';		
		$granCorVenc +=$sumacr;  //cortesia
		$granTotVenc +=$suma;  //subtotal
		$granPagVenc +=$reg["iva_ven"];  //iva
		$granSalVenc +=($reg["tot_ven"]);  //total
		$granProc    +=($reg["propina"]);  //propina	
		$numVen++;
	} else {
		echo '<tr class="granTotParR">';
		echo '<td class="granTotParR">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotParL" >'.chfecha($reg['fec_ven'],'Y-m-d','d/m/Y').'&nbsp;</td>';	//fecha		
		echo '<td class="granTotParL" colspan="2" >'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		echo '<td class="granTotParR"></td>'; //subtotal
		echo '<td class="granTotParL" colspan="3">'.$reg['dptvta'].'</td>';  //punto vta
		echo '<td class="granTotParL" colspan="3">'.$reg["dmesa"].'</td>';  //mesa
/*
				//saldo			
*/

		echo '</tr>';				
		
			///--------------------rep cancelados----------
//		$granDesVen +=$des;  //descuento
		$granCorVen +=$sumacr;  //cortesia
		$granTotVen +=$suma;  //subtotal
		$granPagVen +=$reg["iva_ven"];  //iva
		$granSalVen +=($reg["tot_ven"]);  //total
		$granPro    +=($reg["propina"]);  //propina				
		$numVen++;
		}
		
		
	
	} //totales
	echo "<tr> 
			<td class=\"granTotL\" colspan=\"6\">Numero Ventas: $numVen</td>  						
			<td class=\"granTotR\">".number_format($granCorVen,2,'.',',')."</td>  	
			<td class=\"granTotR\">".number_format($granPro,2,'.',',')."</td> 						
			<td class=\"granTotR\">".number_format($granTotVen-$granCorVen,2,'.',',')."</td>  						
			<td class=\"granTotR\">".number_format($granPagVen,2,'.',',')."</td>						
			<td class=\"granTotR\"></td>												
		</tr>";
		//".number_format(($granSalVen-$granCorVen)+$granPro,2,'.',',').

}else if(mysqli_num_rows($sql)==0){  
echo '<h2>!!! NO SE HA ENCONTRADO CUENTAS ABIERTAS EN PUNTOS DE VENTA !!!</h2>';
 echo '<input name="buscal" id="buscal" type="submit" class="styTabEspA" value="Siguiente"/>';
} 

			
}

?> 
</table>  
    <?php

	$fecha = $vfa; /*$dt_empres['fec_alta'];*/
	$fechita = chfecha($fecha,'Y-m-d','d/m/Y');
	//$fec = date("d/m/Y");
	//include('DF20000.php');
	//$fecha = $f_m;
	
	if(isset($_POST['buscal'])){
	$dt_user=mysqli_fetch_array(mysqli_query($con ,"SELECT count(*) as numRows FROM valeryus19 WHERE (status='RESERVA INDIVIDUAL' or status= 'RESERVA GRUPO') AND ffecllegada = '$fecha' AND cancelado ='0' ORDER BY n_reg"));
	if($dt_user['numRows'] == 0){
	echo '<h2>!!! NO SE HA ENCONTRADO NINGUNA RESERVA QUE ENTRE EL DIA HOY !!!</h2>';
	echo '<input name="buscar2" id="buscar2" type="submit" class="styTabEspA" value="Siguiente"/>';
	}else{
	@$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE (status='RESERVA INDIVIDUAL' or status='RESERVA GRUPO') AND ffecllegada = '$fecha' and cancelado = '0' ORDER BY n_reg");
	
	?>
    <table width="1057"   align="center" >
      <tr>
        <th colspan="13">
          <div align="center">REPORTE DE RESERVACIONES CON FECHA DE ENTRADA DE <?php
echo "".$fechita."";?></div></th></tr>
      <tr>
        <th width="50"><div align="center">FOLIO.</div></th>
		<th width="190"><div align="center">CLIENTE.</div></th>
		<th width="40"><div align="center">ADUL.</div></th>
		<th width="35"><div align="center">MEN.</div></th>
		<th width="35"><div align="center"> HAB.</div></th>
		<th width="50"><div align="center">TIPO.</div></th>
		<th width="35"><div align="center">G/NG</div></th>
		<th width="70"><div align="center">FECHA DE LLEGADA</div></th>
		<th width="70"><div align="center">FECHA DE SALIDA.</div></th>
		<th width="80"><div align="center">FORMA DE PAGO.</div></th>
		<th width="60"><div align="center">TARIFA.</div></th>
		<th width="200"><div align="center">NOTAS.</div></th>
	  </tr>
	<?php

	include("DE10000.php");
	while($reg = mysqli_fetch_array($result))
	{
	  	echo "<tr>";
		echo "<td> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "&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>";
		echo "<td> <div align='center'><strong>" . $reg[""] . "&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['ftotal'], 2, '.', ',') . "</strong></div></td>";
	    echo "<td> <div align='center'><strong>" . $reg["fnorasvip"] . "&nbsp;</strong></div></td></tr>";
	}
	}
	?>
	</table>
	<?php

	}if(isset($_POST['buscar2'])){
	//$fec = date("d/m/Y");
	//include('DF20000.php');
	//$fecha = $f_m;
        
	$fecha = $vfa;/*$dt_empres['fec_alta'];*/
	$fechita = chfecha($fecha,'Y-m-d','d/m/Y');
	$dt_user=mysqli_fetch_array(mysqli_query($con ,"SELECT count(*) as numRows FROM valeryus19 WHERE (status='HUESPED' or status='MISCELANEOS') AND ffecsalida = '$fecha'"));
	if($dt_user['numRows'] == 0){
	echo '<h2>!!! NO SE HA ENCONTRADO NINGUN HUESPED CON FECHA DE SALIDA DE HOY !!!</h2>';
	
	echo '<input name="buscar4" id="buscar4" type="submit" value="Buscar Salidas OCO" class="styTabEspA"/>';
	}else{
	@$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE (status='HUESPED' OR status='MISCELANEOS') AND ffecsalida = '$fecha'");
	?>
	<table width="1057"   align="center" >
      <tr>
        <th colspan="13">REPORTE DE HUESPEDES CON FECHA DE SALIDA DE <?php
echo "".$fechita."";?></th></tr>
      <tr>
        <th width="50"><div align="center">FOLIO.</div></th>
		<th width="190"><div align="center">CLIENTE.</div></th>
	
		<th width="40"><div align="center">ADUL.</div></th>
		<th width="35"><div align="center">MEN.</div></th>
		<th width="35"><div align="center"> HAB.</div></th>
		<th width="50"><div align="center">TIPO.</div></th>
		<th width="35"><div align="center">G/NG</div></th>
		<th width="70"><div align="center">FECHA DE LLEGADA</div></th>
		<th width="70"><div align="center">FECHA DE SALIDA.</div></th>
		<th width="80"><div align="center">FORMA DE PAGO.</div></th>
		<th width="60"><div align="center">TARIFA.</div></th>
		<th width="200"><div align="center">NOTAS.</div></th>
	  </tr>
	<?php

	include("DE10000.php");
	while($reg = mysqli_fetch_array($result))
	{
	  	echo "<tr>";
		echo "<td> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "&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>";
		echo "<td> <div align='center'><strong>" . $reg[""] . "&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['ftotal'], 2, '.', ',') . "</strong></div></td>";
	    echo "<td> <div align='center'><strong>" . $reg["fnorasvip"] . "&nbsp;</strong></div></td></tr>";
	}
	
	}
	?>
	</table>
	<?php

	}
	
	if(isset($_POST['buscar4'])){
	
	$fecha = $vfa;
	$fechita = chfecha($fecha,'Y-m-d','d/m/Y');
	
	function sumaDia($fecha,$dia){	
	list($year,$mon,$day) = explode('-',$fecha);	
	return date('Y-m-d',mktime(0,0,0,$mon,$day+$dia,$year));		
	} 
	
	$nueva_fecha = sumaDia($fecha,1);//salida: 2008-02-04 
	$nueva = chfecha($nueva_fecha,'Y-m-d','d/m/Y');

	$dt_user=mysqli_fetch_array(mysqli_query($con ,"SELECT count(*) as numRows FROM valeryus19 WHERE status = 'HUESPED' AND ffecsalida = '$nueva_fecha'"));
	if($dt_user['numRows'] == 0){
	echo '<h2>!!! NO SE HA ENCONTRADO NINGUN HUESPED CON FECHA DE SALIDA DE MAÑANA !!!</h2>';
	echo '<input name="buscar3" id="buscar3" type="submit" value="Cargar Renta Y Cambiar Dia" class="styTabEspA"/>';
	
	}else{
	$kjksk = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'HUESPED' AND ffecsalida = '$nueva_fecha'");
	while ($jdkjs = mysqli_fetch_array($kjksk)){
	$loodj = $jdkjs['fnumcto'];
	$kkslk = mysqli_query($con ,"update valeryus08 set status='OCO' where ncto = '$loodj'");
	}
	
	@$result = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'HUESPED' AND ffecsalida = '$nueva_fecha'");
	?>
	<table width="1057"   align="center" >
      <tr>
        <th colspan="13">REPORTE DE HUESPEDES CON FECHA DE SALIDA DE <?php
echo "".$nueva."";?></th></tr>
      <tr>
        <th width="50"><div align="center">FOLIO.</div></th>
		<th width="190"><div align="center">CLIENTE.</div></th>
	    <th width="40"><div align="center">ADUL.</div></th>
		<th width="35"><div align="center">MEN.</div></th>
		<th width="35"><div align="center"> HAB.</div></th>
		<th width="50"><div align="center">TIPO.</div></th>
		<th width="50"><div align="center">STATUS.</div></th>

		<th width="70"><div align="center">FECHA DE LLEGADA</div></th>
		<th width="70"><div align="center">FECHA DE SALIDA.</div></th>
		
		<th width="200"><div align="center">NOTAS.</div></th>
	  </tr>
	<?php

	include("DE10000.php");
	while($reg = mysqli_fetch_array($result))
	{
	  	echo "<tr>";
		echo "<td> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $reg["fapellido"] . ' '. $reg["fnombre"] . "&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>";
		$wej = $reg["fnumcto"];
		$qzp = mysqli_fetch_array(mysqli_query($con ,"select * from valeryus08 where ncto = '$wej'"));
		echo "<td> <div align='center'><strong>" . $qzp["nstaamalla"] . "&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["fnorasvip"] . "&nbsp;</strong></div></td></tr>";
	}
	
	echo '<input name="buscar3" id="buscar3" type="submit" value="Cargar Renta Y Cambiar Dia" class="styTabEspA"/>';
	
	}
	?>
	</table>
	<?php	
	}
	
	if (isset($_POST['buscar3'])){
	?>
	<table width="1057"   align="center" >
      <tr>
        <th colspan="13">FOLIOS A LOS QUE CARGO RENTA</th></tr>
      <tr>
        <th width="50"><div align="center">FOLIO</div></th>
		<th width="190"><div align="center">CLIENTE</div></th>
		<th width="60"><div align="center">NUM HABTACION</div></th>
		<th width="40"><div align="center">TIPO HABITACION</div></th>
		<th width="35"><div align="center">TOTAL DIAS</div></th>
		<th width="70"><div align="center">TARIFA APLICADA</div></th>
		<th width="70"><div align="center">TOTAL</div></th>
	  </tr>
	<?php

	$fecha1 = $vfa;
	$asdfj = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE (status='HUESPED' OR status='MISCELANEOS') ORDER BY fnumcto");
	while ($qwkjd = mysqli_fetch_array($asdfj)){
	//$sql_rt=mysqli_query($con ,"select * from valeryus030 where nparte1='".$qwkjd['n_reg']."' and nparte1_det between 1 and 2 and acc_fec='$fecha1' and cancelado = '0' and can_ref != 'AUT' and costo > '0'");
	 //mysqli_num_rows($sql_rt);
	//if (mysqli_num_rows($sql_rt)==0){
	$jhdsk = $qwkjd["n_reg"];
	$mercado = $qwkjd["fcodmeca"];
	$grupo = $qwkjd["fcodgrupo"];
	$agencia = $qwkjd["fcodagen"];
	$segmento = $qwkjd["codseg"];
	$smerf=$qwkjd["smerf"];
	
	$akdjj1 = $qwkjd["tex"];//tarifa
	
    $fecha1 = $vfa;
	$fecha = chfecha($fecha1,'Y-m-d','d/m/Y');
    $today = date('l', strtotime($fecha1));
	
	$newTar=mysqli_query($con ,"select * from ftarifas where gclave='$akdjj1'");
	$arayTar=mysqli_fetch_array($newTar);
	
	if ($arayTar['manual']=='SI'){
	
	$msdjj = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref, mercado, grupo, agencia, segmento, smerf)values('$jhdsk', '1', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '".$qwkjd['tex4']."', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	
	}else{
	
	$desTar=mysqli_query($con ,"select * from ftarifad where nparte1='".$arayTar['n_reg']."'");
	while($detTar=mysqli_fetch_array($desTar)){
	
	$msdjj = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref, mercado, grupo, agencia, segmento, smerf)values('$jhdsk', '".$detTar['nparte1_det']."', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '".$detTar['costo']."', 'AUT', '$mercado', '$grupo', '$agencia', '$segmento', '$smerf')");
	}
	}
	
	if ($qwkjd['ftarifaxa']!=''){
	$paxAdu=mysqli_query($con ,"select * from ftarifas where gdescrip='".$qwkjd['ftarifaxa']."'");
	$newPax=mysqli_fetch_array($paxAdu);
	
	$detAdu=mysqli_query($con ,"select * from ftarifad where nparte1='".$newPax['n_reg']."'");
	while($tarAdu=mysqli_fetch_array($detAdu)){
	$newTarPax=$tarAdu['costo']*$qwkjd['fnumadulx'];
	$adultos=mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref, mercado, grupo, agencia, segmento, smerf)values('$jhdsk', '".$tarAdu['nparte1_det']."', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$newTarPax', 'AUT-PX', '$mercado', '$grupo', '$agencia', '$segmento', '$smerf')");
	}
	}if($qwkjd['ftarifaxm']!=''){
	$paxMen=mysqli_query($con ,"select * from ftarifas where gdescrip='".$qwkjd['ftarifaxm']."'");
	$newPam=mysqli_fetch_array($paxMen);
	
	$detMen=mysqli_query($con ,"select * from ftarifad where nparte1='".$newPam['n_reg']."'");
	while($tarMen=mysqli_fetch_array($detMen)){
	$newTarMen=$tarMen['costo']*$qwkjd['fnummenorx'];
	$menores = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref, mercado, grupo, agencia, segmento, smerf)values('$jhdsk', '".$tarMen['nparte1_det']."', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$newTarMen', 'AUT-PX', '$mercado', '$grupo', '$agencia', '$segmento', '$smerf')");
	}
		}
	
	$sqo=mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1='$jhdsk' and (cancelado='0' or cancelado='2')"));
	
	$sqy = mysqli_query ($con ,"UPDATE valeryus19 SET suma = '".$sqo['total']."' WHERE n_reg = '$jhdsk'");
	
	    $kdjfk = mysqli_fetch_array(mysqli_query($con ,"select sum(costo) as hoy from valeryus030 where nparte1 = '$jhdsk' and acc_fec = '$fecha1'"));
		echo "<tr>";
		echo "<td> <div align='center'><strong>" . $qwkjd["n_reg"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'>" . $qwkjd["fnombre"] . ' '. $qwkjd["fapellido"] . "&nbsp;</div></td>";
		echo "<td> <div align='center'><strong>" . $qwkjd["fnumcto"] . "&nbsp;</strong></div></td>";
		$ama=mysqli_query($con ,"update valeryus08 set ocupado='#FF0000', nstaamalla='SUCIO', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= 'AUDITORIA' where ncto='".$qwkjd['fnumcto']."'");
		echo "<td> <div align='center'><strong>" . $qwkjd["ftipocto"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $qwkjd["tex4"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $qwkjd["text4"] . "&nbsp;</strong></div></td>";	
		$fec1=$qwkjd["ffecllegada"];
		include('DF20000.php');
		echo "<td> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
		echo "<td> <div align='center'><strong>" . $kdjfk['hoy'] . "&nbsp;</strong></div></td>";
	    echo "<td> <div align='center'><strong>" . $qwkjd["ftotal"] . "&nbsp;</strong></div></td></tr>";
	
	}
	
	//}
	
	$llaves=mysqli_query($con ,"select fnumcto from valeryus19 where status='HUESPED'");
	while ($sucio=mysqli_fetch_array($llaves)){
	
	$sucios=mysqli_query($con ,"update valeryus08 set ocupado='#FF0000', nstaamalla='SUCIO', status='AUD', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario='AUDITORIA' where ncto='".$sucio['fnumcto']."' and status!='OCO'");
	
	}
	
	$regresar=mysqli_query($con ,"update valeryus19 set tus='OUT' where tus='IN' and status='HISTORICO'");
	
	$fecha1 = $vfa;
	$fec = chfecha($fecha1,'Y-m-d','d/m/Y');
	
	function sumaDia($fecha,$dia){	
	list($year,$mon,$day) = explode('-',$fecha);	
	return date('Y-m-d',mktime(0,0,0,$mon,$day+$dia,$year));		
	} 
	
	$wert = sumaDia($fecha1,1);//salida: 2008-02-04 
	$lkj = chfecha($wert,'Y-m-d','d/m/Y');
	//$akjdk = mysqli_query($con ,"update dxempres set fec_alta='$wert' WHERE cla_emp = '".$_SESSION['empresa']."'");
$akjdk = mysqli_query($con ,"update dxempres set fec_alta=DATE_ADD(fec_alta, INTERVAL 1 DAY)");


	?>
	<h2>
  <label>
	A CAMBIADO LA FECHA EL DIA DE HOY ES:
	</label>
	</h2>
	<h2>
	<label>
	<?php

	echo whatDay($wert).', '.chfecha($wert,'Y-m-d','d de M de Y');
	?>
	</label>
	</h2>
	<?php

//	echo '<meta content="1; url=cerrar.php" HTTP-EQUIV="REFRESH">';
	} 
	mysqli_close($con);
	?>
    </table>
<?php
 
}
 ?>	
  </form>
</div>
</body>
</html>
