<?php
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DF30000.inc");
include ("varfun.php");
include("JQUERY.inc");
$c=0
?>
<html>
<HEAD> 
    <link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
</HEAD>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>	
<body onload >
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="441" border="0">
	<tr>
	  <th>INVENTARIO FISICO DE ARTICULOS </th>
	  </tr>
	 <tr>
		<td>
	    <span class="Estilo25"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /></span>
        <select name="almacen" id="almacen">
          <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>
	  <td>
	    <span class="Estilo25"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /></span>
        <select name="agrupador" id="agrupador" onChange="javascript: document.getElementById('frm1').submit()">
          <option value="T">-----TODOS-----</option>-->
          <?php
		/*
		  include("DMMYSQLG.php");
			@$resultado=mysqli_query($con ,"select * from fagrupadores where t1='ACTIVO'order by np_desc1");
			if(!isset($_REQUEST['agrupador'])){
				$dt_paises=mysqli_fetch_array($resultado);
				$selPais=$dt_paises['n_reg'];
				if(mysqli_num_rows($resultado)>0)
					mysqli_data_seek($resultado,0);		
			}else{
				$selPais=$_REQUEST['agrupador'];
			}
			while($registro=mysqli_fetch_array($resultado)){
				if($selPais==$registro['n_reg']){
					echo '<option value="' . $registro['n_reg'] . '" selected>' . $registro['np_desc1'] . '</option>';
				}else{
					echo '<option value="' . $registro['n_reg'] . '">' . $registro['np_desc1'] . '</option>';
				}
				}*/			
		?>
        <!--</select>       		</td>
	  </tr>
	<tr>
	  <td> <span class="Estilo25"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /></span>
	    <select name="sub" id="sub" onChange="javascript: document.getElementById('frm1').submit()">
          <option  value="T">-----TODOS-----</option>-->
          <?php
   /*
		 include("DMMYSQLG.php");
		@$resultado=mysqli_query($con ,"select * from fsubagrupadores where almacen='$selPais' AND t1='ACTIVO' order by np_desc1");
		if(!isset($_REQUEST['sub'])){
			$dt_estado=mysqli_fetch_array($resultado);
			$selEnt=$dt_estado['np_desc1'];
			if(mysqli_num_rows($resultado)>0)
				mysqli_data_seek($resultado,0);		
		}else{
			$selEnt=$_REQUEST['sub'];
		}
		while($registro=mysqli_fetch_array($resultado)){
			if($selEnt==$registro['np_desc1'] ){ 
				echo '<option value="' . $registro['np_desc1'] . '" selected>' . $registro['np_desc1'] . '</option>';
			}else{
				echo '<option value="' . $registro['np_desc1'] . '">' . $registro['np_desc1'] . '</option>';
			}
			}*/
?>
        <!--</select></td>
	  </tr>-->
	  
      <tr>
        <td>
            <div align="center">
              <input name="Submit" type="button" class="original" onClick="openpage('AL30000_PR.php','_self')" value="Buscar"/>
			  <input name="Submit2" type="button" class="original" onClick="openpage('AL30000_IM.php','_self')" value="Imprimir"/>
			  
		  </div></td>  </tr>  
	 </table>  
  </form> </div>
<div align="center">
  <form method="post" action="" >
    <?php

	//<input name="bot4" type="button" class="bot_WsW" onClick="cargapag('ger_auditorias_IM.php','_self')" value="Imprimir "/>
	$result = mysqli_query($con ,"select * from farticulos WHERE order by sub, np_desc1");
	?>
    <div style="height:450px; overflow:scroll; width:1050;">
	<table>
	
      <tr>
        <th width="7%"><div align="center">Clave</div></th>
		<th width="26%"><div align="center">Articulo</div></th>
		<th width="9%"><div align="center">Almacen</div></th>
		<th width="9%"><div align="center">U. Costo</div></th>
		<th width="10%"><div align="center">Precio Prom. </div></th>
		<th width="7%"><div align="center">Existencia</div></th>
		<th width="10%"><div align="center">vs Fisica</div></th>
		<th width="10%"><div align="center">Diferencia</div></th>
      </tr>
	<?php

	 // --->
	  	$fec = isset($_POST['fec'])?$_POST['fec']:"";
		include('DF20000.php');
		$fecha_inicial = isset($f_m)?$f_m:"";
		
		$fec = isset($_POST['fec2'])?$_POST['fec2']:"";
		include('DF20000.php');
		$fecha_final = isset($f_m)?$f_m:"";
	  // -->
	$vpa=(isset($_POST['agrupador']))?$_POST['agrupador']:"";
	$mysql=mysqli_fetch_array(mysqli_query($con ,"select * from fagrupadores where n_reg='".$vpa."'"));
	
	
	if($vpa!='T') {
		 $arrBus[]="WHERE t8='".$mysql['np_desc1']."'";	
               
	}
	if(isset($_POST['sub'])&&$_POST['sub']!='T') 
	{
            $vps=(isset($_POST['sub']))?$_POST['sub']:"";
	 	$arrBus[]="t7='".$vps."'";
              
	    
	}else{
	    $sub=mysqli_query($con ,"SELECT distinct(np_desc1) FROM fsubagrupadores where almacen='$selPais' and t1='ACTIVO'");
	}	
	
 	//$WHERE=implode(" AND ",$arrBus);
	
	
	
	if (isset($_POST['sub'])&&$_POST['sub']!='T'){
	echo "<tr>
          <td colspan='2' style='#9B0F1A'><div align='left'><strong>".$mysql['np_desc1']."-".$_POST['sub']."</strong></div></td>
          </tr>";
	}else{
	while($sql=mysqli_fetch_array($sub)){
	
	//echo "<tr>
      //    <td colspan='2' style='#9B0F1A'><div align='left'><strong>".$mysql['np_desc1']."-".$sql['np_desc1']."</strong></div></td>
       //   </tr>";
	}
	}
	if($vpa=='T' && $_POST['sub']=='T'){
            $result = mysqli_query($con ,"select  * from farticulos where t1='ACTIVO' order by nparte1");
        }else{
            $WHERE=implode(" AND ",$arrBus);
            '<tr>';
          //  echo $WHERE=implode(" AND ",$arrBus);
	$result = mysqli_query($con ,"select * from farticulos $WHERE order by sub, np_desc1");
        echo "select * from farticulos $WHERE order by np_desc1";
        };
	while($reg = mysqli_fetch_array($result))
	{
	$vc=(isset($col))?$col:"";
	echo "<tr>";
	echo "<td style='".$vc."'> <div align='center' style='color:#000'><strong>" . $reg["nparte1"] . "&nbsp;</strong></div></td>";
	echo "<td style='".$vc."'> <div align='left' style='color:#000'><strong>" . $reg["np_desc1"] . "&nbsp;</strong></div></td>";
	$almacen=mysqli_fetch_array(mysqli_query($con ,"select np_desc1 from falmacen where nparte1='".$reg['sub']."'"));
	echo "<td style='".$vc."'> <div align='center' style='color:#000'><strong>" . $almacen["np_desc1"] . "</strong></div></td>";
	echo "<td style='".$vc."'> <div align='center' style='color:#000'><strong>$ ".number_format($reg["t3"],2,'.',',')."</strong></div></td>";
	echo "<td style='".$vc."'> <div align='center' style='color:#000'><strong>$ ".number_format($reg["cos_prom"],2,'.',',')."</strong></div></td>";
	echo "<td style='".$vc."'> <div align='center' style='color:#000'><strong>" . $reg["t5"] . "&nbsp;</strong></div></td>";
	echo "<td style='".$vc."'> <div align='center' style='color:#000'><strong>____________________</strong></div></td>";
	echo "<td style='".$vc."'> <div align='center' style='color:#000'><strong>____________________</strong></div></td></tr>";
			
		$c++;
		
	    }
	     
		echo "<tr>";
		echo "<td style='#9B0F1A'> <div align='right'><strong>".$c."</strong></div></td>";
		echo "<td style='#9B0F1A'> <div align='left'><strong>Articulos Encontrados</strong></div></td>";
		echo "<td colspan='4' style='#9B0F1A'> <div align='center'><strong></strong></div></td></tr>";
		
	mysqli_close($con);
	?>
    </table> </div></form>  </div>  </body>  </html>
<?php
 //303 --> 150  ULTIMA ACTUALIZACION 24/JUNIO/2013 REPORTE DE INVENTARIO GENERAL ?>