<?php 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("JQUERY.inc");
$nr=0; 
?>
<html>
<HEAD> 
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
</HEAD>
<body>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="586" border="0">
	<tr>
        <th colspan="2">INVENTARIO FINAL DE ARTICULOS POR ALMACEN</th>
      </tr>
	  <tr>
	  <td>
	    <span class="Estilo25"><img src="magnifier.png" alt="Buscar"/></span>
            <select name="almacen" id="almacen" onchange="frm1.submit()">
          <option value="TO">-----TODOS-----</option>
          <?php
    
		  include("DMMYSQLG.php");
			@$resultado=mysqli_query($con ,"select * from falmacen where t1='ACTIVO'order by np_desc1");
			if(isset($_REQUEST['almacen']))
				$selAlmacen = $_REQUEST['almacen'];	
			else
				$selAlmacen = "T";
			while($registro=mysqli_fetch_array($resultado)){
				if($selAlmacen==$registro['nparte1']){
					echo '<option value="' . $registro['nparte1'] . '" selected>' . $registro['np_desc1'] . '</option>';
				}else{
					echo '<option value="' . $registro['nparte1'] . '">' . $registro['np_desc1'] . '</option>';
				}
			}			
		?>
        </select>       		</td>
	  </tr>
	<tr>
      <tr>
        <td colspan="2">
            <div align="center">
             
		  </div></td>
      </tr>
    </table>   
  </form>
</div> 
<div align="center">
    <?php
            if(isset($_POST['almacen'])){
                $alm=$_POST['almacen'];
@$resultado=mysqli_query($con ,"select ini.tot as inicial,fin.tot,ent.ent,sal.sal,((ini.tot+ent.ent)-sal.sal)as op,
fin.tot-(ini.tot+ent.ent-sal.sal) as dif
 from
(select  sum(cos_prom*t5) tot from farticulosn where sub=$alm ) ini,
(select  sum(cos_prom*t5) tot from farticulos where sub=$alm) fin,

(select   sum(subtotal) ent from dgreqded where nparte1 in (select  nparte1 from farticulos where sub=$alm) and cons_ven not in (select fol_ven from dgreqdev where dgreqdev.cancelado = 1 ) ) ent,
(select  sum(subtotal) sal from dgrequid where nparte1 in (select  nparte1 from farticulos where sub=$alm) and cons_ven not in (select fol_ven from dgrequie where dgrequie.cancelado = 1 )) sal");


            } 
    ?>
        
  <form method="post" action="" >
    <?php

	
	?>
	<div style="height:450px; overflow:scroll; width:1150;" align="center">
	<table width="87%" align="center" bordercolor=" " bordercolordark=" ">
      <tr>
      <th width="116"><div align="center">INICIAL</div></th>
        <th width="196"><div align="center">ENTRADA</div></th>
        <th width="116"><div align="center">SALIDA</div></th>
        <th width="116"><div align="center">TOTAL FINAL</div></th>
         <th width="116"><div align="center">ini+ent-sal</div></th>
        <th width="116"><div align="center">DIFERENCIA</div></th>
       
      </tr>
      <?php
while($registro=mysqli_fetch_array($resultado)){
echo "<tr>";
echo "<td>".$registro['inicial']."</td>";

echo "<td>".$registro['ent']."</td>";
echo "<td>".$registro['sal']."</td>";
echo "<td>".$registro['tot']."</td>";
echo "<td>".$registro['op']."</td>";
echo "<td>".$registro['dif']."</td>";
echo "</tr>";

    
    
}?>
    </table>
	</div>
  </form>
</div>
</body>
</html><?php
 /* 100 LISTO ULTIMA ACTUALIACION 21/AGOSTO/2012
             225 LISTO ULTIMA ACTUALIACION 27/AGOSTO/2013 */ ?>