<?php

namespace App\Controllers;

use App\Models\Process;
use App\Services\VoucherService;

class VoucherController extends BaseController
{
    public function printVoucher($id)
    {
        $process = Process::find($id);

        if (!$process) {
            $_SESSION['message'] = "Error: Támite no encontrado.";
            $_SESSION['message_type'] = "danger";
            header("Location: " . BASE_HEADER . "processes/show-processes");
            exit;
        }

        $voucherService = new VoucherService();
        $voucherService->generate($process);

        // Retornar el PDF al navegador
        // Esto puede ser un 'output' o un 'download' dependiendo de la lógica
        exit;
    }
}