Proyectos de Subversion LeadersLinked - Backend

Rev

Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

namespace LeadersLinked\Library;

use Fpdf\Fpdf;
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;

class SelfEvaluationPdf extends FPDF {

    /**
     * Header PDF
     */
    function Header() {
        $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/header_background.png', 10, 8, 190);
        $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/header_logo.png', 130, 20, 60);
    }
    /**
     * Header custom PDF
     * @param string $headerFormName
     * @param string $headerUsername
     */
    function customHeader($headerFormName, $headerUsername) {
        $s = utf8_decode(' Página: ' . $this->PageNo());
        $this->SetFont('Arial', '', 10);
        $this->SetY(40);
        $this->Cell(190, 10, $s, 0, 0, 'R');

        $this->SetFont('Arial', 'B', 15);
        $this->SetY(50);
        $this->Cell(180, 10, $headerFormName, 0, 0, 'C');
        $this->setY($this->getY() + 8);


        $this->SetFont('Arial', '', 10);
        $this->Cell(180, 10, $headerUsername, 0, 0, 'C');
        $this->setY($this->getY() + 10);
    }
    /**
     * Footer PDF
     */
    function Footer() {
        $this->SetY(-30);
        $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/footer_background.jpg', 10, $this->getY(), 190);
    }
    /**
     * Create chart PDF
     * @param string[] $labels
     * @param float[] $values
     * @param string $title
     * @param string $filename
     */
    function pieChart($labels, $values, $title, $filename) {
        // We need some data
        $datay = $values;
        $datax = $labels;

        // Setup the graph.
        $graph = new Graph\PieGraph(400, 240);
        $graph->clearTheme();
        $graph->img->SetMargin(60, 20, 35, 75);
        $graph->SetScale("textlin");
        $graph->SetShadow();

        // Set up the title for the graph
        $graph->title->Set($title);
        $graph->title->SetMargin(8);
        $graph->title->SetColor("darkred");

        // Show 0 label on Y-axis (default is not to show)
        $graph->yscale->ticks->SupressZeroLabel(false);

        // Setup X-axis labels
        $graph->xaxis->SetTickLabels($datax);
        $graph->xaxis->SetLabelAngle(50);

        // Create the bar pot
        $bplot = new Plot\PiePlot($datay);

        // Setup color for gradient fill style
        // Set color for the frame of each bar
        $bplot->SetColor("white");
        $graph->Add($bplot);


        $graph->Stroke($filename);
    }

}