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 1... Línea 1...
1
<?php
1
<?php
Línea 2... Línea 2...
2
 
2
 
Línea 3... Línea 3...
3
namespace LeadersLinked\Library;
3
namespace LeadersLinked\Library;
-
 
4
 
Línea 4... Línea 5...
4
 
5
use Fpdf\Fpdf;
5
use Fpdf\Fpdf;
6
use Laminas\Mvc\I18n\Translator;
-
 
7
 
-
 
8
class UniqueSurveyReport extends FPDF 
-
 
9
{
-
 
10
    /**
6
 
11
     *
-
 
12
     * @var string
-
 
13
     */
-
 
14
    public $header;
-
 
15
    
-
 
16
    /**
7
class UniqueSurveyReport extends FPDF {
17
     *
-
 
18
     * @var string
-
 
19
     */
-
 
20
    public $footer;
-
 
21
    
-
 
22
    /**
-
 
23
     *
-
 
24
     * @var string
-
 
25
     */
-
 
26
    public $formName;
-
 
27
    
-
 
28
    /**
-
 
29
     *
-
 
30
     * @var string
-
 
31
     */
-
 
32
    public $formText;
-
 
33
    
-
 
34
    /**
-
 
35
     * 
-
 
36
     * @var string
-
 
37
     */
-
 
38
    public $userName;
-
 
39
    
-
 
40
    /**
-
 
41
     *
-
 
42
     * @var string
-
 
43
     */
-
 
44
    public $formDate;
-
 
45
    
-
 
46
    /**
-
 
47
     * 
-
 
48
     * @var Translator
-
 
49
     */
8
    
50
    public $translator;
9
    public $header;
51
    
10
    public $footer;
52
    
11
    /**
53
    /**
-
 
54
     * Header PDF
12
     * Header PDF
55
     */
13
     */
56
    function Header() 
14
    function Header() {
57
    {
15
        if ($this->header != '') {
58
        if ($this->header != '') {
16
            $this->Image($this->header, 10, 8, 190);
59
            $this->Image($this->header, 10, 8, 190);
-
 
60
            $this->SetY(55);
17
            $this->SetY(55);
61
        }
18
        }
-
 
19
    }
62
        
20
 
63
        $s  = $this->translator->translate('LABEL_DATE') .  ' : ' . $this->formDate . ' '. $this->translator->translate('LABEL_PAGE') . ' : ' . $this->PageNo();
21
    function customHeader($headerFormName,$headerUserName) {
64
        
22
        $s = Functions::utf8_decode(' Página: ' . $this->PageNo());
65
        $s = Functions::utf8_decode( $s );
23
        $this->SetFont('Arial', '', 10);
-
 
24
        $this->SetY(40);
-
 
25
        $this->Cell(190, 10, $s, 0, 0, 'R');
-
 
26
 
-
 
27
        $this->SetFont('Arial', 'B', 15);
-
 
Línea -... Línea 66...
-
 
66
        $this->SetFont('Arial', '', 10);
-
 
67
        $this->SetY(12);
-
 
68
        $this->Cell(190, 10, $s, 0, 0, 'R');
-
 
69
        
28
        $this->SetY(50);
70
        
Línea 29... Línea 71...
29
        $this->Cell(180, 10, $headerFormName, 0, 0, 'C');
71
        $this->SetFont('Arial', 'B', 10);
-
 
72
        $this->SetY(20);
-
 
73
        $this->SetX(45);
-
 
74
        if($this->userName) {
-
 
75
            
-
 
76
            $this->SetFont('Arial', 'B', 10);
-
 
77
            $this->Cell(180, 8, Functions::utf8_decode($this->userName), 0, 0, 'L');
-
 
78
            $this->setY($this->getY() + 6);
-
 
79
        }
-
 
80
        
-
 
81
        $this->SetFont('Arial', 'B', 10);
-
 
82
        //$this->SetY(20);
-
 
83
        $this->SetX(45);
-
 
84
        $this->Cell(155, 8, $this->formName, 0, 0, 'L');
-
 
85
        $this->SetY($this->getY() + 6);
-
 
86
        
-
 
87
        $this->SetFont('Arial', '', 10);
-
 
88
       // $this->SetY(30);
-
 
89
        $this->SetX(45);
30
        $this->setY($this->getY() + 8);
90
        
31
        
91
        $lines = explode('|-|', wordwrap(Functions::utf8_decode($this->formText), 95, '|-|', true) );
-
 
92
        foreach($lines as $line) 
-
 
93
        {
-
 
94
            $this->SetX(45);
-
 
95
            $this->Cell(155, 8, $line, 0, 0, 'L');
32
        if($headerUserName) {
96
            $this->SetY($this->getY() + 6);
Línea 33... Línea -...
33
            
-
 
34
            $this->SetFont('Arial', '', 10);
-
 
35
            $this->Cell(180, 10, $headerUserName, 0, 0, 'C');
97
        }
Línea -... Línea 98...
-
 
98
        
-
 
99
        if($this->GetY() < 50) {
36
            $this->setY($this->getY() + 10);
100
            $this->SetY(50);
37
        }
101
        }
38
 
102
 
39
 
103
 
40
        $this->SetFont('Arial', '', 10);
104
    }
41
        $this->setY($this->getY() + 10);
105
 
42
    }
106
 
43
 
107
 
44
    /**
108
    /**
-
 
109
     * Footer PDF
-
 
110
     */
-
 
111
    function Footer() {
-
 
112
        if ($this->footer != '') {
-
 
113
            $this->SetY(-40);
-
 
114
            $this->Image($this->footer, 10, $this->getY(), 190);
-
 
115
        }
-
 
116
    }
-
 
117
   
-
 
118
    
-
 
119
    function addSection($name, $text)
-
 
120
    {
-
 
121
        $this->SetFont('Arial', 'B', 10);
-
 
122
        $this->setX(10);
-
 
123
        $this->Cell(190, 8, Functions::utf8_decode($name), 0, 0, 'C');
-
 
124
        $this->setY($this->getY() + 6);
-
 
125
        
Línea 45... Línea -...
45
     * Footer PDF
-
 
46
     */
-
 
47
    function Footer() {
-
 
48
        if ($this->footer != '') {
-
 
49
            $this->SetY(-40);
-
 
50
            $this->Image($this->footer, 10, $this->getY(), 190);
-
 
51
        }
-
 
52
    }
-
 
53
 
-
 
54
    /**
-
 
55
     * Section Scale
-
 
56
     */
-
 
57
    function sectionScale() {
-
 
58
        $this->SetFillColor(225, 255, 255);
-
 
59
        $this->SetTextColor(0);
-
 
60
        $this->SetFont('Arial', 'B', 9);
-
 
61
 
-
 
62
 
-
 
63
        $this->Cell(35, 8, utf8_decode(' Escala/Niveles:'), 1, 0, 'L', false);
-
 
64
 
-
 
65
        $this->SetFillColor(225, 255, 255);
-
 
66
        $this->SetTextColor(0);
-
 
67
        $this->SetFont('Arial', '', 9);
-
 
68
 
-
 
69
        $this->Cell(155, 8, utf8_decode(' 1: Mínimo  2: Medio  3: Medio-Alto  4: Alto  N/A: No aplica 
-
 
70
'), 1, 'L', false);
-
 
71
        $this->Ln(15);
-
 
72
    }
-
 
73
 
-
 
74
    /**
-
 
75
     * Create Table
-
 
76
     * @param string $title
-
 
77
     * @param array $content
-
 
78
     */
-
 
79
    function borderTable($title, $content) {
-
 
80
 
-
 
81
        // Header Table
-
 
82
        $this->SetFillColor(204, 204, 204);
-
 
83
        $this->SetDrawColor(0, 0, 0);
-
 
84
        $this->SetLineWidth(0);
-
 
85
        $this->SetFont('Arial', 'B', 9);
-
 
86
 
-
 
87
        $this->Cell(190, 6, utf8_decode($title), 1, 0, 'L', true);
-
 
88
        $this->Ln();
-
 
89
 
-
 
90
        // Body Table
-
 
91
        $this->SetFillColor(225, 255, 255);
-
 
92
        $this->SetTextColor(0);
-
 
93
 
-
 
94
        foreach ($content as $rs) {
-
 
95
            if (isset($rs['title'])) {
-
 
96
 
-
 
97
                $this->SetFont('Arial', 'B', 9);
126
        $s = Functions::utf8_decode($text);
98
                $this->Cell(50, 10, utf8_decode($rs['title']), 1, 0, 'L', false);
-
 
99
                $this->MultiCell(140, 10, utf8_decode($rs['content']), 1, 'L', false);
127
        $lines = explode('|-|', wordwrap( $s, 115, '|-|', true) );
100
                $this->Ln();
128
        foreach($lines as $line)
101
            } else {
-
 
102
 
129
        {
103
                $this->SetFont('Arial', '', 9);
-
 
104
                $this->MultiCell(190, 6, utf8_decode($rs['content']), 1, 'L', false);
130
            $this->setX(10);
105
            }
-
 
106
        }
-
 
107
        $this->Ln(5);
131
            $this->SetFont('Arial', '', 10);
108
    }
-
 
109
 
-
 
110
    /**
-
 
111
     * title option table
-
 
112
     * @param string $title
-
 
113
     */
-
 
114
    function titleOptionTable($title) {
-
 
115
 
132
            $this->Cell(155, 8, $line, 0, 0, 'L');
116
        if ($title != '') {
133
            $this->setY($this->getY() + 6);
117
            // Body Table
-
 
118
            $this->SetFillColor(204, 204, 204);
134
 
-
 
135
        }
Línea 119... Línea -...
119
            $this->SetDrawColor(0, 0, 0);
-
 
120
            $this->SetLineWidth(0);
136
    }
121
            $this->SetFont('Arial', 'B', 9);
137
    
122
 
138
    function questionAndAnswer($text, $value)
123
            $this->Cell(190, 6, utf8_decode($title), 1, 0, 'L', true);
139
    {
124
            $this->Ln();
-
 
125
        }
140
        if($this->GetY() > 250) {
126
    }
141
            $this->AddPage();
127
 
-
 
128
 
-
 
129
    /**
-
 
130
     * Create Table
142
        }
131
     * @param string $title
-
 
132
     * @param array $content
-
 
133
     */
143
        
134
    function singleTable($title, $content) {
-
 
135
 
-
 
136
        // Header Table
144
        $s = Functions::utf8_decode($text);
137
        $this->SetFillColor(255, 255, 255);
145
 
138
        $this->SetDrawColor(0, 0, 0);
-
 
139
        $this->SetLineWidth(0);
146
        $lines = explode('|-|', wordwrap( $s, 105, '|-|', true) );
140
        $this->SetFont('Arial', 'B', 9);
-
 
141
 
147
        $first = true;
142
        $this->Cell(190, 6, utf8_decode($title), 0, 0, 'L', true);
-
 
143
        $this->Ln();
-
 
144
 
148
        foreach($lines as $line)
145
        // Body Table
-
 
146
        $this->SetFillColor(225, 255, 255);
-
 
147
        $this->SetTextColor(0);
-
 
148
        $this->SetFont('Arial', '', 9);
149
        {
-
 
150
            
149
 
151
            if($first) {
-
 
152
                $this->SetFont('Arial', 'B', 10);
-
 
153
                $this->setX(10);
-
 
154
                $this->Cell(40, 8, $this->translator->translate('LABEL_QUESTION') . ' : ', 0, 0, 'L');
-
 
155
                $first = false;
-
 
156
                
-
 
157
                if($this->GetY() > 250) {
150
        foreach ($content as $rs) {
158
                    $this->AddPage();
151
            if (isset($rs['title'])) {
-
 
152
                $this->Cell(40, 6, utf8_decode($rs['title']), 0, 0, 'L', false);
-
 
153
                $this->Cell(150, 6, utf8_decode($rs['content']), 0, 'L', false);
159
                }
154
                $this->Ln();
-
 
155
            } else {
-
 
156
                if ($rs['content'] != "") {
160
                    
157
                    $this->MultiCell(190, 6, utf8_decode($rs['content']), 0, 'L', false);
-
 
158
                }
161
            }
159
            }
-
 
160
        }
162
            
161
        $this->Ln(5);
163
            $this->setX(32);
162
    }
-
 
163
 
-
 
164
    function optionTable($questionText, $options) {
-
 
165
 
164
            $this->SetFont('Arial', '', 10);
166
 
165
            $this->Cell(168, 8, $line, 0, 0, 'L');
167
        // Header Table
166
            $this->setY($this->getY() + 6);
168
        $this->SetFillColor(255, 255, 255);
167
            
169
        $this->SetDrawColor(0, 0, 0);
168
        }
170
        $this->SetLineWidth(0);
169
        
171
        $this->SetFont('Arial', 'B', 9);
-
 
172
 
170
        
173
        $this->MultiCell(190, 5, utf8_decode($questionText), 0, 'L', false);
171
        $lines = explode('|-|', wordwrap( strval($value), 105, '|-|', true) );
174
 
-
 
175
        // Body Table
-
 
176
 
-
 
177
        $this->SetFillColor(204, 204, 204);
172
        $first = true;
178
        $this->SetDrawColor(0, 0, 0);
173
        foreach($lines as $line)
179
        $this->SetLineWidth(0);
-
 
180
        $this->SetFont('Arial', 'B', 9);
-
 
181
 
-
 
182
        if (count($options)>0) {
174
        {
183
 
175
            
184
            $this->Cell(182, 6, utf8_decode('Opcion :'), 1, 0, 'L', true);
-
 
185
            $this->Cell(8, 6, 'Sel.', 1, 0, 'C', true);
-
 
186
            $this->Ln();
-
 
187
 
-
 
188
            // Body Table
176
            if($first) {
189
            $this->SetFillColor(225, 255, 255);
177
                $this->SetFont('Arial', 'B', 10);
-
 
178
                $this->setX(10);
-
 
179
                $this->Cell(40, 8, $this->translator->translate('LABEL_ANSWER') . ' : ', 0, 0, 'L');
-
 
180
                $first = false;
-
 
181
                
-
 
182
                
-
 
183
            }
190
            $this->SetTextColor(0);
184
            
Línea -... Línea 185...
-
 
185
            if($this->GetY() > 250) {
-
 
186
                $this->AddPage();
-
 
187
            }
-
 
188
            
-
 
189
            $this->setX(32);
-
 
190
            $this->SetFont('Arial', '', 10);
-
 
191
            $this->Cell(168, 8, $line, 0, 0, 'L');
-
 
192
            $this->setY($this->getY() + 6);
-
 
193
            
Línea -... Línea 194...
-
 
194
        }
-
 
195
 
-
 
196
    }
-
 
197
    
-
 
198
    function questionAndAnswers($text, $values)
-
 
199
    {
-
 
200
        if($this->GetY() > 250) {
-
 
201
            $this->AddPage();
-
 
202
        }
-
 
203
        
-
 
204
        $s = Functions::utf8_decode($text);
-
 
205
 
-
 
206
        $lines = explode('|-|', wordwrap( $s, 105, '|-|', true) );
-
 
207
        $first = true;
-
 
208
        foreach($lines as $line)
-
 
209
        {
-
 
210
            
191
            $this->SetFont('Arial', '', 9);
211
            if($first) {
-
 
212
                $this->SetFont('Arial', 'B', 10);
-
 
213
                $this->setX(10);
-
 
214
                $this->Cell(40, 8, $this->translator->translate('LABEL_QUESTION') . ' : ', 0, 0, 'L');
-
 
215
                $first = false;
-
 
216
                
-
 
217
            }
-
 
218
            
-
 
219
            if($this->GetY() > 250) {
-
 
220
                $this->AddPage();
-
 
221
            }
-
 
222
            
-
 
223
            $this->setX(32);
-
 
224
            $this->SetFont('Arial', '', 10);
-
 
225
            $this->Cell(168, 8, $line, 0, 0, 'L');
-
 
226
            $this->setY($this->getY() + 6);
-
 
227
            
-
 
228
        }
-
 
229
        
-
 
230
        $first = true;
-
 
231
        foreach($values as $value)
-
 
232
        {
-
 
233
        
-
 
234
            $lines = explode('|-|', wordwrap( strval($value), 105, '|-|', true) );
-
 
235
        
-
 
236
            foreach($lines as $line)
-
 
237
            {
-
 
238
                
-
 
239
                if($first) {
-
 
240
                    $this->SetFont('Arial', 'B', 10);
-
 
241
                    $this->setX(10);
-
 
242
                    $this->Cell(40, 8, $this->translator->translate('LABEL_ANSWER') . ' : ', 0, 0, 'L');
192
 
243
                    $first = false;
-
 
244
                    
-
 
245
                }
Línea 193... Línea 246...
193
            for ($i = 0; $i < count($options); $i++) {
246