<?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;
}
//+++++
$APLICAR=0;
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$LStrPag=V($_POST['TxtPag']);
//-------------------------
$StrONE=trim(V($_GET['CmdB']));	
//-------------------------
$StrEmp=V($_POST['CboEmp']);		
$StrAlm=V($_POST['CboAlm']);			
$StrCod=V($_POST['TxtCod']);		
$StrDes=V($_POST['TxtDes']);
$StrMar=V($_POST['CboMar']);
$StrSto=V($_POST['CboSto']);
//
if(strlen($StrCmd)==0)$StrCmd=V($_GET['TxtAc']);
if(strlen($StrMar)==0)$StrMar="TODOS";	
if(strlen($StrSto)==0)$StrSto="MAYOR A CERO";	

//
if(strlen($StrEmp)==0)$StrEmp=GE("S");
if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");
//
$StrEmp_=LIKE($StrEmp);
$StrAlm_=LIKE($StrAlm);
//	
if(strlen($StrCod)>0){
	$StrCodT=$StrCod."%";
	$APLICAR=1;
}
if($APLICAR==0){
	if(strlen($StrDes)>0){
		$StrDesT=$StrDes."%";
		$APLICAR=1;
	}
}else{
	$StrDesT=$StrDes."%";
}
$StrMarT=$StrMar;
if($StrMarT=="TODOS") $StrMarT="%";
if($StrSto=="TODOS"){
	$FF="ID>0 AND COD LIKE '$StrCodT'  AND 
	DESCRIPCION LIKE '$StrDesT' AND 
	LINEA LIKE '$StrMarT' AND ALMC LIKE '$StrAlm_' AND EMPC LIKE '$StrEmp_' ";
}
if($StrSto=="MAYOR A CERO"){
	$FF="ID>0 AND COD LIKE '$StrCodT'  AND 
	DESCRIPCION LIKE '$StrDesT' AND 
	LINEA LIKE '$StrMarT' AND ALMC LIKE '$StrAlm_' AND C_CAJA>0 AND EMPC LIKE '$StrEmp_' ";
}
if($StrSto=="IGUAL A CERO"){
	$FF="ID>0 AND COD LIKE '$StrCodT'  AND 
	DESCRIPCION LIKE '$StrDesT' AND 
	LINEA LIKE '$StrMarT' AND ALMC LIKE '$StrAlm_' AND C_CAJA=0 AND EMPC LIKE '$StrEmp_' ";
}
if($StrSto=="MENOR A CERO"){
	$FF="ID>0 AND COD LIKE '$StrCodT'  AND 
	DESCRIPCION LIKE '$StrDesT' AND 
	LINEA LIKE '$StrMarT' AND ALMC LIKE '$StrAlm_' AND C_CAJA<0 AND EMPC LIKE '$StrEmp_' ";
}
if($APLICAR==0){
	$FF="ID<0 ";
}

$LStrTR=gn("count(*)","vis_stock_presentacionez",$FF);
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=5000;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
$LStrFoc="document.getElementById('CboEmp').focus();";
$LStrMsg="onload=\"$LStrFoc;\"";
?>
<!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>Procesar / Transformaciones</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();
});
});
//
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>
<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;}
.z4 {color: #000099}
.Estilo5 {color: #000000}
#Frm center #DivFRM #layer3 .f2 table tr td {
	color: #000;
	text-align: left;
}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="lq_transformaciones.php" autocomplete="off">    
    <div style="position:absolute; left: 100px; top: 50px; width: 205px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('menu.php');" />
        <input type="hidden" name="TxtAc" id="TxtAc" />
        <input type="hidden" name="TxtPag" id="TxtPag" value="<?php echo $LStrPag; ?>" />
      </div>
    </div>

<div id="layer3" style="position:absolute; left: 30px; top: 138px; width: 959px; height: 425px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="933" height="19" border="1" cellpadding="0" cellspacing="0">

<tr>
<td height="18" colspan="8" bgcolor="#666666" align="center" ><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr>
<td width="91" height="17" bgcolor="#999999"><span class="z4">ALMACEN</span></td>
<td width="112" height="17" bgcolor="#999999"><span class="z4">CODIGO</span></td>
<td width="360" bgcolor="#999999"><span class="z4">DESCRIPCION</span></td>
<td width="206" bgcolor="#999999"><span class="z4">LINEA</span></td>
<td width="60" bgcolor="#999999"><span class="z4">STOCK/CAJAS</span></td>
<td width="52" bgcolor="#999999"><span class="z4">PIEZAS</span></td>
<td width="36" bgcolor="#999999" align="center"><span class="z4">#</span></td>
</tr>
<?php	
$_TP=0;	  		 	
$s="SELECT * FROM vis_stock_presentacionez 
	WHERE ".$FF." ORDER BY COD,C_UNI ";
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);	
//echo $s."<br>";			
$rs = grs($s);
while ($r = $rs->fetch_assoc()){
	//$S_STOCK=$row[5]*$row[6];
	$FTR="TR('".$r['ALM_ID']."','".$r['ID']."','".$r['C_UNI']."','".$r['C_CAJA']."')";
?>
	<tr class="Estilo5">
	<td bgcolor="#FFFFFF">'<?php echo $r['ALMC'];?></td>
	<td bgcolor="#FFFFFF"><?php echo $r['COD'];?></td>    
	<td bgcolor="#FFFFFF"><?php echo $r['DESCRIPCION'];?></td>
	<td bgcolor="#FFFFFF" ><?php echo $r['LINEA'];?></td>
    <td bgcolor="#FFFFFF" style="text-align:right"><?php echo $r['C_CAJA'];?></td>
    <td bgcolor="#FFFFFF" style="text-align:right"><?php echo $r['C_UNI'];?></td>
		
    <td bgcolor="#FFFFFF" >
    <input name="CmdT" type="button" value=">>" onclick="<?php echo $FTR;?>" />
    </td>
	</tr>
<?php
	$_TP=$_TP +$row[5];
}
?>
<tr>
<td width="91" height="17" bgcolor="#999999">&nbsp;</td>
<td width="112" height="17" bgcolor="#999999">&nbsp;</td>
<td width="360" bgcolor="#999999">&nbsp;</td>
<td width="206" bgcolor="#999999"><span class="z4">TOT.CAJAS</span></td>
<td width="60" bgcolor="#999999"><span class="z4"><?php echo NF4($_TP);?></span></td>
<td width="52" bgcolor="#999999">&nbsp;</td>
<td width="36" bgcolor="#999999">&nbsp;</td>
</tr>
</table>
</div>
<script>
function TR(alm,pro,pie,can){
	Ow("lq_transformaciones_det.php?ALM="+alm+"&PRO="+pro+"&PIE="+pie+"&CAN="+can,800,500);	
}
</script>
</div>


    <div id="layer" style="position:absolute; left: 100px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">PROCESAR / TRANSFORMACIONES</div>
    </div>
    

    <div id="LblTit" style="position:absolute; left: 41px; top: 25px; width: 64px;">
    <div align="left" class="Estilo1"><img src="img/buscar.png" width="57" height="60" /></div>
  </div>	
        <input name="CmdB" type="button" id="CmdB"
style="position:absolute; left: 827px; top: 109px; width: 132px;"
 value="Filtrar / actualizar" onclick="fFiltrar();" tabindex="6" />


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

<div style="position:absolute; left: 182px; top: 89px; width: 127px;">
<div align="left" class="f2">ALMACEN</div>
</div>
<select name="CboAlm" id="CboAlm" 
style="position:absolute; left: 181px; top: 109px; width: 130px;" 
onkeydown="return SoloTextoEx(event,'TxtCod');" tabindex="1">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div id="layer6" style="position:absolute; left: 327px; top:60px; width: 496px;">
<div align="left" class="f2">* SE REQUIERE INGRESAR UN CODIGO DESCRIPCION LUEGO CLICK EN FILTRAR</div>
</div>

<div id="layer6" style="position:absolute; left: 327px; top: 89px; width: 89px;">
<div align="left" class="f2">CODIGO</div>
</div>
<input name="TxtCod" type="text" id="TxtCod" 
style="position:absolute; left: 326px; top: 109px; width: 88px;" value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
tabindex="2" />
<div id="layer8" style="position:absolute; left: 429px; top: 89px; width: 136px;">
<div align="left" class="f2">DESCRIPCION</div>
</div>
<input name="TxtDes" type="text" id="TxtDes" style="position:absolute; left: 427px; top: 109px; width: 155px;" 
value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'CboMar');"
tabindex="3" />
<div id="layer12" style="position:absolute; left: 595px; top: 89px; width: 83px;">
<div align="left" class="f2">LINEA</div>
</div>
<select name="CboMar" id="CboMar" style="position:absolute; left: 593px; top: 108px; width: 96px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="4">
<?php	
echo FCBO_("lin_nombre","lineas","id_linea>0",$StrMar,"S","N");
?>
</select>

<div id="layer12" style="position:absolute; left: 701px; top: 89px; width: 72px;">
<div align="left" class="f2">STOCK</div>
</div>
<select name="CboSto" id="CboSto" style="position:absolute; left: 702px; top: 108px; width: 112px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="5">
<?php	
echo FCBOO_("au_item","auxiliar","au_tab='RANGO'",$StrSto,"S","N","au_orden");
?>
</select>
  

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