<?php
ob_start();
session_start();

require '../../../conexion.php';
require_once('../../../include/sesiones.php');
require "../../php_qr/qrlib.php";    
require_once dirname(__FILE__).'../../vendor/autoload.php';

use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
    
$number =count($_GET["ven_id"]);  
if($number > 0)  
{  
    for($i=0; $i<$number; $i++)  
    { 
        if(trim($_GET["ven_id"][$i] != '') )
        $ven_id=$_GET["ven_id"][$i];  
        $query=mysqli_query($con,"SELECT * FROM ventas where ven_id='$ven_id' and empresa='$empresa' ");
        $roww=mysqli_fetch_array($query);
        $ven_nombre=$roww['ven_nombre'];
        $ven_prefijo=$roww['ven_prefijo']; 
        $ven_n_venta=$roww['ven_n_venta']; 
        include(dirname('__FILE__').'/facturas/factura_venta.php');
    }
}
$content = ob_get_clean();

try {
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 0);
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output($ven_nombre.'-'.$ven_prefijo.$ven_n_venta.'.pdf', 'I');
} catch (Html2PdfException $e) {
    $html2pdf->clean();
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
?>