<?php
	session_start();
	include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
	if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
	//-------------------------	
	
	//-------------------------
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);	
	//-------------------------
	$StrONE=trim(V($_GET['CmdB']));	
	//-------------------------
	$StrCod=V($_POST['TxtCod']);	
	$Lin=V($_POST['Lin']);		
	$StrDes=V($_POST['TxtDes']);
	$StrMar=V($_POST['CboMar']);
	//
	$Fab="";
	$Mod="";
	//
	$Lin_=LIKE($Lin);
	$Fab_=LIKE($Fab);
	$Mod_=LIKE($Mod);
	//
	if(strlen($StrCmd)==0)$StrCmd=V($_GET['TxtAc']);
	if($StrCmd=="X"){
		$StrLin="TODOS";
		$StrMar="TODOS";	
	}
	//-------------------------
	$StrCodT=$StrCod."%";
	$StrDesT="%".$StrDes."%";


	$StrMarT=T($StrMar);
	
	$FF="ID>0 AND COD LIKE '$StrCodT' 
		 AND DESCRIPCION LIKE '$StrDesT' 
		 AND MARCA LIKE '$StrMarT' 
		 AND FAB LIKE '$Fab_' AND MODELO LIKE '$Mod_' AND LINEA LIKE '$Lin_' ";
	$LStrTR=gn("count(*)","vproductos",$FF);
	$VP_RegXPag=100;	
	$LStrPag=V($_POST['TxtPag']);
	if($StrCmd=="F"){$LStrPag="1";}
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
	//-------------------------
	$LStrFoc="document.getElementById('TxtCod').focus();";
	$LStrMsg="onload=\"$LStrFoc;\"";
	
$IdUsu=$_SESSION['SYS_USER_ID'];
$AT=gs("at","usuarios","id_usuario=$IdUsu");
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Reporte de Stock</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<script type="text/javascript" src="ja/marcas.js"></script>
<!--FIN_SCRIPT------------------------------------->
<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/basic.css"  />
<link rel="stylesheet" type="text/css" href="css/mnu.css"  />

<style type="text/css">
.cF {height:600px;width:1250px;position:relative;top:0px}
.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}

</style>
<script>
$(document).ready(function(){  
   Inicializar();
});


$(document).keydown(function(e){
	var AT=gv("TxtAT");

	if(e.which==66 && e.altKey){
		if(AT=="1"){	
		document.getElementById("CmdB").click();
		return;
		}
	}

	if(e.which==86 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").click();
		return;
		}
	}
  
});
</script>
</head>

<body  <?php echo $LStrMsg;?>>
<div align="center">


<div class="mM" align="left" style="font-size:12px">
<?php
$HTM=file_get_contents("http://inversionessounduniversal.com/ventas/phpmnu.php?USER_ID=$IdUsu");
echo $HTM;
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;">
<form id="Frm" name="Frm" method="post"  autocomplete="off"
action="stockgeneral.php" 
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

<!----------------------------------------->
<div id="DivT" class="dT"  style="width:1250px;">
<img src="b.png" class="iT" />
<div class="tT">REPORTE DE STOCK GENERAL</div>
</div>
<!----------------------------------------->
  
  


    
<?php
	$TA=gn("count(*)","almacenes","id_almacen>0");
	$W=125+125+125+330+150+(80*$TA)+80;
?>

<div class="datagrid" style="height: 382px; width: 1180px; position: absolute; left: 35px; top: 180px; color: #0FF; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000; overflow: auto; z-index: 0">
<table width="<?php echo $W;?>" height="19" border="1" cellpadding="0" cellspacing="0" style="color:#000">
<tr>
<td width="104" bgcolor="#999999"><span class="eS4">CODIGO</span></td>
<td width="210" bgcolor="#999999"><span class="eS4">TIPO DE PRODUCTO</span></td>
<td width="421" bgcolor="#999999"><span class="eS4">DESCRIPCION</span></td>
<td width="139" bgcolor="#999999"><span class="eS4">MARCA</span></td>
<?php
$s="SELECT alm_obs FROM almacenes WHERE id_almacen>0 ORDER BY alm_obs";
$rs = grs($s);
while ($r = $rs->fetch_assoc()){
	echo "<td width=\"80\" bgcolor=\"#999999\"><span class=\"eS4\">".$r['alm_obs']."</span></td>";
}
?>
<td width="105"  bgcolor="#999999"><span class="eS4" >TOTAL</span></td>
</tr>
<?php  	
	$s="SELECT * FROM vproductos WHERE ".$FF." ORDER BY LINEA,DESCRIPCION,MARCA";		  					
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
	$rs = grs($s);
	while ($r = $rs->fetch_assoc()){
	?>	
	<tr onDblClick="location.href='productos.php?Id=<?php echo $r['ID'];?>&Pag=0'">
	<!----------------------------------------------->
    <td><?php echo $r['COD'];?></td>
    <td><?php echo $r['LINEA'];?></td>
    <td><?php echo $r['DESCRIPCION'];?></td>
    <td><?php echo $row['MARCA'];?></td>
	<!----------------------------------------------->
	<?php
	//
	$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=".$r['ID']." AND id_almacen=$roww[0]");
		echo "<td  > $Stock</td>";
		$TTT=$TTT+$Stock;
	}
	echo "<td  >$TTT</td>";
	//
	echo "</tr>";
	}

?>
</table>

</div>

	


<div class="s1" style="left: 35px; top: 117px; width: 52px;">
CODIGO</div>

<input name="TxtCod" type="text" id="TxtCod" 
class="lt" style="left: 35px; top: 134px; width: 119px;" 
value="<?php echo $StrCod;?>"  
tabindex="<?php echo ++$TI;?>"/> 


<div class="s1" style="left: 159px; top: 117px; width: 139px;"> TIPO DE PRODUCTO
</div>
<select name="Lin" id="Lin" 
class="lt"  style="left:159px; top: 134px; width: 149px;"
tabindex="<?php echo ++$TI;?>">
<?php
	echo FCBO_("lin_nombre","lineas","id_linea>0",$Lin,"S","N");
?>
</select>
<div class="s1" style="left: 323px; top: 117px; width: 197px;">
  DESCRIPCION</div>

<input name="TxtDes" type="text" id="TxtDes" 
class="lt" style="left: 322px; top: 134px; width: 608px;"
value="<?php echo $StrDes;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 940px; top: 117px; width: 100px;">
MARCA</div>
<select name="CboMar" id="CboMar" 
class="lt" style="left: 938px; top: 134px; width: 137px;"
tabindex="<?php echo ++$TI;?>">
<?php
	echo FCBO("mar_nombre","marcas","id_marca>0",$StrMar,"S","N");
?>
</select>

<!----------------------------------------->
<?php $VOLVER="productos.php";?>
<?php include("botones_b.php");?>;

<!-----------------------------------------><!----------------------------------------->    
<?php include("ocultos.php");?>

</form>
</div>
</div>
</body>
</html>
