<?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']);
	//-------------------------
	$StrONE=trim(V($_GET['CmdB']));	
	//-------------------------
	$StrAlm=V($_POST['CboAlm']);		
	$StrCod=V($_POST['TxtCod']);		
	$StrDes=V($_POST['TxtDes']);
	$StrMar=V($_POST['CboMar']);
	if(strlen($StrCmd)==0)$StrCmd=V($_GET['TxtAc']);
	if($StrCmd=="X"){
		$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;
	if($StrMarT=="TODOS") $StrMarT="%";
	$FF="ID>0 AND COD LIKE '$StrCodT'  AND 
		 DESCRIPCION LIKE '$StrDesT' AND 
		 LINEA LIKE '$StrMarT' AND ALM LIKE '$StrAlm'";
	$LStrTR=gn("count(*)","v_stocks",$FF);
	$LStrPag=V($_POST['TxtPag']);	
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=20;	
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
	//-------------------------
	if($StrCmd=="PDF"){	
		//
		$TI="REPORTE DE STOCK - ALMACEN : $StrAlm" ;
		$s="SELECT COD,DESCRIPCION,LINEA,STOCK FROM v_stocks
			WHERE $FF ORDER BY DESCRIPCION ";
		$T="CODIGO,DESCRIPCION,LINEA,STOCK";
		$E="12,47,18,6";
		$A=" 0, 0, 0,2";		
		//
		$_ID=GenId("id","reportes");
		PDF_TIT($_ID,$TI);
		PDF_SQL($_ID,$s);
		PDF_CAM($_ID,$T);
		PDF_ESP($_ID,$E);
		PDF_ANC($_ID,$A);		
		$StrFilePDF=PDF_CREATE($_ID);	
		$StrMsg="onload=\"alert('Ahora puede descargar el reporte');\"";
}
	$LStrFoc="document.getElementById('CboAlm').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</title>
<script type="text/javascript" src="fe/funciones.js"></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:50%;
	top:50%;
	background-color:#006699;
	margin:-300px 0 0 -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;?>>
<form id="Frm" name="Frm" method="post" action="rep_stock_presentacion.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    <div id="layer6" style="position:absolute; left: 163px; top: 89px; width: 52px;">
      <div align="left" class="f2">CODIGO</div>
    </div>
    <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: 43px; top: 138px; width: 608px; height: 433px;">
      <div align="left" class="f2">
        <table width="817" height="19" border="1" cellpadding="0" cellspacing="0">
<tr  >
<td height="18" colspan="5" bgcolor="#666666" > 
<p align="center"> <?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></p>
</td>
</tr>
<tr>
<td width="129" height="17" bgcolor="#999999"><span class="Estilo4">CODIGO</span></td>
<td width="297" bgcolor="#999999"><span class="Estilo4">DESCRIPCION</span></td>
<td width="114" bgcolor="#999999"><span class="Estilo4">LINEA</span></td>
<td width="56" bgcolor="#999999"><span class="Estilo4">STOCK</span></td>
</tr>
<?php		  		
    $IdAlm=gn("id_almacen","almacenes","alm_obs='$StrAlm'");		  	
    $s="SELECT ID,COD,LINEA,DESCRIPCION,MARCA,STOCK
        FROM v_stocks WHERE ".$FF."	ORDER BY DESCRIPCION ";		  					
    $s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);				
    $result = grs($s);
    while ($row = $result->fetch_row()){
    echo "<tr>";
    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 "</tr>";
    }

?>
</table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 100px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">REPORTE DE STOCK</div>
    </div>
          <input name="TxtCod" type="text" id="TxtCod" 
          style="position:absolute; left: 163px; top: 109px; width: 91px;" value="<?php echo $StrCod;?>"  
          onkeydown="return SoloTextoEx(event,'TxtDes');"
          tabindex="1" />

    <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: 708px; top: 109px; width: 54px;"
 value="Filtrar" onclick="fFiltrar();" />

    <div align="left" class="f2"></div>
    <div id="layer13" style="position:absolute; left: 769px; top: 109px; width: 111px; height: 24px;">
      <div align="left" class="f2">
        <input name="CmdB" type="button" id="CmdB" value="Imprimir" onclick="fPDF();" />
        <a href="<?php echo $StrFilePDF;?>" target="_blank" >
<img src="save.gif" width="16" height="16" />
</a>
      </div>
    </div>
    <div id="layer8" style="position:absolute; left: 273px; top: 89px; width: 136px;">
      <div align="left" class="f2">DESCRIPCION</div>
  </div>
        <input name="TxtDes" type="text" id="TxtDes" style="position:absolute; left: 271px; top: 109px; width: 299px;" 
        value="<?php echo $StrDes;?>"  
        onkeydown="return SoloTextoEx(event,'CboMar');"
        tabindex="1" />

<select name="CboMar" id="CboMar" style="position:absolute; left: 585px; top: 108px; width: 115px;" 
onkeydown="return SoloTextoEx(event,'CmdB');">
<?php
echo FCBO_("lin_nombre","lineas","id_linea>0",$StrMar,"S","N");
?>

</select>

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

    <div id="layer14" style="position:absolute; left: 45px; top: 89px; width: 102px;">
      <div align="left" class="f2">ALMACEN</div>
    </div>
  </div>
</center>	
</form>
</body>
</html>
