<?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']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrCon=V($_POST['TxtCon']);				
	$StrCli=V($_POST['TxtCli']);				
	$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");
	//
	$StrEmp_=LIKE($StrEmp);
	$StrNum_="%".$StrNum;	
	$StrDex_=val_dex($StrDex);
	$StrHax_=val_hax($StrHax);
	$StrCon_="%".$StrCon;
	$StrCli_=$StrCli."%";
	if($StrMod=="TODOS"){
		$StrMod_="%";
	}else{
		$StrMod_=$StrMod;
	}
	$StrUsu_=LIKE($StrUsu);
	//-------------------------
	$FF="ID>0 AND EMPC LIKE '$StrEmp_' AND NUM LIKE '$StrNum_' AND 
		FEC>='$StrDex_' AND FEC<='$StrHax_' AND 
		CON_NRO LIKE '$StrCon_' AND 
		CLI LIKE '$StrCli_' AND TIP LIKE '$StrMod_' AND USU LIKE '$StrUsu_' ";
	$LStrTR=gn("count(*)","vis_contratos_ingresos",$FF);
	$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=200;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
$LStrFoc="document.getElementById('CboEmp').focus();";
$LStrMsg="onload=\"$LStrFoc;\"";	
?>
<!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>Contratos Ingresos - 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:1050px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-525px";?>;
}
#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 $LStrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="contratos_ingresos_buscar.php">
<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>	
<div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; height: 24px;">
<div align="left" class="Estilo1">CONTRATOS INGRESOS - 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="CmdV" type="button" id="CmdV"  
style="position:absolute; left: 79px; top: 50px; width: 60px;"
value="Volver" onclick="fVolver('contratos_ingresos.php');" />

<div id="layer3" 
style="position:absolute; left: 25px; top: 147px; width: 1021px; height: 423px; overflow:auto">
<div align="left" class="f2">
        <table id="Exportar_a_Excel" width="1001" 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="69" bgcolor="#999999" style="color:#000">NºINGRESO</td>            
<td width="76" bgcolor="#999999" style="color:#000">FECHA</td>
<td width="88" bgcolor="#999999" style="color:#000">N&ordm;CONTRATO</td>
<td width="325" bgcolor="#999999" style="color:#000">CLIENTE</td> 
<td width="142" bgcolor="#999999" style="color:#000" align="right">TOT.CONTRATO</td>            
<td width="64" bgcolor="#999999" style="color:#000" align="right">T.ACUENTA</td>
<td width="67" bgcolor="#999999" style="color:#000" align="right">COBRADO</td>
<td width="69" bgcolor="#999999" style="color:#000" >MODALIDAD</td>
<td width="67" bgcolor="#999999" style="color:#000" align="right">SALDO</td>
<td width="67" bgcolor="#999999" style="color:#000" >USUARIO</td>
<td width="12" bgcolor="#999999">&nbsp;</td>
</tr>

<?php		
	$T_T=0;  		
	$StrTemp=$StrPag * $VP_RegXPag;
	$ss="SELECT ID,NUM,DATE_FORMAT(FEC,'%d-%m-%y') as F,CON_NRO,CLI,
		 CON_TOT,ACU,ROUND(TOT,2) as T,TIP,SAL,USU 
		 FROM vis_contratos_ingresos 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_assoc()){		
		$ID=$row['ID'];
		echo "<tr 
			  ondblclick=\"location.href='contratos_ingresos.php?Id=$ID&Pag=0';\">";
		echo $X1.$row['NUM'].$X2;		
		echo $X1.$row['F'].$X2;
		echo $X1.$row['CON_NRO'].$X2;
		echo $X1.$row['CLI'].$X2;
		echo $X1B.NF3($row['CON_TOT']).$X2;
		echo $X1B.NF3($row['ACU']).$X2;
		echo $X1B.NF3($row['T']).$X2;
		echo $X1.$row['TIP'].$X2;
		echo $X1B.NF3($row['SAL']).$X2;
		echo $X1.$row['USU'].$X2;
		echo "<td bgcolor=\"#FFFFFF\" align=\"center\">
			 <a href=\"contratos_ingresos.php?Id=$ID&Pag=0\" >
			 <img src=\"img/b_edit.png\"  border=\"0\"/>
			 </a>
			 </td>";
		echo "</tr>";
		$T_T=$T_T + $row['T'];  
	}

?>		  
<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" align="right"></td>
<td bgcolor="#999999" style="color:#000" align="right">TOTAL</td>
<td bgcolor="#999999" style="color:#000" align="right"><?php echo NF3($T_T);?></td>
<td bgcolor="#999999" style="color:#000" >&nbsp;</td>
<td bgcolor="#999999" style="color:#000" align="right">&nbsp;</td>
<td bgcolor="#999999">&nbsp;</td>
<td bgcolor="#999999">&nbsp;</td>
</tr>        
        </table>
      </div>
    </div>
<div class="s1" style="left: 24px; top: 102px; width: 80px;">
EMPRESA</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:24px; top:117px; width: 113px;" 
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<div class="s1" style="left: 149px; top: 102px; width: 80px;">
Nº INGRESO</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 147px; top: 117px; width: 75px;" value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="1" />

<div class="s1" style="left: 234px; top: 85px; width: 45px;">
DESDE</div>
<div class="EV" style="left: 230px; top: 101px; width: 88px; color:#FF0">
<u><a onclick="fFecServer('TxtDex')">(dd-mm-yy) +</a></u></div>
<input name="TxtDex" type="text" id="TxtDex" 
style="left: 232px; top: 117px; width: 76px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="2" />

<div class="s1" style="left: 324px; top: 85px; width: 60px;">
HASTA</div>
<div class="EV" style="left: 320px; top: 101px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>
<input name="TxtHax" type="text" id="TxtHax" 
style="left: 321px; top: 117px; width: 76px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtCon');"
tabindex="3" />

<div class="s1" style="left:408px; top: 102px; width: 92px;">
Nº CONTRATO</div>
<input name="TxtCon" type="text" id="TxtCon" 
style="left:408px; top: 117px; width: 87px;" value="<?php echo $StrCon;?>"  
onkeydown="return SoloTextoEx(event,'TxtCli');"
tabindex="4" />

<div class="s1" style="left: 509px; top: 101px; width: 113px;">
CLIENTE</div>
<input name="TxtCli" type="text" id="TxtCli" 
style="left: 507px; top: 117px; width: 181px;" 
value="<?php echo $StrCli;?>"  
onkeydown="return SoloTextoEx(event,'CboMod');" 
tabindex="5" />

<div class="s1" style="left:702px; top: 101px; width: 98px;"> MODALIDAD
</div>
<select name="CboMod" id="CboMod" 
style="width:109px; position:absolute; left: 701px; top: 117px;" 
onkeydown="return SoloTextoEx(event,'CboUsu');" 
tabindex="6" 
>
<?php
echo FCBOO_("au_item","auxiliar","au_tab='MODA'",$StrMod,"S","N","au_orden");
?>
</select>

<div class="s1" style="left:819px; top: 101px; width: 129px;"> USUARIO
</div>
<select name="CboUsu" id="CboUsu" 
style="width:127px; position:absolute; left: 818px; top: 117px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" 
tabindex="6" 
>
<?php
	echo FCBO("USU","vis_usuarios_cargos","CAR='CAJERO'",$StrUsu,"S","N");
?>
</select>

<input name="CmdB" type="button" id="CmdB" 
style="position:absolute; left: 956px; top: 117px; width: 68px;" 
value="Filtrar" onclick="fFiltrar();"  tabindex="7"/>

</form>
<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position:absolute; left: 156px; 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>
