<?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);
	}
	
	$FF="ID>0 
	AND PROV 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_' ";
	
	//-------------------------
	$LStrTR=gn("count(*)","vpagos",$FF);
	$LStrPag=V($_POST['TxtPag']);	
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=50000;	
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
	//-------------------------	
	
$IdUsu=$_SESSION['SYS_USER_ID'];
$AT=gs("at","usuarios","id_usuario=$IdUsu");
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Proveedores - Buscar pagos emitidos</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("TxtPro");
});

</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="proveedores_edc_buscar.php">

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

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

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

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

<div class="s1"style="left: 543px; top: 117px; width: 46px;">
SERIE</div>
<input name="TxtSer" type="text" id="TxtSer" 
class="lt" style="left: 541px; top: 134px; width: 68px" 
value="<?php echo $StrSer;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 616px; top: 117px; width: 46px;">
NUMERO</div>    
<input name="TxtNum" type="text" id="TxtNum" 
class="lt" style="left: 616px; top: 135px; width: 66px" 
value="<?php echo $StrNum;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 694px; top: 118px; width: 109px;">
FORMA DE PAGO</div>
<select name="CboFdp" id="CboFdp" 
class="lt" style="left: 692px; top: 135px; width: 191px" 
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO("nombre","fpagos","id_fpago>0",$StrFdp,"S","N");?>
</select>

<div class="s1" style="left: 896px; top: 118px; width: 102px;">
COMPROBANTE</div>
<select name="CboCom" id="CboCom" 
class="lt" style="left: 895px; top: 135px; width: 177px" 
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO("com_nombre","comprobantes","id_comprobante>0",$StrCom,"S","N");?>
</select>

<div class="s1" style="left: 1077px; top: 118px; width: 63px;">
PAGO</div>
<select name="CboPag" id="CboPag" 
class="lt" style="left: 1078px; top: 135px; width: 60px" 
tabindex="<?php echo ++$TI;?>">
<?php
if($StrPago=="TODOS"){
echo "<option value=\"TODOS\" selected=\"selected\">TODOS</option>";
echo "<option value=\"NO\">NO</option>";
echo "<option value=\"SI\">SI</option>";
}
if($StrPago=="NO"){
echo "<option value=\"TODOS\">TODOS</option>";
echo "<option value=\"NO\" selected=\"selected\">NO</option>";
echo "<option value=\"SI\">SI</option>";
}
if($StrPago=="SI"){
echo "<option value=\"TODOS\">TODOS</option>";
echo "<option value=\"NO\">NO</option>";
echo "<option value=\"SI\" selected=\"selected\">SI</option>";
}

?>
</select>

<!----------------------------------------->
<?php $VOLVER="proveedores_edc.php";?>
<?php include("botones_b.php");?>;

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

<div class="datagrid" style="position: absolute; left: 35px; top: 165px; width: 1180px; height: 416px; overflow: auto">
<table width="100%">
<thead>
<tr>
<td colspan="13" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr>
<th width="55%">FEC.EMI</th>
<th width="13%">PROVEEDOR</th>
<th width="15%">F. PAGO</th>
<th width="14%">NUMERO</th>
<th width="14%">COMPROBANTE</th>
<th width="14%">SERIE</th>
<th width="14%">NUMERO</th>
<th width="14%">TOTAL</th>
<th width="3%">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php		  		
	$StrTemp=$StrPag * $VP_RegXPag;
	$s="SELECT ID,DATE_FORMAT(FEC,'%d-%m-%y'),PROV,FPAGO,NUMF,COM,SERR,NUMR,TOT 
	FROM vpagos 
	WHERE $FF	 
	ORDER BY FEC,PROV,FPAGO,NUMF ";		  							

    $result = grs($s);				
    while ($row = $result->fetch_row()){	
		?>	
        <tr onDblClick="location.href='proveedores_edc.php?Id=<?php echo $r[0];?>&Pag=0'">
        <!----------------------------------------------->
        <td ><?php echo $r[1];?></td>
        <td ><?php echo $r[2];?></td>
        <td ><?php echo $r[3];?></td>
        <td ><?php echo $r[4];?></td>
        <td ><?php echo $r[5];?></td>
        <td ><?php echo $r[6];?></td>
        <td ><?php echo $r[7];?></td>
        <td ><?php echo $r[8];?></td>
        <!----------------------------------------------->
        <td bgcolor="#FFFFFF" align="center">
        <a href="proveedores_edc.php?Id=<?php echo $r[0];?>&Pag=0">
        <img src="img/b_edit.png"  border="0"/></a></td>
        </tr>
        <?php

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

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

</tbody>
</table>
</div>


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