<?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']);			
	$StrPro=V($_POST['TxtPro']);			
	$StrSN=V($_POST['CboSN']);			
	$StrCod=V($_POST['TxtCod']);	
	$StrDes=V($_POST['TxtDes']);		
	$StrSerR=V($_POST['TxtSerR']);		
	$StrNumR=V($_POST['TxtNumR']);		
	//	
	if(strlen($StrEmp)==0)$StrEmp=GE("S");
	if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");
	//
	if(strlen($StrSN)==0)$StrSN="NO";
	/*
	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);
	$StrPro_=$StrPro."%";		
	$StrSN_=substr($StrSN,0,1);
	if(strlen($StrCod)==0){
		$StrCod_="%";	
	}else{
		$StrCod_=$StrCod;
	}
	$StrDes_=$StrDes."%";	
	$StrSerR_=val_vac($StrSerR);	
	$StrNumR_=val_vac($StrNumR);	
	//-------------------------
	$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 DEST LIKE '$StrPro_' AND 
		 ANU LIKE '$StrSN_' AND PRO_DES LIKE '$StrDes_' AND 
		 COT_SER LIKE '$StrSerR_' AND COT_NUM LIKE '$StrNumR_' AND 
		 PRO_COD LIKE '$StrCod_'";

$LStrTR=gn("count(*)","vginterna_det",$FF);
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=200;	
$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>Guia Interna - Buscar - Detallado</title>
<link rel="stylesheet" type="text/css" href="basic.css"  />
<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/funcionez.js"></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>
<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:1100px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-550px";?>;
}
#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;}
.z4 {
	color: #000099;
}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body  >
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="guia_interna_buscar_det.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 id="layer3" 
style="position:absolute; left: 25px; top: 143px; width: 1069px; height: 434px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="1048" height="19" border="1" cellpadding="0" cellspacing="0">
<tr  >
<td height="18" colspan="7" bgcolor="#666666" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>
           
</tr>
<tr>
<td width="125" bgcolor="#999999"><span class="z4">EMP / ALM</span></td>
<td width="126" bgcolor="#999999"><span class="z4">NUMERO</span></td>
<td width="91" bgcolor="#999999"><span class="z4">FECHA</span></td>
<td width="262" bgcolor="#999999"><span class="z4">DESTINATARIO</span></td>
<td width="107" bgcolor="#999999" ><span class="z4">COD</span></td>
<td width="273" bgcolor="#999999" ><span class="z4">DESCRIPCION</span></td>
<td width="48" bgcolor="#999999" ><span class="z4">CANT</span></td>

</tr>
<?php		
	$_TP=0;  		
	$s="SELECT ID,ALM,CONCAT(SER,'-',NUM) as SN,DATE_FORMAT(FEC,'%d-%m-%y'),SUBSTRING(DEST,1,30),PRO_COD,".
	   "PRO_DES,CA,PIEZAS,EMPC  ".
	   "FROM vginterna_det WHERE $FF ORDER BY ID,PRO_COD";    
	//echo $s;
	$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);
	//echo $s."<br>";
	$result = grs($s);				
	while ($row = $result->fetch_row()){
		echo "<tr 
			  ondblclick=\"location.href='guia_interna.php?Id=$row[0]&Pag=0';\">";
		echo $X1.$row[9]." / ".$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]."x".$row[8].$X2;
		echo $X1.$row[6].$X2;
		echo $X1.$row[7].$X2;	
		echo "</tr>";
		$_TP=$_TP + $row[7];
	}
?>		  
<tr>
<td width="125" bgcolor="#999999">&nbsp;</td>
<td width="126" bgcolor="#999999">&nbsp;</td>
<td width="91" bgcolor="#999999">&nbsp;</td>
<td width="262" bgcolor="#999999">&nbsp;</td>
<td width="107" bgcolor="#999999" >&nbsp;</td>
<td width="273" bgcolor="#999999" ><span class="z4">TOTAL CAJAS</span></td>
<td width="48" bgcolor="#999999" ><span class="z4"><?php echo NF4($_TP);?></span></td>

</tr>
</table>
      </div>
    </div>
<div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; 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");?>"/>  
- Detallado</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:25px; top:96px; width: 89px;">
<div align="left" class="f2">EMPRESA</div>
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:23px; top:114px; width: 99px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>
	

<div class="s1" style="left: 133px; top: 96px; width: 106px;">
ALMACEN</div>
<select name="CboAlm" id="CboAlm" style="left: 129px; top: 114px; width: 113px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');" tabindex="<?php echo ++$TI;?>">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div class="s1" style="left:249px; top: 96px; width: 74px;">
SERIE</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="left: 249px; top: 114px; width: 51px;" 
value="<?php echo $StrSer;?>"   onblur="_S(this);"
onkeydown="return SoloTextoEx(event,'TxtNum');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 306px; top: 96px; width: 74px;">NUMERO</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 307px; top: 114px; width: 59px;" 
onblur="_N(this);"
value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 378px; top: 85px; width: 59px;">
DESDE</div>
<div class="EV" style="left: 375px; top: 98px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtDex')">(dd-mm-yy) +</a></u></div>
<input name="TxtDex" type="text" id="TxtDex" 
style="left: 378px; top: 114px; width: 65px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 457px; top: 85px; width: 60px;">
HASTA</div>
<div class="EV" style="left: 452px; top: 98px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>   
<input name="TxtHax" type="text" id="TxtHax" 
style="left: 456px; top: 114px; width: 61px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtPro');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 534px; top: 96px; width: 93px;">
DESTINATARIO</div>
<input name="TxtPro" type="text" id="TxtPro" 
style="left: 531px; top: 114px; width: 103px;" value="<?php echo $StrPro;?>"  
onkeydown="return SoloTextoEx(event,'CboSN');" 
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 640px; top: 96px; width: 70px;">
ANULADO</div>
<select name="CboSN" id="CboSN" 
style="left: 640px; top: 114px; width: 63px;" 
onkeydown="return SoloTextoEx(event,'TxtCod');" tabindex="<?php echo ++$TI;?>">
<?php
	echo FCBO_("au_item","auxiliar","au_tab='SI_NO'",$StrSN,"N","N");
?>
</select>

<div class="s1" style="left:708px; top: 96px; width: 62px;">
CODIGO</div>
<input name="TxtCod" type="text" id="TxtCod" 
style="left:708px; top: 114px; width: 61px;" value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 779px; top: 96px; width: 116px;">
DESCRIPCION</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="left: 777px; top: 114px; width: 94px;" value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'TxtSerR');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 879px; top: 78px; width: 151px;">
PROFORMA</div>
<div class="s1" style="left: 879px; top: 96px; width: 53px;">
SERIE</div>
<div class="s1" style="left: 939px; top: 96px; width: 74px;">
NUMERO</div>
<input name="TxtSerR" type="text" id="TxtSerR" 
style="left: 879px; top: 114px; width: 53px;" 
value="<?php echo $StrSerR;?>"   onblur="_S(this);"
onkeydown="return SoloTextoEx(event,'TxtNumR');"
tabindex="<?php echo ++$TI;?>" />

<input name="TxtNumR" type="text" id="TxtNumR" 
style="left: 938px; top: 114px; width: 67px;" 
value="<?php echo $StrNumR;?>"   onblur="_N(this);"
onkeydown="return SoloTextoEx(event,'CmdB');"
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdB"
style="position:absolute; left: 1013px; top: 114px; 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: 157px; 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>
