<?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']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrCli=V($_POST['TxtCli']);
	$StrCom=V($_POST['CboCom']);		
	$StrSerR=V($_POST['TxtSerR']);			
	$StrNumR=V($_POST['TxtNumR']);			
	$StrSN=V($_POST['CboSN']);				
	$StrUsu=V($_POST['CboUsu']);				
	//
	if(strlen($StrEmp)==0)$StrEmp=GE("S");
	if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");
	if(strlen($StrUsu)==0)$StrUsu="TODOS";
	//
	$StrEmp_=LIKE($StrEmp);
	$StrAlm_=LIKE($StrAlm);
	//		
	$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);
	}
	$StrCli_=$StrCli."%";
	if(strlen($StrSerR)==0){
		$StrSerR_="%";
	}else{
		$StrSerR_=$StrSerR;
	}
	if(strlen($StrNumR)==0){
		$StrNumR_="%";
	}else{
		$StrNumR_=$StrNumR;
	}
	if($StrCom=="TODOS" || strlen($StrCom)==0){
		$StrCom_="%";
	}else{
		$StrCom_=$StrCom;
	}
	if(strlen($StrSN)==0)$StrSN="NO";
	$StrSN_=substr($StrSN,0,1);	
	$StrUsu_=LIKE($StrUsu);
	//-------------------------
	$FF="ID>0 AND EMPC LIKE '$StrEmp_' AND ALMC LIKE '$StrAlm_' AND  
		 NRO LIKE '$StrNum_' AND FEC >= '$StrDex_' AND 
		 FEC <= '$StrHax_' AND CLI LIKE '$StrCli_' AND 
		 COM LIKE '$StrCom_' AND SER LIKE '$StrSerR_' AND 
		 NUM LIKE '$StrNumR_' AND  
		 ANU LIKE '$StrSN_' AND TIP='J' AND USU LIKE '$StrUsu_' ";
	$LStrTR=gn("count(*)","vdevoluciones",$FF);
	$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=500;	
$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>Devoluciones - Buscar</title>
<?php AddJs();?>
<script type="text/javascript" src="fe/funcionez.js"></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>
<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>
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<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:1200px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-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;
}
.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;}

}
.Estilo5 {color:#003}

-->
</style>

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

<div id="layer5" style="position:absolute; left: 79px; top: 50px; width: 85px; height: 28px;">
<div align="left" class="f2">
<input name="CmdV" type="button" id="CmdV" 
value="Volver" onclick="fVolver('devoluciom.php?TxtAc=X');" />
</div>
</div>
<div id="layer3" style="position:absolute; left: 25px; top: 147px; width: 1154px; height: 422px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="1135" 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>
<td width="132" bgcolor="#999999" style="color:#000">ALMACEN</td>
<td width="83" bgcolor="#999999" style="color:#000">NUMERO</td>
<td width="93" bgcolor="#999999" style="color:#000">FECHA</td>
<td width="366" bgcolor="#999999" style="color:#000">CLIENTE</td>
<td width="127" bgcolor="#999999" style="color:#000">COMPROBANTE</td>
<td width="121" bgcolor="#999999" style="color:#000">SERIE-NUMERO</td>
<td width="34" bgcolor="#999999" style="color:#000">ANU</td>
<td width="126" bgcolor="#999999" style="color:#000">USUARIO</td>
<td width="33" bgcolor="#999999" style="color:#000">&nbsp;</td>
</tr>
<?php		  			
	$s="SELECT ID, ALM, NRO, DATE_FORMAT(FEC,'%d-%m-%y'), SUBSTRING(CLI,1,53), COM,".
	   "CONCAT(SER,'-',NUM) as SER_NUM, ANU,USU ".
	   "FROM vdevoluciones WHERE $FF ORDER BY ID DESC";	
	$X1="<td bgcolor=\"#FFFFFF\" style=\"color:#000\">";
	$X1B="<td bgcolor=\"#FFFFFF\" align=\"right\" style=\"color:#000\">";
	$X2="</span></td>";
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);	
	$result = grs($s);				
	while ($row = $result->fetch_row()){
		echo "<tr 
			  ondblclick=\"location.href='devoluciom.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=\"devoluciom.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: 79px; top: 30px; width: 412px; height: 24px;">
<div align="left" class="Estilo1">DEVOLUCIONES (DEJA) - 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>


<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 class="s1" style="left: 24px; top: 100px; width: 96px;">
EMPRESA
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:24px; top:118px; width: 110px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<div class="s1" style="left: 147px; top: 100px; width: 96px;">
ALMACEN
</div>
<select name="CboAlm" id="CboAlm" 
style="left: 144px; top: 118px; width: 107px;" 
onkeydown="return SoloTextoEx(event,'TxtNum');" tabindex="1">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div class="s1" style="left: 260px; top: 100px; width: 74px;">
NUMERO
</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 261px; top: 118px; width: 60px;" value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="2" />

<div class="s1" style="left: 330px; top: 86px; width: 45px;">
DESDE
</div>
<div class="EV" style="left: 328px; top: 102px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtDex')">(dd-mm-yy) +</a></u></div>

<input name="TxtDex" type="text" id="TxtDex" 
style="left: 330px; top: 118px; width: 69px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="3" />

<div class="s1" style="left: 409px; top: 86px; width: 60px;">
HASTA
</div>
<div class="EV" style="left: 408px; top: 102px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>
<input name="TxtHax" type="text" id="TxtHax" 
style="left: 410px; top: 118px; width: 65px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtCli');"
tabindex="4" />

<div class="s1" style="left: 488px; top: 100px; width: 31px;">
 CLIENTE
</div>
<input name="TxtCli" type="text" id="TxtCli" 
style="left: 486px; top: 118px; width: 97px;" value="<?php echo $StrCli;?>"  
onkeydown="return SoloTextoEx(event,'TxtSerR');" 
tabindex="5" />

<div class="s1" style="left: 595px; top: 100px; width: 98px;">
COMPROBANTE
</div>
<select name="CboCom" id="CboCom" 
style="left: 595px; top: 118px; width: 104px;" 
onkeydown="return SoloTextoEx(event,'TxtSerR');"
tabindex="6">
<?php
echo FCBO_("com_nombre","comprobantes",
		  "com_nombre IN ('FACTURA','BOLETA','PROFORMA','FACT. ELEC.','BOL. ELEC.')",$StrCom,"S","N");
?>
</select>

<div class="s1" style="left: 595px; top:83px; width: 169px;">
REFERENCIA
</div>
<div class="s1" style="left: 707px; top: 100px; width: 48px;">
SERIE
</div>
<input name="TxtSerR" type="text" id="TxtSerR" 
style="left: 707px; top: 118px; width: 43px;" 
onblur="_S(this);"
value="<?php echo $StrSerR;?>"  
onkeydown="return SoloTextoEx(event,'TxtNumR');"
tabindex="7" />

<div class="s1" style="left: 760px; top: 100px; width: 70px;">
NUMERO
</div>
<input name="TxtNumR" type="text" id="TxtNumR" 
style="left: 760px; top: 118px; width: 69px;" 
onblur="_N(this);"
value="<?php echo $StrNumR;?>"  
onkeydown="return SoloTextoEx(event,'CboSN');"
tabindex="8" />

<div class="s1" style="left: 840px; top: 100px; width: 75px;">
ANULADO
</div>
<select name="CboSN" id="CboSN" 
style="position:absolute; left: 840px; top: 118px; width: 67px;" 
onkeydown="return SoloTextoEx(event,'CboUsu');" tabindex="9">
<?php
if($StrSN=="" || $StrSN=="NO"){
AD("NO",1);	AD("SI",0);
}else{
AD("NO",0);	AD("SI",1);
}
?>
</select>

<div class="s1" style="left:919px; top: 101px; width: 160px;"> USUARIO
</div>
<select name="CboUsu" id="CboUsu" 
style="width:159px; position:absolute; left: 918px; 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: 1094px; top: 118px; width: 85px;"
value="Filtrar" onclick="fFiltrar();"  tabindex="10"/>


</form>

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