<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DF30000.inc");
include("JQUERY.inc");
?>
<html>
<HEAD> <meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
<style type="text/css">
<!--
.Estilo16 {font-size: 14px}
.Estilo19 {font-family: Verdana, Helvetica; font-weight: bold; font-size: 10px; }
.Estilo20 {color: #FFFFFF}
-->
</style>
</HEAD>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<body>
<div align="center">
  <form name="frm1" id="frm1" method="post" action="">
    <table width="333" border="0">
	<tr> <th colspan="2"><span class="Estilo16">MAXIMOS Y MINIMOS</span> </th> 
	</tr>
	<tr>
	  <td><div align="right"><span class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /><span class="Estilo20">MAXIMOS DE STOCK</span></span></div></td>
	  <td><input name="r1" type="radio" value="p" tabindex="3"/></td>
	  </tr>
	<tr> <td width="62%"><div align="right" class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /><span class="Estilo20">MINIMOS DE STOCK</span></div></td>
        <td width="38%"><input name="r1" type="radio" value="no" tabindex="3"/></td>
	</tr>
      <tr>
        <td> <div align="right" class="Estilo19"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> <span class="Estilo20">AGRUPADORES /EXISTENCIAS EN 0.</span>
          <select name="agrupador" id="agrupador" tabindex="6">
            <option>---SELECCIONE AGRUPADOR---</option>
            <?php
 
$sql = mysqli_query($con ,"SELECT distinct(t7) FROM farticulos order by t7");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['agrupador']==$reg['t7'] ){
		echo '<option value="' . $reg['t7'] . '" selected>' . $reg['t7'] . '</option>';
	}else{
		echo '<option value="' . $reg['t7'] . '">' . $reg['t7'] . '</option>';
	}
}
?>
          </select>
</div></td>
        <td><input name="r1" type="radio" value="f" tabindex="5"/></td>
      </tr>
      <tr>
        <td colspan="2">
          <div align="center">
            
            <input name="Submit" type="button" class="boton" onClick="openpage('AL30100_PR.php','_self')" value="Buscar"/>
			<input name="bot4" type="button" class="boton" onClick="openpage('AL30100_IM.php','_self')" value="Imprimir "/>
		  </div></td>
      </tr>
    </table>
     
  </form>
</div>
<div align="center">
  <form method="post" action="" >
    <?php

	//@$result = mysqli_query($con ,"SELECT * FROM farticulos order by np_desc1");
    @$result = mysqli_query($con ,"SELECT * FROM farticulos order by nparte1");
	?>
    <table width="1049"   align="center" >
      <tr>
        <th colspan="13">
          <div align="center"></div></th></tr>
      <tr>
        <th width="42"><div align="center">CLAVE</div></th>
		<th width="200"><div align="center">ARTICULO</div></th>
		<th width="100"><div align="center">UNIDAD</div></th>
		<th width="200"><div align="center">AGRUPADOR</div></th>
		<th width="200"><div align="center">ALMACEN</div></th>
		<th width="75"><div align="center">COS. PROM.</div></th>
		<th width="100"><div align="center">EXISTENCIA</div></th>
		<th width="80"><div align="center">MIN STOCK</div></th>
		<th width="80"><div align="center">MAX STOCK</div></th>
	  </tr>
	<?php

	if(isset($_POST['r1'])&&$_POST['r1']=="no"){
		echo '<input name="tbusqueda" type="hidden" value="no">';
	  	$min = mysqli_query($con ,"select * from farticulos order by np_desc1");
		while($nim = mysqli_fetch_array($min)){
		$minimo = $nim['min'];
		//echo "".$minimo."";
		$result = mysqli_query($con ,"SELECT * FROM farticulos WHERE t7 = '".$_POST['agrupador']."' AND t5 <= '$minimo'");
		}
   	}elseif(isset($_POST['r1'])&&$_POST['r1']=="f"){
		echo '<input name="tbusqueda" type="hidden" value="f">';
	$result = mysqli_query($con ,"SELECT * FROM farticulos WHERE t7 = '".$_POST['agrupador']."' and t5 = '0'");
	
	}elseif(isset($_POST['r1'])&&$_POST['r1']=="p"){
		echo '<input name="tbusqueda" type="hidden" value="p">';
	  	$min = mysqli_query($con ,"select * from farticulos order by nparte1");
		while($nim = mysqli_fetch_array($min)){
		$maximo = $nim['max'];
		$result = mysqli_query($con ,"SELECT * FROM farticulos WHERE t7 = '".$_POST['agrupador']."' AND t5 >= '$maximo'");
	  }
	}
	include("DE10000.php");
	while($reg = mysqli_fetch_array($result))
	{
	  	echo "<tr>";
		//echo '<td><div align="center"><input name="bot" type="radio" value="'. $reg["n_reg"].'">&nbsp</div></td>';
		echo "<td> <div align='center' style=' '><strong>" . $reg["nparte1"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center' style=' '><strong>" . $reg["np_desc1"] .   "&nbsp;</strong></div></td>"; //'. $reg["fnombre"] .'
		$dgmedida=mysqli_fetch_array(mysqli_query($con ,"select * from dgmedida where nparte1='".$reg['pais']."'"));
		echo "<td> <div align='center' style=' '><strong>" . $dgmedida["np_desc1"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center' style=' '><strong>" . $reg["t7"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center' style=' '><strong>" . $reg["t8"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center' style=' '><strong>" . $reg["cos_prom"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center' style=' '><strong>" . $reg["t5"] . "&nbsp;</strong></div></td>";
	
		echo "<td> <div align='center' style=' '><strong>" . $reg["min"] . "&nbsp;</strong></div></td>";
		echo "<td> <div align='center' style=' '><strong>" . $reg["max"] . "&nbsp;</strong></div></td>";
		//$fec1=$reg["ffecllegada"];
		//include('DF20000.php');
		//echo "<td> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
	}
	mysqli_close($con);
	?>
    </table>
  </form>
</div>
</body>
</html>