<?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']);		
	$StrSer=V($_POST['TxtSer']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrCli=V($_POST['TxtCli']);			
	$StrSerR=V($_POST['TxtSerR']);			
	$StrNumR=V($_POST['TxtNumR']);			
	$StrSN=V($_POST['CboSN']);			
	//
	if(strlen($StrEmp)==0)$StrEmp=GE("S");
	if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");
	//
	if(strlen($StrDex)==0)$StrDex=HACE_UN_MES();
	if(strlen($StrHax)==0)$StrHax=HOY();
	//
	$StrEmp_=LIKE($StrEmp);
	$StrAlm_=LIKE($StrAlm);
	$StrSer_=$StrSer."%";	
	$StrNum_=$StrNum."%";
	$StrDex_=val_dex($StrDex);
	$StrHax_=val_hax($StrHax);
	$StrCli_=$StrCli."%";
	if(strlen($StrSerR)==0){
		$StrSerR_="%";
	}else{
		$StrSerR_=$StrSerR;
	}
	if(strlen($StrNumR)==0){
		$StrNumR_="%";
	}else{
		$StrNumR_=$StrNumR;
	}
	if(strlen($StrSN)==0)$StrSN="NO";
	$StrSN_=substr($StrSN,0,1);	
	
	//-------------------------
	$FF="ID>0 AND EMPC LIKE '$StrEmp_' AND ALM LIKE '$StrAlm_' AND 
		 SER LIKE '$StrSer_' AND 
		 NUM LIKE '$StrNum_' AND FEC >= '$StrDex_' AND 
		 FEC <= '$StrHax_' AND DES LIKE '$StrCli_' AND 
		 ANU LIKE '$StrSN_' AND COT_SER LIKE '$StrSerR_' AND 
		 COT_NUM LIKE '$StrNumR_'";
	$LStrTR=gn("count(*)","vginterna",$FF);
	$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=22;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
$TI=0;
?>
<!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>Guias - 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 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>
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);
	}
}


$(document).ready(function(){
	$("#TxtDex").mask("99-99-99");
	$("#TxtHax").mask("99-99-99");
	jFocus("CboAlm");
});
</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:1000px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-500px";?>;
}
#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  >
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="guia_interna_buscar_express.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('guia_interna.php?TxtAc=X');" />
</div>
</div>

<div class="s1" 
style="position:absolute; left: 25px; top: 146px; width: 969px; height: 422px; overflow:auto">

<table id="Exportar_a_Excel" width="946" height="19" border="1" cellpadding="0" cellspacing="0">
<tr  >
<td height="18" colspan="5" bgcolor="#666666" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>

</tr>
<tr class="Estilo5">
<td width="151" bgcolor="#999999">EMP/ALM</td>
<td width="160" bgcolor="#999999">NUMERO</td>
<td width="72" bgcolor="#999999">FECHA</td>
<td width="451" bgcolor="#999999">DESTINATARIO / CLIENTE </td>
<td width="100" bgcolor="#999999">PROFORMA</td>
</tr>
<?php		  			
	$s="SELECT ID,ALM,CONCAT(SER,'-',NUM) as SN,DATE_FORMAT(FEC,'%d-%m-%y'),
		SUBSTRING(DES,1,58) AS DES,".
	   "CONCAT(COT_SER,'-',COT_NUM),EMPC ".
	   "FROM vginterna WHERE $FF ORDER BY ID DESC ";
	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X1B="<td bgcolor=\"#FFFFFF\" align=\"right\"><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='guia_interna.php?Id=$row[0]&Pag=0';\">";
		echo $X1.$row[6]." / ".$row[1].$X2;
		//echo $X1.$row[2].$X2;
		echo "<td bgcolor=\"#FFFFFF\"><a target=\"_blank\" href=\"guia_interna.php?Id=$row[0]\">'$row[2]</a></td>";
		echo $X1.$row[3].$X2;
		echo $X1.$row[4].$X2;
		echo $X1.$row[5].$X2;
		echo "</tr>";
	}
?>		  
         
         
</table>
</div>


<div id="layer" style="position:absolute; left: 79px; top: 30px; width: 511px; height: 24px;">
<div align="left" class="Estilo1">GUIA INTERNA - 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");?>"/> 
(X) Ordenado por el mas reciente
</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 style="position:absolute; left: 26px; top: 100px; width: 146px;">
<div align="left" class="f2">EMPRESA</div>
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:24px; top:119px; width: 123px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>


<div class="s1" style="left: 158px; top: 98px; width: 76px;">
ALMACEN</div>
<select name="CboAlm" id="CboAlm" 
style="left: 156px; top: 117px; width: 103px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');" 
tabindex="<?php echo ++$TI;?>">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div class="s1" style="left:265px; top: 98px; width: 52px;">SERIE</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="left: 265px; top: 117px; width: 47px;" value="<?php echo $StrSer;?>"  
onkeydown="return SoloTextoEx(event,'TxtNum');" onblur="_S(this);"
tabindex="<?php echo ++$TI;?>" maxlength="4" />

<div class="s1" style="left: 321px; top: 98px; width: 65px;">NUMERO</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 322px; top: 117px; width: 60px;" value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TxtDex');" onblur="_N(this);" maxlength="6"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 389px; top: 86px; width: 45px;">
DESDE</div>
<div class="EV" style="left: 384px; 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: 389px; top: 117px; width: 65px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 464px; top: 86px; width: 60px;">
HASTA</div>
<div class="EV" style="left: 459px; 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: 463px; top: 117px; width: 65px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtCli');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 540px; top: 85px; width: 133px;">
DESTINATARIO / CLIENTE</div>
<input name="TxtCli" type="text" id="TxtCli" 
style="left: 538px; top: 117px; width: 144px;" value="<?php echo $StrCli;?>"  
onkeydown="return SoloTextoEx(event,'TxtSerR');" 
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 691px; top:81px; width: 135px;">
PROFORMA
</div>
<div class="s1" style="left: 691px; top: 98px; width: 48px;">
SERIE
</div>
<input name="TxtSerR" type="text" id="TxtSerR" 
style="left: 691px; top: 117px; width: 43px;" value="<?php echo $StrSerR;?>"  
onkeydown="return SoloTextoEx(event,'TxtNumR');" onblur="_S(this);"
tabindex="<?php echo ++$TI;?>" maxlength="4" />
<div class="s1" style="left: 737px; top: 98px; width: 70px;">
NUMERO
</div>
<input name="TxtNumR" type="text" id="TxtNumR" 
style="left: 741px; top: 117px; width: 78px;" value="<?php echo $StrNumR;?>"  
onkeydown="return SoloTextoEx(event,'CboSN');" onblur="_N(this);" maxlength="6"
tabindex="<?php echo ++$TI;?>" />



<div class="s1" style="left: 828px; top: 98px; width: 75px;">
ANULADO
</div>
<select name="CboSN" id="CboSN" 
style="position:absolute; left: 826px; top: 117px; width: 64px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="<?php echo ++$TI;?>">
<?php
if($StrSN=="" || $StrSN=="NO"){
AD("NO",1);	AD("SI",0);
}else{
AD("NO",0);	AD("SI",1);
}
?>
</select>

<input name="CmdB" type="button" id="CmdB"
style="position:absolute; left: 899px; top: 117px; width: 57px;"
value="Filtrar" onclick="fFiltrar();"  tabindex="<?php echo ++$TI;?>"/>

</form>

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