<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
$date=$_GET['back'];
//echo $date;
$da_te = chfecha($date,'Y-m-d','d/m/Y');
//echo $da_te;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<style type="text/css">
BODY {
SCROLLBAR-FACE-COLOR:#0000CC; SCROLLBAR-HIGHLIGHT-COLOR:#00CCFF; SCROLLBAR-SHADOW-COLOR:#0000CC; SCROLLBAR-3DLIGHT-COLOR:#0000CC; SCROLLBAR-ARROW-COLOR:#FFFFFF; SCROLLBAR-TRACK-COLOR:#FFFFFF; SCROLLBAR-DARKSHADOW-COLOR: #330000
}
.Estilo3 {font-size: 16px}
</style>
<?php
 
$ayuda = 'DG1110A_PR.php';
include("DYAYUDA.php");
?>
<body>
<div align="center">
  <form name="form1" method="post" action="">
    <table width="433" border="0" align="center">
      <tr>
        <th colspan="2"><span class="Estilo3">REGISTRO DE RESERVACIONES INDIVIDUALES</span> </th>
      </tr>
      <tr>
        <th>FECHA DE LLEGADA </th>
        <th><div align="left">
          <input name="r1" type="radio" value="fecha" tabindex="2" <? if($_POST['r1']=='fecha') echo 'checked'; elseif ($date!='') echo 'checked';?>>
        <input name="fec" type="text" class="emplea" id="fec" size="9" maxlength="20"
			
			<?php

				$fecha = $dt_empres['fec_alta'];
	            $fechita = chfecha($fecha,'Y-m-d','d/m/Y');
				
				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}elseif($date==''){
					echo 'value="'.$fechita.'"';
				}else{
				    echo 'value="'.$da_te.'"';
				}
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
            <input name="bot" id="bot" type="image" value=" ... " src="logos/cal4.jpg"/>
        <script type="text/javascript">
  Calendar.setup(
    {
      inputField  : "fec",        // ID of the input field
      ifFormat    : "%d/%m/%Y",    // the date format
      button      : "bot"      // ID of the button
    }
  );
            </script>
        <input name="fec2" type="text" class="emplea" id="fec2" size="9" maxlength="20"
			
			<?php

				$fecha = $dt_empres['fec_alta'];
	            $fechita = chfecha($fecha,'Y-m-d','d/m/Y');
				
				if(isset($_POST['fec2'])){ //este es el truco
					echo 'value="' . $_POST['fec2'] .  '"';
				}elseif($date==''){
					echo 'value="'.$fechita.'"';
				}else{
				    echo 'value="'.$da_te.'"';
				}
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
            <input name="bot1" id="bot1" type="image" value=" ... " src="logos/cal4.jpg"/>
        <script type="text/javascript">
  Calendar.setup(
    {
      inputField  : "fec2",        // ID of the input field
      ifFormat    : "%d/%m/%Y",    // the date format
      button      : "bot1"      // ID of the button
    }
  );
            </script>
        </div></th>
      </tr>
      <tr>
        <th> APELLIDO DEL CLIENTE</th>
        <th><div align="left">
          <input name="r1" type="radio" value="nombre" tabindex="2">
        </div></th>
      </tr>
      <tr>
        <th>NUMERO DE FOLIO </th>
        <th><label>
          <div align="left">
            <input name="r1" type="radio" value="folio">
            </div>
        </label></th>
      </tr>
      <tr>
        <th width="204">          NUMERO DE HABITACION </th>
        <th width="219"><div align="left">
          <input name="r1" type="radio" value="clave" tabindex="1">
        </div></th>
      </tr>
      <tr>
        <td colspan="2">
		<img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" />
		<input name="tbus" type="text" onBlur="may(this)" size="55"/></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 name="frm1" method="post" action="" >
	<?php
 
	    $fec = $_POST['fec'];
		include('DF20000.php');
		$fecha_inicial = $f_m; 
		$fec = $_POST['fec2'];
		include('DF20000.php');
		$fecha_final = $f_m;  
	if(isset($_POST['Submit'])){
	$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'RESERVA INDIVIDUAL' ORDER BY fnumcto");
	include("DE10000.php");
	}elseif($date!=''){
	$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'RESERVA INDIVIDUAL' and cancelado = '0' and ffecllegada='$date' ORDER BY fnumcto");
	//echo "SELECT * FROM valeryus19 WHERE status = 'RESERVA INDIVIDUAL' and ffecllegada=".$fecha_inicial." ORDER BY fnumcto";
//	echo $date;
$da_te = chfecha($date,'d/m/Y','Y-m-d');
//$fechita = chfecha($fecha,'Y-m-d','d/m/Y');
//echo $da_te;
	}else{
	$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE status = 'RESERVA INDIVIDUAL' and cancelado = '0' ORDER BY fnumcto");
	include("DE10000.php");
	}
	
	?>
    <table width="689" border='1' cellpadding="0" cellspacing="0">
      <tr>
        <th colspan="11"> <div align="center">
          <input name="Submit6" type="button" class="form" onClick="openpage('res_registro_AG.php','_self')" value="Agregar"/>
          <input name="bot3" type="Submit" class="form"  onClick="openpage('res_registro_CO.php','_self')" value="Consultar"/>
          <input name="bot2" type="button" class="form" onClick="openpage('res_registro_ACEX.php?fecha=<? echo $_POST['fec']; ?>','_self')" value="Modificar"/>
          <input name="bot1" type="button" class="error" onClick="openpage('res_registro_EL.php','_self')" value="Cancelar"/>
          <input name="Submit" type="submit" class="form" id="Submit" onClick="openpage('res_registro_PR.php','_self')" value="Canceladas"/>
		  <input name="bot4" type="button" class="form" onClick="openpage('res_registro_IM.php','_self')" value="Papeleta Reservas"/>
		  <input name="bot44" type="button" class="form" onClick="openpage('rec_checkin_IM.php','_self')" value="Tarjeta de Registro"/>
          <input name="bot442" type="button" class="form" onClick="openpage('valeryus61000_IM.php','_self')" value="Carta Confirmacion"/>
        </div></th>
      </tr>
      <tr>
        <th colspan="11" ><strong>REGISTRO DE RESERVACIONES INDIVIDUALES </strong></th>
      </tr>
      <tr>
        <th width="33" height="32"><div align="center">A</div></th>
        <th width="53"><div align="center">B</div></th>
        <th width="102"><div align="center">C</div></th>
        <th width="64"><div align="center">D</div></th>
		<th width="131"><div align="center">E</div></th>
		<th width="92"><div align="center">F</div></th>
		<th width="89"><div align="center">G</div></th>
		<th width="107"><div align="center">H</div></th>
		<th width="107"><div align="center">I</div></th>
		<th width="107"><div align="center">J</div></th>
		<th width="107"><div align="center">K</div></th>
      </tr>
      <?php

	
	echo '<input name="txt_bus" type="hidden" value="'.$_POST['tbus'].'">';
	if($_POST['r1']=="clave")
	{
		echo '<input name="tip_bus" type="hidden" value="clave">';
	  	@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto = '".$_POST['tbus']."' and status = 'RESERVA INDIVIDUAL' order by fnumcto");
		
	}elseif($_POST['r1']=="nombre")
	{
		echo '<input name="tip_bus" type="hidden" value="nombre">';
		@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fapellido like '%".$_POST['tbus']."%' AND status = 'RESERVA INDIVIDUAL' ORDER BY fapellido");
	}elseif($_POST['r1']=="fecha")
	{
		echo '<input name="tip_bus" type="hidden" value="fecha">';
		
		@$sql = mysqli_query($con ,"SELECT * FROM fposres order by id");
		
		//@$sql = mysqli_query($con ,"SELECT * FROM fimpresion order by nparte1");
		
		//@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 order by n_reg");
		
		//@$sql = mysqli_query($con ,"SELECT * FROM dgger_cajerosd where num_pag > '7242' order by num_pag limit 3250");
		
		//@$sql = mysqli_query($con ,"SELECT * FROM dgpememd where fol_ven1 > 19443 order by fol_ven1 limit 10000");
		
		//@$sql = mysqli_query($con ,"SELECT * FROM rspemema where fec_ven = '2012-12-31' order by fol_ven limit 5000");
		//@$sql = mysqli_query($con ,"SELECT * FROM fpropina where fol_ven>'11195' order by nparte1");
		
		//echo "SELECT * FROM dgpemema where fec_ven between '".$fecha_inicial."' and '".$fecha_final."'"; 
	}elseif($_POST['r1']=="folio")
	{
		echo '<input name="tip_bus" type="hidden" value="folio">';
		@$sql = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE n_reg = '".$_POST['tbus']."' AND status = 'RESERVA INDIVIDUAL' ORDER BY n_reg");
	}
	$a='0'; 
	
	while($reg = mysqli_fetch_array($sql))
	{
	$a++;
	  	echo "<tr>";
	
		echo "<td> <div align='center' style=' '>" . $reg["nparte1"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["mesa"] . "&nbsp;</div></td>";			
		echo "<td> <div align='center' style=' '>" . $reg["fol_ven"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["tip"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["acc_fec"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["acc_hor"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["usuario"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["status"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg["fol_unp"] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $reg[""] . "&nbsp;</div></td>";
		echo "<td> <div align='center' style=' '>" . $a . "&nbsp;</div></td>";
	    //$fpos=mysqli_query($con ,"update dgpemema set con_ven='$a' where fol_ven='".$reg['fol_ven']."'");
		//$fpos=mysqli_query($con ,"UPDATE pvrestip set status='".$reg['status']."', fol_unp='".$reg['fol_unp']."', acc_fec='".$reg['acc_fec']."', acc_hor='".$reg['acc_hor']."', usuario='".$reg['usuario']."' where nparte1='".$reg['nparte1']."' and fol_ven='".$reg['fol_ven']."'");
		//$fpos=mysqli_query($con ,"INSERT INTO pvrescad set num_pag='".$reg['num_pag']."', n_rec='".$reg['n_rec']."'");
		//$fpos=mysqli_query($con ,"UPDATE pvrescad set tdp='".$reg['tdp']."', acc_fec='".$reg['acc_fec']."', acc_hor='".$reg['acc_hor']."', usuario='".$reg['usuario']."', fol_unp='".$reg['fol_unp']."' where num_pag='".$reg['num_pag']."' and n_rec='".$reg['n_rec']."'");
		//$insert=mysqli_query($con ,"update pvresmema set fpos_mesa='".$reg['mesa']."' where fol_ven='".$reg['fol_ven']."'");
		//$insert=mysqli_query($con ,"update dgpemema set tip='".$reg['tip']."' where fol_ven='".$reg['fol_ven']."'");
		//$insert=mysqli_query($con ,"update pvresimp set mesa='".$reg['mesa']."', num_imp='".$reg['num_imp']."', acc_fec='".$reg['acc_fec']."', acc_hor='".$reg['acc_hor']."', usuario='".$reg['usuario']."', status='".$reg['status']."', clave='".$reg['clave']."' where fol_ven='".$reg['fol_ven']."' and nparte1='".$reg['nparte1']."'");
		//$insert = mysqli_query($con ,"UPDATE pvresmema set tip='".$reg['tip']."' where fol_ven='".$reg['fol_ven']."'");
		//$insert = mysqli_query($con ,"UPDATE pvresmema set por_des='".$reg['por_des']."', cancela='".$reg['cancela']."', cancelado='".$reg['cancelado']."', servicio='".$reg['servicio']."', mt_cancela='".$reg['mt_cancela']."' where fol_ven='".$reg['fol_ven']."' and con_ven='".$reg['con_ven']."'");
		//$insert = mysqli_query($con ,"insert into pvresmema set fol_ven='".$reg['fol_ven']."', con_ven='".$reg['con_ven']."'");
		//$insert = mysqli_query($con ,"update chart set ffecllegada='".$reg['ffecllegada']."', ffecsalida='".$reg['ffecsalida']."', fnumcto='".$reg['fnumcto']."', status='".$reg['status']."' where n_reg='".$reg['n_reg']."' and cancelado='".$reg['cancelado']."'");
		//$insert = mysqli_query($con ,"update respaldotel19 set fec_fac='".$reg['fec_fac']."', fnombre='".$reg['fnombre']."' where n_reg='".$reg['n_reg']."' and cancelado='".$reg['cancelado']."'");
		echo "</tr>";
		
		//$insert = mysqli_query($con ,"insert into pvresimp set nparte1='".$reg['nparte1']."', fol_ven='".$reg['fol_ven']."'");
		//$insert = mysqli_query($con ,"update fposres set nparte1='".$reg['nparte1']."', mesa='".$reg['mesa']."', usuario='".$reg['usuario']."' where id='".$reg['id']."' and fol_ven='".$reg['fol_ven']."'");
	}
	mysqli_close($con);
	?>
    </table>
  </form>
  </div>
</body>
</html>
<?php

//227-->200 ultima actualizacion 20/diciembre/2011 respetar agrupador por fehca
?>




<?  
/*session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
?>
<html>
<head>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<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:left;
	background-color:#FF0000;
	color:#000000;	
}
.granTotAb{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	font-weight:bold;
	text-align:left;
	background-color:#00CC33;
	color:#000000;	
}
.detFacTr{
	font-family:Arial, Helvetica, sans-serif;
	font-size:16px;

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

$sq_tipven = mysqli_query($con ,"select * from dgtipven");//Datos para combo setipven 
$sq_pvta = mysqli_query($con ,"select * from ptventa");//Datos para combo punto de venta 


?>
<div align="center">
<form name="frm1" id="frm1" method="post" action="">
  <table  align="center">
    	<tr>
    	  <th colspan="2">CONCENTRADO VENTAS POR DIA </th>
		</tr>
     	<tr>
     	  <td>Punto de Venta:</td>
        	<td>
            	<div align="left">
            	  <select name="setipvent" id="setipvent">
            	    <option value="T">------ TODOS ------</option>
            	    <?php
 
						while ($dt_tippag = mysqli_fetch_array($sq_pvta)){
							if($dt_tippag['nparte1'] == $_POST['setipvent']) 
								echo '<option value="'.$dt_tippag['nparte1'].'" selected>'.$dt_tippag['np_desc1'].'</option>';
							else
								echo '<option value="'.$dt_tippag['nparte1'].'">'.$dt_tippag['np_desc1'].'</option>';
						}
					?>
          	    </select>
       	        </div></td>
      	</tr>
		<tr style="display:none">
     	  <td>Tipo Venta:</td>
        	<td>
            	<div align="left">
            	  <select name="setipven" id="setipven">
            	    <option value="T">---- TODAS ----</option>
            	    <?php
 
						while ($dt_tipven = mysqli_fetch_array($sq_tipven)){
							if($dt_tipven['tip_ven'] == $_POST['setipven']) 
								echo '<option value="'.$dt_tipven['tip_ven'].'" selected>'.$dt_tipven['des_tipven'].'</option>';
							else
								echo '<option value="'.$dt_tipven['tip_ven'].'">'.$dt_tipven['des_tipven'].'</option>';
						}
					?>
          	    </select>
       	        </div></td>
      	</tr>
      	<tr>
      	  <td colspan="2" nowrap>
		    <div align="center" class="estiloFecha">

			  Del 
			  <input name="fecini" type="text" class="Estilo3" id="fecini" size="15" 
			  	<?php
 
					if(isset($_POST['fecini']))
						echo 'value="'.$_POST['fecini'].'"'; 
				  	else
				    	echo 'value="'.date('d/m/Y').'"'; 
				?>>		      
	      	  <input name="reset2" id="bot1" value=" ... " type="image" src="logos/cal4.jpg"/> 
	      	  al 
	          <script type="text/javascript">
				  	Calendar.setup(
    					{
      						inputField  : "fecini",        // ID of the input field
      						ifFormat    : "%d/%m/%Y",    // the date format
      						button      : "bot1"      // ID of the button
    					}
  					);
				</script>

	          <input name="fecfin" type="text" class="Estilo3" id="fecfin" size="15" 
			<?php
 
				if(isset($_POST['fecfin']))
			  		echo 'value="'.$_POST['fecfin'].'"'; 
			  	else
			  		echo 'value="'.date('d/m/Y').'"'; 
			?>>
	          <input name="reset2" id="bot2" value=" ... " type="image" src="logos/cal4.jpg"/>
	          <script type="text/javascript">
				  	Calendar.setup(
    					{
      						inputField  : "fecfin",        // ID of the input field
      						ifFormat    : "%d/%m/%Y",    // the date format
      						button      : "bot2"      // ID of the button
    					}
  					);
			    </script>
          </div></td>
       	</tr>
      	<tr>
      	  <td>Cajero:</td>
      	  <td><select name="secodven" id="secodven">
			<option value="T">---- TODOS ----</option>
            <?php
 
			$sql = mysqli_query($con ,"SELECT * FROM dgcatven order by CONCAT(nom_ven,' ',ap_pat_ven,' ',ap_mat_ven) asc");
			while($reg=mysqli_fetch_array($sql)){
				if($reg['cod_ven'] == $_POST['secodven']){
					echo '<option value="' . $reg['cod_ven'] . '" selected>' . $reg['nom_ven'] . ' ' . $reg['ap_pat_ven'] . ' ' . $reg['ap_mat_ven'] .'</option>';
				}else{
					echo '<option value="' . $reg['cod_ven'] . '">' . $reg['nom_ven'] . ' ' . $reg['ap_pat_ven'] . ' ' . $reg['ap_mat_ven'] . '</option>';
				}
			
			}
			?>
            </select>&nbsp;</td>
   	  </tr>
      	<tr>
      	  <td colspan="2"><div align="center">
       		  <input name="boproc" type="submit" id="boproc" value="Procesar" onClick="openpage('PV40000_PR.php','_self')" />
       	  </div></td>
       	</tr>
	</table>

  <table border="0" cellpadding="0" width="100%">
    	<tr>
        	<th colspan="16">
          	<div align="left">
            	<input type="button" name="bot4" value="Imprimir" onClick="openpage('PV40000_IM.php','_self')">
          	</div>			</th>
      	</tr>
    	<tr>
    	  <th colspan="16" align="justify"><?php
 if ($_POST["setipvent"]=="T"){
					echo "TIP. VTA.: ";
					echo "TODAS"; 
					} else 
					{
					@$bus = mysqli_query($con ,"SELECT * FROM ptventa WHERE nparte1= '".$_POST['setipvent']."'");
					$re = mysqli_fetch_array($bus);
					echo "TIP. VTA.: ";
					echo $re['np_desc1'];
					}			
				 ?></th>
  	  </tr>
    	<tr>
    	  <th colspan="16"><?php
 if ($_POST["secodven"]=="T"){
					echo "CAJERO: ";
					echo "TODOS"; 
					} else 
					{
					@$bus1 = mysqli_query($con ,"SELECT * FROM dgcatven WHERE cod_ven = '".$_POST['secodven']."'");
					$re1 = mysqli_fetch_array($bus1);
					echo "CAJERO: ";
					echo $re1['nom_ven'];
					echo ' ';
					echo $re1['ap_pat_ven']; 
					echo ' ';
					echo $re1['ap_mat_ven'];
					}			
				 ?></th>
  	  </tr>
	 	<tr class="typeagre">
	 	  <td><div align="center">Folio Vta.</div></td>
		  <td><div align="center">Pax.</div></td>
		  <td><div align="center">P. Vta. / Mesa</div></td>
		  <td><div align="center">Fecha</div></td>		  
		  <td><div align="center">Hora</div></td>
		  <td><div align="center">Mesero</div></td>
  		  <td><div align="center">FP</div></td>
		  <td>Desc %</td>
		  <td>Descuento</td>
		  <td>Cortesia</td>
		  <td>Propina</td>		  
		  <td>Subtotal</td>
		  <td>Iva</td>
  		  <td>Total</td>
	 	</tr>
		

<?php

if (isset ($_POST["boproc"])){
	$fecIni=chfecha($_POST['fecini'],'d/m/Y','Y-m-d');
	$fecFin=chfecha($_POST['fecfin'],'d/m/Y','Y-m-d');
	$arrBus[]="(dgpemema.fec_ven between '$fecIni' and '$fecFin') AND dgpemema.cancelado!=1 ";	
	
	if($_POST['secodven']!='T') {
		 $arrBus[]="dgger_cajerosj.vendedor='".$_POST['secodven']."'";		
	}
	if($_POST['setipven']!='T') 
	{
	 	$arrBus[]="dgpemema.tip_ven=$_POST['setipven']";
	}	
	if($_POST['setipvent']!='T') {
  		$arrBus[]=' ptventa.nparte1='.$_POST['setipvent'].' ';
	}else {
		$arrBus[]=' ptventa.nparte1!=0 ';
    }
	
	
 	$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.tip_ven,
			
			dgpemema.cod_ven,
			dgpemema.iva_ven,
			ctmeser.np_desc1 as nomVen,
			dgpemema.tot_ven,
			dgpemema.imp_pag,
			dgpemema.sub_ven,
			dgpemema.por_des as descuento,
			fpos.mesa as mesa,
			ctmesas.np_desc1 as dmesa,
			ctarea.np_desc1 as  darea,
			ptventa.tip_ven as dptvta,
			dgger_cajerosj.acc_hor as hora,
			dgger_cajerosj.num_cli as cliente,
			fpropina.tip as propina,
			dgger_cajerosd.tip_pag as tipag,
			dgtippag.ini_pag as descpag,
			dgpemema.cancela as cancela,
			dgpemema.cancelado as cancelado,
			fcomhues.no_pers as pax
		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 dgger_cajerosd ON dgger_cajerosd.n_rec=dgger_cajerosj.n_rec	
			LEFT JOIN  dgtippag ON dgtippag.tip_pag=dgger_cajerosd.tip_pag
			LEFT JOIN dgcatven ON dgpemema.cod_ven=dgcatven.cod_ven
			LEFT JOIN fcomhues ON dgpemema.fol_ven=fcomhues.fol_ven
			
		$WHERE and dgger_cajerosj.fol_unp=0
		group by dgpemema.fol_ven
		ORDER BY 
			dgpemema.con_ven");
	echo mysqli_error($con);
	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!=1 and dgpemema.cancela=0 and dgger_cajerosj.cancelado=0 and dgpememd.cancela=0");
		echo mysqli_error($con);
		while($r = mysqli_fetch_array($s)){
		$suma=$r["sumat"];
		}
////---------------------------------	

//------suma de productos solo cortesia
	@$cr=mysqli_query($con ,"select dgger_cajerosd.importe as sumat from dgger_cajerosj left join dgger_cajerosd on (dgger_cajerosd.n_rec=dgger_cajerosj.n_rec) where dgger_cajerosj.pedido='".$reg['fol_ven']."' and dgger_cajerosd.tip_pag=3");
	echo mysqli_error($con);
	$ccr = mysqli_fetch_array($cr);
	if ($ccr['sumat']!=0){
	$sumacr=$ccr["sumat"]+$reg['propina'];
	}else{
	$sumacr=$ccr["sumat"];
	}
////---------------------------------

	//IMPRESION DE CUENTAS NO PAGADAS
	if (($reg["imp_pag"]==0.00) && ($reg["tippag"]=='') && ($reg["cancela"]==0)) {
		echo '<tr class="granTotAb">';
		echo '<td class="granTotAb">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotAb">'.$reg['pax'].'</td>';   //orden
		echo '<td class="granTotAb">'.$reg['dptvta'].' | '.$reg["dmesa"].'</td>';   //mesa	
		echo '<td class="granTotAb" >'.chfecha($reg['fec_ven'],'Y-m-d','d/m/Y').'&nbsp;</td>';	//fecha	
		echo '<td class="granTotAb" >'.$reg['hora'].'</td>';	//fecha				
		echo '<td class="granTotAb" colspan="2">'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		echo '<td class="granTotAb" colspan="8"> <div align="center">CUENTA ABIERTA</div></td>';  //cortesia
		echo '</tr>';		
		$numVen++;
	}else	if (($reg["imp_pag"]==0.00) && ($reg["cancela"]==1)) { //CUENTAS CANCELADAS
		echo '<tr class="granTotCan">';
		echo '<td class="granTotCan">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotCan">'.$reg['pax'].'</td>';   //orden
		echo '<td class="granTotCan" colspan="2">'.$reg['dptvta'].' | '.$reg["dmesa"].'</td>';   //orden	
		echo '<td class="granTotCan" colspan="2">'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		echo '<td class="granTotCan" colspan="8"> <div align="center">CANCELADO</div></td>';  //cortesia
		echo '</tr>';		
		$numVen++;
	} else {
		echo '<tr class="granTotParR">';
		echo '<td class="granTotParR">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotParR">'.$reg['pax'].'</td>';   //orden
		echo '<td class="granTotParL">'.$reg['dptvta'].' | '.$reg["dmesa"].'</td>';   //orden	
		echo '<td class="granTotParL" >'.chfecha($reg['fec_ven'],'Y-m-d','d/m/Y').'&nbsp;</td>';		
		echo '<td class="granTotParL" >'.$reg['hora'].'</td>';	//fecha		
		echo '<td class="granTotParL" >'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		$folio=mysqli_query($con ,"select dgger_cajerosj.num_cli as cliente,dgger_cajerosd.tip_pag as tppag,dgtippag.ini_pag as pagoo from dgger_cajerosd inner join dgtippag on dgtippag.tip_pag=dgger_cajerosd.tip_pag inner join dgger_cajerosj on dgger_cajerosj.n_rec=dgger_cajerosd.n_rec
	   where dgger_cajerosj.pedido='".$reg['fol_ven']."'");
	   $saldo=0;
	   $cont=0;
	   $_SESSION['clientec']=0;
		echo '<td class="granTotParL">&nbsp;';
		while($rg=mysqli_fetch_array($folio)){
		if ($rg['tppag']==1){
		$_SESSION['clientec']=$rg['cliente'];
		$cont++;
		}
	   echo $rg['pagoo'];
	   echo ' | ';
	   }
	   if ($cont>=1){	
	   	$sql_cli=mysqli_query($con ,"select * from valeryus19 where n_reg=$_SESSION['clientec']");
	$reg_hb=mysqli_fetch_array($sql_cli);
		if ($reg_hb['fnumcto']!='')
		$hbit=$reg_hb['fnumcto'];
		else
		$hbit=$reg_hb['fmuncto'];

		echo 'F.'.$reg_hb['n_reg'].'H.'.$hbit;	
		}
//		echo '<td class="granTotParL">'.$reg["tipag"].' '.$reg["descpag"].'</td>'; //forma de pago
		echo '<td class="granTotParR">'.number_format($reg['descuento'],2,'.',',').'%</td>';  //porcentaje descuento
		echo '<td class="granTotParR">'.number_format($desc=$suma*($reg['descuento']/100),2,'.',',').'</td>';  //cantidad descuento descuento		
		echo '<td class="granTotParR">'.number_format($sumacr,2,'.',',').'</td>';  //cortesia
		echo '<td class="granTotParR">'.number_format($reg['propina'],2,'.',',').'</td>';  //propina		
		echo '<td class="granTotParR">'.number_format($suma,2,'.',',').'</td>'; //subtotal
		echo '<td class="granTotParR">'.number_format($reg["iva_ven"],2,'.',',').'</td>';		//iva	
		echo '<td class="granTotParR">'.number_format($sumtot=(($suma-$desc-$sumacr)+$reg['propina']),2,'.',',').'</td>';			//saldo			
		echo '</tr>';				
		
				///--------------------rep cancelados----------
		$granDesVen +=$desc;  //descuento
		$granCorVen +=$sumacr;  //cortesia
		$granTotVen +=$suma;  //subtotal
		$granPagVen +=$reg["iva_ven"];  //iva
		if($reg["imp_pag"]!=0){
		 $granSalVen +=$sumtot;  //total
		}
		$granPro    +=($reg["propina"]);  //propina		
		$numVen++;
		}
	}

//**************************************************pagos de cuentas totales*************************************************+*****////
	/*@$sql = mysqli_query($con ,"
		SELECT 
			
			
			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,
			sum(dgpemema.por_des) as descuentog,
			dgpemema.por_des as descuento,
			fpos.mesa as mesa,
			ctmesas.np_desc1 as dmesa,
			ctarea.np_desc1 as  darea,
			ptventa.tip_ven as dptvta,
			dgger_cajerosj.acc_hor as hora,
			fpropina.tip as propina,
			sum(dgger_cajerosd.importe) as impdg,
			dgger_cajerosd.tip_pag as tipag,
			dgtippag.ini_pag as descpag,
			dgpemema.cancela as cancela,
			dgger_cajerosj.fol_unp as folp
		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_unp=dgger_cajerosj.fol_unp
			LEFT JOIN dgger_cajerosd ON dgger_cajerosd.n_rec=dgger_cajerosj.n_rec	
			LEFT JOIN  dgtippag ON dgtippag.tip_pag=dgger_cajerosd.tip_pag
			LEFT JOIN dgcatven ON dgpemema.cod_ven=dgcatven.cod_ven
			
		$WHERE and dgger_cajerosj.fol_unp!=0
		GROUP BY dgger_cajerosj.fol_unp
		ORDER BY 
			dgpemema.con_ven");
	echo mysqli_error($con);

	while($reg = mysqli_fetch_array($sql)){
//------suma de productos
	@$s=mysqli_query($con ,"select * from dgpemema where fol_ven IN (select pedido from dgger_cajerosj where fol_unp='".$reg['folp']."')");
		$sumare=0;
	while($r=mysqli_fetch_array($s)){
	
	$resu3=mysqli_fetch_array(mysqli_query($con ,"select sum(pre_bas*can_ref) as summ from dgpememd where cons_ven = '".$r['fol_ven']."' and cancela=0 "));
	 $sumare+=$resu3['summ'];
	}
////---------------------------------	

//------suma de productos solo cortesia
	@$cr=mysqli_query($con ,"select dgger_cajerosd.importe as sumat from dgger_cajerosj left join dgger_cajerosd on (dgger_cajerosd.n_rec=dgger_cajerosj.n_rec) where dgger_cajerosj.fol_unp='".$reg['folp']."' and dgger_cajerosd.tip_pag=3");
	echo mysqli_error($con);
	$ccr = mysqli_fetch_array($cr);
	$sumacr=$ccr["sumat"];
	
	
	@$cr2=mysqli_query($con ,"select dgger_cajerosj.imp_pag as sumat from dgger_cajerosj where dgger_cajerosj.fol_unp='".$reg['folp']."' group by dgger_cajerosj.fol_unp");
	echo mysqli_error($con);
	$ccr2= mysqli_fetch_array($cr2);
	$sumacr2=$ccr2["sumat"];	
////---------------------------------


	//IMPRESION DE CUENTAS NO PAGADAS
	if (($reg["imp_pag"]==0.00) && ($reg["tippag"]=='') && ($reg["cancela"]==0)) {
		echo '<tr class="granTotAb">';
		$folio=mysqli_query($con ,"select dgpemema.tot_ven as importe,dgpemema.con_ven as folio, dgger_cajerosj.fol_unp as folpf from dgger_cajerosj inner join dgpemema on dgpemema.fol_ven=dgger_cajerosj.pedido
	   where dgger_cajerosj.fol_unp='".$reg['folp']."'");
	   $saldo=0;
		echo '<td class="granTotAb">&nbsp;';
		while($rg=mysqli_fetch_array($folio)){
			   $saldo+=$rg['importe'];
	   echo $rg['folio'];
	   echo ' | ';
	   }
//		echo '<td class="granTotAb">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotAb">'.$reg['dptvta'].' | '.$reg["dmesa"].'</td>';   //mesa	
		echo '<td class="granTotAb" >'.chfecha($reg['fec_ven'],'Y-m-d','d/m/Y').'&nbsp;</td>';	//fecha	
		echo '<td class="granTotAb" >'.$reg['hora'].'</td>';	//fecha				
		echo '<td class="granTotAb" colspan="2">'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		echo '<td class="granTotAb" colspan="8"> <div align="center">CUENTA ABIERTA</div></td>';  //cortesia
		echo '</tr>';		
		$numVen++;
	}else	if (($reg["imp_pag"]==0.00) && ($reg["cancela"]==1)) { //impresion de reportes cancelados
		echo '<tr class="granTotCan">';
	$folio=mysqli_query($con ,"select dgpemema.tot_ven as importe,dgpemema.con_ven as folio, dgger_cajerosj.fol_unp as folpf from dgger_cajerosj inner join dgpemema on dgpemema.fol_ven=dgger_cajerosj.pedido where dgger_cajerosj.fol_unp='".$reg['folp']."'");
	   $saldo=0;
		echo '<td class="granTotCan">&nbsp;';
		while($rg=mysqli_fetch_array($folio)){
			   $saldo+=$rg['importe'];
	   echo $rg['folio'];
	   echo ' | ';
	   }		
		//echo '<td class="granTotCan">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotCan" colspan="2">'.$reg['dptvta'].' | '.$reg["dmesa"].'</td>';   //orden	
		echo '<td class="granTotCan" colspan="2">'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		echo '<td class="granTotCan" colspan="8"> <div align="center">CANCELADO</div></td>';  //cortesia
		echo '</tr>';		
		$numVen++;
	} else {
		echo '<tr class="granTotParR">';
	$folio=mysqli_query($con ,"select dgpemema.tot_ven as importe,dgpemema.con_ven as folio, dgger_cajerosj.fol_unp as folpf from dgger_cajerosj inner join dgpemema on dgpemema.fol_ven=dgger_cajerosj.pedido
	   where dgger_cajerosj.fol_unp='".$reg['folp']."'");
	   $saldo=0;
		echo '<td class="granTotPaR">&nbsp;';
		while($rg=mysqli_fetch_array($folio)){
			   $saldo+=$rg['importe'];
	   echo $rg['folio'];
	   echo ' | ';
	   }		

		//echo '<td class="granTotParR">'.$reg["con_ven"].'&nbsp;</td>';   //orden
		echo '<td class="granTotParL">'.$reg['dptvta'].' | '.$reg["dmesa"].'</td>';   //orden	
		echo '<td class="granTotParL" >'.chfecha($reg['fec_ven'],'Y-m-d','d/m/Y').'&nbsp;</td>';		
		echo '<td class="granTotParL" >'.$reg['hora'].'</td>';	//fecha		
		echo '<td class="granTotParL" >'.$reg["cod_ven"].' '.$reg["nomVen"].'&nbsp;</td>';	//operador				
		$folio2=mysqli_query($con ,"select dgger_cajerosj.num_cli as cliente,dgger_cajerosd.tip_pag as tppag,dgtippag.ini_pag as pagoo from dgger_cajerosd inner join dgtippag on dgtippag.tip_pag=dgger_cajerosd.tip_pag inner join dgger_cajerosj on dgger_cajerosj.n_rec=dgger_cajerosd.n_rec
	   where dgger_cajerosj.fol_unp='".$reg['folp']."' group by dgger_cajerosd.tip_pag");
		echo '<td class="granTotParL">&nbsp;';
		$cont=0;
		$_SESSION['clientec']=0;
		while($rg2=mysqli_fetch_array($folio2)){
		if ($rg2['tppag']==1){
		$cont++;
		$_SESSION['clientec']=$rg2['cliente'];
		}
	   echo $rg2['pagoo'];
	   echo ' | ';
	   }		
   	   if ($cont>=1){	
	   	$sql_cli=mysqli_query($con ,"select * from valeryus19 where n_reg=$_SESSION['clientec']");
	$reg_hb=mysqli_fetch_array($sql_cli);
		if ($reg_hb['fnumcto']!='')
		$hbit=$reg_hb['fnumcto'];
		else
		$hbit=$reg_hb['fmuncto'];

		echo 'F.'.$reg_hb['n_reg'].'H.'.$hbit;	
		}

//		echo '<td class="granTotParL">'.$reg["tipag"].' '.$reg["descpag"].'</td>'; //subtotal
	$a1=($sumare+$reg['propina'])-$sumacr2;
	$porDes=round($a1/$sumare*100,4);
		echo '<td class="granTotParR">'.number_format($porDes,2,'.',',').'%</td>';  //porcentaje descuento
		echo '<td class="granTotParR">'.number_format($dsc=$a1,2,'.',',').'</td>';  //cantidad descuento descuento		
		echo '<td class="granTotParR">'.number_format($sumacr,2,'.',',').'</td>';  //cortesia
		echo '<td class="granTotParR">'.number_format($reg['propina'],2,'.',',').'</td>';  //propina		
		echo '<td class="granTotParR">'.number_format($sumare,2,'.',',').'</td>'; //subtotal
		echo '<td class="granTotParR">'.number_format($reg["iva_ven"],2,'.',',').'</td>';		//iva	
		echo '<td class="granTotParR">'.number_format($tot=(($sumare-$sumacr-$dsc)+$reg["propina"]),2,'.',',').'</td>';			//saldo			
		echo '</tr>';				
		
			///--------------------rep cancelados----------
		$granDesVen +=$dsc;  //descuento
		$granCorVen +=$sumacr;  //cortesia
		$granTotVen +=$sumare;  //subtotal
		$granPagVen +=$reg["iva_ven"];  //iva
		if($reg["imp_pag"]!=0){
		$granSalVen +=$tot;  //total
		}
		$granPro    +=($reg["propina"]);  //propina		
		$numVen++;
		}
	}




//		}
		
		
//	} //totales
	echo "<tr> 
			<td class=\"granTotL\" colspan=\"8\">TOTALES</td>
			<td class=\"granTotR\">".number_format($granDesVen,2,'.',',')."</td> 
			<td class=\"granTotR\">".number_format($granCorVen,2,'.',',')."</td> 
			<td class=\"granTotR\">".number_format($granPro,2,'.',',')."</td> 			 						
			<td class=\"granTotR\">".number_format($granTotVen,2,'.',',')."</td>  						
			<td class=\"granTotR\">".number_format($granPagVen,2,'.',',')."</td>						
			<td class=\"granTotR\">".number_format($granSalVen,2,'.',',')."</td>												
		</tr>";
}
?>	
    </table>
  </form>
</div>
</body>
</html> 

<input name="Check1" type="checkbox" id="Check1" value="checkbox" onChange="Sumar()" >
<input name="Check2" type="checkbox" id="Check2" value="checkbox" onChange="Sumar()">
<input name="Resultado" type="text" id="Resultado">
<script type="text/javascript">
function Sumar(){
	var Valor1 = document.getElementById('Check1').checked?100:0;
	var Valor2 = document.getElementById('Check2').checked?50:0;
	document.getElementById('Resultado').value = Valor1+Valor2;
}
</script>



*/

 /*
  <script language="javascript">
<!--
function Suma(isChecked, myValue)
{
	tot = parseFloat(document.form1.total.value);
	myValue = parseFloat(myValue);
	if (isChecked) document.form1.total.value = tot + myValue;
	else document.form1.total.value = tot - myValue;
}
-->
</script>

  
  $e=mysqli_query($con ,"select * from valeryus19 where n_reg='145'");
  $r=mysqli_fetch_array($e);
  
  $f=mysqli_query($con ,"select * from valeryus030 where nparte1='145'");
  while($s=mysqli_fetch_array($f)){
  
  echo "<input name='checkbox' type='checkbox' onClick='Suma(this.checked,this.value)' value='".$s['costo']."' />";
  echo "<input name='checkbos' type='text' value='".$s['costo']."' />";
  }
 */
  ?>