<?php

require_once('config/lang/eng.php');
require_once('tcpdf.php');

// extend TCPF with custom functions
class CDPDF extends TCPDF {

    public $tipo;
    public $titulo;

    public function setTipo($tipo) {


        $this->tipo = $tipo;
    }

    public function setTitulo($titulo) {


        $this->titulo = $titulo;
    }

    public function Header() {


        if ($this->tipo == 1) {

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);

//            $html = <<<EOD
//<table border="2" width="100%">
//<tr><td width="26%" rowspan="4">
//<img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>
//
//<td width="20%" align="center">CODIGO A301PR01I1F7</td></tr>
//<tr><td width="20%" align="center">Versión 00</td></tr>
//<tr><td width="20%" align="center">Fecha 2011-05</td></tr>
//<tr><td width="20%" align="center">Página </td></tr>
//</table>                       
//EOD;

            $html = '<table border="2" width="100%">';
            $html .= '<tr><td width="80%" rowspan="4">'
                    . '<img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            //. '<img width="100px" height="55px" src="images/nuevo_pais.jpg"/>';
            //$html .= '<td width="54%" align="center" rowspan="4"><b>' . $this->titulo . '</td>';
            $html .= '<td width="20%" align="center">CODIGO A301PR01I1F7</td></tr>';
            $html .= '<tr><td width="20%" align="center">Versión 00</td></tr>';
            $html .= '<tr><td width="20%" align="center">Fecha: ' . date("Y-m-d") . '</td></tr>';
            $html .= '<tr><td width="20%" align="center">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr>';
            $html .='</table>';


            $this->writeHTML($html);


            //$img_file = K_PATH_IMAGES.'logo_example.png';
            //$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
            $this->Ln(8);
            $this->SetMargins(20, 30, 20);
            $this->Ln(8);
        }
    }

    public function Footer() {
        $html = "";


        $date = date('d-M-y  h:m');
        $time = time();
        $html = "";
        $this->SetRightMargin(15);
        $this->SetLeftMargin(15);
        $this->SetFont('helvetica', '', 7);
        $this->SetY(-20);



        $this->writeHTML($html);
    }

    function fechaEspanol($fecha) {


        $transf = strtotime($fecha);
        $dia = date("d", $transf);
        $mes = date("F", $transf);

        if ($mes == "January")
            $mes = "Enero";
        if ($mes == "February")
            $mes = "Febrero";
        if ($mes == "March")
            $mes = "Marzo";
        if ($mes == "April")
            $mes = "Abril";
        if ($mes == "May")
            $mes = "Mayo";
        if ($mes == "June")
            $mes = "Junio";
        if ($mes == "July")
            $mes = "Julio";
        if ($mes == "August")
            $mes = "Agosto";
        if ($mes == "September")
            $mes = "Septiembre";
        if ($mes == "October")
            $mes = "Octubre";
        if ($mes == "November")
            $mes = "Noviembre";
        if ($mes == "December")
            $mes = "Diciembre";

        $ano = date("Y", $transf);

        $fecha_resol = $ano . "-" . $mes . "-" . $dia;

        return $fecha_resol;
    }

}
