Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16768 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16768 Rev 16817
Línea 9... Línea 9...
9
use Amenadiel\JpGraph\Plot\LinePlot;
9
use Amenadiel\JpGraph\Plot\LinePlot;
10
use Amenadiel\JpGraph\Plot\BarPlot;
10
use Amenadiel\JpGraph\Plot\BarPlot;
11
use Amenadiel\JpGraph\Themes\UniversalTheme;
11
use Amenadiel\JpGraph\Themes\UniversalTheme;
12
use Amenadiel\JpGraph\Themes\PastelTheme;
12
use Amenadiel\JpGraph\Themes\PastelTheme;
13
use Amenadiel\JpGraph\Themes\SoftyTheme;
13
use Amenadiel\JpGraph\Themes\SoftyTheme;
-
 
14
use Laminas\Mvc\I18n\Translator;
Línea 14... Línea 15...
14
 
15
 
Línea -... Línea 16...
-
 
16
 
15
 
17
class SurveyReport extends FPDF {
-
 
18
 
-
 
19
    /**
16
class SurveyReport extends FPDF {
20
     *
-
 
21
     * @var string
-
 
22
     */
-
 
23
    public $header;
-
 
24
    
-
 
25
    /**
17
 
26
     *
Línea -... Línea 27...
-
 
27
     * @var string
-
 
28
     */
-
 
29
    public $footer;
-
 
30
    
-
 
31
    /**
-
 
32
     *
-
 
33
     * @var string
-
 
34
     */
-
 
35
    public $campaignName;
-
 
36
    
-
 
37
    
-
 
38
    /**
-
 
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
     */
Línea 18... Línea 60...
18
    
60
    public $translator;
19
    public $header;
61
 
20
    public $footer;
62
    
21
    
63
    
Línea -... Línea 64...
-
 
64
    
-
 
65
    /**
-
 
66
     * Header PDF
-
 
67
     */
22
    
68
    function Header() {
23
    /**
69
        
24
     * Header PDF
70
        if(empty($this->printDate)) {
25
     */
71
            $this->printDate = date('d/m/Y H:i a');
26
    function Header() {
72
        }
27
        
73
        
28
        if ($this->header != '') {
-
 
29
            $this->Image($this->header, 10, 8, 190);
-
 
30
            $this->SetY(55);
-
 
31
        }
74
        if ($this->header != '') {
32
    }
-
 
33
    /**
75
            $this->Image($this->header, 10, 8, 190);
34
     * Header custom PDF
76
            $this->SetY(55);
35
     * @param string $headerFormName
77
        }
36
     * @param string $headerUsername
78
        
37
     */
-
 
38
    function customHeader($headerFormName, $headerUsername) {
-
 
39
        $s = Functions::utf8_decode(' Página: ' . $this->PageNo());
-
 
40
        $this->SetFont('Arial', '', 10);
-
 
41
        $this->SetY(40);
-
 
42
        $this->Cell(190, 10, $s, 0, 0, 'R');
-
 
43
 
-
 
44
        $this->SetFont('Arial', 'B', 15);
-
 
Línea -... Línea 79...
-
 
79
        
-
 
80
        
-
 
81
        $s = Functions::utf8_decode($this->printDate . '  ' . $this->translator->translate('LABEL_PAGE') . ' : ' . $this->PageNo());
-
 
82
        $this->SetFont('Arial', '', 10);
-
 
83
        $this->SetY(12);
-
 
84
        $this->Cell(190, 10, $s, 0, 0, 'R');
-
 
85
        
-
 
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');
45
        $this->SetY(50);
125
        $this->setY($this->getY() + 6);
46
        $this->Cell(180, 10, $headerFormName, 0, 0, 'C');
126
        
47
        $this->setY($this->getY() + 8);
127
        $s = Functions::utf8_decode($text);
-
 
128
        $lines = explode('|-|', wordwrap( $s, 115, '|-|', true) );
48
 
129
        foreach($lines as $line)
49
 
130
        {
-
 
131
            $this->setX(10);
50
        if($headerUsername) {
132
            $this->SetFont('Arial', '', 10);
51
        
133
            $this->Cell(155, 8, $line, 0, 0, 'L');
52
            $this->SetFont('Arial', '', 10);
134
            $this->setY($this->getY() + 6);
53
            $this->Cell(180, 10, $headerUsername, 0, 0, 'C');
135
            
54
            $this->setY($this->getY() + 10);
136
        }
Línea 125... Línea 207...
125
 
207
 
126
        $graph->Stroke($filename);
208
        $graph->Stroke($filename);
Línea 127... Línea 209...
127
    }
209
    }
128
 
-
 
129
     /**
-
 
130
     * Create Table
-
 
131
     * @param string $title
-
 
132
     * @param array $content
210
 
Línea 133... Línea 211...
133
     */
211
     /**
134
    function borderTable($title, $content) {
212
    function borderTable($title, $content) {
135
 
213
 
136
        // Header Table
214
        // Header Table
137
        $this->SetFillColor(204, 204, 204);
215
        $this->SetFillColor(204, 204, 204);
Línea 138... Línea 216...
138
        $this->SetDrawColor(0, 0, 0);
216
        $this->SetDrawColor(0, 0, 0);
139
        $this->SetLineWidth(0);
217
        $this->SetLineWidth(0);
Línea 140... Línea 218...
140
        $this->SetFont('Arial', 'B', 9);
218
        $this->SetFont('Arial', 'B', 9);
141
 
219
 
142
        $this->Cell(190, 6, $this-> cleanStringToPdf($title), 1, 0, 'L', true);
220
        $this->Cell(190, 6, Functions::utf8_decode($title), 1, 0, 'L', true);
Línea 143... Línea 221...
143
        $this->Ln();
221
        $this->Ln();
144
 
222
 
Línea 145... Línea 223...
145
        // Body Table
223
        // Body Table
146
        $this->SetFillColor(225, 255, 255);
224
        $this->SetFillColor(225, 255, 255);
147
        $this->SetTextColor(0);
225
        $this->SetTextColor(0);
148
 
226
 
149
        foreach ($content as $rs) {
227
        foreach ($content as $rs) {
Línea 150... Línea 228...
150
            if (isset($rs['title'])) {
228
            if (isset($rs['title'])) {
151
 
229
 
152
                $this->SetFont('Arial', 'B', 9);
230
                $this->SetFont('Arial', 'B', 9);
153
                $this->Cell(50, 10, $this-> cleanStringToPdf($rs['title']), 1, 0, 'L', false);
231
                $this->Cell(50, 10, Functions::utf8_decode($rs['title']), 1, 0, 'L', false);
154
                $this->MultiCell(140, 10, $this-> cleanStringToPdf($rs['content']), 1, 'L', false);
232
                $this->MultiCell(140, 10, Functions::utf8_decode($rs['content']), 1, 'L', false);
155
                $this->Ln();
233
                $this->Ln();
156
            } else {
-
 
Línea 157... Línea -...
157
 
-
 
158
                $this->SetFont('Arial', '', 9);
-
 
159
                $this->MultiCell(190, 6, $this-> cleanStringToPdf($rs['content']), 1, 'L', false);
234
            } else {
160
            }
-
 
161
        }
-
 
162
        $this->Ln(5);
-
 
163
    }
-
 
164
    
-
 
165
    
-
 
166
    private function cleanStringToPdf($s)
-
 
167
    {
-
 
168
        
-
 
169
        $s = html_entity_decode($s);
-
 
170
        $detect = mb_detect_encoding($s);
-
 
171
        
-
 
172
        if(strtoupper($detect) != 'UTF8') {
235