<?php

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=Reporte_inventario.xls");

 include ("../conexion.php");	

       $parametros = "SELECT * FROM web_0000 ";
       $result_parametros = $mysqli->query($parametros);
       $row_para = $result_parametros->fetch_array();
     
	   $NombreComercial =  $row_para["NOMCOM"];
	   $Razon          =  $row_para["RAZSOC"];
	   $Direccion       =  $row_para["DIREMP"];
	   $Cedula          =  $row_para["CEDJUR"];
	   $Telefono        =  $row_para["NUMTEL"];


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LISTA DE INVENTARIO</title>
</head>
<body>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
    <tr>   </tr>
  <tr>
     <td></td>
 <td colspan="9"  bgcolor="skyblue"><div align="center"><strong>REPORTE LISTA DE INVENTARIO</strong></div></td>
  </tr>
     <tr>   </tr>
  <tr>
      <td width="10%"></td>
    <td  border="1" width="10%"><div align="center"><strong>CODIGO</strong></div></td>
    <td width="12%"><div align="center"><strong>BARRAS</strong></div></td>
    <td width="37%"><div align="center"><strong>DESCRIPCION</strong></div></td>
    <td width="16%"><div align="center"><strong>EXISTENCIA</strong></div></td>
    <td width="25%"><div align="center"><strong>PRECIO</strong></div></td>
	<td width="25%"><div align="center"><strong>PRECIO SIN IVA</strong></div></td>
	<td width="25%"><div align="center"><strong>MAYOREO</strong></div></td>
	<td width="25%"><div align="center"><strong>IMPUESTO</strong></div></td>
	<td width="25%"><div align="center"><strong>ESTANTE</strong></div></td>

  </tr>
  
<?PHP
$estante= 0;
$estante2= 0;		
$dsclin  =000;
$cdglin  =000;

 $consulta= "select cdgart,cdgbar,dscart,exiact,Pre001, Pre002,cdgfam,cdglin,COB_IV , ivporc , estante from web_1001 ORDER BY estante , cdgbar";
	if ($resultado = $mysqli->query($consulta)) 

  	while ($res = $resultado->fetch_assoc()) {
	
	$codigo  = $res["cdgart"];
	$cdgbar  = $res["cdgbar"];
	$cdgbar2 = "Cod. ".$cdgbar;
	$dscart  = $res["dscart"];
	$exiact  = number_format ( $res["exiact"], 2, '.', ',');
	$Pre001  = number_format ( $res["Pre001"], 2, '.', ',');
	$Pre002  = number_format ( $res["Pre002"], 2, '.', ',');
	$presinimp= $res["Pre001"] / ($res["ivporc"]/100+1);
	$presinimp  = number_format ( $presinimp, 2, '.', ',');
	$cdgfam  = $res["cdgfam"];
	$cdglin  = $res["cdglin"];
	$cob_iv  = $res["COB_IV"];
	$estante  = $res["estante"];
	$cdgfam  = sprintf("%03d",$cdgfam); 
	$cdglin  = sprintf("%03d",$cdglin); 
	

				
if ($cob_iv  == 1 ){$impuesto="GRAVADO";} else {$impuesto="EXENTO";};

?>  


<?php  if ($estante <> $estante2 ){ 


		
		$estante  = $res["estante"];	

		
		


  ?>


 <tr>
   <td></td>
   <td  bgcolor="skyblue">ESTANTE N.</td>
   <td  bgcolor="skyblue"><?php echo $estante ?></td>
   <td  bgcolor="skyblue">&nbsp;</td>
   <td  bgcolor="skyblue">&nbsp;</td>
   <td  bgcolor="skyblue">&nbsp;</td>
     <td  bgcolor="skyblue">&nbsp;</td>
	    <td  bgcolor="skyblue">&nbsp;</td>
     <td  bgcolor="skyblue">&nbsp;</td>
	      <td  bgcolor="skyblue">&nbsp;</td>
 </tr>
<?php  }    ?>
 <tr>
   <td></td>
   <td><div align="left"><?php echo $codigo; ?></div></td>
	<td><div align="left"><?php echo $cdgbar2; ?></div></td>
	<td><?php echo $dscart; ?></td>
	<td><div align="center"><?php echo $exiact; ?></div></td>
	<td><div align="right"><?php echo $Pre001; ?></div></td>    
		<td><div align="right"><?php echo $presinimp; ?></div></td>   
	<td><div align="center"><?php echo $Pre002; ?></div></td>     
	<td><div align="center"><?php echo $impuesto; ?></div></td>      
	        <td><div align="center"><?php echo $estante; ?></div></td>                    
 </tr> 
  <?php
  
  $estante2=$res["estante"];

}
  ?>
</table>
</body>
</html>