Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16768 | | 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;
15152 efrain 6
use Amenadiel\JpGraph\Graph\PieGraph;
7
use Amenadiel\JpGraph\Plot\PiePlot;
8
use Amenadiel\JpGraph\Graph\Graph;
9
use Amenadiel\JpGraph\Plot\LinePlot;
10
use Amenadiel\JpGraph\Plot\BarPlot;
11
use Amenadiel\JpGraph\Themes\UniversalTheme;
12
use Amenadiel\JpGraph\Themes\PastelTheme;
13
use Amenadiel\JpGraph\Themes\SoftyTheme;
16817 efrain 14
use Laminas\Mvc\I18n\Translator;
5866 eleazar 15
 
15152 efrain 16
 
5866 eleazar 17
class SurveyReport extends FPDF {
18
 
16817 efrain 19
    /**
20
     *
21
     * @var string
22
     */
23
    public $header;
15152 efrain 24
 
16817 efrain 25
    /**
26
     *
27
     * @var string
28
     */
15152 efrain 29
    public $footer;
30
 
16817 efrain 31
    /**
32
     *
33
     * @var string
34
     */
35
    public $campaignName;
15152 efrain 36
 
16817 efrain 37
 
5866 eleazar 38
    /**
16817 efrain 39
     *
40
     * @var string
41
     */
42
    public $printDate;
43
 
44
    /**
45
     *
46
     * @var string
47
     */
48
    public $formName;
49
 
50
    /**
51
     *
52
     * @var string
53
     */
54
    public $formText;
55
 
56
    /**
57
     *
58
     * @var Translator
59
     */
60
    public $translator;
61
 
62
 
63
 
64
 
65
    /**
5866 eleazar 66
     * Header PDF
67
     */
68
    function Header() {
15152 efrain 69
 
16817 efrain 70
        if(empty($this->printDate)) {
71
            $this->printDate = date('d/m/Y H:i a');
72
        }
73
 
15152 efrain 74
        if ($this->header != '') {
75
            $this->Image($this->header, 10, 8, 190);
76
            $this->SetY(55);
77
        }
16817 efrain 78
 
79
 
80
 
81
        $s = Functions::utf8_decode($this->printDate . '  ' . $this->translator->translate('LABEL_PAGE') . ' : ' . $this->PageNo());
5866 eleazar 82
        $this->SetFont('Arial', '', 10);
16817 efrain 83
        $this->SetY(12);
5866 eleazar 84
        $this->Cell(190, 10, $s, 0, 0, 'R');
15154 efrain 85
 
16817 efrain 86
 
87
        $this->SetFont('Arial', 'B', 10);
88
        $this->SetY(20);
89
        $this->SetX(45);
90
        $this->SetFont('Arial', 'B', 10);
91
        $this->Cell(180, 8, Functions::utf8_decode($this->campaignName), 0, 0, 'L');
92
        $this->setY($this->getY() + 6);
93
 
94
        $this->SetFont('Arial', 'B', 10);
95
        //$this->SetY(20);
96
        $this->SetX(45);
97
        $this->Cell(155, 8, $this->formName, 0, 0, 'L');
98
        $this->setY($this->getY() + 6);
99
 
100
        $this->SetFont('Arial', '', 10);
101
        // $this->SetY(30);
102
        $this->SetX(45);
103
 
104
        $lines = explode('|-|', wordwrap(Functions::utf8_decode($this->formText), 95, '|-|', true) );
105
        foreach($lines as $line)
106
        {
107
            $this->SetX(45);
108
            $this->Cell(155, 8, $line, 0, 0, 'L');
109
            $this->setY($this->getY() + 6);
110
        }
111
 
112
 
113
        if($this->GetY() < 50) {
114
            $this->SetY(50);
115
        }
116
    }
117
 
118
 
119
 
120
    function addSection($name, $text)
121
    {
122
        $this->SetFont('Arial', 'B', 10);
123
        $this->setX(10);
124
        $this->Cell(190, 8, Functions::utf8_decode($name), 0, 0, 'C');
125
        $this->setY($this->getY() + 6);
126
 
127
        $s = Functions::utf8_decode($text);
128
        $lines = explode('|-|', wordwrap( $s, 115, '|-|', true) );
129
        foreach($lines as $line)
130
        {
131
            $this->setX(10);
15154 efrain 132
            $this->SetFont('Arial', '', 10);
16817 efrain 133
            $this->Cell(155, 8, $line, 0, 0, 'L');
134
            $this->setY($this->getY() + 6);
135
 
15154 efrain 136
        }
5866 eleazar 137
    }
16817 efrain 138
 
5866 eleazar 139
    /**
140
     * Footer PDF
141
     */
142
    function Footer() {
15152 efrain 143
        if ($this->footer != '') {
144
            $this->SetY(-40);
145
            $this->Image($this->footer, 10, $this->getY(), 190);
146
        }
5866 eleazar 147
    }
148
    /**
149
     * Create chart PDF
150
     * @param string[] $labels
151
     * @param float[] $values
152
     * @param string $title
153
     * @param string $filename
154
     */
6039 eleazar 155
    function pieChart($labels, $values, $title, $filename) {
6916 eleazar 156
 
5866 eleazar 157
        // Setup the graph.
15152 efrain 158
        $graph = new PieGraph(600, 240);
159
        $graph->SetTheme(new SoftyTheme());
160
        //$graph->clearTheme();
161
        //$graph->SetShadow();
5866 eleazar 162
 
15152 efrain 163
 
5866 eleazar 164
        // Create the bar pot
15152 efrain 165
        $bplot = new PiePlot($values);
166
        $bplot->SetLegends($labels);
167
        $bplot->SetCenter(0.2);
5866 eleazar 168
 
169
        // Setup color for gradient fill style
170
        // Set color for the frame of each bar
171
        $bplot->SetColor("white");
6128 eleazar 172
        $bplot->SetLabelType(PIE_VALUE_PER);
15152 efrain 173
 
5866 eleazar 174
        $graph->Add($bplot);
15152 efrain 175
 
5866 eleazar 176
 
177
 
6098 eleazar 178
        $graph->Stroke($filename);
5866 eleazar 179
    }
15152 efrain 180
 
6143 eleazar 181
 
15152 efrain 182
 
183
    function barChart($labels, $values, $title, $filename)
6143 eleazar 184
    {
15152 efrain 185
        $graph = new Graph(700, count($values) * 100, 'auto');
6148 eleazar 186
        $graph->SetScale('textint');
6143 eleazar 187
        $graph->clearTheme();
188
        $graph->SetShadow();
6179 eleazar 189
        $graph->Set90AndMargin(130, 30, 60, 30);
15152 efrain 190
 
191
        $graph->yscale->ticks->SupressZeroLabel(false);
192
 
193
        // Setup X-axis labels
194
        $graph->xaxis->SetTickLabels($labels);
195
        $graph->xaxis->SetLabelAngle(40);
196
 
6144 eleazar 197
 
15152 efrain 198
        $bplot = new BarPlot($values);
7048 eleazar 199
        $bplot->SetFillColor('orange');
15152 efrain 200
 
7048 eleazar 201
        $bplot->SetShadow();
15152 efrain 202
        $bplot->SetCenter(0.2);
203
        $bplot->SetWidth(0.6);
6144 eleazar 204
 
205
        $bplot->value->Show();
206
        $graph->Add($bplot);
207
 
208
        $graph->Stroke($filename);
6143 eleazar 209
    }
6908 eleazar 210
 
6935 eleazar 211
     /**
212
    function borderTable($title, $content) {
213
 
214
        // Header Table
215
        $this->SetFillColor(204, 204, 204);
216
        $this->SetDrawColor(0, 0, 0);
217
        $this->SetLineWidth(0);
218
        $this->SetFont('Arial', 'B', 9);
219
 
16817 efrain 220
        $this->Cell(190, 6, Functions::utf8_decode($title), 1, 0, 'L', true);
6935 eleazar 221
        $this->Ln();
222
 
223
        // Body Table
224
        $this->SetFillColor(225, 255, 255);
225
        $this->SetTextColor(0);
226
 
227
        foreach ($content as $rs) {
228
            if (isset($rs['title'])) {
229
 
230
                $this->SetFont('Arial', 'B', 9);
16817 efrain 231
                $this->Cell(50, 10, Functions::utf8_decode($rs['title']), 1, 0, 'L', false);
232
                $this->MultiCell(140, 10, Functions::utf8_decode($rs['content']), 1, 'L', false);
6935 eleazar 233
                $this->Ln();
234
            } else {
235
 
236
                $this->SetFont('Arial', '', 9);
16817 efrain 237
                $this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 1, 'L', false);
6935 eleazar 238
            }
239
        }
240
        $this->Ln(5);
16817 efrain 241
    }*/
15152 efrain 242
 
16817 efrain 243
 
5866 eleazar 244
}