<?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']);
	//-------------------------
	$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_="2030-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(*)","vpagos",
							"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_'
							");
	$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>Proveedores - Buscar pagos emitidos</title>
<script type="text/javascript" src="fe/funciones.js"></script>
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:800px;
	height:600px;
	position:absolute;
	left:50%;
	top:50%;
	background-color:#006699;
	margin:-300px 0 0 -400px;
}
#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;}
.Estilo4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<form id="Frm" name="Frm" method="post" action="proveedores_edc_buscar.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    <div id="layer6" style="position:absolute; left: 585px; top: 96px; width: 63px;">
      <div align="left" class="f2">NUMERO</div>
    </div>
    <div id="layer5" style="position:absolute; left: 86px; top: 50px; width: 388px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('proveedores_edc.php');" />
        <input type="hidden" name="TxtAc" id="TxtAc" />
        <input name="TxtPag" id="TxtPag" type="hidden" value="<?php echo $LStrPag; ?>" />
      </div>
    </div>
    <div id="layer3" style="position:absolute; left: 31px; top: 146px; width: 746px; height: 381px;">
      <div align="left" class="f2">
        <table width="746" height="19" border="1" cellpadding="0" cellspacing="0">
        <tr  >
            <td height="18" colspan="9" bgcolor="#666666" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
            </td>
           
          </tr>
          <tr>
            <span class="Estilo4">
            <td width="66" bgcolor="#999999">FEC.EMI</td>
            <td width="200" bgcolor="#999999">PROVEEDOR</td>
            <td width="61" bgcolor="#999999">F. PAGO</td>
            <td width="69" bgcolor="#999999">NUMERO</td>
            <td width="95" bgcolor="#999999">COMPROBANTE</td>
            <td width="54" bgcolor="#999999">SERIE</td>
            <td width="82" bgcolor="#999999">NUMERO</td>
            <td width="63" align="right" bgcolor="#999999">TOTAL</td>
            <td width="36" bgcolor="#999999">&nbsp;</td>
            </span>
          </tr>
		  <?php		  		
		  		$StrTemp=$StrPag * $VP_RegXPag;
				$s="SELECT ID,DATE_FORMAT(FEC,'%d-%m-%y'),PROV,FPAGO,NUMF,COM,
					 SERR,NUMR,TOT 
				     FROM vpagos 
					 WHERE 
					 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_' 
					 ORDER BY FEC,PROV,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='proveedores_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=\"proveedores_edc.php?Id=$row[0]&Pag=0\" >
						 <img src=\"img/b_edit.png\"  border=\"0\"/>
						 </a>
						 </td>";
					echo "</tr>";
				}

		  ?>		  
         
         
        </table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 86px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">PROVEEDORES - BUSCAR PAGOS EMITIDOS</div>
    </div>
          <input name="TxtNum" type="text" id="TxtNum" 
          style="position:absolute; left: 586px; top: 116px; width: 53px;" value="<?php echo $StrNum;?>"  
          onkeydown="return SoloTextoEx(event,'CboPag');"
          tabindex="7" />

    <div id="LblTit" style="position:absolute; left: 27px; 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: 720px; top: 115px; width: 57px;"
value="Filtrar" 
        onclick="fFiltrar();"  tabindex="9"/>

    <div id="layer7" style="position:absolute; left: 160px; top: 96px; width: 45px;">
      <div align="left" class="f2">DESDE</div>
    </div>
        <input name="TxtDex" type="text" id="TxtDex" 
        style="position:absolute; left: 161px; top: 116px; width: 63px;" value="<?php echo $StrDex;?>"  
        onkeydown="return SoloFec(this,event,'TxtHax');"
        tabindex="2" />

        <input name="TxtPro" type="text" id="TxtPro" 
        style="position:absolute; left: 31px; top: 116px; width: 115px;" value="<?php echo $StrPro;?>"  
        onkeydown="return SoloTextoEx(event,'TxtDex');" 
        tabindex="1" />

    <div id="layer10" style="position:absolute; left: 30px; top: 96px; width: 124px;">
      <div align="left" class="f2">PROVEEDOR</div>
    </div>
    <div id="layer11" style="position:absolute; left: 237px; top: 96px; width: 60px;">
      <div align="left" class="f2">HASTA</div>
    </div>
        <input name="TxtHax" type="text" id="TxtHax" 
        style="position:absolute; left: 237px; top: 116px; width: 62px;" 
        value="<?php echo $StrHax;?>"  
        onkeydown="return SoloFec(this,event,'CboFdp');"
        tabindex="3" />

        <select name="CboCom" id="CboCom" 
style="position:absolute; left: 427px; top: 116px; width: 100px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');" tabindex="5">
<?php
if($StrCom=="TODOS"){
	echo "<option value=\"TODOS\" selected=\"selected\">TODOS</option>";	
}else{
	echo "<option value=\"TODOS\" >TODOS</option>";	
}
$s="SELECT com_nombre FROM comprobantes WHERE id_comprobante>= 0 ORDER BY com_nombre";
$result = grs($s);
while ($row = $result->fetch_row()){
if($StrCom==$row[0]){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[0]</option>";
}else{
echo "<option value=\"$row[0]\" >$row[0]</option>";
}
}
?>
        </select>

    <div id="layer13" style="position:absolute; left: 428px; top: 96px; width: 102px;">
      <div align="left" class="f2">COMPROBANTE</div>
    </div>
        <select name="CboFdp" id="CboFdp" style="position:absolute; left: 311px; top: 116px; width: 106px;" 
onkeydown="return SoloTextoEx(event,'CboCom');" tabindex="4">
<?php
if($StrFdp=="TODOS"){
	echo "<option value=\"TODOS\" selected=\"selected\">TODOS</option>";
}else{
	echo "<option value=\"TODOS\" >TODOS</option>";
}
$s="SELECT nombre FROM fpagos WHERE id_fpago>= 0 ORDER BY nombre";
$result = grs($s);
while ($row = $result->fetch_row()){
if($StrFdp==$row[0]){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[0]</option>";
}else{
echo "<option value=\"$row[0]\" >$row[0]</option>";
}
}
?>
        </select>

    <div id="layer14" style="position:absolute; left: 313px; top: 96px; width: 109px;">
      <div align="left" class="f2">FORMA DE PAGO</div>
    </div>
    <div id="layer15" style="position:absolute; left: 533px; top: 96px; width: 46px;">
      <div align="left" class="f2">SERIE</div>
    </div>
        <input name="TxtSer" type="text" id="TxtSer" 
          style="position:absolute; left: 533px; top: 116px; width: 45px;" value="<?php echo $StrSer;?>"  
          onkeydown="return SoloTextoEx(event,'TxtNum');"
          tabindex="6" />

    <div id="layer17" style="position:absolute; left: 654px; top: 96px; width: 63px;">
      <div align="left" class="f2">PAGO</div>
    </div>
        <select name="CboPag" id="CboPag" 
        style="position:absolute; left: 655px; top: 116px; width: 57px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="8">
<?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>

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