Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7048 | Rev 7050 | 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() {
6847 eleazar 15
        $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/header_background.png', 10, 8, 190);
16
        $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/header_logo.png', 130, 20, 60);
5866 eleazar 17
    }
18
    /**
19
     * Header custom PDF
20
     * @param string $headerFormName
21
     * @param string $headerUsername
22
     */
23
    function customHeader($headerFormName, $headerUsername) {
24
        $s = utf8_decode(' Página: ' . $this->PageNo());
25
        $this->SetFont('Arial', '', 10);
26
        $this->SetY(40);
27
        $this->Cell(190, 10, $s, 0, 0, 'R');
28
 
29
        $this->SetFont('Arial', 'B', 15);
30
        $this->SetY(50);
31
        $this->Cell(180, 10, $headerFormName, 0, 0, 'C');
32
        $this->setY($this->getY() + 8);
33
 
34
 
35
        $this->SetFont('Arial', '', 10);
36
        $this->Cell(180, 10, $headerUsername, 0, 0, 'C');
37
        $this->setY($this->getY() + 10);
38
    }
39
    /**
40
     * Footer PDF
41
     */
42
    function Footer() {
43
        $this->SetY(-30);
44
        $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/footer_background.jpg', 10, $this->getY(), 190);
45
    }
46
    /**
47
     * Create chart PDF
48
     * @param string[] $labels
49
     * @param float[] $values
50
     * @param string $title
51
     * @param string $filename
52
     */
6039 eleazar 53
    function pieChart($labels, $values, $title, $filename) {
6916 eleazar 54
 
55
        $this->SetLegends($values, '');
56
 
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);
7001 eleazar 68
        $bplot->SetLegends($datax);
7005 eleazar 69
        $bplot->SetCenter(0.3);
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);
7048 eleazar 92
        $bplot->SetFillColor('orange');
93
        $bplot->SetWidth(0.5);
94
        $bplot->SetShadow();
7049 eleazar 95
        $bplot->SetLegend($values);
7021 eleazar 96
        $bplot->SetCenter(0.3);
6144 eleazar 97
 
98
        $bplot->value->Show();
99
        $graph->Add($bplot);
100
 
101
        $graph->Stroke($filename);
6143 eleazar 102
    }
6908 eleazar 103
 
6935 eleazar 104
     /**
105
     * Create Table
106
     * @param string $title
107
     * @param array $content
108
     */
109
    function borderTable($title, $content) {
110
 
111
        // Header Table
112
        $this->SetFillColor(204, 204, 204);
113
        $this->SetDrawColor(0, 0, 0);
114
        $this->SetLineWidth(0);
115
        $this->SetFont('Arial', 'B', 9);
116
 
117
        $this->Cell(190, 6, utf8_decode($title), 1, 0, 'L', true);
118
        $this->Ln();
119
 
120
        // Body Table
121
        $this->SetFillColor(225, 255, 255);
122
        $this->SetTextColor(0);
123
 
124
        foreach ($content as $rs) {
125
            if (isset($rs['title'])) {
126
 
127
                $this->SetFont('Arial', 'B', 9);
128
                $this->Cell(50, 10, utf8_decode($rs['title']), 1, 0, 'L', false);
129
                $this->MultiCell(140, 10, utf8_decode($rs['content']), 1, 'L', false);
130
                $this->Ln();
131
            } else {
132
 
133
                $this->SetFont('Arial', '', 9);
134
                $this->MultiCell(190, 6, utf8_decode($rs['content']), 1, 'L', false);
135
            }
136
        }
137
        $this->Ln(5);
138
    }
5866 eleazar 139
}