<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
?>
<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>
</HEAD>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<body>
<?php
 
$ayuda = 'DV3300A_PR.php';
include("DYAYUDA.php");
?>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
  <?php

//  echo $dt_empres['fec_alta'];
  echo date('Y-m-d');
   if ($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['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="" >
    <?php

	$fecha = $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['buscar'])){
	$dt_user=mysqli_fetch_array(mysqli_query($con ,"SELECT count(*) as numRows FROM valeryus19 WHERE status = 'RESERVA INDIVIDUAL' AND ffecllegada = '$fecha' AND cancelado ='0'"));
	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' AND ffecllegada = '$fecha' and cancelado = '0'");
	
	?>
    <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 = $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' 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="buscar3" id="buscar3" type="submit" value="Cargar Renta" class="styTabEspA"/>';
	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' 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 = $dt_empres['fec_alta'];
	$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 nstaamalla = '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>
	<?	
	}
	
	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 = $dt_empres['fec_alta'];
	$asdfj = mysqli_query($con ,"select * from valeryus19 where status = 'HUESPED' and folio = 'RENTAS' and ffecllegada != '$fecha1' and ffecllegada < '$fecha1'");
	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"];
	
	
	$sfggh1 = $qwkjd["tex4"];//alta viernes y sabados
	$sfggh  = $sfggh1/1.18; 
	$lñask = $sfggh * 0.02;
 	$skdji = $sfggh * 1.16;
	
	$akdjj1 = $qwkjd["text4"];//baja
	$akdjj	= $akdjj1/1.18;
 	$skdja = $akdjj * 0.02;
 	$saooj = $akdjj * 1.16;
	
	if ($qwkjd["tex4"] == 0 && $qwkjd["text4"] != 0){
	$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']."', '$saooj', 'AUT','$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$skdja', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	}
	
	if ($qwkjd["text4"] == 0 && $qwkjd["tex4"] != 0){
	$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']."', '$skdji', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$lñask', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	}
	
	if 	 ($asd["text4"] != 0 && $asd["tex4"] != 0){
    $fecha1 = $dt_empres['fec_alta'];
	$fecha = chfecha($fecha1,'Y-m-d','d/m/Y');
    $today = date('l', strtotime($fecha1));
	
	if ($today == "Sunday"){
	$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']."', '$saooj', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$skdja', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	echo mysqli_error($msdjj);
	}if ($today == "Monday"){
	$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']."', '$saooj', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$skdja', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	}if ($today == "Tuesday"){
	$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']."', '$saooj', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$skdja', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	}if ($today == "Wednesday"){
	$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']."', '$saooj', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$skdja', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	}if ($today == "Thursday"){
	$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']."', '$saooj', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$skdja', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	}if ($today == "Friday"){
	$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']."', '$skdji', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$lñask', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' WHERE n_reg = '$jhdsk'");
	}if ($today == "Saturday"){
	$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']."', '$skdji', 'AUT', '$mercado','$grupo','$agencia','$segmento','$smerf')");
	$aloqi = mysqli_query($con ,"insert into valeryus030 (nparte1, nparte1_det, acc_fec, acc_hor, usuario, costo, can_ref,mercado,grupo,agencia,segmento,smerf)values('$jhdsk', '2', '$fecha1', '".date('H:i:s')."', '".$_SESSION['usuario']."', '$lñask', 'AUT', '$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'"));
	$sxc = mysqli_fetch_array(mysqli_query($con ,"SELECT SUM(costo) AS total FROM valeryus030 WHERE nparte1 = '$jhdsk' and cancelado = '2'"));
	$kskjk = $sqo['total'] + $sxc['total'];
	$sqy = mysqli_query ("UPDATE valeryus19 SET suma = '$kskjk' 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>";
		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>";
	
	}
	
	}
	
	

	$fecha1 = $dt_empres['fec_alta'];
	
	$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 geoyos_jc.dxempres set fec_alta='$wert' WHERE cla_emp = '".$_SESSION['empresa']."'");
	?>
	<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="2; url=cerrar.php" HTTP-EQUIV="REFRESH">';
	} 
	mysqli_close($con);
	?>
    </table>

<?php
 
}
 ?>	
  </form>
</div>
</body>
</html>