Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15152 | 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;

class JobPdf extends FPDF {

    public $header;
    public $footer;
    
    
    /**
     * 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);
            }
        }
        $this->Ln(5);
    }

    /**
     * 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);
            }
        }
        $this->Ln(5);
    }

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


        // 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);

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

        if (count($behaviors)>0) {

            $this->Cell(150, 6, Functions::utf8_decode('Conductas observables :'), 1, 0, 'L', true);
            $this->Cell(8, 6, '1', 1, 0, 'C', true);
            $this->Cell(8, 6, '2', 1, 0, 'C', true);
            $this->Cell(8, 6, '3', 1, 0, 'C', true);
            $this->Cell(8, 6, '4', 1, 0, 'C', true);
            $this->Cell(8, 6, 'N/A', 1, 0, 'C', true);
            $this->Ln();

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

            for ($i = 0; $i < count($behaviors); $i++) {

                $this->Cell(150, 6, Functions::utf8_decode($behaviors[$i]['description']), 1, 0, 'L', false);
                $this->Cell(8, 6, $behaviors[$i]['level'] == '1' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(8, 6, $behaviors[$i]['level'] == '2' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(8, 6, $behaviors[$i]['level'] == '3' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(8, 6, $behaviors[$i]['level'] == '4' ? 'X' : '', 1, 0, 'C', false);
                $this->Cell(8, 6, $behaviors[$i]['level'] == '0' ? 'X' : '', 1, 0, 'C', false);

                $this->Ln();
            }
        }


        $this->Ln();
    }

}