<?php 
ob_start();
require_once('../config/Conexion.php');
  ?>
<!DOCTYPE html>
<html>
<head><meta charset="gb18030">
	<title>Reporte Kardex</title>
	<style type="text/css">
		  table {color:black; 
		  	widows: 100%;
		 	border: none;
            border-collapse: collapse;
            
          }
          .cliente{
		 	padding-left: 20px; 
		 	padding-right: 20px;
		 	font-size:14px;
		 }
      </style>
		
</head>
<body>
	<?php
date_default_timezone_set('America/Los_Angeles');

?>
	<br>
	<div class="cliente">
    <table style="width: 100%; text-align: center;">
        <tr>
            <td style="width: 100%; text-align: center;">
                <h4>REPORTE KARDEX</h4>
            </td>
        </tr>
        <tr>
            <td style="width: 100%; text-align: center; font-size: 12px;">
                Fecha de impresión: 
                <?php 
                    setlocale(LC_ALL, "es_ES");
                    echo date('d-m-Y H:i');
                ?>
            </td>
        </tr>
    </table>
</div>
	<br>

	<table border="1" cellpadding="1" cellspacing="1" style="width: 100%; " >
		<tr style="text-align: center" >
			<th style="">CODIGO</th>
			<th width="">ARTICULO</th>
			<th width="15">INGRESO</th>
			<th width="15">SALIDA</th>
			<th width="10">STOCK </th>
		</tr>
		<?php 
			require_once "../modelos/Consulta.php";
			$consulta=new Consulta();
			$rpta=$consulta->kardex();
			while ($reg=$rpta->fetch_object()) {
				$total=$reg->stock_ingreso-$reg->stock_salida;
			?>
		<tr style=" margin: 20px; padding: 20px;">
			<td align="center" ><?php echo $reg->codigo; ?></td>
			<td width="340"><?php echo $reg->producto ?></td>
			<td align="center"><?php echo $reg->stock_ingreso; ?></td>
			<td align="center"><?php echo $reg->stock_salida; ?></td>
			<td  align="center"><?php echo $total; ?></td>
			
		</tr>
			<?php }

			 ?>
			
		
	</table>
	<br>
	<!-- <div align="center" class="t2" >
				Fecha: <?php 
				setlocale(LC_ALL,"es_ES");
				echo $dia=date('d').'-'.date('M').'-'.date('Y');?>
			</div> -->
</body>
</html>

<?php 
$html=ob_get_clean();
//echo $html;

require_once '../reportes/libreria/dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();

$options = $dompdf->getOptions();
$options->set(array('isRemoteEnabled' => true));
$dompdf->setOptions($options);

$dompdf->loadHtml($html);

$dompdf->setPaper('letter');
$dompdf->setPaper('A4','landscape');
$dompdf->setPaper('A4','');
//$dompdf->set

$dompdf->render();
$dompdf->stream("reportekardex.pdf",array('Attachment' => false));

?>