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

// extend TCPF with custom functions
class CDPDF extends TCPDF {
  public $comision;
  public $inv;
    public function setComision($id_comision,$vigencia) {
      $this->comision = ComisionesPeer::retrieveByPK($id_comision,$vigencia);
    }
       
    public function setInversion($inv) {
     $this->inv=$inv;
    }
    public function Header() {
        // Logo

	if($this->inv==1){
	sfLoader::loadHelpers('Date');
        sfLoader::loadHelpers('Asset');
        $this->Ln(10);
        $this->SetRightMargin(15);
        $this->SetTopMargin(8);
        $this->SetFont('helvetica', '', 10);
        $html  = '<table border="2" cellpadding="3" width="100%"><tr><td width="20%" rowspan="3"><img src="images/logoCertificado.png" width="90" height="40" /></td>';
        $html .= '<td width="60%" rowspan="3" align="center"><b>SOLICITUD DE CERTIFICADO DE DISPONIBILIDAD PRESUPUESTAL<br/>INVERSION</b></td>';
        $html .= '<td width="25%" align="center"><b>VERSIÓN 8</b></td></tr>';
        $html .= '<tr><td width="25%" align="center">F-FIN-GAS-001</td></tr>';
        $html .= '<tr><td width="25%" align="center">Página '.$this->getAliasNumPage().' de '.$this->getAliasNbPages().'</td></tr></table>';
        $this->writeHTML($html);
        $this->Ln(15);
        $this->SetMargins(20,40,20);
	}else{


        sfLoader::loadHelpers('Date');
        sfLoader::loadHelpers('Asset');
        $this->Ln(10);
        $this->SetRightMargin(15);
        $this->SetTopMargin(8);
        $this->SetFont('helvetica', '', 10);
        $html  = '<table border="2" cellpadding="3" width="100%"><tr><td width="20%" rowspan="3"><img src="images/logoCertificado.png" width="90" height="40" /></td>';
        $html .= '<td width="60%" rowspan="3" align="center"><b>SOLICITUD DE CERTIFICADO DE DISPONIBILIDAD PRESUPUESTAL<br/>FUNCIONAMIENTO</b></td>';
        $html .= '<td width="25%" align="center"><b>VERSIÓN 9</b></td></tr>';
        $html .= '<tr><td width="25%" align="center">F-FIN-GAS-001</td></tr>';
        $html .= '<tr><td width="25%" align="center">Página '.$this->getAliasNumPage().' de '.$this->getAliasNbPages().'</td></tr></table>';
        $this->writeHTML($html);
        $this->Ln(15);
        $this->SetMargins(20,40,20);
	}
    }
    
    public function Footer() {
        $this->SetRightMargin(2);
        $this->SetLeftMargin(2);
        $this->SetFont('helvetica', '', 7);
        $this->SetY(-9);
        $html = '<div align="center" style="font-style:italic;color:gray">Websafi - comisiones</div>';
        $this->writeHTML($html);        
    }  
}
