<?php
	session_start();
	include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
	if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}	
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	$StrPro=V($_POST['TxtPro']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrFdp=V($_POST['CboFdp']);			
	$StrCom=V($_POST['CboCom']);			
	$StrSer=V($_POST['TxtSer']);			
	$StrNum=V($_POST['TxtNum']);			
	$StrPago=V($_POST['CboPag']);			
	
	//-------------------------
	if(strlen($StrFdp)==0) $StrFdp="TODOS";
	if(strlen($StrCom)==0) $StrCom="TODOS";
	if(strlen($StrPag)==0) $StrPago="TODOS";
	//-------------------------
	$StrPro_=$StrPro."%";
	if(strlen($StrDex)==0){
		$StrDex_="2000-01-01";
	}else{
		$StrDex_=ToDate($StrDex);
	}
	if(strlen($StrHax)==0){
		$StrHax_="2020-12-01";
	}else{
		$StrHax_=ToDate($StrHax);
	}
	if($StrFdp=="TODOS"){
		$StrFdp_="%";
	}else{
		$StrFdp_=$StrFdp;
	}
	if($StrCom=="TODOS"){
		$StrCom_="%";
	}else{
		$StrCom_=$StrCom;
	}
	$StrSer_=$StrSer."%";
	$StrNum_=$StrNum."%";
	if($StrPago=="TODOS"){
		$StrPag_="%";
	}else{
		$StrPag_=substr($StrPago,0,1);
	}
	//-------------------------
	$LStrTR=gn("count(*)","vcobros",
							"ID>0 AND 
							CLI LIKE '$StrPro_' AND 
							FEC>='$StrDex_' AND FEC<='$StrHax_' AND
							FPAGO LIKE '$StrFdp_' AND 
							COM LIKE '$StrCom_' AND
							SERR LIKE '$StrSer_' AND
							NUMR LIKE '$StrNum_' AND 
							PAG LIKE '$StrPag_'
							");
	$LStrPag=V($_POST['TxtPag']);	
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=50000;	
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
	
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Clientes - Buscar cobros realizados</title>
<!----------------------------------------->
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>

<!----------------------------------------->
<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/basic.css"  />
<link rel="stylesheet" type="text/css" href="css/mnu.css"  />
<!----------------------------------------->
<style type="text/css">
.cF {height:600px;width:1250px;position:relative;top:0px}
.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}

</style>

<!----------------------------------------->
<script>
$(document).ready(function(){  
   Inicializar();
   jF("TxtNom");
});

$(document).keydown(function(e){
	var AT=gv("TxtAT");

	if(e.which==66 && e.altKey){
		if(AT=="1"){	
		document.getElementById("CmdB").click();
		return;
		}
	}

	if(e.which==86 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").click();
		return;
		}
	}
  
});
</script>
<!----------------------------------------->

<body  <?php echo $LStrMsg;?>  >
<div align="center">

<div class="mM" align="left" style="font-size:12px">
<?php
$HTM=file_get_contents("http://inversionessounduniversal.com/ventas/phpmnu.php?USER_ID=$IdUsu");
echo $HTM;
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="clientes_edc_buscar.php">

<!----------------------------------------->
<div id="DivT" class="dT"  style="width:1250px;">
<img src="b.png" class="iT" />
<div class="tT">CLIENTES - BUSCAR COBROS REALIZADOS</div>
</div>
<!----------------------------------------->

<div class="s1" style="left: 35px; top: 121px; width: 124px;">
CLIENTE</div>
<input name="TxtPro" type="text" id="TxtPro" 
class="lt" style="left: 35px; top: 138px; width: 237px" 
value="<?php echo $StrPro;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 280px; top: 121px; width: 45px;">
DESDE</div>
<input name="TxtDex"  type="text" id="TxtDex"
class="fe" style="left: 280px; top: 138px; width: 73px;" 
value="<?php echo $StrDex;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 360px; top: 121px; width: 60px;">
HASTA</div>
<input name="TxtHax"  type="text" id="TxtHax"
class="fe" style="left: 361px; top: 138px; width: 73px;" 
value="<?php echo $StrHax;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 444px; top: 121px; width: 46px;">
SERIE</div>
<input name="TxtSer" type="text" id="TxtSer" 
class="lt" style="left: 444px; top: 138px; width: 55px;"
value="<?php echo $StrSer;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 511px; top: 121px; width: 63px;">
NUMERO</div>
<input name="TxtNum" type="text" id="TxtNum" 
class="lt" style="left: 509px; top: 138px; width: 60px;"
value="<?php echo $StrNum;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 746px; top: 121px; width: 102px;">
COMPROBANTE</div>
<select name="CboCom" id="CboCom" 
style="position: absolute; left: 745px; top: 138px; width: 193px" 
onkeydown="return SoloTextoEx(event,'TxtSer');" tabindex="5">
<?php echo FCBO("com_nombre","comprobantes","id_comprobante>0",$StrCom,"S","N");?>
</select>

<div class="s1" style="left: 586px; top: 121px; width: 109px;">
FORMA DE PAGO</div>
<select name="CboFdp" id="CboFdp" style="position: absolute; left: 584px; top: 138px; width: 151px" 
onkeydown="return SoloTextoEx(event,'CboCom');" tabindex="4">
<?php echo FCBO("nombre","fpagos","id_fpago>0",$CboFdp,"S","N");?>
</select>

<div class="s1" style="left: 948px; top: 121px; width: 63px;">
PAGO</div>
<select name="CboPag" id="CboPag" 
style="position: absolute; left: 949px; top: 138px; width: 80px" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="8">
<?php echo FCBO("aux_nom","auxiliar","aux_des='SN'",$CboPag,"S","N");?>
</select>
	
<!----------------------------------------->
<?php $VOLVER="clientes_edc.php";?>
<?php include("botones_b.php");?>;

<!-----------------------------------------> 

<div class="datagrid" style="position: absolute; left: 35px; top: 174px; width: 1180px; height: 400px; overflow: auto">

<table width="100%">
<thead>
<tr>
<td colspan="10" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr>
<th width="75">FEC.EMI</th>
<th width="320">CLIENTE</th>
<th width="138">F.PAGO</th>
<th width="148">NUMERO</th>
<th width="151">COMPROBANTE</th>
<th width="81">SERIE</th>
<th width="94">NUMERO</th>
<th width="88">TOTAL</th>
<th width="43">&nbsp;</th>
</tr>
</thead>
<tbody>

<?php		  		

	$s="SELECT ID,DATE_FORMAT(FEC,'%d-%m-%y'),CLI,FPAGO,NUMF,COM,
		 SERR,NUMR,TOT 
		 FROM vcobros  
		 WHERE 
		 ID>0 AND 
		 CLI LIKE '$StrPro_' AND 
		 FEC>='$StrDex_' AND FEC<='$StrHax_' AND
		 FPAGO LIKE '$StrFdp_' AND 
		 COM LIKE '$StrCom_' AND
		 SERR LIKE '$StrSer_' AND
		 NUMR LIKE '$StrNum_' AND 
		 PAG LIKE '$StrPag_' 
		 ORDER BY FEC,CLI,FPAGO,NUMF ";
							
	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X2="</span></td>";
	//$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
	$result = grs($s);				
	while ($row = $result->fetch_row()){
echo "<tr ondblclick=\"location.href='clientes_edc.php?Id=$row[0]&Pag=0';\">";
		echo $X1.$row[1].$X2;
		echo $X1.$row[2].$X2;
		echo $X1.$row[3].$X2;
		echo $X1.$row[4].$X2;
		echo $X1.$row[5].$X2;
		echo $X1.$row[6].$X2;
		echo $X1.$row[7].$X2;
		echo $X1.$row[8].$X2;
		echo "<td bgcolor=\"#FFFFFF\" align=\"center\">
			 <a href=\"clientes_edc.php?Id=$row[0]&Pag=0\" >
			 <img src=\"img/b_edit.png\"  border=\"0\"/>
			 </a>
			 </td>";
		echo "</tr>";

		$ST=$ST+$row[8];
	}

?>		  
        
<tr>
<td colspan="7" bgcolor="#999999" style="text-align:right"><span class="Estilo4"><b>TOTAL</b></span></td>
<td width="88" bgcolor="#999999" style="text-align:right"><span class="Estilo4"><b><?php echo NF2($ST,1);?></b></span></td>
<td bgcolor="#999999">&nbsp;</td>

</tr>
       
</tbody>
</table>
</div>
    
<!----------------------------------------->
<?php include("ocultos.php");?>

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