Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15447 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

namespace LeadersLinked\Library;

use Fpdf\Fpdf;
use LeadersLinked\Model\Competency;
use LeadersLinked\Model\CompetencyType;
use LeadersLinked\Model\Behavior;
use Laminas\Mvc\I18n\Translator;

class JobDescriptionPdf extends FPDF {
    
    const MAX_Y_ADD_PAGE = 240;

    /**
     *
     * @var string
     */
    public $header;
    
    /**
     * 
     * @var string
     */
    public $footer;
    
    /**
     * 
     * @var Translator
     */
    public $translator; 
    
   
    
    
    /**
     * Header PDF
     */
    function Header() {

        if ($this->header != '') {
            $this->Image($this->header, 10, 8, 190);
            $this->SetY(55);
        }
    }

    /**
     * Custom Header PDF
     */
    function customHeader() {
        $this->SetFont('Arial', 'B', 11);
        $this->Cell(60, 10, Functions::utf8_decode('DESCRIPCIÓN DE CARGOS DE TRABAJO'));
        $this->Ln(10);
    }

    /**
     * Footer PDF
     */
    function Footer() {
        if ($this->footer != '') {
            $this->SetY(-40);
            $this->Image($this->footer, 10, $this->getY(), 190);
        }
    }

    /**
     * Section Signature
     */
    function sectionSignature() {

        $this->SetFont('Arial', 'B', 9);
        $this->Cell(60, 10, Functions::utf8_decode('Elaborado por:'));
        $this->Ln(8);
        $this->Cell(60, 10, Functions::utf8_decode('Firma:'));
        $this->Ln(8);
        $this->Cell(60, 10, Functions::utf8_decode('Fecha:'));
        $this->Ln(8);
    }

    /**
     * Section Scale
     */
    function sectionScale() {
        $this->SetFillColor(225, 255, 255);
        $this->SetTextColor(0);
        $this->SetFont('Arial', 'B', 9);


        $this->Cell(35, 8, Functions::utf8_decode(' Escala/Niveles:'), 1, 0, 'L', false);

        $this->SetFillColor(225, 255, 255);
        $this->SetTextColor(0);
        $this->SetFont('Arial', '', 9);

        $this->Cell(155, 8, Functions::utf8_decode(' 1: Mínimo  2: Medio  3: Medio-Alto  4: Alto  N/A: No aplica '), 1, 'L', false);
        $this->Ln(15);
    }

    /**
     * Create Table
     * @param string $title
     * @param array $content
     */
    function borderTable($title, $content) {

        // Header Table
        $this->SetFillColor(204, 204, 204);
        $this->SetDrawColor(0, 0, 0);
        $this->SetLineWidth(0);
        $this->SetFont('Arial', 'B', 9);

        $this->Cell(190, 6, Functions::utf8_decode($title), 1, 0, 'L', true);
        $this->Ln();

        // Body Table
        $this->SetFillColor(225, 255, 255);
        $this->SetTextColor(0);

        foreach ($content as $rs) {
            if (isset($rs['title'])) {

                $this->SetFont('Arial', 'B', 9);

                $this->Cell(40, 10, Functions::utf8_decode($rs['title']), 1, 0, 'L', false);
                $this->Cell(150, 10, Functions::utf8_decode($rs['content']), 1, 'L', false);
                $this->Ln();
            } else {

                $this->SetFont('Arial', '', 9);
                $this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 1, 'L', false);
            }
            
            $y = $this->getY();
            if($y >= self::MAX_Y_ADD_PAGE) {
                $this->addPage();
            }
        }
        $this->Ln(5);
        
        $y = $this->getY();
        if($y >= self::MAX_Y_ADD_PAGE) {
            $this->addPage();
        }
    }

    /**
     * Create Table
     * @param string $title
     * @param array $content
     */
    function singleTable($title, $content) {

        // Header Table
        $this->SetFillColor(255, 255, 255);
        $this->SetDrawColor(0, 0, 0);
        $this->SetLineWidth(0);
        $this->SetFont('Arial', 'B', 9);

        $this->Cell(190, 6, Functions::utf8_decode($title), 0, 0, 'L', true);
        $this->Ln();

        // Body Table
        $this->SetFillColor(225, 255, 255);
        $this->SetTextColor(0);
        $this->SetFont('Arial', '', 9);

        foreach ($content as $rs) {
            if (isset($rs['title'])) {
                $this->Cell(40, 6, Functions::utf8_decode($rs['title']), 0, 0, 'L', false);
                $this->Cell(150, 6, Functions::utf8_decode($rs['content']), 0, 'L', false);
                $this->Ln();
            } else {
                $this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 0, 'L', false);
            }
            
            $y = $this->getY();
            if($y >= self::MAX_Y_ADD_PAGE) {
                $this->addPage();
            }
        }
        $this->Ln(5);
        
        $y = $this->getY();
        if($y >= self::MAX_Y_ADD_PAGE) {
            $this->addPage();
        }
    }

    /**
     * Create Competency Table
     * @param string $index
     * @param CompetencyType $competenceType
     * @param Competency $competency
     * @param Behavior[] $behaviors
     * @param boolean $last
     */
    function competencyTable($index, $competenceType, $competency, $behaviors, $last ) {


        // Header Table
        $this->SetFillColor(255, 255, 255);
        $this->SetDrawColor(0, 0, 0);
        $this->SetLineWidth(0);
        $this->SetFont('Arial', 'B', 9);

        $this->MultiCell(190, 5, $index . '- ' . Functions::utf8_decode($competenceType->name) . ': ' . Functions::utf8_decode($competency->name), 0, 'L', false);



        // Body Table
        $this->SetFillColor(225, 255, 255);
        $this->SetTextColor(0);
        $this->SetFont('Arial', '', 9);

        $this->MultiCell(190, 6, Functions::utf8_decode(strip_tags($competency->description)), 0, 'L', false);

        $this->Ln(3);



        if ($behaviors) {

            $first  = true;
            
     
            $max =  count($behaviors);
            for ($i = 0; $i <$max; $i++) {
                
                if($first) {
                    $this->SetFillColor(204, 204, 204);
                    $this->SetDrawColor(0, 0, 0);
                    $this->SetLineWidth(0);
                    $this->SetFont('Arial', 'B', 9);
                    
                    /*
                    $this->Cell(155, 6, Functions::utf8_decode('Conductas observables :'), 1, 0, 'L', true);
                    $this->Cell(7, 6, '1', 1, 0, 'C', true);
                    $this->Cell(7, 6, '2', 1, 0, 'C', true);
                    $this->Cell(7, 6, '3', 1, 0, 'C', true);
                    $this->Cell(7, 6, '4', 1, 0, 'C', true);
                    $this->Cell(7, 6, 'N/A', 1, 0, 'C', true);
                    */
                    $this->Cell(180, 6, Functions::utf8_decode('Conductas observables :'), 1, 0, 'L', true);
                    $this->Cell(10, 6, 'Nivel', 1, 0, 'C', true);
                    $this->Ln();
                    
                    // Body Table
                    $this->SetFillColor(225, 255, 255);
                    $this->SetTextColor(0);
                    $this->SetFont('Arial', '', 9);
                    $first = false;
                }
                

                $this->Cell(180, 6, Functions::utf8_decode($behaviors[$i]['description']), 1, 0, 'L', false);
                $this->Cell(10, 6, $behaviors[$i]['level'], 1, 0, 'C', false);
                /*
                $this->Cell(155, 6, Functions::utf8_decode($behaviors[$i]['description']), 1, 0, 'L', false);
                $this->Cell(7, 6, $behaviors[$i]['level'] == '1' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(7, 6, $behaviors[$i]['level'] == '2' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(7, 6, $behaviors[$i]['level'] == '3' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(7, 6, $behaviors[$i]['level'] == '4' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(7, 6, $behaviors[$i]['level'] == '0' ? 'X' : '', 1, 0, 'C', false);
                */
                $this->Ln();
                
                
                $y = $this->getY();
                if( ($y >= self::MAX_Y_ADD_PAGE) && ($max - 1 > $i)) {
                    $this->addPage();
                    $first  = true;
                }
            }
        }


        $this->Ln();
        
        if(!$last) {
        
            $y = $this->getY();
            if($y >= self::MAX_Y_ADD_PAGE) {
                $this->addPage();
            } else {
                
            }
        }
      
        
    }

}