<?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;
}
//
	//-------------------------	
	$VP_RegXPag=200;
	//-------------------------
	$StrPag=V($_POST['TxtPag']);	
	//-------------------------
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	$StrFdp=V($_POST['CboFdp']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrPro=V($_POST['TxtPro']);		
	$StrMon=V($_POST['CboMon']);			
	//-------------------------
	if($StrCmd=="F"){
		$StrPag="0";
	}
	//-------------------------
	if(strlen($StrFdp)==0) $StrFdp="TODOS";	
	if(strlen($StrMon)==0) $StrMon="SOLES";	
	//-------------------------
	$StrMon_=substr($StrMon,0,1);
	if($StrFdp=="TODOS"){
		$StrFdp_="%";
	}else{
		$StrFdp_=$StrFdp;
	}
	$StrNum_=$StrNum."%";
	if(strlen($StrDex)==0){
		$StrDex_="2000-01-01";
	}else{
		$StrDex_=ToDate($StrDex);
	}
	if(strlen($StrHax)==0){
		$StrHax_="2030-12-01";//
	}else{
		$StrHax_=ToDate($StrHax);
	}
	$StrPro_=$StrPro."%";
	//-------------------------
	$StrTR=gn("count(*)","vcobros",
							"(ID>0 AND FPAGO<>'EFECTIVO' )AND			
							FPAGO LIKE '$StrFdp_' AND 
							NUMF LIKE '$StrNum_' AND 
							FECVEN >= '$StrDex_' AND 
							FECVEN <= '$StrHax_' AND 
							CLI LIKE '$StrPro_' AND MON LIKE '$StrMon_'");
	//-------------------------
	if(strlen($StrPag)==0)$StrPag="0";
	if($StrCmd=="MSig")$StrPag=($StrPag+1);
	if($StrCmd=="MAnt")	$StrPag=($StrPag-1);
	if($StrCmd=="MPri")	$StrPag=0;
	if($StrCmd=="MUlt")	$StrPag=(floor($StrTR / $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>Compras - Buscar</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}
#Frm center #DivFRM #layer3 .f2 table tr td {
	color: #000;
}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<form id="Frm" name="Frm" method="post" action="letras_x_cobrar.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    <div id="layer6" style="position:absolute; left: 171px; top: 86px; width: 74px;">
      <div align="left" class="f2">NUMERO</div>
    </div>
    <div id="layer5" style="position:absolute; left: 116px; top: 50px; width: 138px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('menu.php');" />
        <input type="hidden" name="TxtAc" id="TxtAc" />
      </div>
    </div>
    <div id="layer3" style="position:absolute; left: 34px; top: 138px; width: 739px; height: 200px;">
      <div align="left" class="f2">
        <table width="737" height="36" border="1" cellpadding="0" cellspacing="0">
        
        <tr  >
            <td height="18" colspan="5" bgcolor="#666666" align="center">
<?php
if($LStrTR>$VP_RegXPag){
if($LStrPag==0){
	echo "<input style=\"width:40px\" name=\"CmdNP\" type=\"button\" id=\"CmdNP\" value=\"|&lt;\"  onclick=\"fPrimero();\" disabled=\"disabled\"/>";
	echo "<input style=\"width:40px\" name=\"CmdNA\" type=\"button\" id=\"CmdNA\" value=\"<\"  onclick=\"fAnterior();\" disabled=\"disabled\" />";
}else{
	echo "<input style=\"width:40px\" name=\"CmdNP\" type=\"button\" id=\"CmdNP\" value=\"|&lt;\"  onclick=\"fPrimero();\"/>";
	echo "<input style=\"width:40px\" name=\"CmdNA\" type=\"button\" id=\"CmdNA\" value=\"<\"  onclick=\"fAnterior();\"/>";
}
if($LStrPag==(floor($LStrTR / $VP_RegXPag)) ){
	echo "<input style=\"width:40px\" name=\"CmdNS\" type=\"button\" id=\"CmdNS\" value=\">\"  onclick=\"fSiguiente();\"  disabled=\"disabled\" />";
	echo "<input style=\"width:40px\" name=\"CmdNU\" type=\"button\" id=\"CmdNU\" value=\"&gt;|\"  onclick=\"fUltimo();\"  disabled=\"disabled\"/>";				
}else{
	echo "<input style=\"width:40px\" name=\"CmdNS\" type=\"button\" id=\"CmdNS\" value=\">\"  onclick=\"fSiguiente();\" />";
	echo "<input style=\"width:40px\" name=\"CmdNU\" type=\"button\" id=\"CmdNU\" value=\"&gt;|\"  onclick=\"fUltimo();\"/>";				
}
}
?>
            </td>
           
          </tr>
          <tr>
            <td width="93" bgcolor="#999999"><span class="Estilo4">F. PAGO</span></td>
            <td width="93" bgcolor="#999999"><span class="Estilo4">NUMERO</span></td>
            <td width="75" bgcolor="#999999"><span class="Estilo4">FEC.VEN.</span></td>
            <td width="84" bgcolor="#999999" style="text-align:right"><span class="Estilo4">TOTAL</span></td>
            <td bgcolor="#999999"><span class="Estilo4">CLIENTE</span></td>            
          </tr>
		  <?php	
		  		$TOT=0;	  		
		  		$StrTemp=$StrPag * $VP_RegXPag;
				$ss="SELECT FPAGO,NUMF,DATE_FORMAT(FECVEN,'%d-%m-%y'),TOT,CLI
				     FROM vcobros 
					 WHERE 
					 (ID>0 AND FPAGO<>'EFECTIVO' )AND			
					 FPAGO LIKE '$StrFdp_' AND 
					 NUMF LIKE '$StrNum_' AND 
					 FECVEN >= '$StrDex_' AND 
					 FECVEN <= '$StrHax_' AND 
					 CLI LIKE '$StrPro_' AND MON LIKE '$StrMon_' 
					 ORDER BY FECVEN,FPAGO,NUMF ";
		  		if($StrTR<=$VP_RegXPag){
					$s=$ss;
				}else{
					$s=$ss." LIMIT $StrTemp,$VP_RegXPag";
				}
				$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
				$X2="</span></td>";
				$result = grs($s);				
				while ($row = $result->fetch_row()){
					echo "<tr>";
					echo $X1.$row[0].$X2;
					echo $X1.$row[1].$X2;
					echo $X1.$row[2].$X2;
					echo "<td bgcolor=\"#FFFFFF\" style=\"text-align:right\"><span class=\"Estilo5\">".$row[3].$X2;
					echo $X1.$row[4].$X2;				
					echo "</tr>";
					$TOT=$TOT + $row[3];
				}

		  ?>		  
          <tr  >
            <td height="17" colspan="2" bgcolor="#FFFFFF">
             </td>
            <td bgcolor="#FFFFFF" >TOTAL</td>
            <td bgcolor="#FFFFFF" style="text-align:right" ><?php echo $TOT;?></td>
            <td bgcolor="#FFFFFF" ></td>
           
          </tr>
         
        </table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 116px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">LETRAS / CHEQUES POR COBRAR</div>
    </div>
          <input name="TxtNum" type="text" id="TxtNum" 
          style="position:absolute; left: 170px; top: 109px; width: 86px;" value="<?php echo $StrNum;?>"  
          onkeydown="return SoloTextoEx(event,'TxtDex');"
          tabindex="2" />

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

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

        <input name="TxtPro" type="text" id="TxtPro" 
        style="position:absolute; left: 417px; top: 109px; width: 191px;" value="<?php echo $StrPro;?>"  
        onkeydown="return SoloTextoEx(event,'CboMon');" 
        tabindex="5" />

    <div id="layer10" style="position:absolute; left: 417px; top: 86px; width: 100px;">
      <div align="left" class="f2">CLIENTE</div>
    </div>
    <div id="layer11" style="position:absolute; left: 346px; top: 86px; width: 60px;">
      <div align="left" class="f2">HASTA</div>
    </div>
        <input name="TxtHax" type="text" id="TxtHax" 
        style="position:absolute; left: 344px; top: 109px; width: 62px;" 
        value="<?php echo $StrHax;?>"  
        onkeydown="return SoloFec(this,event,'TxtPro');"
        tabindex="4" />

<select name="CboFdp" id="CboFdp" 
style="position:absolute; left: 34px; top: 109px; width: 125px;" 
onkeydown="return SoloTextoEx(event,'TxtNum');" tabindex="1">
<?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  AND nombre<>'EFECTIVO' 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="layer13" style="position:absolute; left: 35px; top: 86px; width: 128px;">
      <div align="left" class="f2">FORMA DE PAGO</div>
    </div>
    <div id="layer14" style="position:absolute; left: 268px; top: 67px; width: 151px;">
      <div align="left" class="f2">FEC. VENCIMIENTO</div>
    </div>
<select name="CboMon" id="CboMon" style="position:absolute; left: 618px; top: 108px; width: 91px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="6">
<?php
$s="SELECT mon_nombre FROM monedas WHERE id_moneda<>'X' ORDER BY mon_nombre DESC";
$result = grs($s);
while ($row = $result->fetch_row()){
if($StrMon==$row[0]){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[0]</option>";
}else{
echo "<option value=\"$row[0]\" >$row[0]</option>";
}
}
?>
</select>

    <div id="layer15" style="position:absolute; left: 618px; top: 86px; width: 100px;">
      <div align="left" class="f2">MONEDA</div>
    </div>
  </div>
</center>	
</form>
</body>
</html>
