<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/SaleController.php';

use Dompdf\Dompdf;

class ReportController {

    public function generateSalesReport() {
        $saleController = new SaleController();
        $salesBySeller = $saleController->getSalesBySeller();

        ob_start();
        include __DIR__ . '/../views/admin/reports/sales_by_seller_pdf.php';
        $html = ob_get_clean();

        $dompdf = new Dompdf();
        $dompdf->loadHtml($html);
        $dompdf->setPaper('A4', 'landscape');
        $dompdf->render();
        $dompdf->stream("reporte_ventas.pdf");
    }
}

if (isset($_GET['action']) && $_GET['action'] == 'generate_sales_report') {
    $reportController = new ReportController();
    $reportController->generateSalesReport();
}
?>