<?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;
    
$desde=$_GET["desde"];  
$hasta=$_GET["hasta"];  
$cliente=$_GET["cliente"];  
$total=0;

if($cliente==0)
{
    $query1=mysqli_query($con,"SELECT * FROM ventas where ven_fecha BETWEEN '$desde' AND '$hasta' and sucursal='$sucursal' and empresa='$empresa' and ven_estado<>'anulada' order by ven_n_venta desc ") or die(mysqli_error($con));
}
else
{
    $query1=mysqli_query($con,"SELECT * FROM ventas where Cliente_clie_id='$cliente' and ven_fecha BETWEEN '$desde' AND '$hasta' and sucursal='$sucursal' and empresa='$empresa' and ven_estado<>'anulada' order by ven_n_venta desc  ") or die(mysqli_error($con));
}
while ($roww1=mysqli_fetch_array($query1))    
{
    $ven_id=$roww1["ven_id"];  
    include(dirname('__FILE__').'/facturas/factura_venta5.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('Lote_facturas.pdf', 'I');
} catch (Html2PdfException $e) {
    $html2pdf->clean();

    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
?>