Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
1336 efrain 1
<?php
2
 
3
namespace LeadersLinked\Library;
4
 
5
use Fpdf\Fpdf;
6
use Amenadiel\JpGraph\Graph;
7
use Amenadiel\JpGraph\Plot;
8
 
9
class SelfEvaluationPdf extends FPDF {
15079 efrain 10
 
11
    public $header;
12
    public $footer;
13
 
1336 efrain 14
 
15
    /**
16
     * Header PDF
17
     */
18
    function Header() {
15079 efrain 19
 
20
        if ($this->header != '') {
21
            $this->Image($this->header, 10, 1, 190);
22
            $this->SetY(55);
23
        }
1336 efrain 24
    }
25
    /**
26
     * Header custom PDF
27
     * @param string $headerFormName
28
     * @param string $headerUsername
29
     */
30
    function customHeader($headerFormName, $headerUsername) {
31
        $s = utf8_decode(' Página: ' . $this->PageNo());
32
        $this->SetFont('Arial', '', 10);
33
        $this->SetY(40);
34
        $this->Cell(190, 10, $s, 0, 0, 'R');
35
 
36
        $this->SetFont('Arial', 'B', 15);
37
        $this->SetY(50);
38
        $this->Cell(180, 10, $headerFormName, 0, 0, 'C');
39
        $this->setY($this->getY() + 8);
40
 
41
 
42
        $this->SetFont('Arial', '', 10);
43
        $this->Cell(180, 10, $headerUsername, 0, 0, 'C');
44
        $this->setY($this->getY() + 10);
45
    }
46
    /**
47
     * Footer PDF
48
     */
49
    function Footer() {
15079 efrain 50
        if ($this->footer != '') {
51
            $this->SetY(-40);
52
            $this->Image($this->footer, 10,$this->getY() , 190);
53
        }
1336 efrain 54
    }
55
    /**
56
     * Create chart PDF
57
     * @param string[] $labels
58
     * @param float[] $values
59
     * @param string $title
60
     * @param string $filename
61
     */
62
    function pieChart($labels, $values, $title, $filename) {
63
        // We need some data
64
        $datay = $values;
65
        $datax = $labels;
66
 
67
        // Setup the graph.
68
        $graph = new Graph\PieGraph(400, 240);
69
        $graph->clearTheme();
70
        $graph->img->SetMargin(60, 20, 35, 75);
71
        $graph->SetScale("textlin");
72
        $graph->SetShadow();
73
 
74
        // Set up the title for the graph
75
        $graph->title->Set($title);
76
        $graph->title->SetMargin(8);
77
        $graph->title->SetColor("darkred");
78
 
79
        // Show 0 label on Y-axis (default is not to show)
80
        $graph->yscale->ticks->SupressZeroLabel(false);
81
 
82
        // Setup X-axis labels
83
        $graph->xaxis->SetTickLabels($datax);
84
        $graph->xaxis->SetLabelAngle(50);
85
 
86
        // Create the bar pot
87
        $bplot = new Plot\PiePlot($datay);
88
 
89
        // Setup color for gradient fill style
90
        // Set color for the frame of each bar
91
        $bplot->SetColor("white");
92
        $graph->Add($bplot);
93
 
94
 
95
        $graph->Stroke($filename);
96
    }
97
 
98
}