<?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']);	
	$StrAlm=V($_POST['CboAlm']);		
	$StrTde=V($_POST['CboTde']);		
	$StrDex=V($_POST['TxtDex']);
	$StrHax=V($_POST['TxtHax']);	
	$StrNro=V($_POST['TxtNro']);	
	$StrUsu=V($_POST['CboUsu']);	
	$StrAnu=V($_POST['CboAnu']);	
	//
	if(strlen($StrEmp)==0)$StrEmp=GE("S");
	if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");
	//		
	if(strlen($StrDex)==0)$StrDex=date("d-m-y");
	if(strlen($StrHax)==0)$StrHax=date("d-m-y");	
	//-------------------------
	if(strlen($StrTde)==0) $StrTde="TODOS";
	if(strlen($StrUsu)==0) $StrUsu="TODOS";
	if(strlen($StrAnu)==0) $StrAnu="TODOS";
	//-------------------------
	$StrTde_=$StrTde;
	if($StrTde=="TODOS") $StrTde_="%";
	$StrEmp_=LIKE($StrEmp);
	$StrAlm_=LIKE($StrAlm);
	$StrDex_=val_dex($StrDex);
	$StrHax_=val_hax($StrHax);
    $StrNro_=$StrNro."%";
	$StrUsu_=LIKE($StrUsu);
	$StrAnu_=substr(LIKE($StrAnu),0,1);
	//-------------------------
	$FF="ID>0 AND EMPC LIKE '$StrEmp_' AND ALM LIKE '$StrAlm_' AND 
		 TDE LIKE '$StrTde_' AND 
		 FEC >= '$StrDex_' AND 
		 FEC <= '$StrHax_' AND 
		 NRO LIKE '$StrNro_' AND USU LIKE '$StrUsu_' AND anu LIKE '$StrAnu_' ";
	//-------------------------
	$LStrTR=gn("count(*)","vegresos",$FF);
	$LStrPag=V($_POST['TxtPag']);	
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=20;	
	$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>Egresos buscar</title>
<!--CSS_NEW------------------------------------->
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<!--CSS_NEW------------------------------------->
<?php AddJs();?>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script>
$(document).ready(function(){
   $("#TxtDex").mask("99-99-99");      
   $("#TxtHax").mask("99-99-99");      
});
function EM_OC(){	
	var Emp=gv("CboEmp");	
	var r=AX("03",Emp);
	if(r=="X"){
		CBO_CLS("CboAlm",1);
	}else{
		CBO_FILL("CboAlm",r,0);
	}
}
</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>
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:1200px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px 0 0 -600px";?>;
}
#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;
}
.xx2 {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;}
.z4 {color: #000099}
.z5 {color: #000000}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="egresos_buscar.php">

  
    <div id="layer5" style="position:absolute; left: 116px; top: 50px; width: 85px; height: 28px;">
      <div align="left" class="xx2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('egresos.php');" />
        <input type="hidden" name="TxtAc" id="TxtAc" />
        <input name="TxtPag" id="TxtPag" type="hidden" value="<?php echo $LStrPag; ?>" />
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/>  
      </div>
  </div>

<div id="layer3" style="position:absolute; left: 30px; top: 146px; width: 1157px; height: 428px;">
<div align="left" class="xx2">
<table id="Exportar_a_Excel" width="1132" height="52" border="1" cellpadding="0" cellspacing="0">

<tr>
<td height="18" colspan="10" bgcolor="#666666" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>
<tr>
<td width="118" bgcolor="#999999"><span class="z4">EMPRESA</span></td>
<td width="83" bgcolor="#999999"><span class="z4">FECHA</span></td>
<td width="113" bgcolor="#999999"><span class="z4">ALMACEN</span></td>
<td width="267" bgcolor="#999999"><span class="z4">TIPO DE EGRESO</span></td>
<td width="227" bgcolor="#999999"><span class="z4">OBS</span></td>
<td width="75" bgcolor="#999999" align="right"><span class="z4">TOTAL</span></td>
<td width="67" bgcolor="#999999" ><span class="z4">RECIBO</span></td>
<td width="109" bgcolor="#999999" ><span class="z4">USUARIO</span></td>
<td width="24" bgcolor="#999999" ><span class="z4">ANU</span></td>
<td width="27" bgcolor="#999999"></td>
</tr>
<?php	
$TOTAL=0; 		
$s="SELECT ID, DATE_FORMAT(FEC,'%d-%m-%y'),
	ALM,SUBSTRING(TDE,1,20),
	SUBSTRING(OBS,1,33) AS OBS,ROUND(TOT,1),
	NRO,EMPC,USU,ANU 
	FROM vegresos 
	WHERE  $FF ORDER BY FEC,ALM,TDE ";

$X1="<td bgcolor=\"#FFFFFF\"><span class=\"z5\">";
$X2="</span></td>";
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
$result = grs($s);				
while ($row = $result->fetch_row()){
	echo "<tr 
	ondblclick=\"location.href='egresos.php?Id=$row[0]&Pag=0';\">";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[7]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[1]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[2]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[3]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[4]</span></td>";
	echo "<td bgcolor=\"#FFFFFF\" align=\"right\">
	<span class=\"z5\">".NF3($row[5])."</span></td>";
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[6]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[8]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\">
	<span class=\"z5\">$row[9]</span></td>";
	
	echo "<td bgcolor=\"#FFFFFF\" align=\"center\">
	<a href=\"egresos.php?Id=$row[0]&Pag=0\" >
	<img src=\"img/b_edit.png\"  border=\"0\"/>
	</a>
	</td>";
	echo "</tr>";
	$TOTAL=$TOTAL + $row[5];
}

?>		  
<tr class="z5"  >
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF" >&nbsp;</td>

<td bgcolor="#FFFFFF" style="text-align:right; color: #000;">TOTAL</td>
<td  bgcolor="#FFFFFF" style="text-align:right; color: #000;" ><?php echo NF3($TOTAL);?></td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
</tr>
</table>
</div>
</div>


<div id="layer" style="position:absolute; left: 116px; top: 30px; width: 622px; height: 20px;">
<div align="left" class="Estilo1">EGRESOS - BUSCAR</div>
</div>
<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>	

<div style="position:absolute; left: 29px; top: 101px; width: 92px;">
<div align="left" class="xx2">EMPRESA</div></div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:29px; top:117px; width: 154px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<div style="position:absolute; left: 196px; top: 101px; width: 92px;">
<div align="left" class="xx2">ALMACEN</div></div>
<select name="CboAlm" id="CboAlm" style="position:absolute; left: 193px; top: 117px; width: 121px;" 
onkeydown="return SoloTextoEx(event,'CboTde');">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div style="position:absolute; left: 330px; top: 101px; width: 143px;">
<div align="left" class="xx2">TIPO DE EGRESO</div></div>
<select name="CboTde" id="CboTde" 
style="position:absolute; left: 329px; top: 117px; width: 199px;" 
onkeydown="return SoloTextoEx(event,'TxtDex');">
<?php
echo FCBO_("nombre","egresos_tipos","id_et>0",$StrTde,"S","N");
?>
</select>

<div style="position:absolute; left: 537px; top: 85px; width: 45px;">
<div align="left" class="xx2">DESDE</div>
</div>
<div class="EV" style="left: 536px; top: 100px; width: 88px; color:#FF0"><u>
<a onclick="fFecServer('TxtDex')">(dd-mm-yy) +</a></u></div>
<input name="TxtDex" type="text" id="TxtDex" 
style="position:absolute; left: 535px; top: 117px; width: 73px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="1" />

<div style="position:absolute; left: 626px; top: 85px; width: 66px;">
<div align="left" class="xx2">HASTA</div>
</div>
<div class="EV" style="left: 623px; top: 100px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>
<input name="TxtHax" type="text" id="TxtHax" 
style="position:absolute; left: 623px; top: 117px; width: 73px;" value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtNro');"
tabindex="1" />

<div style="position:absolute; left: 709px; top: 101px; width: 99px;">
<div align="left" class="xx2">NRO. RECIBO</div>
</div>
<input name="TxtNro" type="text" id="TxtNro" 
style="position:absolute; left: 709px; top: 117px; width: 107px;" 
value="<?php echo $StrNro;?>"  
onkeydown="return SoloTextoEx(event,'CboUsu');"
tabindex="1" />

<div style="position:absolute; left: 832px; top: 101px; width: 98px;">
<div align="left" class="xx2">USUARIO</div></div>
<select name="CboUsu" id="CboUsu" 
style="position:absolute; left: 832px; top: 117px; width: 135px;" 
onkeydown="return SoloTextoEx(event,'CboAnu');">
<?php
echo FCBO("USU","vis_usuarios_cargos","CAR='CAJERO'",$StrUsu,"S","N");
?>
</select>

<div style="position:absolute; left: 983px; top: 101px; width: 143px;">
<div align="left" class="xx2">ANULADO</div></div>
<select name="CboAnu" id="CboAnu" 
style="position:absolute; left: 983px; top: 117px; width: 85px;" tabindex="8"
onkeydown="return SoloTextoEx(event,'CmdB');">
<?php echo FCBO_("au_item","auxiliar","au_tab='SI_NO'",$StrAnu,"S","N");?>
</select>



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

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