<?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']);	
	$StrEmpD=V($_POST['CboEmpD']);	
	$StrAlmD=V($_POST['CboAlmD']);
	$StrSN=V($_POST['CboSN']);		
	$StrNum=V($_POST['TxtNum']);	
	$TraSer=V($_POST['TraSer']);		
	$TraNum=V($_POST['TraNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrDes=V($_POST['TxtDes']);		
	$StrMar="%";
	$StrCod=V($_POST['TxtCod']);			
	//
	if(strlen($StrEmp)==0)$StrEmp=GE("S");
	if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");
	if(strlen($StrEmpD)==0)$StrEmpD="TODOS";
	if(strlen($StrAlmD)==0)$StrAlmD="TODOS";
	//
	if(strlen($StrSN)==0)$StrSN="NO";	
	//
	$StrEmp_=LIKE($StrEmp);
	$StrEmpD_=LIKE($StrEmpD);
	$StrAlm_=LIKE($StrAlm);
	$StrAlmD_=LIKE($StrAlmD);
	
	$StrNum_=$StrNum."%";
	$TraSer_="%".$TraSer;
	$TraNum_="%".$TraNum;
	$StrCod_=$StrCod."%";
	$StrDex_=val_dex($StrDex);
	$StrHax_=val_hax($StrHax);
	$StrDes_=$StrDes."%";
	$StrMar_=$StrMar."%";
	//-------------------------
	$StrSN_=substr($StrSN,0,1);
	//-------------------------	
	$FF="ID>0 AND O_EMPC LIKE '$StrEmp_' AND D_EMPC LIKE '$StrEmpD_' AND 
		ALM_O LIKE '$StrAlm_' 
		AND ALM_D LIKE '$StrAlmD_' 
		AND NUM LIKE '$StrNum_' 
		AND FEC >= '$StrDex_' 
		AND FEC <= '$StrHax_' 
		AND ANU LIKE '$StrSN_' 
		AND DES LIKE '$StrDes_' 
		AND LINEA LIKE '$StrMar_' 
		AND COD LIKE '$StrCod_' 
		AND TSER LIKE '$TraSer_' 
		AND TNUM LIKE '$TraNum_' ";

	include("trasferencias_b_fun.php");
	$LStrTR=gn("count(*)","vtransferencias_det",$FF);								
	$LStrPag=V($_POST['TxtPag']);
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=1000;
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
	$LStrFoc="document.getElementById('CboAlm').focus();";
	$LStrMsg="onload=\"$LStrFoc;\"";
	$IT=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>Transferencias - Buscar - Detallado</title>
<?php AddJs();?>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script>
$(document).ready(function(){  
   Inicializar();
});
//
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);
	}
}
//
function EM_OCD(){
	var Emp=gv("CboEmpD");	
	var r=AX("01",Emp);
	if(r=="X"){
		CBO_CLS("CboAlmD",1);
	}else{
		CBO_FILL("CboAlmD",r,0);
	}
}
//
function fGenPDF(){
	var eo =gv("CboEmp");
	var ao =gv("CboAlm");
	var ed =gv("CboEmpD");
	var ad =gv("CboAlmD");
	if(eo=="TODOS"){
		alert("Seleccione una empresa de origen");
		jF("CboEmp");return;
	}
	if(ao=="TODOS"){
		alert("Seleccione un almacen de origen");
		jF("CboAlm");return;
	}

	if(ed=="TODOS"){
		alert("Seleccione una empresa de origen");
		jF("CboEmpD");return;
	}
	if(ad=="TODOS"){
		alert("Seleccione un almacen de origen");
		jF("CboAlmD");return;
	}

	document.getElementById("TxtAc").value="GEN_PDF_3";
	document.getElementById("Frm").submit();
}
</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");
});
</script>
<!--CSS_NEW------------------------------------->
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<!--CSS_NEW------------------------------------->
<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;}
.s4 {color: #000099}
.Estilo5 {color: #000000}
.x4 {color: #000099}

-->
</style>

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

  

<div id="layer5" style="position:absolute; left: 116px; top: 50px; width: 554px;">
<div align="left" class="f2">
<input name="CmdV" type="button" id="CmdV" 
value="Volver" onclick="fVolver('transferencias.php?TxtAc=X');" />

<input name="CmdPDF" type="button" id="CmdPDF" 
value="Generar PDF" onclick="fGenPDF();"  
tabindex="<?php echo ++$TI;?>" />


</div>
</div>

<div style="position:absolute; left: 30px; top: 155px; width: 1160px; height: 399px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="1140" height="19" 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="114" bgcolor="#999999"><span class="x4">ORIGEN</span></td>
<td width="121" bgcolor="#999999"><span class="x4">DESTINO</span></td>
<td width="127" bgcolor="#999999"><span class="x4">NUM.AUT.</span></td>
<td width="93" bgcolor="#999999"><span class="x4">FECHA</span></td>
<td width="94" bgcolor="#999999"><span class="x4">T.SER.NUM</span></td>
<td width="105" bgcolor="#999999"><span class="x4">CODIGO</span></td>
<td width="266" bgcolor="#999999"><span class="x4">DESCRIPCION</span></td>
<td width="97" bgcolor="#999999"><span class="x4">LINEA</span></td>
<td width="54" bgcolor="#999999"><span class="x4">CANT</span></td>
<td width="47" bgcolor="#999999"><span class="x4">PIEZA</span></td>

</tr>
<?php
$_TP=0;
	$s="SELECT ID,ALM_O,ALM_D,NUM,DATE_FORMAT(FEC,'%d-%m-%y') AS FEC,
		DES,LINEA,KA,COD,
		CAN_UNI AS PIEZA,TSER,TNUM,O_EMPC,D_EMPC
		FROM vtransferencias_det WHERE ".$FF." ORDER BY ALM_O,ALM_D,NUM,FEC  ";	
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);	  				
	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X2="</span></td>";
	$result = grs($s);				
	while ($row = $result->fetch_assoc()){
		$S_=$row['TSER'];
		$N_=$row['TNUM'];
		if(strlen($S_)>0 && strlen($N_)>0){
			$S_=$S_."-".$N_;
		}else{
			$S_="";
		}
		echo "<tr ondblclick=\"location.href='transferencias.php?Id=$row[ID]&Pag=0';\">";
		echo $X1.$row['O_EMPC']." / ".$row['ALM_O'].$X2;
		echo $X1.$row['D_EMPC']." / ".$row['ALM_D'].$X2;
		echo "<td bgcolor=\"#FFFFFF\"><a target=\"_blank\" href=\"transferencias.php?Id=$row[ID]\">'$row[NUM]</a></td>";
		echo $X1.$S_.$X2;
		echo $X1.$row['FEC'].$X2;
		echo $X1."'".$row['COD'].$X2;
		echo $X1.$row['DES'].$X2;
		echo $X1.VV($row['LINEA']).$X2;
		echo $X1.$row['KA'].$X2;
		echo $X1.$row['PIEZA'].$X2;
		echo "</tr>";
		$_TP=$_TP + $row['KA'];
	}
?>		  
<tr>
<td width="114" bgcolor="#999999">&nbsp;</td>
<td width="121" bgcolor="#999999">&nbsp;</td>
<td width="127" bgcolor="#999999">&nbsp;</td>
<td width="93" bgcolor="#999999">&nbsp;</td>
<td width="94" bgcolor="#999999">&nbsp;</td>
<td width="105" bgcolor="#999999">&nbsp;</td>
<td width="266" bgcolor="#999999">&nbsp;</td>
<td width="97" bgcolor="#999999"><span class="x4">TOTAL CAJAS</span></td>
<td width="54" bgcolor="#999999"><span class="x4"><?php echo NF4($_TP);?></span></td>
<td width="47" bgcolor="#999999">&nbsp;</td>

</tr>
        </table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 116px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">TRANSFERENCIAS - 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: 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:30px; top: 109px; width: 87px;">
<div align="left" class="f2">EMP. ORIGEN</div>
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:30px; top:126px; width: 112px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<div style="position:absolute; left: 153px; top: 109px; width: 87px;">
<div align="left" class="f2">ALM. ORIGEN</div>
</div>
<select name="CboAlm" id="CboAlm" 
style="position:absolute; left: 148px; top: 126px; width: 95px;" 
tabindex="<?php echo ++$IT;?>"
onkeydown="return SoloTextoEx(event,'CboAlmD');">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div style="position:absolute; left:253px; top: 109px; width: 97px;">
<div align="left" class="f2">EMP. DESTINO</div>
</div>
<select name="CboEmpD" id="CboEmpD" 
style="position:absolute; left:251px; top:127px; width: 96px;" 
onchange="EM_OCD();"
onkeydown="return SoloTextoEx(event,'CboAlmD');" tabindex="1">
<?php 
	echo FCBO_("emp_nomc","empresas","id_emp>0",$StrEmpD,"S","N");
?>
</select>


<div style="position:absolute; left: 357px; top: 109px; width: 97px;">
<div align="left" class="f2">ALM. DESTINO</div>
</div>
<select name="CboAlmD" id="CboAlmD" 
style="position:absolute; left: 354px; top: 126px; width: 105px;" 
tabindex="<?php echo ++$IT;?>"
onkeydown="return SoloTextoEx(event,'TxtNum');">
<?php 
	if(strlen($StrEmpD)==0 || $StrEmpD=="TODOS"){
		echo FCBO_("ANC","vis_almacenes","IDA>0 ",$StrAlmD,"S","N");
	}else{
		echo FCBO_("ANC","vis_almacenes","IDA>0 AND ENC ='$StrEmpD'",$StrAlmD,"S","N");
	}
?>
</select>

<div style="position:absolute; left: 465px; top: 95px; width: 68px;">
<div align="left" class="f2">CODIGO TRANSFE..</div>
</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="position:absolute; left: 465px; top: 126px; width: 63px;" 
value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TraSer');"
tabindex="<?php echo ++$IT;?>" />

<div style="position:absolute; left:534px; top: 95px; width: 118px;">
<div align="left" class="f2">TRANSFERENCIA</div>
</div>
<div style="position:absolute; left: 534px; top: 109px; width: 49px;">
<div align="left" class="f2">SERIE</div>
</div>
<input name="TraSer" type="text" id="TraSer" 
style="position:absolute; left: 534px; top: 126px; width: 43px;" 
value="<?php echo $TraSer;?>"   onblur="_S(this);"
onkeydown="return SoloTextoEx(event,'TraNum');"
tabindex="<?php echo ++$IT;?>" />

<div style="position:absolute; left: 584px; top: 109px; width: 49px;">
<div align="left" class="f2">NUMERO</div>
</div>
<input name="TraNum" type="text" id="TraNum" 
style="position:absolute; left: 584px; top: 126px; width: 60px;" 
value="<?php echo $TraNum;?>"   onblur="_N(this);"
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="<?php echo ++$IT;?>" />

<div style="position:absolute; left: 651px; top: 94px; width: 45px;">
<div align="left" class="f2">DESDE</div>
</div>
<div class="EV" style="left: 648px; top: 108px; 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: 651px; top: 126px; width: 67px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="<?php echo ++$IT;?>" />

<div style="position:absolute; left: 731px; top: 94px; width: 71px;">
<div align="left" class="f2">HASTA</div>
</div>
<div class="EV" style="left: 730px; top: 108px; width: 75px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>
<input name="TxtHax" type="text" id="TxtHax" 
style="position:absolute; left: 729px; top: 126px; width: 76px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'CboSN');"
tabindex="<?php echo ++$IT;?>" />


<div style="position:absolute; left: 812px; top: 109px; width: 69px;">
<div align="left" class="f2">ANULADO</div>
</div>
<select name="CboSN" id="CboSN" 
style="position:absolute; left: 810px; top: 126px; width: 63px;" 
tabindex="<?php echo ++$IT;?>"
onkeydown="return SoloTextoEx(event,'TxtCod');">
<?php
	if($StrSN=="" || $StrSN=="NO"){
		AD("NO",1);	AD("SI",0);
	}else{
		AD("NO",0);	AD("SI",1);
	}
?>
</select>

<div style="position:absolute; left: 883px; top: 109px; width: 70px;">
<div align="left" class="f2">CODIGO</div>
</div>
<input name="TxtCod" type="text" id="TxtCod" 
style="position:absolute; left: 880px; top: 126px; width: 75px;" 
value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
tabindex="<?php echo ++$IT;?>" />

<div style="position:absolute; left: 967px; top: 111px; width: 139px;">
<div align="left" class="f2">DESCRIPCION</div>
</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="position:absolute; left: 964px; top: 126px; width: 142px;" value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'TxtMar');"
tabindex="<?php echo ++$IT;?>" />

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

<?php
if(strlen($StrDESCARGAR)>0){
echo "<div id=\"layer51\" 
	  style=\"position:absolute; left: 173px; top: 77px; 
	  width: 90px; background-color: #FFCC00; layer-background-color: #FFCC00; 
	  border: 1px none #000000; height: 17px;\">";
echo "<div align=\"center\" class=\"f2\"> ";
echo " <a href=\"$StrDESCARGAR\" download>Descarga.PDF</a> ";
echo "</div>";
echo "</div>";
}
?>


</form>



<div class="s1" style="left: 27px; top: 559px; width: 166px;">Doble Click sobre el registro para activar Actualizacion </div>

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