Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
1336 efrain 1
<?php
2
 
3
namespace LeadersLinked\Library;
4
 
5
use Fpdf\Fpdf;
15447 efrain 6
use Laminas\Mvc\I18n\Translator;
7
use LeadersLinked\Model\Competency;
1336 efrain 8
 
9
class PerformanceEvaluationPdf extends FPDF {
15447 efrain 10
 
11
    const MAX_Y_ADD_PAGE = 240;
1336 efrain 12
 
15447 efrain 13
    /**
14
     *
15
     * @var string
16
     */
15079 efrain 17
    public $header;
15447 efrain 18
 
19
    /**
20
     *
21
     * @var string
22
     */
15079 efrain 23
    public $footer;
24
 
1336 efrain 25
    /**
15447 efrain 26
     *
27
     * @var Translator
28
     */
29
    public $translator;
30
 
31
    /**
1336 efrain 32
     * Header PDF
33
     */
34
    function Header() {
15079 efrain 35
        if ($this->header != '') {
36
            $this->Image($this->header, 10, 1, 190);
37
            $this->SetY(55);
38
        }
1336 efrain 39
    }
40
 
41
    /**
42
     * Footer PDF
43
     */
44
    function Footer() {
15079 efrain 45
        if ($this->footer != '') {
46
            $this->SetY(-40);
47
            $this->Image($this->footer, 10,$this->getY() , 190);
48
        }
1336 efrain 49
    }
50
 
51
    /**
52
     * Section Scale
53
     */
54
    function sectionScale() {
55
        $this->SetFillColor(225, 255, 255);
56
        $this->SetTextColor(0);
57
        $this->SetFont('Arial', 'B', 9);
58
 
59
 
16768 efrain 60
        $this->Cell(35, 8, Functions::utf8_decode(' Escala/Niveles:'), 1, 0, 'L', false);
1336 efrain 61
 
62
        $this->SetFillColor(225, 255, 255);
63
        $this->SetTextColor(0);
64
        $this->SetFont('Arial', '', 9);
65
 
16768 efrain 66
        $this->Cell(155, 8, Functions::utf8_decode(' 1: Mínimo  2: Medio  3: Medio-Alto  4: Alto  N/A: No aplica '), 1, 'L', false);
1336 efrain 67
        $this->Ln(15);
68
    }
69
 
70
    /**
71
     * Create Table
72
     * @param string $title
73
     * @param array $content
74
     */
75
    function borderTable($title, $content) {
76
 
77
        // Header Table
78
        $this->SetFillColor(204, 204, 204);
79
        $this->SetDrawColor(0, 0, 0);
80
        $this->SetLineWidth(0);
81
        $this->SetFont('Arial', 'B', 9);
82
 
16768 efrain 83
        $this->Cell(190, 6, Functions::utf8_decode($title), 1, 0, 'L', true);
1336 efrain 84
        $this->Ln();
85
 
86
        // Body Table
87
        $this->SetFillColor(225, 255, 255);
88
        $this->SetTextColor(0);
89
 
90
        foreach ($content as $rs) {
91
            if (isset($rs['title'])) {
92
 
93
                $this->SetFont('Arial', 'B', 9);
16768 efrain 94
                $this->Cell(50, 10, Functions::utf8_decode($rs['title']), 1, 0, 'L', false);
95
                $this->Cell(140, 10, Functions::utf8_decode($rs['content']), 1, 'L', false);
1336 efrain 96
                $this->Ln();
97
            } else {
98
 
99
                $this->SetFont('Arial', '', 9);
16768 efrain 100
                $this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 1, 'L', false);
1336 efrain 101
            }
15447 efrain 102
 
103
            $y = $this->getY();
104
            if($y >= self::MAX_Y_ADD_PAGE) {
105
                $this->addPage();
106
            }
1336 efrain 107
        }
108
        $this->Ln(5);
15447 efrain 109
 
110
        $y = $this->getY();
111
        if($y >= self::MAX_Y_ADD_PAGE) {
112
            $this->addPage();
113
        }
1336 efrain 114
    }
115
 
116
    /**
117
     * title option table
118
     * @param string $title
119
     */
120
    function titleOptionTable($title) {
121
 
122
        if ($title != '') {
123
            // Body Table
124
            $this->SetFillColor(204, 204, 204);
125
            $this->SetDrawColor(0, 0, 0);
126
            $this->SetLineWidth(0);
127
            $this->SetFont('Arial', 'B', 9);
128
 
16768 efrain 129
            $this->Cell(190, 6, Functions::utf8_decode($title), 1, 0, 'L', true);
1336 efrain 130
            $this->Ln();
131
        }
132
    }
133
 
134
    /**
135
     * Create Section Option Table
136
     * @param string $content
137
     */
138
    function optionTable($title) {
139
 
140
        // Body Table
141
        $this->SetFillColor(225, 255, 255);
142
        $this->SetTextColor(0);
143
        $this->SetFont('Arial', 'B', 9);
16768 efrain 144
        $this->Cell(50, 10, Functions::utf8_decode($title), 1, 0, 'L', false);
1336 efrain 145
        $this->Cell(140, 10, '', 1, 'L', false);
146
        $this->Ln();
147
    }
148
 
149
    /**
150
     * Create Table
151
     * @param string $title
152
     * @param array $content
153
     */
154
    function singleTable($title, $content) {
155
 
156
        // Header Table
157
        $this->SetFillColor(255, 255, 255);
158
        $this->SetDrawColor(0, 0, 0);
159
        $this->SetLineWidth(0);
160
        $this->SetFont('Arial', 'B', 9);
161
 
16768 efrain 162
        $this->Cell(190, 6, Functions::utf8_decode($title), 0, 0, 'L', true);
1336 efrain 163
        $this->Ln();
164
 
165
        // Body Table
166
        $this->SetFillColor(225, 255, 255);
167
        $this->SetTextColor(0);
168
        $this->SetFont('Arial', '', 9);
169
 
170
        foreach ($content as $rs) {
171
            if (isset($rs['title'])) {
16768 efrain 172
                $this->Cell(40, 6, Functions::utf8_decode($rs['title']), 0, 0, 'L', false);
173
                $this->Cell(150, 6, Functions::utf8_decode($rs['content']), 0, 'L', false);
1336 efrain 174
                $this->Ln();
175
            } else {
176
                if ($rs['content'] != "") {
16768 efrain 177
                    $this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 0, 'L', false);
1336 efrain 178
                }
179
            }
15447 efrain 180
 
181
            $y = $this->getY();
182
            if($y >= self::MAX_Y_ADD_PAGE) {
183
                $this->addPage();
184
            }
1336 efrain 185
        }
186
        $this->Ln(5);
15447 efrain 187
 
188
        $y = $this->getY();
189
        if($y >= self::MAX_Y_ADD_PAGE) {
190
            $this->addPage();
191
        }
1336 efrain 192
    }
15447 efrain 193
 
194
    function evaluationTable()
195
    {
196
 
197
        // Header Table
198
        $this->SetFillColor(204, 204, 204);
199
        $this->SetDrawColor(0, 0, 0);
200
        $this->SetLineWidth(0);
201
        $this->SetFont('Arial', 'B', 9);
202
 
16768 efrain 203
        $this->Cell(150, 6, Functions::utf8_decode('Resumen General Final'), 1, 0, 'L', true);
204
        $this->Cell(24, 6, Functions::utf8_decode('Evaluación'), 1, 0, 'L', true);
15447 efrain 205
        $this->Cell(16, 6, '', 1, 0, 'C', true);
206
        $this->Ln();
207
        $this->SetFont('Arial', 'B', 9);
16768 efrain 208
        $this->Cell(190, 8, Functions::utf8_decode('Comentario final'), 0, 0, 'L', false);
15447 efrain 209
        $this->Ln();
210
        $this->SetFont('Arial', '', 9);
16768 efrain 211
        $this->MultiCell(190, 80, Functions::utf8_decode('   '), 0, 'J', false);
15447 efrain 212
 
213
 
214
        /*
16768 efrain 215
        $this->Cell(160, 6, Functions::utf8_decode('Resumen General Final'), 1, 0, 'L', true);
216
        $this->Cell(30, 6, Functions::utf8_decode('Evaluación'), 1, 0, 'C', true);
15447 efrain 217
        $this->Ln();
218
 
1336 efrain 219
 
15447 efrain 220
 
221
        $this->SetFillColor(225, 255, 255);
222
        $this->SetTextColor(0);
223
        $this->SetFont('Arial', 'B', 9);
224
 
225
 
16768 efrain 226
        $this->Cell(35, 8, Functions::utf8_decode(' Escala/Niveles:'), 1, 0, 'L', false);
15447 efrain 227
 
228
        $this->SetFillColor(225, 255, 255);
229
        $this->SetTextColor(0);
230
        $this->SetFont('Arial', '', 9);
231
 
16768 efrain 232
        $this->Cell(125, 8, Functions::utf8_decode(' 1: Mínimo  2: Medio  3: Medio-Alto  4: Alto  N/A: No aplica '), 1, 'L', false);
233
        $this->Cell(30, 8, Functions::utf8_decode(' N/A '), 1, 0, 'C', false);
15447 efrain 234
        $this->Ln();
235
        $this->SetFont('Arial', 'B', 9);
16768 efrain 236
        $this->Cell(190, 8, Functions::utf8_decode('Comentario final'), 1, 0, 'L', false);
15447 efrain 237
        $this->Ln();
238
        $this->SetFont('Arial', '', 9);
16768 efrain 239
        $this->MultiCell(190, 80, Functions::utf8_decode('   '), 1, 'J', false);
15447 efrain 240
        */
241
 
242
 
243
 
244
    }
245
 
1336 efrain 246
    /**
247
     * Create Competency Table
248
     * @param int $index
15447 efrain 249
     * @param array $competency_selected
250
     *  @param array $competencies
251
     * @param array $competency_types
252
     * @param array $behaviors
1336 efrain 253
     */
15447 efrain 254
    function competencyTable($index, $competency_selected, $competencies, $competency_types, $behaviors, $last) {
1336 efrain 255
 
15447 efrain 256
        /*
257
         uuid] => 64597e43-4a44-416a-9d30-f88cfbf2021a [competency_type_uuid] => dd955db7-3bd4-4408-8ef9-11fea6780a63 [behaviors] => Array ( [0] => stdClass Object ( [uuid] => 9ad8fa37-1290-4182-962a-6e29ef1d6119 [level] => 1 ) [1] => stdClass Object ( [uuid] => aedb8677-93c5-463a-9042-4f75d1fa2b86 [level] => 2 ) [2] => stdClass Object ( [uuid] => 6a8c6427-b51e-4deb-8438-5d24b25b645f [level] => 3 ) [3] => stdClass Object ( [uuid] => d0890a5f-c23e-4ca0-a3ba-ac1b15ce68b3 [level] => 4 ) ) ) stdClass Object ( [26] => stdClass Object ( [id] => 26 [competency_id_default] => [competency_type_id] => 7 [company_id] => 1 [name] => Comunicación [uuid] => 64597e43-4a44-416a-9d30-f88cfbf2021a [description] =>
258
         */
259
 
260
        $competency = [];
261
        foreach($competencies as $competency)
262
        {
263
            if($competency_selected->uuid == $competency->uuid) {
264
                break;
265
            }
266
        }
267
 
268
        foreach($competency_types as $competency_type)
269
        {
270
            if($competency_selected->competency_type_uuid == $competency_type->uuid) {
271
                break;
272
            }
273
        }
1336 efrain 274
 
15447 efrain 275
 
276
 
1336 efrain 277
        // Header Table
278
        $this->SetFillColor(255, 255, 255);
279
        $this->SetDrawColor(0, 0, 0);
280
        $this->SetLineWidth(0);
281
        $this->SetFont('Arial', 'B', 9);
282
 
16768 efrain 283
        $this->MultiCell(190, 5, $index . '- ' . Functions::utf8_decode($competency_type->name) . ': ' . Functions::utf8_decode($competency->name), 0, 'L', false);
1336 efrain 284
 
285
        // Body Table
286
        $this->SetFillColor(225, 255, 255);
287
        $this->SetTextColor(0);
288
        $this->SetFont('Arial', '', 9);
289
 
16768 efrain 290
        $this->MultiCell(190, 6, Functions::utf8_decode(strip_tags($competency->description)), 0, 'L', false);
1336 efrain 291
 
292
        $this->Ln(3);
293
 
294
 
15447 efrain 295
        $y = $this->getY();
296
        if( $y >= self::MAX_Y_ADD_PAGE) {
297
            $this->addPage();
298
            $first  = true;
299
        }
1336 efrain 300
 
15447 efrain 301
        if ($competency_selected->behaviors) {
302
 
303
            $first = true;
1336 efrain 304
 
15447 efrain 305
 
306
            $max = count($competency_selected->behaviors);
307
            for($i = 0; $i < $max; $i++)
308
            {
1336 efrain 309
 
15447 efrain 310
 
311
                $competency_behavior = $competency_selected->behaviors[$i];
1336 efrain 312
 
15447 efrain 313
                foreach($behaviors as $behavior)
314
                {
315
                    if($competency_behavior->uuid == $behavior->uuid) {
316
                        break;
317
                    }
318
                }
319
 
320
                if($first) {
321
                    $this->SetFillColor(204, 204, 204);
322
                    $this->SetDrawColor(0, 0, 0);
323
                    $this->SetLineWidth(0);
324
                    $this->SetFont('Arial', 'B', 9);
325
 
16768 efrain 326
                    $this->Cell(150, 6, Functions::utf8_decode('Conductas observables :'), 1, 0, 'L', true);
15447 efrain 327
                    $this->Cell(16, 6, 'Nivel', 1, 0, 'C', true);
16768 efrain 328
                    $this->Cell(24, 6, Functions::utf8_decode('Evaluación'), 1, 0, 'C', true);
15447 efrain 329
                    $this->Ln();
330
 
331
                    // Body Table
332
                    $this->SetFillColor(225, 255, 255);
333
                    $this->SetTextColor(0);
334
                    $first = false;
335
                }
336
 
337
 
1336 efrain 338
                $this->SetFont('Arial', '', 8.5);
339
 
16768 efrain 340
                $this->Cell(150, 6, Functions::utf8_decode($behavior->description), 1, 0, 'L', false);
15447 efrain 341
                //$this->Cell(16, 6, $competency_behavior->level == '0' ? 'N/A' : $competency_behavior->level, 1, 0, 'C', false);
342
                $this->Cell(16, 6, $competency_behavior->level, 1, 0, 'C', false);
1336 efrain 343
                $this->Cell(24, 6, '', 1, 0, 'C', false);
344
 
345
                $this->Ln();
346
 
347
                $this->SetFont('Arial', 'B', 9);
348
 
16768 efrain 349
                $this->Cell(190, 6, Functions::utf8_decode('Comentarios:'), 1, 0, 'L', false);
1336 efrain 350
 
351
 
352
                $this->Ln();
15447 efrain 353
 
354
 
355
                $y = $this->getY();
356
                if( ($y >= self::MAX_Y_ADD_PAGE) && ($max - 1 > $i)) {
357
                    $this->addPage();
358
                    $first  = true;
359
                }
1336 efrain 360
            }
361
        }
362
 
363
 
364
        $this->Ln();
15447 efrain 365
 
366
        if(!$last) {
367
 
368
            $y = $this->getY();
369
            if($y >= self::MAX_Y_ADD_PAGE) {
370
                $this->addPage();
371
            } else {
372
 
373
            }
374
        }
1336 efrain 375
    }
15447 efrain 376
 
377
 
378
 
1336 efrain 379
 
380
}