<?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 $version;
    public $contrato;
    public $contratista;

    public function setTipo($tipo) {
        $this->tipo = $tipo;
    }

    public function setTitulo($titulo) {
        $this->titulo = $titulo;
    }
    
    public function setVersion($version) {
        $this->version = $version;
    }
    
    public function setContrato($contrato) {
        $this->contrato = $contrato;
    }
    
    public function setContratista($contratista) {
        $this->contratista = $contratista;
    }

    public function Header() {


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

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" align="center"><br/><br/><b>' . $this->titulo . '</b></td>';
            $html .= '<td width="30%"><table border="2" width="100%">';
            $html .= '<tr><td width="100%"><img width="150px" height="30px" src="images/minminas_prospe.png"/></td></tr>';
            $html .= '<tr><td width="100%" align="center">Version 7</td></tr>';
            $html .= '<tr><td width="100%" align="center">F-CIN-PER-002</td></tr>';
            $html .= '<tr><td width="100%" align="center">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr>';
            $html.='</table></td></tr></table>';
            $this->writeHTML($html);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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);
        }
        if ($this->tipo == 2) {

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '<table border="2" cellpadding="5" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" rowspan="4" align="center"><br/><br/><b>' . $this->titulo . '</b></td>';
            $html .= '<td width="30%"><table border="2" width="100%">';
            $html .= '<tr><td width="100%"><img width="150px" height="30px" src="images/minminas_prospe.png" /></td></tr>';
            $html .= '<tr><td width="100%">Version </td></tr>';
            $html .= '<tr><td width="100%">Codigo </td></tr>';
            $html .= '<tr><td width="100%">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr></table></td></table>';
            $this->writeHTML($html);
            //$img_file = K_PATH_IMAGES.'borrador.jpg';
            //$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
            $this->Image(K_PATH_IMAGES . '/borrador.jpg', 0, 30, 200, 200, '', 'http://www.tcpdf.org', '', true, 150);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            $this->Ln(8);
            $this->SetMargins(20, 30, 20);
            $this->Ln(8);
        }
        if ($this->tipo == 4) {

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" align="center"><br/><br/><b>' . $this->titulo . '</b></td>';
            $html .= '<td width="30%"><table border="2" width="100%">';
            $html .= '<tr><td width="100%"><img width="150px" height="30px" src="images/minminas_prospe.png"/></td></tr>';
            $html .= '<tr><td width="100%" align="center">Version 2</td></tr>';
            $html .= '<tr><td width="100%" align="center">Codigo F-CIN-LIC-014</td></tr>';
            $html .= '<tr><td width="100%" align="center">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr>';
            $html.='</table></td></tr></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);
        }

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

            $date = date('d-M-y');
            $this->SetTopMargin(15);
            $this->SetRightMargin(30);
            $this->SetLeftMargin(30);
            $this->SetFont('helvetica', '', 7);
            $html = '<table border="2" width="100%"><tr><td width="30%"><img width="100px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" align="center"><br/><br/><b>' . $this->titulo . '</b></td>';
            $html .= '<td width="30%"><table border="2" width="100%">';
            $html .= '<tr><td width="100%"><img width="100px" height="30px" src="images/minminas_prospe.png"/></td></tr>';
            $html .= '<tr><td width="100%" align="center">Fecha: ' . $date . '</td></tr>';
            $html .= '<tr><td width="100%" align="center">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr>';
            $html.='</table></td></tr></table>';
            $this->writeHTML($html);

            $this->Ln(8);
            $this->Ln(8);
        }

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

            $date = date('d-M-y');
            $this->SetTopMargin(15);
            $this->SetRightMargin(30);
            $this->SetLeftMargin(30);
            $this->SetFont('helvetica', '', 7);

            $this->titulo = '';

            $html = '<table border="2" width="100%">';
            $html .='<tr>';
            $html .='<td width="25%" align="left" valign="bottom"><img src="images/LogoEmpresa2.png" alt="" width="80px" height="83px" /></td>';
            $html .='<td width="60%"><br /><br /></td>';
            $html .='<td width="25%" align="center" valign="bottom"><br/><img src="images/prosperidad.png" alt="" width="130px" height="60px" /></td>';
            $html .='</tr>';
            $html .='</table>';

            //$this->writeHTML($html);

            $this->Ln(8);
            $this->Ln(8);
        }
        if ($this->tipo == 7) {//Version Remplaza el Tipo 1 a partir de 20190701 

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            /*$html = '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" align="center"><br/><br/><b>' . $this->titulo . '</b></td>';
            $html .= '<td width="30%"><table border="2" width="100%">';
            $html .= '<tr><td width="100%"><img width="150px" height="30px" src="images/minminas_props20190701.png"/></td></tr>';
            $html .= '<tr><td width="100%" align="center">Version 7</td></tr>';
            $html .= '<tr><td width="100%" align="center">F-CIN-PER-002</td></tr>';
            $html .= '<tr><td width="100%" align="center">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr>';
            $html.='</table></td></tr></table>';*/
            $html = '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" style="align:center;vertical-align: middle"><img width="200px" height="40px" src="images/minminas_props20190701.png"/></td>';
            $html .= '<td width="30%"><table border="2" width="100%" height="100%">';
            $html .= '<tr><td width="100%" align="center">Version 7</td></tr>';
            $html .= '<tr><td width="100%" align="center">F-CIN-PER-002</td></tr>';
            $html .= '<tr><td width="100%" align="center">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr>';
            $html.='</table></td></tr></table>';
            $this->writeHTML($html);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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);
        }
        if ($this->tipo == 8) {//Version Remplaza el Tipo 2 a partir de 20190701 

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            /*$html = '<table border="2" cellpadding="5" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" rowspan="4" align="center"><br/><br/><b>' . $this->titulo . '</b></td>';
            $html .= '<td width="30%"><table border="2" width="100%">';
            $html .= '<tr><td width="100%"><img width="150px" height="30px" src="images/minminas_props20190701.png" /></td></tr>';
            $html .= '<tr><td width="100%">Version </td></tr>';
            $html .= '<tr><td width="100%">Codigo </td></tr>';
            $html .= '<tr><td width="100%">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr></table></td></table>';*/
            $html = '<table border="2" cellpadding="5" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="40%" style="align:center;vertical-align: middle"><img width="200px" height="40px" src="images/minminas_props20190701.png" /></td>';
            $html .= '<td width="30%"><table border="2" width="100%" height="100%">';
            $html .= '<tr><td width="100%">Version </td></tr>';
            $html .= '<tr><td width="100%">Codigo </td></tr>';
            $html .= '<tr><td width="100%">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr></table></td></tr></table>';
            $this->writeHTML($html);
            //$img_file = K_PATH_IMAGES.'borrador.jpg';
            //$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
            $this->Image(K_PATH_IMAGES . '/borrador.jpg', 0, 30, 200, 200, '', 'http://www.tcpdf.org', '', true, 150);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            $this->Ln(8);
            $this->SetMargins(20, 30, 20);
            $this->Ln(8);
        }
        if ($this->tipo == 9) {//Header CEV

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '';
            $html .= '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="70%" align="center">';
            $html .= '<table width="100%">';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<br/>';
            $html .= '<b>'.$this->titulo.'</b>';
            $html .= '<br/>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<table border="1" width="100%">';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= 'Proceso: Gestión Jurídica y Contractual';
            $html .= '</td>';
            $html .= '<td>';
            $html .= 'Versión: 1';
            $html .= '</td>';
            $html .= '<td>';
            $html .= 'Código:F2.M1.JC';
            $html .= '</td>';
            $html .= '<td>';
            $html .= 'Fecha Publicación: 30/07/2019';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '</table>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '</table>';       
            $html .= '</td>';
            $html .= '</tr></table>';
            $this->writeHTML($html);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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);
        }
        if ($this->tipo == 10) {//HEADER CEV BORRADOR

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '';
            $html .= '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="70%" align="center">';
            $html .= '<table width="100%">';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<br/>';
            $html .= '<b>'.$this->titulo.'</b>';
            $html .= '<br/>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<table border="1" width="100%">';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= 'Proceso: Gestión Jurídica y Contractual';
            $html .= '</td>';
            $html .= '<td>';
            $html .= 'Versión: 1';
            $html .= '</td>';
            $html .= '<td>';
            $html .= 'Código:F2.M1.JC';
            $html .= '</td>';
            $html .= '<td>';
            $html .= 'Fecha Publicación: 30/07/2019';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '</table>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '</table>';       
            $html .= '</td>';
            $html .= '</tr></table>';
            //$html .= '<tr><td width="100%">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr></table></td></tr></table>';
            $this->writeHTML($html);
            //$img_file = K_PATH_IMAGES.'borrador.jpg';
            //$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
            $this->Image(K_PATH_IMAGES . '/borrador.jpg', 0, 30, 200, 200, '', 'http://www.tcpdf.org', '', true, 150);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            $this->Ln(8);
            $this->SetMargins(20, 30, 20);
            $this->Ln(8);
        }
        if ($this->tipo == 11) {//Header ANM

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '';
            $html .= '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="70%" align="center">';
            $html .= '<table width="100%">';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<br/>';
            $html .= '<b>ESTUDIOS PREVIOS</b>';
            $html .= '<br/>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<b>'.$this->titulo.'</b>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '</table>';       
            $html .= '</td>';
            $html .= '</tr></table>';
            $this->writeHTML($html);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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);
        }
        if ($this->tipo == 12) {//HEADER ANM BORRADOR

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '';
            $html .= '<table border="2" width="100%"><tr><td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="70%" align="center">';
            $html .= '<table width="100%">';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<br/>';
            $html .= '<b>ESTUDIOS PREVIOS</b>';
            $html .= '<br/>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '<tr>';
            $html .= '<td>';
            $html .= '<b>'.$this->titulo.'</b>';
            $html .= '</td>';
            $html .= '</tr>';
            $html .= '</table>';       
            $html .= '</td>';
            $html .= '</tr></table>';
            //$html .= '<tr><td width="100%">Página ' . $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages() . '</td></tr></table></td></tr></table>';
            $this->writeHTML($html);
            //$img_file = K_PATH_IMAGES.'borrador.jpg';
            //$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
            $this->Image(K_PATH_IMAGES . '/borrador.jpg', 0, 30, 200, 200, '', 'http://www.tcpdf.org', '', true, 150);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            $this->Ln(8);
            $this->SetMargins(20, 30, 20);
            $this->Ln(8);
        }
        if ($this->tipo == 13) {//HEADER CONTRATO ESTANDART

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '<table border="2" width="100%"><tr><td width="30%"></td>';
            $html .= '<td width="40%" align="center"><br/><br/><b></b></td>';
            $html .= '<td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html.='</tr></table>';
            $this->writeHTML($html);

            $this->SetLineStyle(array('color' => array(0, 0, 0)));

            $this->Line(10, 30, $this->getPageWidth() - 10, 30);
            $this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            $this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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);
        }
        if ($this->tipo == 14) {//HEADER CONTRATO CEV

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 7);
            $html = '<table border="0" width="100%"><tr><td width="30%"></td>';
            $html .= '<td width="40%" align="center"><br/><br/><b></b></td>';
            $html .= '<td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html.='</tr></table>';
            $this->writeHTML($html);

            //$this->SetLineStyle(array('color' => array(0, 0, 0)));

            //$this->Line(10, 30, $this->getPageWidth() - 10, 30);
            //$this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            //$this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            //$this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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);
        }
        if ($this->tipo == 15) {//HEADER CONTRATO CEV ARRENDAMIENTO

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 11);
            $html = '<table border="0" width="100%"><tr><td width="30%"></td>';
            $html .= '<td width="40%" align="center"><br/><br/><b></b></td>';
            $html .= '<td width="30%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '</tr>';
            $html .= '<tr>';
            $html .= '<td colspan="3"  align="center">';
            $html .= '<strong>CONTRATO DE ARRENDAMIENTO DE BIEN INMUEBLE No. CO-AJ-'.$this->contrato.' SUSCRITO ENTRE LA COMISIÓN PARA EL ESCLARECIMIENTO DE LA VERDAD, LA CONVIVENCIA Y LA NO REPETICIÓN Y PROKSOL S.A.S.</strong>';
            $html .= '</td>';
            $html .= '</tr>';
            $html.='</tr></table>';
            $this->writeHTML($html);

            //$this->SetLineStyle(array('color' => array(0, 0, 0)));

            //$this->Line(10, 30, $this->getPageWidth() - 10, 30);
            //$this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            //$this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            //$this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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, 40, 20);
            $this->Ln(8);
        }
        if ($this->tipo == 16) {//HEADER CONTRATO ANM PRESTACION SERVICIOS PERSONA NATURAL

            $this->SetTopMargin(2);
            $this->SetFont('helvetica', '', 10);
            $html = '<table border="0" width="100%"><tr>';
            $html .= '<td width="30%"><img width="120px" height="44px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="70%" align="left">';
            $html .= '<strong>CLAUSULADO COMPLEMENTARIO AL CONTRATO DE PRESTACIÓN DE SERVICIOS PROFESIONALES No. '.$this->contrato.' SUSCRITO ENTRE LA AGENCIA NACIONAL DE MINERIA Y '.$this->contratista.'.</strong>';
            $html .= '</td>';
            $html .= '</tr>';
            $html.='</table>';
            $this->writeHTML($html);

            //$this->SetLineStyle(array('color' => array(0, 0, 0)));

            //$this->Line(10, 30, $this->getPageWidth() - 10, 30);
            //$this->Line($this->getPageWidth() - 10, 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            //$this->Line(10, $this->getPageHeight() - 20, $this->getPageWidth() - 10, $this->getPageHeight() - 20);
            //$this->Line(10, 30, 10, $this->getPageHeight() - 20);

            //$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, 40, 20);
            $this->Ln(8);
        }
        if ($this->tipo == 17) { 
            
            $date = date('d-M-y');
            $this->SetTopMargin(15);
            $this->SetRightMargin(30);
            $this->SetLeftMargin(30);
            $this->SetFont('helvetica', '', 7);
            $html = '<table border="2" width="100%"><tr><td width="50%"><img width="150px" height="55px" src="images/LogoEmpresa.png" /></td>';
            $html .= '<td width="50%" style="align:center;vertical-align: middle"><img width="200px" height="40px" src="images/minminas_props20190701.png"/></td>';
            $html .= '</tr></table>';
            $this->writeHTML($html);
            
            $this->Ln(8);
            $this->Ln(8);
        }
    }

    public function Footer() {
        $html = "";
        
        switch($this->tipo){
            CASE 11:
                $date = date('d-M-y  h:m');
                $time = time();
                $html = "";
                $this->SetFont('helvetica', '', 7);
                $this->SetY(-20);
                $html = '';
                $html .= '<table align="right">';
                $html .= '<tr>';
                $html .= '<td>';
                $html .= 'APO1-P-001-F-030 / v'.$this->version;
                $html .= '</td>';
                $html .= '</tr>';
                $html .= '<tr>';
                $html .= '<td>';
                $html .=  $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages();
                $html .= '</td>';
                $html .= '</tr>';
                $html .= '</table>';
                break;
            CASE 12:
                $date = date('d-M-y  h:m');
                $time = time();
                $html = "";
                $this->SetFont('helvetica', '', 7);
                $this->SetY(-20);
                $html = '';
                $html .= '<table align="right">';
                $html .= '<tr>';
                $html .= '<td>';
                $html .= 'APO1-P-001-F-030 / v'.$this->version;
                $html .= '</td>';
                $html .= '</tr>';
                $html .= '<tr>';
                $html .= '<td>';
                $html .=  $this->getAliasNumPage() . ' de ' . $this->getAliasNbPages();
                $html .= '</td>';
                $html .= '</tr>';
                $html .= '</table>';
                break;
            CASE 14:
                $date = date('d-M-y  h:m');
                $time = time();
                $html = "";
                $this->SetFont('helvetica', '', 7);
                $this->SetY(-20);

                $html = '<table style="width:600px">
                                <tr>';
                $html.='<td style="color: #999" align="center">Comisión para el Esclarecimiento de la Verdad, la Convivencia y No Repetición.<br />
    Carrera 9 No.12 C – 10-Bogotá D.C.</td></tr>
		</table>';
                break;
            CASE 6:
                break;
            default:
                $date = date('d-M-y  h:m');
                $time = time();
                $html = "";
                $this->SetFont('helvetica', '', 7);
                $this->SetY(-20);

                $html = '<table style="width:600px">
                                <tr>
                                    <td style="color: #999"></td>';
                $html.='<td style="color: #999"></td>
                         <td style="color: #999">Fecha de Impresion: ' . $date . '</td></tr>
			    
                        </table>';
                break;
        }

        /*if ($this->tipo != 6 and $this->tipo != 14) {

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

            $html = '<table style="width:600px">
                            <tr>
                                <td style="color: #999"></td>';
            $html.='<td style="color: #999"></td>
	             <td style="color: #999">Fecha de Impresion: ' . $date . '</td></tr>
			    
                        </table>';
        }
        
        if ($this->tipo == 14) {

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

            $html = '<table style="width:600px">
                            <tr>';
            $html.='<td style="color: #999" align="center">Comisión para el Esclarecimiento de la Verdad, la Convivencia y No Repetición.<br />
Carrera 9 No.12 C – 10-Bogotá D.C.</td></tr>
		</table>';
        }*/

        $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 = $dia . " " . $mes . " " . $ano;
        return $fecha_resol;
    }

}
