<?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']));	
//-------------------------
$StrAlm=V($_POST['CboAlm']);		
$StrCod=V($_POST['TxtCod']);		
$StrDes=V($_POST['TxtDes']);
$StrLin=V($_POST['CboLin']);

if(strlen($StrCmd)==0)$StrCmd=V($_GET['TxtAc']);
if($StrCmd=="X" || strlen($StrCmd)==0){
$StrLin="TODOS";
$StrMar="TODOS";	
}
//-------------------------
if($_SESSION['SYS_USER_ALM']=="%"){
if(strlen($StrAlm)==0)$StrAlm=GetSO("alm_obs","almacenes","","alm_obs");
}else{
$StrAlm=$_SESSION['SYS_USER_ALM'];
}
$StrCodT=$StrCod."%";
$StrDesT=$StrDes."%";
$StrMarT=$StrMar;

$StrLinT=VCbo($StrLin);

$FF="ID>0 
AND COD LIKE '$StrCodT' 
AND DESCRIPCION LIKE '$StrDesT' 
AND LINEA LIKE '$StrLinT' ";

include("rep_stock_vpv_pdf.php");
//-------------------------
$LStrTR=gn("count(*)","vproductos",$FF);
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=5000;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
?>
<!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 Valorizado Por Precio de Venta</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/funciones.js"></script>
<script>
$(document).ready(function(){  
   Inicializar();
});

function fGenPDF(){
	document.getElementById("TxtAc").value="GEN_PDF_1";
	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>
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:900px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-450px";?>;
}
#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;}
.Estilo4 {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_vpv.php">

 
    <div id="layer6" style="position:absolute; left: 162px; top: 109px; width: 52px;">
      <div align="left" class="f2">CODIGO</div>
    </div>
    <div id="layer5" style="position:absolute; left: 99px; top: 50px; width: 563px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('menu.php');" />

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

        <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: 157px; width: 840px; height: 415px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="824" height="19" border="1" cellpadding="0" cellspacing="0"> 
       
<tr>
<td height="18" colspan="6" bgcolor="#666666" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr class="Estilo5">
<td width="107" height="17" bgcolor="#999999"><span class="Estilo4">CODIGO</span></td>
<td width="327" bgcolor="#999999"><span class="Estilo4">DESCRIPCION</span></td>
<td width="180" bgcolor="#999999"><span class="Estilo4">LINEA</span></td>
<td width="63" bgcolor="#999999"><span class="Estilo4">STOCK</span></td>
<td width="63" bgcolor="#999999"><span class="Estilo4">PRECIO</span></td>
<td width="70" bgcolor="#999999"><span class="Estilo4">TOTAL</span></td>
</tr>
<?php		  		
$IdAlm=gn("id_almacen","almacenes","alm_obs='$StrAlm'");
$StrTemp=$StrPag * $VP_RegXPag;
$s="SELECT ID,COD,SUBSTRING(LINEA,1,22) AS LINEA,DESCRIPCION,LINEA,ROUND(PV_MAX,1)
FROM vproductos 
WHERE $FF 
ORDER BY COD ";		  		
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);					
$result = grs($s);
while ($row = $result->fetch_row()){
	echo "<tr class=\"Estilo5\">";
	echo "<td bgcolor=\"#FFFFFF\">$row[1]</td>";
	echo "<td bgcolor=\"#FFFFFF\">$row[3]</td>";
	echo "<td bgcolor=\"#FFFFFF\" >$row[2]</td>";
	$Stock=gn("stock","stocks","id_producto=$row[0] AND id_almacen=$IdAlm");
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> $Stock</td>";
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> ".NF3($row[5])."</td>";
	$Tot= NF3($Stock * $row[5]);
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\"> $Tot</td>";
	echo "</tr>";
}
?>
</table>
</div>
</div>

    <div id="layer" style="position:absolute; left: 99px; top: 30px; width: 762px; height: 24px;">
      <div align="left" class="Estilo1">REPORTE DE STOCK VALORIZADO POR PRECIO DE VENTA (Precio de venta maximo)</div>
    </div>
          <input name="TxtCod" type="text" id="TxtCod" 
          style="position:absolute; left: 162px; top: 126px; width: 132px;" value="<?php echo $StrCod;?>"  
          onkeydown="return SoloTextoEx(event,'TxtDes');"
          tabindex="1" />

    <div id="LblTit" style="position:absolute; left: 40px; 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: 757px; top: 126px; width: 54px;"
value="Filtrar" onclick="fFiltrar();" />

    <div id="layer8" style="position:absolute; left: 308px; top: 109px; width: 115px;">
      <div align="left" class="f2">DESCRIPCION</div>
  </div>
        <input name="TxtDes" type="text" id="TxtDes" style="position:absolute; left: 306px; top: 126px; width: 292px;"
         value="<?php echo $StrDes;?>"  
        onkeydown="return SoloTextoEx(event,'CboMar');"
        tabindex="1" />

    <select name="CboLin" id="CboLin" style="position:absolute; left: 608px; top: 126px; width: 136px;" 
    onkeydown="return SoloTextoEx(event,'CmdB');">
    <?php
        echo FCBO_("lin_nombre","lineas","id_linea>0",$StrLin,"S","");
    ?>
    </select>

    <div id="layer12" style="position:absolute; left: 613px; top: 109px; width: 76px;">
      <div align="left" class="f2">LINEA</div>
    </div>
        <select name="CboAlm" id="CboAlm" 
        style="position:absolute; left: 29px; top: 126px; width: 124px;" 
		onkeydown="return SoloTextoEx(event,'TxtCod');">
          <?php echo ListALM($StrAlm); ?>
        </select>

    <div id="layer14" style="position:absolute; left: 30px; top: 109px; width: 116px;">
      <div align="left" class="f2">ALMACEN</div>
    </div>


  

	<?php
    if(strlen($StrDESCARGAR)>0){
    echo "<div id=\"layer51\" 
          style=\"position:absolute; left: 154px; top: 80px; 
          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>

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