<?php
session_start();
require_once('../conexion.php');
require_once('../include/sesiones.php');
if (isset($_SESSION['usu_nombre']))
{
  echo  $vend_referencia=$_GET["vend_referencia"];

?>
<html >
<head>
<script src="../js/jstirilla.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="https://cdn.jsdelivr.net/jsbarcode/3.6.0/JsBarcode.all.min.js"></script>
</head>
<body >
<table cellspacing="9" style="  text-align: center; height: auto; " border="1">
<?php
$ven1=mysqli_query($con,"SELECT * FROM ventas WHERE ven_fecha BETWEEN '2017-01-01' AND '2022-12-31' ") or die(mysqli_error($con));  
while ($ven11=mysqli_fetch_array($ven1))
{
    $ven_id=$ven11["ven_id"];
    $can1=mysqli_query($con,"SELECT * FROM venta_detalle WHERE ventas_ven_id='$ven_id' and vend_referencia='$vend_referencia' ") or die(mysqli_error($con));  
    while ($row=mysqli_fetch_array($can1))
    {
        $ven_fecha=$ven11["ven_fecha"];
        $vend_id=$row["vend_id"];
        $sql_tar=mysqli_query($con, "SELECT * from seriales where venta_detalle_vend_id='$vend_id' and venta_detalle_ventas_ven_id ='$ven_id'");
        while ($row2=mysqli_fetch_array($sql_tar))
        {
            $ser_codigo=$row2['ser_codigo'];
        ?>
        <svg class="barcode" 
            jsbarcode-value="<?php echo $ser_codigo  ?>"
            jsbarcode-textmargin="10"
            jsbarcode-fontoptions="bold" style="height: 70px; width: 100px; padding: 0px">
        </svg>
        <br>
        <?php echo $ven_fecha; ?>      
        <?php    
        } 
    }
} 
?>
</table>    

<script type="text/javascript">
$(window).load(function()
{
   window.print();
});


</script>
<script type="text/javascript">
    JsBarcode(".barcode").init();
   
</script>


</body></html> 
<?php
}
else
{
    echo '<script>alert("primero debes Iniciar Cesion para ver esta pagina")</script>';
    echo '<script>location.href = "index.php";</script>';
}
?>
