<?php
include_once("../../../php/sessionStart.php"); 
include_once("../../../php/db/dbExec.php");
include_once("../../../php/fpdf/functions.php");
include_once('../../../php/timezone.php');
include_once('../../../php/maxExecTime.php');

$empCod=utf8_decode($_SESSION["empCod"]);
$empNom=utf8_decode($_SESSION["empNom"]);

$jsonTblError=json_decode($_GET['TblErrores']);

$lineWidth=17;
$lineHeight=0.5;

class generatePDF extends PDF_MC_Table {
    function Header() {
        global $empNom, $lineWidth, $lineHeight;
        $this->SetMargins(2.5, 1, 2.5);

        $this->SetFont("Arial","",9);
        $this->Cell(0, 0, "", 0, 1);
        $this->Cell(20,.7,"Listado de Errores econtrados en el archivo cargado",0,1,"L");

        $header = array("Linea","Mensaje");
        $this->SetFont("","B");
        $this->SetWidths(array(3,14));
        $this->SetAligns(array("C","C"));
        $this->Row($header, $lineHeight);

        $this->SetFont("");
        $this->SetAligns(array("C","L"));

    }
    
    function Footer() {
        global $btn, $dtGrabado;
        // Posición: a 1,5 cm del final
        $this->SetY(-2.5);
        $this->SetFont("Arial","I",8);
        $this->Cell(0,1,utf8_decode("PÁGINA ").$this->PageNo(),0,0,"C");
        $this->Ln(.5);
    }
}

# GENERAR PDF
$pdf = new generatePDF("P","cm", "Letter");
$pdf->AddPage();
foreach ($jsonTblError as $recd) {
    $body = array(
        $recd->Linea,
        $recd->Mensaje,
    );
    $pdf->RowBorderHidden($body, $lineHeight);
}
$pdf->line($pdf->GetX(), $pdf->GetY(), 19.5, $pdf->GetY());

$pdf->Output(utf8_decode("Errores").".pdf","I");
?>