<?php
session_start();
if (!isset($_SESSION["user_id"]) || $_SESSION["user_id"]==null):
   print "<script>alert(\"Acceso Invalido!\");
   window.location='login.php';</script>";
endif;
if ($_SESSION["user_at"] < 2):
   print "<script>alert(\"Sin Acceso a Transaccion!\");
   window.location='vt000.php';</script>";
endif;
include_once ("lib/fpdf/funci.php");
date_default_timezone_set('America/La_Paz');
//$coalm = $_SESSION["user_al"];
$bupro = trim($_POST["buspro"]);
$fehoy = date("Y-m-d");
$conex = conectar();
?>
<body bgcolor="#E0FFFF">
<div class="main-wrapper">
<link href="css/tabla.css" rel="stylesheet" type="text/css" />
<link href="bootstrap/css/bootstrap.css" rel="stylesheet" />
<center><h1>Consulta de Productos</h1></center>
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&ensp;&nbsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&ensp;&nbsp;&nbsp;
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&ensp;&nbsp;&nbsp;
<a class="btn btn-danger" href="vt000.php">Salir</a></center>
<center><table border="0" cellpadding="0" cellspacing="0" class="tabla">
   <thead>
	<th><center>Codigo</center></th>
	<th>Nombre Producto</th>
	<th>Umed</th>
	<th><center>Existencia</center></th>
	<th><center>Lote</center></th>
	<th><center>Fecha Venc</center></th>
   </thead>
<?php
if (strlen($bupro) > 0):
   $mysql = "select inalmcorr,inalmcart,inartdesc,inartumed,inalmcant,inalmlote,inalmfven
             from   inalm,inart
             where  inalmcart = inartcart
             and    inartdesc like '%$bupro%'
             and    inalmcant > 0
             order  by 3,7";
else:
   $mysql = "select inalmcorr,inalmcart,inartdesc,inartumed,inalmcant,inalmlote,inalmfven
             from   inalm,inart
             where  inalmcart = inartcart
             and    inalmcant > 0
             order  by 3,7";
endif;
$result = mysql_query($mysql);
while ($row = mysql_fetch_array($result)): ?>
   <tr class="modo1">
   <td><center><?php echo $row[1];?></center></td>
   <td><?php echo $row[2];?></td>
   <td><?php echo $row[3];?></td>
   <td><center><?php echo number_format($row[4],2);?></center></td>
   <td><center><?php echo $row[5];?></center></td>
   <?php if (strlen($row[5]) > 0):
      if ($fehoy > $row[6]): ?>
         <td style="background-color: yellow;"><center><?php echo date('d-m-Y',strtotime($row[6]));?></center></td>
      <?php else: ?>
         <td><center><?php echo date('d-m-Y',strtotime($row[6]));?></center></td>
      <?php endif;
   else: ?>
      <td><center><?php echo "";?></center></td>
   <?php endif; ?>
   </tr>
   <?php
endwhile; ?>
</table></center>
</div>
</body>
