Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16768 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6898 eleazar 1
<?php
2
 
3
namespace LeadersLinked\Library;
4
 
5
use Fpdf\Fpdf;
16817 efrain 6
use Laminas\Mvc\I18n\Translator;
6898 eleazar 7
 
16817 efrain 8
class UniqueSurveyReport extends FPDF
9
{
10
    /**
11
     *
12
     * @var string
13
     */
14
    public $header;
15152 efrain 15
 
16817 efrain 16
    /**
17
     *
18
     * @var string
19
     */
15152 efrain 20
    public $footer;
16817 efrain 21
 
6898 eleazar 22
    /**
16817 efrain 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
     */
50
    public $translator;
51
 
52
 
53
    /**
6898 eleazar 54
     * Header PDF
55
     */
16817 efrain 56
    function Header()
57
    {
15152 efrain 58
        if ($this->header != '') {
59
            $this->Image($this->header, 10, 8, 190);
60
            $this->SetY(55);
61
        }
16817 efrain 62
 
63
        $s  = $this->translator->translate('LABEL_DATE') .  ' : ' . $this->formDate . ' '. $this->translator->translate('LABEL_PAGE') . ' : ' . $this->PageNo();
64
 
65
        $s = Functions::utf8_decode( $s );
7040 eleazar 66
        $this->SetFont('Arial', '', 10);
16817 efrain 67
        $this->SetY(12);
7040 eleazar 68
        $this->Cell(190, 10, $s, 0, 0, 'R');
15154 efrain 69
 
16817 efrain 70
 
71
        $this->SetFont('Arial', 'B', 10);
72
        $this->SetY(20);
73
        $this->SetX(45);
74
        if($this->userName) {
15154 efrain 75
 
16817 efrain 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);
15154 efrain 79
        }
16817 efrain 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);
90
 
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');
96
            $this->SetY($this->getY() + 6);
97
        }
98
 
99
        if($this->GetY() < 50) {
100
            $this->SetY(50);
101
        }
7040 eleazar 102
 
103
 
104
    }
105
 
16817 efrain 106
 
107
 
6898 eleazar 108
    /**
109
     * Footer PDF
110
     */
111
    function Footer() {
15152 efrain 112
        if ($this->footer != '') {
113
            $this->SetY(-40);
114
            $this->Image($this->footer, 10, $this->getY(), 190);
115
        }
6898 eleazar 116
    }
16817 efrain 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
 
126
        $s = Functions::utf8_decode($text);
127
        $lines = explode('|-|', wordwrap( $s, 115, '|-|', true) );
128
        foreach($lines as $line)
129
        {
130
            $this->setX(10);
131
            $this->SetFont('Arial', '', 10);
132
            $this->Cell(155, 8, $line, 0, 0, 'L');
133
            $this->setY($this->getY() + 6);
6898 eleazar 134
 
16817 efrain 135
        }
6898 eleazar 136
    }
16817 efrain 137
 
138
    function questionAndAnswer($text, $value)
139
    {
140
        if($this->GetY() > 250) {
141
            $this->AddPage();
142
        }
143
 
144
        $s = Functions::utf8_decode($text);
6898 eleazar 145
 
16817 efrain 146
        $lines = explode('|-|', wordwrap( $s, 105, '|-|', true) );
147
        $first = true;
148
        foreach($lines as $line)
149
        {
150
 
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) {
158
                    $this->AddPage();
159
                }
160
 
6898 eleazar 161
            }
16817 efrain 162
 
163
            $this->setX(32);
164
            $this->SetFont('Arial', '', 10);
165
            $this->Cell(168, 8, $line, 0, 0, 'L');
166
            $this->setY($this->getY() + 6);
167
 
6898 eleazar 168
        }
16817 efrain 169
 
170
 
171
        $lines = explode('|-|', wordwrap( strval($value), 105, '|-|', true) );
172
        $first = true;
173
        foreach($lines as $line)
174
        {
175
 
176
            if($first) {
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
            }
184
 
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
 
194
        }
195
 
6898 eleazar 196
    }
16817 efrain 197
 
198
    function questionAndAnswers($text, $values)
199
    {
200
        if($this->GetY() > 250) {
201
            $this->AddPage();
202
        }
203
 
204
        $s = Functions::utf8_decode($text);
6898 eleazar 205
 
16817 efrain 206
        $lines = explode('|-|', wordwrap( $s, 105, '|-|', true) );
207
        $first = true;
208
        foreach($lines as $line)
209
        {
210
 
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
 
6898 eleazar 228
        }
16817 efrain 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');
243
                    $first = false;
244
 
6898 eleazar 245
                }
16817 efrain 246
 
247
                $this->setX(32);
248
                $this->SetFont('Arial', '', 10);
249
                $this->Cell(168, 8, $line, 0, 0, 'L');
250
                $this->setY($this->getY() + 6);
251
 
6898 eleazar 252
            }
253
        }
16817 efrain 254
 
6898 eleazar 255
    }
16817 efrain 256
 
6898 eleazar 257
 
7061 eleazar 258
 
6898 eleazar 259
}