<?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']);
$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="TODOS";	

//
if(strlen($StrEmp)==0)$StrEmp=GE("S");
if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");
//
$StrEmp_=LIKE($StrEmp);
$StrAlm_=LIKE($StrAlm);	
//
$StrCodT=$StrCod."%";
$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_' ";
}
$LStrTR=gn("count(*)","vis_stock_presentaciones",$FF);
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=1500;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
$LStrFoc="document.getElementById('TxtNom').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>Reporte de Stock por presentacion - Valorizado por precio de venta</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="rep_stock_vpv2.php">

  
    
    <div id="layer5" 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: 948px; height: 425px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="930" 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="115" height="17" bgcolor="#999999"><span class="z4">ALMACEN</span></td>
<td width="115" height="17" bgcolor="#999999"><span class="z4">CODIGO</span></td>
<td width="253" bgcolor="#999999"><span class="z4">DESCRIPCION</span></td>
<td width="140" bgcolor="#999999"><span class="z4">LINEA</span></td>
<td width="58" bgcolor="#999999" align="right"><span class="z4">CANTIDAD</span></td>
<td width="41" bgcolor="#999999" align="right"><span class="z4">PIEZAS</span></td>
<td width="59" bgcolor="#999999" align="right"><span class="z4">TOT. PZA</span></td>
<td width="56" bgcolor="#999999" align="right"><span class="z4">P.U.</span></td>
<td width="84" bgcolor="#999999" align="right"><span class="z4">TOTAL</span></td>
</tr>
<?php	
$_TP=0;	  
$_TOT=0;		
$IdAlm=gn("id_almacen","almacenes","alm_obs='$StrAlm'");	
	  	
$s="SELECT ID,COD,LINEA,DESCRIPCION,MARCA,C_CAJA,C_UNI,ALMC 
    FROM vis_stock_presentaciones WHERE ".$FF."	ORDER BY COD,C_UNI ";
		  					
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);				
$result = grs($s);
while ($row = $result->fetch_row()){
	$S_PRE=gn("pro_pv_max","productos","id_producto=".$row[0]);
	$S_STOCK=$row[5]*$row[6];
	$S_TOT=$S_PRE * $S_STOCK;
	echo "<tr class=\"Estilo5\">";
	echo "<td bgcolor=\"#FFFFFF\">$row[7]</td>";
	echo "<td bgcolor=\"#FFFFFF\">$row[1]</td>";
	echo "<td bgcolor=\"#FFFFFF\">$row[3]</td>";
	echo "<td bgcolor=\"#FFFFFF\" >$row[2]</td>";
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> $row[5]</td>";
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> $row[6]</td>";
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> $S_STOCK</td>";
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> $S_PRE</td>";
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> ".NF2($S_TOT,2)."</td>";
	echo "</tr>";
	$_TP=$_TP +$row[5];
	$_TOT=$_TOT + $S_TOT;
}
?>
<tr>
<td width="115" height="17" bgcolor="#999999">&nbsp;</td>
<td width="115" height="17" bgcolor="#999999">&nbsp;</td>
<td width="253" bgcolor="#999999">&nbsp;</td>
<td width="140" bgcolor="#999999"><span class="z4">TOTALES</span></td>
<td width="58" bgcolor="#999999" align="right"><span class="z4"><?php echo NF4($_TP);?></span></td>
<td width="41" bgcolor="#999999">&nbsp;</td>
<td width="59" bgcolor="#999999">&nbsp;</td>
<td width="56" bgcolor="#999999">&nbsp;</td>
<td width="84" bgcolor="#999999" align="right"><span class="z4"><?php echo NF2($_TOT,2);?></span></td>
</tr>
</table>
</div>
</div>


    <div id="layer" style="position:absolute; left: 100px; top: 30px; width: 743px; height: 24px;">
      <div align="left" class="Estilo1">REPORTE DE STOCK POR PRESENTACION - VALORIZADO POR PRECIO DE VENTA</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: 901px; top: 109px; width: 54px;"
 value="Filtrar" onclick="fFiltrar();" tabindex="6" />


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

<div style="position:absolute; left: 165px; top: 89px; width: 116px;">
<div align="left" class="f2">ALMACEN</div>
</div>
<select name="CboAlm" id="CboAlm" 
style="position:absolute; left: 163px; top: 109px; width: 123px;" 
onkeydown="return SoloTextoEx(event,'TxtCod');" tabindex="1">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>
<div id="layer6" style="position:absolute; left: 297px; top: 89px; width: 89px;">
<div align="left" class="f2">CODIGO</div>
</div>
<input name="TxtCod" type="text" id="TxtCod" 
style="position:absolute; left: 296px; top: 109px; width: 113px;" value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
tabindex="2" />
<div id="layer8" style="position:absolute; left: 419px; top: 89px; width: 136px;">
<div align="left" class="f2">DESCRIPCION</div>
</div>
<input name="TxtDes" type="text" id="TxtDes" style="position:absolute; left: 420px; top: 109px; width: 183px;" 
value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'CboMar');"
tabindex="3" />
<div id="layer12" style="position:absolute; left: 616px; top: 89px; width: 83px;">
<div align="left" class="f2">LINEA</div>
</div>
<select name="CboMar" id="CboMar" style="position:absolute; left: 614px; top: 108px; width: 115px;" 
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: 740px; top: 89px; width: 138px;">
<div align="left" class="f2">STOCK</div>
</div>
<select name="CboSto" id="CboSto" style="position:absolute; left: 738px; top: 108px; width: 143px;" 
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>
