Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
5866 eleazar 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 SurveyReport extends FPDF {
10
 
11
    /**
12
     * Header PDF
13
     */
14
    function Header() {
6845 eleazar 15
 
16
        if ($this->header != '') {
17
            $this->Image($this->header, 10, 8, 190);
18
            $this->SetY(55);
19
        }
5866 eleazar 20
    }
21
    /**
22
     * Header custom PDF
23
     * @param string $headerFormName
24
     * @param string $headerUsername
25
     */
26
    function customHeader($headerFormName, $headerUsername) {
27
        $s = utf8_decode(' Página: ' . $this->PageNo());
28
        $this->SetFont('Arial', '', 10);
29
        $this->SetY(40);
30
        $this->Cell(190, 10, $s, 0, 0, 'R');
31
 
32
        $this->SetFont('Arial', 'B', 15);
33
        $this->SetY(50);
34
        $this->Cell(180, 10, $headerFormName, 0, 0, 'C');
35
        $this->setY($this->getY() + 8);
36
 
37
 
38
        $this->SetFont('Arial', '', 10);
39
        $this->Cell(180, 10, $headerUsername, 0, 0, 'C');
40
        $this->setY($this->getY() + 10);
41
    }
42
    /**
43
     * Footer PDF
44
     */
45
    function Footer() {
46
        $this->SetY(-30);
47
        $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/footer_background.jpg', 10, $this->getY(), 190);
48
    }
49
    /**
50
     * Create chart PDF
51
     * @param string[] $labels
52
     * @param float[] $values
53
     * @param string $title
54
     * @param string $filename
55
     */
6039 eleazar 56
    function pieChart($labels, $values, $title, $filename) {
5866 eleazar 57
        // We need some data
58
        $datay = $values;
59
        $datax = $labels;
60
 
61
        // Setup the graph.
6106 eleazar 62
        $graph = new Graph\PieGraph(400, 240);
5866 eleazar 63
        $graph->clearTheme();
64
        $graph->SetShadow();
65
 
66
        // Create the bar pot
67
        $bplot = new Plot\PiePlot($datay);
6128 eleazar 68
        $bplot->SetLabels($datax);
69
        $bplot->SetLabelPos(1);
5866 eleazar 70
 
71
        // Setup color for gradient fill style
72
        // Set color for the frame of each bar
73
        $bplot->SetColor("white");
6128 eleazar 74
        $bplot->SetLabelType(PIE_VALUE_PER);
5866 eleazar 75
        $graph->Add($bplot);
76
 
77
 
6098 eleazar 78
        $graph->Stroke($filename);
5866 eleazar 79
    }
6143 eleazar 80
 
81
    function barChart($label, $values, $title, $filename)
82
    {
6168 eleazar 83
        $graph = new Graph\Graph(700, count($values) * 50, 'auto');
6148 eleazar 84
        $graph->SetScale('textint');
6143 eleazar 85
        $graph->clearTheme();
86
        $graph->SetShadow();
6179 eleazar 87
        $graph->Set90AndMargin(130, 30, 60, 30);
6147 eleazar 88
 
6143 eleazar 89
        $graph->xaxis->SetTickLabels($label);
6144 eleazar 90
 
91
        $bplot = new Plot\BarPlot($values);
92
        $bplot->SetFillColor('orange');
93
        $bplot->SetWidth(0.5);
94
        $bplot->SetShadow();
95
 
96
        $bplot->value->Show();
97
        $graph->Add($bplot);
98
 
99
        $graph->Stroke($filename);
6143 eleazar 100
    }
5866 eleazar 101
}