<?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']));	
	//
	$StrCod=V($_POST['TxtCod']);		
	$StrDes=V($_POST['TxtDes']);
	$StrMar=V($_POST['CboMar']);
	//
	if(strlen($StrCmd)==0)$StrCmd=V($_GET['TxtAc']);
	if(strlen($StrMar)==0)$StrMar="TODOS";
	//-------------------------
	$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'";
	$LStrTR=gn("count(*)","vproductos",$FF);
	$VP_RegXPag=20000;	
	$LStrPag=V($_POST['TxtPag']);
	if($StrCmd=="F"){$LStrPag="1";}
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
	//-------------------------
	$LStrFoc="document.getElementById('TxtCod').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;
}
th, td {
border: 1px solid black;
padding: 4px;
white-space: pre; /* CSS 2.0 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3.0 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP */
word-wrap: break-word; /* IE 5+ */
}

#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:1350px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-675px";?>;
}
#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;}
.eS4 {color: #000099}
.Estilo5 {color: #000000}
#Frm center #DivFRM #layer3 .f2 table tr td {
	color: #000;
	text-align: left;
}
#Frm center #DivFRM #layer3 .f2 table {
	font-weight: normal;
}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<form id="Frm" name="Frm" method="post" action="stockgeneral.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    <div id="layer6" style="position:absolute; left: 132px; top: 89px; width: 52px;">
      <div align="left" class="f2">CODIGO</div>
    </div>
    <div id="layer5" style="position:absolute; left: 69px; 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="height:382px; width:1300px; overflow-x:hidden; position:absolute; left: 20px; top: 196px; overflow-y:scroll; color: #0FF; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000;">
      <div align="left" class="f2">
<?php
	$BASE=80+250+120+60;
	$SUMA=0;
	$COLUMNAS="";
	$s="SELECT alm_obs FROM almacenes WHERE id_almacen>0 ORDER BY alm_obs";
	$result = grs($s);
	while ($row = $result->fetch_row()){
		$COLUMNAS=$COLUMNAS."<td style=\"width:60px\" bgcolor=\"#999999\"><span class=\"eS4\">$row[0]</span></td>";
		$SUMA=$SUMA+60;
	}
?>
<table  style="width:<?php echo  ($BASE+$SUMA)?>px"  height="19" border="1" cellpadding="0" cellspacing="0">
<tr>
<td style="width:80px" height="17" bgcolor="#999999"></td>
<td style="width:250px" bgcolor="#999999"></td>
<td style="width:120px" bgcolor="#999999"></td>
<?php
$s="SELECT alm_obs FROM almacenes WHERE id_almacen>0 ORDER BY alm_obs";
$result = grs($s);
while ($row = $result->fetch_row()){
echo "<td style=\"width:60px\" bgcolor=\"#999999\"><span class=\"eS4\"></span></td>";
}
?>
<td style="width:60px"  bgcolor="#999999"></td>
</tr>
<?php  	
	$s="SELECT ID,COD,LINEA,DESCRIPCION,MARCA
		FROM vproductos WHERE ".$FF."	ORDER BY DESCRIPCION ";		  					
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
	$result = grs($s);
	while ($row = $result->fetch_row()){
	echo "<tr ondblclick=\"location.href='productos.php?Id=$row[0]&Pag=0';\">";
	echo "<td >".$row[1]."</td>";	
	echo "<td >$row[3]</td>";
	echo "<td >$row[2]</td>";
	//
	$TTT=0;
	$ss="SELECT id_almacen FROM almacenes WHERE id_almacen>0 ORDER BY alm_obs";
	$resultt = grs($ss);
	while ($roww = $resultt->fetch_row()){
		$Stock=gn("stock","stocks","id_producto=$row[0] AND id_almacen=$roww[0]");
		echo "<td  style=\"text-align:right\"> $Stock</td>";
		$TTT=$TTT+$Stock;
	}
	echo "<td  style=\"text-align:right\">$TTT</td>";
	//
	echo "</tr>";
	}

?>
<tr>
<td  height="17" bgcolor="#999999"></td>
<td  bgcolor="#999999"></td>
<td  bgcolor="#999999"></td>
<?php
$s="SELECT alm_obs FROM almacenes WHERE id_almacen>0 ORDER BY alm_obs";
$result = grs($s);
while ($row = $result->fetch_row()){
echo "<td  bgcolor=\"#999999\"><span class=\"eS4\"></span></td>";
}
?>
<td width="30"  bgcolor="#999999"><span class="eS4" ></span></td>
</tr>
        </table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 69px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">REPORTE DE STOCK GENERAL</div>
    </div>
          <input name="TxtCod" type="text" id="TxtCod" 
          style="position:absolute; left: 132px; top: 109px; width: 97px;" value="<?php echo $StrCod;?>"  
          onkeydown="return SoloTextoEx(event,'TxtDes');"
          tabindex="1" />

    <div id="LblTit" style="position:absolute; left: 10px; 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: 701px; top: 109px; width: 66px;"
value="Filtrar" onclick="fFiltrar();" />

<div align="left" class="f2"></div>
<div id="layer13" style="height:45px; width:1300px; position:absolute; left: 20px; top: 143px; color: #0FF; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000;">
<div align="left" class="f2">


<table width="<?php echo $BASE + $SUMA;?>" height="19" border="1" cellpadding="0" cellspacing="0">
<tr  >
<td height="18" colspan="18" bgcolor="#666666" ><p align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></p></td>
</tr>
<tr>
<td style="width:80px" height="17" bgcolor="#999999"><span class="eS4">CODIGO</span></td>
<td style="width:250px" bgcolor="#999999"><span class="eS4">DESCRIPCION</span></td>
<td style="width:120px" bgcolor="#999999"><span class="eS4">LINEA</span></td>
<?php
echo $COLUMNAS;
?>
<td style="width:60px"  bgcolor="#999999"><span class="eS4" >TOTAL</span></td>
</tr>
</table>
      </div>
    </div>
    <div id="layer8" style="position:absolute; left: 245px; top: 89px; width: 136px;">
      <div align="left" class="f2">DESCRIPCION</div>
</div>
<input name="TxtDes" type="text" id="TxtDes" style="position:absolute; left: 242px; top: 109px; width: 311px;" 
value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'CboMar');"
tabindex="1" />

<select name="CboMar" id="CboMar" style="position:absolute; left: 574px; top: 109px; width: 120px;" 
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: 576px; top: 89px; width: 136px;">
      <div align="left" class="f2">LINEA</div>
    </div>
  </div>
</center>	
</form>
</body>
</html>
