<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
include("DFJQUERY.inc");
include("JQUERY.inc");
	$numVen=0;
	$TotCargo =0;
	$TotAbono=0;
?>
<html>
<head> <meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="RSSCRIPT.js"></script>
<script language="javascript1.2">
$(document).ready(function(){
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
	var pagRes='caj_checkout_DS.php';
	var idObjDes='des_ope';
	var idObjCve='id_ope';
        var nomObjRad='tip_bus_ope';
	$("#"+idObjDes).autocomplete({ //Des
	    source:pagRes,	
            minChars: 1,                 //Caracteres Minimos antes de autocompletar
		max:20,                      //maximo de resultados mostrados, se manda como limit en autosugestion
		cacheLength: 0,
		delay: 200,                  //Retardo de autocompletar 
		width: 500,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: true,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 100,           //alto del cuadro para el scroll
		
		 select: function( event, ui ) {
                      $("#"+idObjCve).val(ui.item.id);
                      $("#"+idObjDes).val(ui.item.descripcion);	
//		$('#fcodgrupo').focus();
                javascript: document.getElementById('frm1').submit();
                }
	});	
	
});
     $(document).ready(function(){
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
        var pagRes='caj_checkout_DS.php';
	var idObjDes='des_ope';
	var idObjCve='id_ope'; 
	var nomObjRad='tip_bus_ope';
	$("#"+idObjCve).autocomplete( {
            source:pagRes,
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		max:20,                      //maximo de resultados mostrados, se manda como limit en autosugestion
		                 //ancho del cuadro de despliegue
		 delay: 200,           //Resalta letras coincidentes
		autoFill: true,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 100,           //alto del cuadro para el scroll
		
                           select: function( event, ui ) {
                      $("#"+idObjCve).val(ui.item.id);
                      $("#"+idObjDes).val(ui.item.descripcion);		
                      $('#fcodgrupo').focus();
		javascript: document.getElementById('frm1').submit();
            }
    });	
    
}); 

</script>
<style type="text/css">
<!--
.Estilo2 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
	font-weight: bold;
}
.Estilo3 {border: 1px; font-family :urw gothic l; color: #000099; background-color: #dbe0e9;}
.Estilo5 {color: #FFFFFF}
.estiloTotal{
	background-color:#0099FF;
	font-size:18px;
	font-family:Arial, Helvetica, sans-serif;
	font-weight:bolder;
	 ;
	text-align:right;
}
.estiloSubTotal{
	background-color:#FFFFF2;
	font-size:12px;
	font-family:Arial, Helvetica, sans-serif;
	font-style:italic;
	font-weight:bolder;
	color:#000000;
}
.estiloGrupo{
	background-color:#E1E1DD;
	font-size:14px;
	font-family:Arial, Helvetica, sans-serif;
	font-weight:bolder;
	color:#000000;
}
.estiloEnc{
	background-color:#6699FF;
	font-size:10px;
	font-family:Arial, Helvetica, sans-serif;
	font-weight:bold;
	color:#000000;
}
.estiloEncR{
	background-color:#D9ECFF;
	font-size:12px;
	font-family:Arial, Helvetica, sans-serif;
	/*font-weight:bold;*/
	color:#000000;
	text-align:right;
}

.estiloDet{
	background- ;
	font-size:10px;
	font-family:Arial, Helvetica, sans-serif;
	font-style:normal;
	font:bold;
	font-weight:bold;
	color:#000000;
}
.estiloDetR{
	background- ;
	font-size:10px;
	font-family:Arial, Helvetica, sans-serif;
	font-style:italic;
	/*font-weight:bold;*/
	color:#000000;
	text-align:right;
}
.detFacTr{
	font-family:Arial, Helvetica, sans-serif;
	font-size:16px;

}
.detFacL{
	text-align:left;
}
.detFacR{
	text-align:right;
}
.detFacC{
	text-align:center;
}
.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;
	 ;	
}
BODY {
SCROLLBAR-FACE-COLOR:#7397A7; 
SCROLLBAR-HIGHLIGHT-COLOR:#5FBEC2;/*sombra izquierda arriba*/ 
SCROLLBAR-SHADOW-COLOR:#5FBEC2;/*sombra derecha abajo*/ 
SCROLLBAR-3DLIGHT-COLOR:#5FBEC2;/*lo mismo que la segunda*/ 
SCROLLBAR-ARROW-COLOR:#5FBEC2;/*flechita*/ 
SCROLLBAR-TRACK-COLOR:#5FBEC2;/*base*/
SCROLLBAR-DARKSHADOW-COLOR:#5FBEC2/*lo mismo que la tercera*/
}--> 


-->
</style>

</head>	
<body>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="634" border="0">
	<tr>
	  <th colspan="2"><span class="Estilo23">REPORTE DE CAJERO </span> </th>
	  </tr>
	<tr>
	  <td width="111"> <div align="right" class="Estilo24"><span class="Estilo25">FECHA </span></div></td>
	  <td width="485"><strong>DEL</strong>
              <?php
          $ffecllegada=(isset($_POST['fec']))?$_POST['fec']:date('d/m/Y');
          ?>
	    <input name="fec" type="text" class="emplea datefrom" id="fec" size="9" maxlength="20" value="<?=$ffecllegada?>"
			<?php

				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?> onkeypress="return soloNumeros(event)"
		/>
         
            
            <strong> AL </strong>
            <input name="fec2" type="text" class="emplea dateto" id="fec2" size="9" maxlength="20" value="<?=date("d/m/Y")?>"
			<?php

				if(isset($_POST['fec2'])){ //este es el truco
					echo 'value="' . $_POST['fec2'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?> onkeypress="return soloNumeros(event)"
		/>
            <!--<input name="bot12" id="bot1" type="image" value="Cal" src="logos/cal4.jpg" /> -->
            	  </td>
	</tr>
	<tr>
	<td><div align="right" class="Estilo24"><span class="Estilo25">CARGO/ABONO.</span></div></td>
	  <td><div class="Estilo24"><span class="Estilo25">&nbsp; &nbsp; TODOS
	    <input name="r1" type="radio" value="T" <?php
 if(isset($_POST['r1']) && $_POST['r1']=='T') echo 'checked';?> onClick="javascript: document.frm1.des_ope.disabled=true; javascript: document.frm1.id_ope.disabled=true;">&nbsp; &nbsp; 
	 	INDIVIDUAL
	    <input name="r1" type="radio" value="N" <?php
  if(isset($_POST['r1']) && $_POST['r1']=='N') echo 'checked';  if (isset($_POST['r1']) && $_POST['r1']=='') echo 'checked';?> onClick="javascript: document.frm1.des_ope.disabled=false;javascript: document.frm1.id_ope.disabled=false;">
		</span></div>		</td>
	  </tr>
	<tr id="descripcion">
      <td align="right"><span class="Estilo25">DESCRIPCION:</span></td>
      <td colspan="3" align="left">
        <input name="id_ope" type="text" id="id_ope" size="10" value="<?php

							if(isset($_POST['id_ope']))
						echo $_POST['id_ope']; 
		?>" />
        <input name="des_ope" type="text" id="des_ope" size="50" value="<?php
 echo trim( (isset($_POST['des_ope']))?$_POST['des_ope']:"" );?>" />      </td>		  	  
    </tr>
	<tr id="descripcion">
	  <td align="right">CAJERO:</td>
	  <td colspan="3" align="left">&nbsp;  <span class="Estilo1">
		    <select name="cajero" id="cajero">
              <option value="">----TODOS LOS CAJEROS----</option>
              <?php
 
$sql1 = mysqli_query($con ,"SELECT valeryus030.usuario,dxopemaex.nomb as nombre, dxopemaex.apa as pat, dxopemaex.ama as mat from valeryus030 left join dxopemaex on (dxopemaex.nombre = valeryus030.usuario) ");
while($reg1=mysqli_fetch_array($sql1)){
	if($_POST['cajero']==$reg1['usuario'] ){
		echo '<option value="' . $reg1['usuario'] . '" selected>('.$reg1['usuario'].') '.$reg1['pat'].' '.$reg1['mat'].'</option>';
	}else{
		echo '<option value="' . $reg1['usuario'] . '">('.$reg1['usuario'].') '.$reg1['pat'].' '.$reg1['mat'].'</option>';
	}
}
?>
            </select>
	      </span>	</td>
	  </tr>
</table>
</div>

<div align="center">

      <table width="634" border="0">
         <td colspan="2">
          <div align="center">
		  	  <input name="Submit32" type="submit" class="original" value="Buscar" onClick="openpage('ger_cajeros_PR.php','_self')" />
              <input name="bot4" type="button" class="bot_WsW" onClick="openpage('ger_cajeros_IM.php','_self')" value="Imprimir "/>
          </div></td>
      </tr>
    </table>
 <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0"> 
  <?php
 
  
  if (isset($_POST['r1']) && $_POST['r1']=='N')
  $condicion='n_reg="'.$_POST['id_ope'].'"';
  else if (isset($_POST['r1']) && $_POST['r1']=='T')
  $condicion='n_reg > 0';
  else 
  $condicion='n_reg = 0';
 
 if (isset($_POST['cajero']) && $_POST['cajero']=='')
  $cajero='usuario!=""'; 
 else if (isset($_POST['cajero']) && $_POST['cajero']!='')
  $cajero='usuario="'.$_POST['cajero'].'"';
  	$fecIni=chfecha(isset($_POST['fec'])?$_POST['fec']:"",'d/m/Y','Y-m-d');	
	$fecFin=chfecha(isset($_POST['fec2'])?$_POST['fec2']:"",'d/m/Y','Y-m-d');
	
  $sql_cb=mysqli_query($con ,"select * from valeryus09 where $condicion order by descripcion ");
  echo "select * from valeryus09 where $condicion order by descripcion ";
  while ($reg=mysqli_fetch_array($sql_cb)){
	$sumcb=mysqli_query($con ,"select * from valeryus030 where nparte1_det='".$reg['n_reg']."' and (acc_fec between '".$fecIni."' and '".$fecFin."') and depositos='0' and $cajero");
	$resm=mysqli_fetch_array($sumcb);
	//if(!isset($resm['ct']))$resm['ct']="";
	(isset($resm['ct']))?$resm['ct']:"" ;
	//if(!isset($resm['ab']))$resm['ab']="";
	(isset( $resm['ab']))? $resm['ab']:"";
	if (mysqli_num_rows($sumcb)!=0){

  echo'<tr>
					<td colspan="12" class="estiloSubTotal"><div align="left">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.substr($reg['descripcion'],0,15).'
					</div></td>
		</tr>';	
	echo '     <tr>
      <td colspan="9"></td>
	  <td></td>
	  <th nowrap colspan="3"><div align="center">TRASPASOS</div></th>
    </tr>
';				
	echo '     <tr>
      <th nowrap>CODIGO CARGO</th>
      <th nowrap>DESCRIPCION</th>
      <th nowrap># VAUCHER</th>
	  <th nowrap># FOLIO</th>
	  <th nowrap>FECHA</th>
      <th nowrap># CUARTO</th>
	  <th nowrap>CARGOS</th>
      <th nowrap>ABONOS</th>
	  <th nowrap>CAJERO</th>
	  <th nowrap>FAC</th>
	  <th nowrap>NOTAS</th>  
	  <th nowrap></th>
	  <th nowrap>FOLIO</th>
	  <th nowrap>FECHA</th>
	  <th nowrap>USUARIO</th>
    </tr>
';		
	$sql="select * from valeryus030 where nparte1_det='".$reg['n_reg']."' and (acc_fec between '".$fecIni."' and '".$fecFin."') and depositos='0' and $cajero";					
	$sql_dt=mysqli_query($con ,$sql);
	$cta=0;
	$cargo=0;
	$abono=0;
	
	while($red=mysqli_fetch_array($sql_dt)){
	$sql2=mysqli_query($con ,"select * from valeryus19 where n_reg='".$red['nparte1']."' ");	
	$dt_h=mysqli_fetch_array($sql2);	
	if ($dt_h['fnumcto']!='')
	$cuarto=$dt_h['fnumcto'];
	else if ($dt_h['fmuncto']!='')
	$cuarto=$dt_h['fmuncto'];
	$cta ++; //cuentas
		if($red['cancelado'] == 0){ //datos normales 
		$cargo +=$red['costo'];
		$abono +=$red['total'];
		echo'<tr>
					<td><div align="center">
					'.$reg['pclave']  //codigo cargo/abono
					. '       
					</div></td>
					<td><div align="left">
					'.substr($reg['descripcion'],0,15)//descripcion cargo /abono
					.'	
					</div></td>
					<td><div align="center">
					'.$red['can_ref']  //numero vaucher
					.'	
					</div></td>
					<td><div align="center">
					'.$dt_h['n_reg'] //folio de registro huesped
					.'	
					</div></td>
					<td><div align="center">'. chfecha($red['acc_fec'],'Y-m-d','d/m/Y').'</div></td>
					<td><div align="center">
					'.$cuarto  //cuarto huesped
					.'	
					</div></td>
					<td><div align="right">
							'.number_format($red['costo'],2,'.',',') //cargo
							.'&nbsp;
					</div></td>
					<td><div align="right">
							'.number_format($red['total'],2,'.',',')  //abono
							.'&nbsp;
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['usuario'] //cajero que da de alta el cargo
							.'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$dt_h['fol_fac'] //Notas cargo/abono
							.'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['proteina'] //Notas cargo/abono
							.'
					</div></td>
					<td><div align="right">
							&nbsp;
					</div></td>			
					<td><div align="right">
							&nbsp; 
					</div></td>
					<td><div align="right">
							&nbsp;
					</div></td>

					<td><div align="right">
							&nbsp;
					</div></td>

		</tr>';		
		}

		if($red['cancelado'] == 2){ //datos con el nuevo cargo del traspaso
$sql_b=mysqli_query($con ,"select * from valeryus030 where num=6 and  cancelado=3 and depositos=0");
$redt=mysqli_fetch_array($sql_b);
		$cargo +=$red['costo'];
		$abono +=$red['total'];
		echo'<tr>
					<td><div align="center">
					'.$reg['pclave'].'	
					</div></td>
					<td><div align="left">
					TR: DE '.$red['num'].' | '.substr($reg['descripcion'],0,15).'	
					</div></td>
					<td><div align="center">
					'.$red['can_ref'].'	
					</div></td>
					<td><div align="center">
					'.$dt_h['n_reg'].'	
					</div></td>
					<td><div align="center">'. chfecha($red['acc_fec'],'Y-m-d','d/m/Y').'</div></td>
					<td><div align="center">
					'.$cuarto.'	
					</div></td>
					<td><div align="right">
							'.number_format($red['costo'],2,'.',',').'&nbsp;
					</div></td>
					<td><div align="right">
							'.number_format($red['total'],2,'.',',').'&nbsp;
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['usuario'].'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$dt_h['fol_fac'] //Notas cargo/abono
							.'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['proteina'].'
					</div></td>
					<td><div align="right">
							&nbsp;
					</div></td>					
					<td><div align="center">
					'.$red['num'].'	
					</div></td>
					<td><div align="right">
					 '. chfecha($red['fec_tra'],'Y-m-d','d/m/Y').'
					</div></td>

					<td><div align="left">
						&nbsp;&nbsp;'.$red['usu_tra'].'
					</div></td>

				
		</tr>';				
		}
		if($red['cancelado'] == 3){ //datos de la huella del traspaso 

		echo'<tr>
					<td><div align="center">
					'.$reg['pclave'].'	
					</div></td>
					<td><div align="left">
					TR: A '.$red['num'].'	
					</div></td>
					<td><div align="center">
					'.$red['can_ref'].'	
					</div></td>
					<td><div align="center">
					'.$dt_h['n_reg'].'	
					</div></td>
					<td><div align="center">'. chfecha($red['acc_fec'],'Y-m-d','d/m/Y').'</div></td>
					<td><div align="center">
					'.$cuarto.'	
					</div></td>
					<td><div align="right">
							'.number_format($red['costo'],2,'.',',').'&nbsp;
					</div></td>
					<td><div align="right">
							'.number_format($red['total'],2,'.',',').'&nbsp;
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['usuario'].'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$dt_h['fol_fac'] //Notas cargo/abono
							.'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['proteina'].'
					</div></td>
					<td><div align="right">
							&nbsp;
					</div></td>
					<td><div align="center">
					&nbsp;
					</div></td>
					<td><div align="right">
					 '. chfecha($red['fec_tra'],'Y-m-d','d/m/Y').'
					</div></td>

					<td><div align="left">
						&nbsp;&nbsp;'.$red['usu_tra'].'
					</div></td>
		</tr>';		
		}
		if($red['cancelado'] == 1){ //datos cancelado

		echo'<tr>
					<td><div align="center">
					'.$reg['pclave']  //codigo cargo/abono
					. '       
					</div></td>
					<td><div align="left">
					CANCELADO | '.substr($reg['descripcion'],0,15) //descripcion cargo /abono
					.'	
					</div></td>
					<td><div align="center">
					'.$red['can_ref']  //numero vaucher
					.'	
					</div></td>
					<td><div align="center">
					'.$dt_h['n_reg'] //folio de registro huesped
					.'	
					</div></td>
					<td><div align="center">'. chfecha($red['acc_fec'],'Y-m-d','d/m/Y').'</div></td>
					<td><div align="center">
					'.$cuarto  //cuarto huesped
					.'	
					</div></td>
					<td><div align="right">
							'.number_format($red['costo'],2,'.',',') //cargo
							.'&nbsp;
					</div></td>
					<td><div align="right">
							'.number_format($red['total'],2,'.',',')  //abono
							.'&nbsp;
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['usuario'] //cajero que da de alta el cargo
							.'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$dt_h['fol_fac'] //Notas cargo/abono
							.'
					</div></td>
					<td><div align="left">
							&nbsp;&nbsp;'.$red['proteina'] //cajero que da de alta el cargo
							.'
					</div></td>
					<td><div align="right">
							&nbsp;
					</div></td>			
					<td><div align="right">
							&nbsp; 
					</div></td>
					<td><div align="right">
							&nbsp;
					</div></td>

					<td><div align="right">
							&nbsp;
					</div></td>

		</tr>';	
		}
	
	}
	echo "<tr class='typeagre'> 
			<td class='estiloDet' colspan=\"5\"> Totales Cod.: ".$reg['pclave']."</td>  						
			<td class='estiloDet' align='right'> $".number_format($cargo,2,'.',',')."</td>  	
			<td class='estiloDet' align='right'> $".number_format($abono,2,'.',',')."</td>  	
			<td class='estiloDet' colspan=\"5\" align=\"right\">  Recibo(s) ".$cta."&nbsp;&nbsp;</td>  													
		</tr>";
	
		$numVen +=$cta;
		
		$TotCargo +=$cargo;
		
		$TotAbono +=$abono;
			echo "<tr>
			  <td></td>
			  <td colspan=\"5\">&nbsp;&nbsp;</td>
          </tr>";		
  }
  
 } 
  echo "<tr> 
  
			<td class=\"granTotL\" colspan=\"5\"> TOTAL TRANSACCIONES: $numVen</td>  						
			<td align='right' class=\"granTotR\"> $".number_format($TotCargo,2,'.',',')."</td>  	
			<td align='right' class=\"granTotR\"> $".number_format($TotAbono,2,'.',',')."</td>  	
			<td  colspan=\"5\" align=\"right\" class=\"granTotR\">  &nbsp;&nbsp;</td>  													

		</tr>";
echo " </table>

<table width='100%'>";

?>
  </table>

  </form>
</div>
</body>
</html>