<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
//-------------------------		
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//
if(vbval($_SESSION['SYS_USER_GI'])!=USU_GET_GI($_SESSION['SYS_USER_ID'])){
JsDir("cerrar.php");	
return;
}
//
//-------------------------
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
//-------------------------
$StrEmp=V($_POST['CboEmp']);
$StrCom=V($_POST['CboCom']);		
$StrSer=V($_POST['TxtSer']);		
$StrNum=V($_POST['TxtNum']);		
$StrDex=V($_POST['TxtDex']);		
$StrHax=V($_POST['TxtHax']);			
$StrPro=V($_POST['TxtPro']);			
$StrSN=V($_POST['CboSN']);
$StrNro=V($_POST['TxtNro']);						
$StrMod=V($_POST['CboMod']);	
$StrUsu=V($_POST['CboUsu']);	
//					
if(strlen($StrMod)==0)$StrMod="TODOS";
if(strlen($StrUsu)==0)$StrUsu="TODOS";
//-------------------------
if(strlen($StrEmp)==0)$StrEmp=GE("S");
if(strlen($StrCom)==0) $StrCom="TODOS";	
if(strlen($StrSN)==0) $StrSN="NO";	
$StrSN_=$StrSN;
//-------------------------
$StrEmp_=LIKE($StrEmp);
$StrCom_=LIKE($StrCom);
$StrSer_="%".$StrSer;
$StrNum_="%".$StrNum;	
$StrDex_=val_dex($StrDex);
$StrHax_=val_hax($StrHax);
$StrPro_=$StrPro."%";
if(strlen($StrNro)==0){
	$StrNro_="%";
}else{
	$StrNro_=$StrNro;
}
$StrMod_=LIKE($StrMod);
$StrUsu_=LIKE($StrUsu);
//-------------------------
$FF="ID>0 AND EMPC LIKE '$StrEmp_' AND COM LIKE '$StrCom_' AND CSER LIKE '$StrSer_' AND ".
"CNUM LIKE '$StrNum_' AND FEC>='$StrDex_' AND  ".
"FEC<='$StrHax_' AND CLI LIKE '$StrPro_' AND ".
"ANU LIKE '$StrSN_' AND NUM LIKE '$StrNro_' AND TDP LIKE '$StrMod_' AND USU LIKE '$StrUsu_' ";
//-------------------------
$LStrTR=gn("count(*)","vcobroz",$FF);
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=200;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cobros - Buscar</title>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript" src="fe/funciones.js"></script>
<script>
$(document).ready(function(){
   $("#TxtDex").mask("99-99-99");    
   $("#TxtHax").mask("99-99-99");    
});
</script>
<script language="javascript">
$(document).ready(function() {
	$(".botonExcel").click(function(event) {
		$("#datos_a_enviar").val( $("<div>").append( $("#Exportar_a_Excel").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});
</script>
<link rel="stylesheet" type="text/css" href="basic.css"  />
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:1200px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-600px";?>;
}
#Layer2 {
	position:absolute;
	left:409px;
	top:205px;
	width:82px;
	height:24px;
	z-index:1;
}
.Estilo1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #FFFFFF;
}
.f2 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 12px; }
.Estilo3 {color: #FFFFFF; font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.s4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="cobroz_buscar.php">


<div class="s1" style="left: 317px; top: 91px; width: 58px;">
NUMERO
</div>
<input name="CmdV" type="button" id="CmdV"  
style="position:absolute; left: 79px; top: 50px; width: 60px;"
value="Volver" onclick="fVolver('cobroz.php');" />

<div id="layer3" 
style="position:absolute; left: 25px; top: 138px; width: 1150px; height: 423px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="1137" height="19" border="1" cellpadding="0" cellspacing="0">

<tr>
<td height="18" colspan="11" bgcolor="#666666" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>           
</tr>
<tr>
<td width="78" bgcolor="#999999" style="color:#000">EMPRESA</td>            
<td width="91" bgcolor="#999999" style="color:#000">NºCOBRO</td>            
<td width="47" bgcolor="#999999" style="color:#000">ANU</td>
<td width="52" bgcolor="#999999" style="color:#000">FECHA</td>
<td width="97" bgcolor="#999999" style="color:#000">COMPROBANTE</td>
<td width="108" bgcolor="#999999" style="color:#000">NUMERO</td> 
<td width="376" bgcolor="#999999" style="color:#000">CLIENTE</td>            
<td width="71" bgcolor="#999999" style="color:#000" align="right">EFECTIVO</td>
<td width="73" bgcolor="#999999" style="color:#000"  align="right">DEPOSITO</td> 
<td width="97" bgcolor="#999999" style="color:#000">USUARIO</td>            
<td width="23" bgcolor="#999999" style="color:#000">&nbsp;</td>
</tr>

<?php	
	$TOT_EFE=0;
	$TOT_DEP=0;
	$TOTAL=0;	  		
	$StrTemp=$StrPag * $VP_RegXPag;
	$ss="SELECT ID, NUM, DATE_FORMAT(FEC,'%d-%m-%y'), COM, CSER, CNUM,".
	    "SUBSTRING(CLI,1,45), ROUND(TOT,2), TDP, EMPC, ANU, USU
		FROM vcobroz WHERE $FF ORDER BY ID DESC ";		
	//echo $ss;		
	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X1B="<td bgcolor=\"#FFFFFF\" align=\"right\"><span class=\"Estilo5\">";
	$X2="</span></td>";
	$s=PagSql($ss,$LStrPag,$VP_RegXPag,$LStrTR);
	$result = grs($s);				
	while ($row = $result->fetch_row()){
		$TDP=$row[8];
		$EFE="0.0";
		$DEP="0.0";
		$SER=$row[4];
		$NUM=$row[5];
		if(strlen($SER)>0){
			$NUM=$SER."-".$NUM;
		}
		if($TDP=="EFECTIVO"){
			$EFE=$row[7];
			$TOT_EFE=$TOT_EFE +  $EFE;
		}else{
			$DEP=$row[7];
			$TOT_DEP=$TOT_DEP +  $DEP;
		}
		echo "<tr 
			  ondblclick=\"location.href='cobroz.php?Id=$row[0]&Pag=0';\">";
		echo $X1.$row[9].$X2;			  
		echo $X1.$row[1].$X2;
		
		echo $X1.$row[10].$X2;
				
		echo $X1.$row[2].$X2;
		echo $X1.$row[3].$X2;
		echo $X1.$NUM.$X2;
		echo $X1.$row[6].$X2;
		echo $X1B.NF3($EFE).$X2;
		echo $X1B.NF3($DEP).$X2;
		echo $X1.$row[11].$X2;
		
		echo "<td bgcolor=\"#FFFFFF\" align=\"center\">
			 <a href=\"cobroz.php?Id=$row[0]&Pag=0\" >
			 <img src=\"img/b_edit.png\"  border=\"0\"/>
			 </a>
			 </td>";
		echo "</tr>";
		$TOTAL=$TOTAL + $row[7];
	}

?>		  
<tr>
  <td bgcolor="#999999" style="color:#000">&nbsp;</td>	
  <td bgcolor="#999999" style="color:#000">&nbsp;</td>
   <td bgcolor="#999999" style="color:#000">&nbsp;</td>
  <td bgcolor="#999999" style="color:#000">&nbsp;</td>
  <td bgcolor="#999999" style="color:#000">&nbsp;</td>
  <td bgcolor="#999999" style="color:#000">&nbsp;</td>
  <td bgcolor="#999999" style="color:#000" align="right">TOTAL</td>
  <td bgcolor="#999999" style="color:#000" align="right"><?php echo NF2($TOT_EFE,2) ?></td>
  <td bgcolor="#999999" style="color:#000" align="right"><?php echo NF2($TOT_DEP,2) ?></td>
  <td bgcolor="#999999" style="color:#000" align="right"><?php echo NF2($TOTAL,2) ?></td>
   <td bgcolor="#999999" style="color:#000">&nbsp;</td>
 
</tr>   
</table>
</div>
</div>

    <div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">COBROS - BUSCAR
        <input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
        <input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
		<input name="TxtAc" type="hidden" id="TxtAc" value="" />
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/>  
      </div>
    </div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 318px; top: 108px; width: 58px;"
tabindex="3"  onblur="_N(this);"  
onkeydown="return SoloTextoEx(event,'TxtDex');" value="<?php echo $StrNum;?>" maxlength="6" />

    <div id="LblTit" style="position:absolute; left: 20px; top: 25px; width: 64px;">
    <div align="left" class="Estilo1"><img src="img/buscar.png" width="57" height="60" /></div>
  </div>	
<input name="CmdB" type="button" id="CmdB" 
style="position:absolute; left: 1100px; top: 108px; width: 78px;" 
value="Filtrar" onclick="fFiltrar();"  tabindex="8"/>
<div class="s1" style="left: 388px; top: 78px; width: 45px;">
DESDE
</div>
<div class="EV" style="left: 382px; top: 92px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtDex')">(dd-mm-yy) +</a></u></div>


<input name="TxtDex" type="text" id="TxtDex" 
style="left: 387px; top: 108px; width: 61px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="4" />

<input name="TxtPro" type="text" id="TxtPro" 
style="left: 532px; top: 108px; width: 122px;" value="<?php echo $StrPro;?>"  
onkeydown="return SoloTextoEx(event,'CboSN');" 
tabindex="6" />
<div class="s1" style="left: 534px; top: 91px; width: 100px;">
CLIENTE
</div>
<div class="s1" style="left: 461px; top: 78px; width: 60px;">
HASTA
</div>
<div class="EV" style="left: 457px; top: 92px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>
<input name="TxtHax" type="text" id="TxtHax" 
style="left: 460px; top: 108px; width: 60px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtPro');"
tabindex="5" />

<div class="s1" style="left:26px; top: 91px; width: 102px;">
EMPRESA
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:24px; top:108px; width: 110px;" 
onkeydown="return SoloTextoEx(event,'CboCom');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<select name="CboCom" id="CboCom" 
style="left: 151px; top: 108px; width: 102px;"  tabindex="1"
onkeydown="return SoloTextoEx(event,'TxtSer');">
<?php
echo FCBO_("com_nombre","comprobantes",
		"com_nombre IN ('FACTURA','BOLETA','PROFORMA','FACT. ELEC.','BOL. ELEC.')",$StrCom,"S","N");
?>
</select>
<div class="s1" style="left: 153px; top: 91px; width: 102px;">
COMPROBANTE
</div>
<div class="s1" style="left: 261px; top: 91px; width: 46px;">
  SERIE
</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="left: 261px; top: 108px; width: 47px;"
tabindex="2"   onblur="_S(this);"
onkeydown="return SoloTextoEx(event,'TxtNum');"
value="<?php echo $StrSer;?>" maxlength="4" />
<div class="s1" style="left: 667px; top: 91px; width: 75px;">
ANULADO
</div>
<select name="CboSN" id="CboSN" 
style="left: 665px; top: 108px; width: 81px;"  tabindex="7"
onkeydown="return SoloTextoEx(event,'TxtNro');">
<?php
if($StrSN=="" || $StrSN=="NO"){
AD("NO",1);	AD("SI",0);
}else{
AD("NO",0);	AD("SI",1);
}
?>
</select>
<div class="s1" style="left: 754px; top: 91px; width: 101px;">
N&ordm; COBRO.
</div>
<input name="TxtNro" type="text" id="TxtNro" 
style="left: 754px; top: 108px; width: 66px;" value="<?php echo $StrNro;?>"  
onkeydown="return SoloTextoEx(event,'CboMod');"
tabindex="8" />

<div class="s1" style="left: 835px; top: 91px; width: 113px;"> MODALIDAD
</div>
<select name="CboMod" id="CboMod" 
style="width:92px; position:absolute; left: 835px; top: 108px;" 
onkeydown="return SoloTextoEx(event,'CboUsu');" 
tabindex="8" 
>
<?php
echo FCBOO_("au_item","auxiliar","au_tab='MODA'",$StrMod,"S","N","au_orden");
?>
</select>

<div class="s1" style="left:946px; top: 91px; width: 133px;"> USUARIO
</div>
<select name="CboUsu" id="CboUsu" 
style="width:135px; position:absolute; left: 942px; top: 108px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" 
tabindex="6" 
>
<?php
	echo FCBO("USU","vis_usuarios_cargos","CAR='CAJERO'",$StrUsu,"S","N");
?>
</select>



</form>


<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position:absolute; left: 157px; top: 50px; width: 45px; height: 15px;">  
<input name="" type="button" class="botonExcel" value="Exportar" />
<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" />
</div>
</form>
</div>
</body>
</html>
