Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15447 efrain 1
<?php
2
 
3
namespace LeadersLinked\Library;
4
 
5
use Fpdf\Fpdf;
6
use Laminas\Mvc\I18n\Translator;
7
use LeadersLinked\Model\Competency;
8
 
9
class PerformanceEvaluationInterviewPDF extends FPDF {
10
 
11
    const MAX_Y_ADD_PAGE = 240;
12
 
13
    /**
14
     *
15
     * @var string
16
     */
17
    public $header;
18
 
19
    /**
20
     *
21
     * @var string
22
     */
23
    public $footer;
24
 
25
    /**
26
     *
27
     * @var Translator
28
     */
29
    public $translator;
30
 
31
    /**
32
     * Header PDF
33
     */
34
    function Header() {
35
        if ($this->header != '') {
36
            $this->Image($this->header, 10, 1, 190);
37
            $this->SetY(55);
38
        }
39
    }
40
 
41
    /**
42
     * Footer PDF
43
     */
44
    function Footer() {
45
        if ($this->footer != '') {
46
            $this->SetY(-40);
47
            $this->Image($this->footer, 10,$this->getY() , 190);
48
        }
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);
15447 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);
15447 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);
15447 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);
15447 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);
15447 efrain 101
            }
102
 
103
            $y = $this->getY();
104
            if($y >= self::MAX_Y_ADD_PAGE) {
105
                $this->addPage();
106
            }
107
        }
108
        $this->Ln(5);
109
 
110
        $y = $this->getY();
111
        if($y >= self::MAX_Y_ADD_PAGE) {
112
            $this->addPage();
113
        }
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);
15447 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);
15447 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);
15447 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);
15447 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);
15447 efrain 178
                }
179
            }
180
 
181
            $y = $this->getY();
182
            if($y >= self::MAX_Y_ADD_PAGE) {
183
                $this->addPage();
184
            }
185
        }
186
        $this->Ln(5);
187
 
188
        $y = $this->getY();
189
        if($y >= self::MAX_Y_ADD_PAGE) {
190
            $this->addPage();
191
        }
192
    }
193
 
194
    /**
195
     *
196
     * @param string $comment
197
     * @param int $points
198
     */
199
    function evaluationTable($comment, $points)
200
    {
201
 
202
 
203
        // Header Table
204
        $this->SetFillColor(204, 204, 204);
205
        $this->SetDrawColor(0, 0, 0);
206
        $this->SetLineWidth(0);
207
        $this->SetFont('Arial', 'B', 9);
208
 
16768 efrain 209
        $this->Cell(150, 6, Functions::utf8_decode('Resumen General Final'), 1, 0, 'L', true);
210
        $this->Cell(24, 6, Functions::utf8_decode('Evaluación'), 1, 0, 'L', true);
15447 efrain 211
        $this->Cell(16, 6, '' . $points, 1, 0, 'C', true);
212
        $this->Ln();
213
        $this->SetFont('Arial', 'B', 9);
16768 efrain 214
        $this->Cell(190, 8, Functions::utf8_decode('Comentario final'), 0, 0, 'L', false);
15447 efrain 215
        $this->Ln();
216
        $this->SetFont('Arial', '', 9);
217
 
16768 efrain 218
        $this->MultiCell(190, 80, Functions::utf8_decode($comment), 1, 'J', false);
15447 efrain 219
 
220
 
221
        /*
16768 efrain 222
        $this->Cell(160, 6, Functions::utf8_decode('Resumen General Final'), 1, 0, 'L', true);
223
        $this->Cell(30, 6, Functions::utf8_decode('Evaluación'), 1, 0, 'C', true);
15447 efrain 224
        $this->Ln();
225
 
226
 
227
 
228
        $this->SetFillColor(225, 255, 255);
229
        $this->SetTextColor(0);
230
        $this->SetFont('Arial', 'B', 9);
231
 
232
 
16768 efrain 233
        $this->Cell(35, 8, Functions::utf8_decode(' Escala/Niveles:'), 1, 0, 'L', false);
15447 efrain 234
 
235
        $this->SetFillColor(225, 255, 255);
236
        $this->SetTextColor(0);
237
        $this->SetFont('Arial', '', 9);
238
 
16768 efrain 239
        $this->Cell(125, 8, Functions::utf8_decode(' 1: Mínimo  2: Medio  3: Medio-Alto  4: Alto  N/A: No aplica '), 1, 'L', false);
240
        $this->Cell(30, 8, Functions::utf8_decode(' N/A '), 1, 0, 'C', false);
15447 efrain 241
        $this->Ln();
242
        $this->SetFont('Arial', 'B', 9);
16768 efrain 243
        $this->Cell(190, 8, Functions::utf8_decode('Comentario final'), 1, 0, 'L', false);
15447 efrain 244
        $this->Ln();
245
        $this->SetFont('Arial', '', 9);
16768 efrain 246
        $this->MultiCell(190, 80, Functions::utf8_decode('   '), 1, 'J', false);
15447 efrain 247
        */
248
 
249
 
250
 
251
    }
252
 
253
    /**
254
     * Create Competency Table
255
     * @param int $index
256
     * @param array $competency_selected
257
     *  @param array $competencies
258
     * @param array $competency_types
259
     * @param array $behaviors
260
     */
261
    function competencyTable($index, $competency_selected, $competencies, $competency_types, $behaviors, $evaluation, $last) {
262
 
263
        /*
264
         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] =>
265
         */
266
 
267
        $competency = [];
268
        foreach($competencies as $competency)
269
        {
270
            if($competency_selected->uuid == $competency->uuid) {
271
                break;
272
            }
273
        }
274
 
275
        foreach($competency_types as $competency_type)
276
        {
277
            if($competency_selected->competency_type_uuid == $competency_type->uuid) {
278
                break;
279
            }
280
        }
281
 
282
 
283
 
284
        // Header Table
285
        $this->SetFillColor(255, 255, 255);
286
        $this->SetDrawColor(0, 0, 0);
287
        $this->SetLineWidth(0);
288
        $this->SetFont('Arial', 'B', 9);
289
 
16768 efrain 290
        $this->MultiCell(190, 5, $index . '- ' . Functions::utf8_decode($competency_type->name) . ': ' . Functions::utf8_decode($competency->name), 0, 'L', false);
15447 efrain 291
 
292
        // Body Table
293
        $this->SetFillColor(225, 255, 255);
294
        $this->SetTextColor(0);
295
        $this->SetFont('Arial', '', 9);
296
 
16768 efrain 297
        $this->MultiCell(190, 6, Functions::utf8_decode(strip_tags($competency->description)), 0, 'L', false);
15447 efrain 298
 
299
        $this->Ln(3);
300
 
301
 
302
        $y = $this->getY();
303
        if( $y >= self::MAX_Y_ADD_PAGE) {
304
            $this->addPage();
305
            $first  = true;
306
        }
307
 
308
        if ($competency_selected->behaviors) {
309
 
310
            $first = true;
311
 
312
 
313
            $max = count($competency_selected->behaviors);
314
            for($i = 0; $i < $max; $i++)
315
            {
316
 
317
 
318
                $competency_behavior = $competency_selected->behaviors[$i];
319
 
320
                $comment = 0;
321
                $points = 0;
322
                foreach($evaluation as $itemEvaluation)
323
                {
324
                    if($itemEvaluation->competency == $competency_selected->uuid
325
                        && $itemEvaluation->behavior == $competency_behavior->uuid) {
326
 
327
                            $comment = $itemEvaluation->comment;
328
                            $points = $itemEvaluation->points;
329
 
330
                        break;
331
                    }
332
                }
333
 
334
 
335
                foreach($behaviors as $behavior)
336
                {
337
                    if($competency_behavior->uuid == $behavior->uuid) {
338
                        break;
339
                    }
340
                }
341
 
342
                if($first) {
343
                    $this->SetFillColor(204, 204, 204);
344
                    $this->SetDrawColor(0, 0, 0);
345
                    $this->SetLineWidth(0);
346
                    $this->SetFont('Arial', 'B', 9);
347
 
16768 efrain 348
                    $this->Cell(150, 6, Functions::utf8_decode('Conductas observables :'), 1, 0, 'L', true);
15447 efrain 349
                    $this->Cell(16, 6, 'Nivel', 1, 0, 'C', true);
16768 efrain 350
                    $this->Cell(24, 6, Functions::utf8_decode('Evaluación'), 1, 0, 'C', true);
15447 efrain 351
                    $this->Ln();
352
 
353
                    // Body Table
354
                    $this->SetFillColor(225, 255, 255);
355
                    $this->SetTextColor(0);
356
                    $first = false;
357
                }
358
 
359
 
360
                $this->SetFont('Arial', '', 8.5);
361
 
16768 efrain 362
                $this->Cell(150, 6, Functions::utf8_decode($behavior->description), 1, 0, 'L', false);
15447 efrain 363
                //$this->Cell(16, 6, $competency_behavior->level == '0' ? 'N/A' : $competency_behavior->level, 1, 0, 'C', false);
364
                $this->Cell(16, 6, $competency_behavior->level, 1, 0, 'C', false);
365
                $this->Cell(24, 6, '' . $points, 1, 0, 'C', false);
366
 
367
                $this->Ln();
368
 
369
                $this->SetFont('Arial', 'B', 9);
370
 
16768 efrain 371
                $this->Cell(190, 6, Functions::utf8_decode('Comentarios: '), 1, 0, 'L', false);
15447 efrain 372
                $this->Ln();
373
 
374
                $this->SetFont('Arial', '', 9);
16768 efrain 375
                $this->Cell(190, 6, Functions::utf8_decode($comment), 1, 0, 'L', false);
15447 efrain 376
                $this->Ln();
377
 
378
 
379
 
380
 
381
                $y = $this->getY();
382
                if( ($y >= self::MAX_Y_ADD_PAGE) && ($max - 1 > $i)) {
383
                    $this->addPage();
384
                    $first  = true;
385
                }
386
            }
387
        }
388
 
389
 
390
        $this->Ln();
391
 
392
        if(!$last) {
393
 
394
            $y = $this->getY();
395
            if($y >= self::MAX_Y_ADD_PAGE) {
396
                $this->addPage();
397
            } else {
398
 
399
            }
400
        }
401
    }
402
 
403
 
404
 
405
 
406
}