Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15394 efrain 1
<?php
2
 
3
namespace LeadersLinked\Library;
4
 
5
use Fpdf\Fpdf;
6
use LeadersLinked\Model\Competency;
7
use LeadersLinked\Model\CompetencyType;
8
use LeadersLinked\Model\Behavior;
9
use Laminas\Mvc\I18n\Translator;
10
 
11
class JobDescriptionPdf extends FPDF {
15447 efrain 12
 
13
    const MAX_Y_ADD_PAGE = 240;
15394 efrain 14
 
15
    /**
16
     *
17
     * @var string
18
     */
19
    public $header;
20
 
21
    /**
22
     *
23
     * @var string
24
     */
25
    public $footer;
26
 
27
    /**
28
     *
29
     * @var Translator
30
     */
31
    public $translator;
32
 
33
 
34
 
35
 
36
    /**
37
     * Header PDF
38
     */
39
    function Header() {
40
 
41
        if ($this->header != '') {
42
            $this->Image($this->header, 10, 8, 190);
43
            $this->SetY(55);
44
        }
45
    }
46
 
47
    /**
48
     * Custom Header PDF
49
     */
50
    function customHeader() {
51
        $this->SetFont('Arial', 'B', 11);
16768 efrain 52
        $this->Cell(60, 10, Functions::utf8_decode('DESCRIPCIÓN DE CARGOS DE TRABAJO'));
15394 efrain 53
        $this->Ln(10);
54
    }
55
 
56
    /**
57
     * Footer PDF
58
     */
59
    function Footer() {
60
        if ($this->footer != '') {
61
            $this->SetY(-40);
62
            $this->Image($this->footer, 10, $this->getY(), 190);
63
        }
64
    }
65
 
66
    /**
67
     * Section Signature
68
     */
69
    function sectionSignature() {
70
 
71
        $this->SetFont('Arial', 'B', 9);
16768 efrain 72
        $this->Cell(60, 10, Functions::utf8_decode('Elaborado por:'));
15394 efrain 73
        $this->Ln(8);
16768 efrain 74
        $this->Cell(60, 10, Functions::utf8_decode('Firma:'));
15394 efrain 75
        $this->Ln(8);
16768 efrain 76
        $this->Cell(60, 10, Functions::utf8_decode('Fecha:'));
15394 efrain 77
        $this->Ln(8);
78
    }
79
 
80
    /**
81
     * Section Scale
82
     */
83
    function sectionScale() {
84
        $this->SetFillColor(225, 255, 255);
85
        $this->SetTextColor(0);
86
        $this->SetFont('Arial', 'B', 9);
87
 
88
 
16768 efrain 89
        $this->Cell(35, 8, Functions::utf8_decode(' Escala/Niveles:'), 1, 0, 'L', false);
15394 efrain 90
 
91
        $this->SetFillColor(225, 255, 255);
92
        $this->SetTextColor(0);
93
        $this->SetFont('Arial', '', 9);
94
 
16768 efrain 95
        $this->Cell(155, 8, Functions::utf8_decode(' 1: Mínimo  2: Medio  3: Medio-Alto  4: Alto  N/A: No aplica '), 1, 'L', false);
15394 efrain 96
        $this->Ln(15);
97
    }
98
 
99
    /**
100
     * Create Table
101
     * @param string $title
102
     * @param array $content
103
     */
104
    function borderTable($title, $content) {
105
 
106
        // Header Table
107
        $this->SetFillColor(204, 204, 204);
108
        $this->SetDrawColor(0, 0, 0);
109
        $this->SetLineWidth(0);
110
        $this->SetFont('Arial', 'B', 9);
111
 
16768 efrain 112
        $this->Cell(190, 6, Functions::utf8_decode($title), 1, 0, 'L', true);
15394 efrain 113
        $this->Ln();
114
 
115
        // Body Table
116
        $this->SetFillColor(225, 255, 255);
117
        $this->SetTextColor(0);
118
 
119
        foreach ($content as $rs) {
120
            if (isset($rs['title'])) {
121
 
122
                $this->SetFont('Arial', 'B', 9);
123
 
16768 efrain 124
                $this->Cell(40, 10, Functions::utf8_decode($rs['title']), 1, 0, 'L', false);
125
                $this->Cell(150, 10, Functions::utf8_decode($rs['content']), 1, 'L', false);
15394 efrain 126
                $this->Ln();
127
            } else {
128
 
129
                $this->SetFont('Arial', '', 9);
16768 efrain 130
                $this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 1, 'L', false);
15394 efrain 131
            }
15447 efrain 132
 
133
            $y = $this->getY();
134
            if($y >= self::MAX_Y_ADD_PAGE) {
135
                $this->addPage();
136
            }
15394 efrain 137
        }
138
        $this->Ln(5);
15447 efrain 139
 
140
        $y = $this->getY();
141
        if($y >= self::MAX_Y_ADD_PAGE) {
142
            $this->addPage();
143
        }
15394 efrain 144
    }
145
 
146
    /**
147
     * Create Table
148
     * @param string $title
149
     * @param array $content
150
     */
151
    function singleTable($title, $content) {
152
 
153
        // Header Table
154
        $this->SetFillColor(255, 255, 255);
155
        $this->SetDrawColor(0, 0, 0);
156
        $this->SetLineWidth(0);
157
        $this->SetFont('Arial', 'B', 9);
158
 
16768 efrain 159
        $this->Cell(190, 6, Functions::utf8_decode($title), 0, 0, 'L', true);
15394 efrain 160
        $this->Ln();
161
 
162
        // Body Table
163
        $this->SetFillColor(225, 255, 255);
164
        $this->SetTextColor(0);
165
        $this->SetFont('Arial', '', 9);
166
 
167
        foreach ($content as $rs) {
168
            if (isset($rs['title'])) {
16768 efrain 169
                $this->Cell(40, 6, Functions::utf8_decode($rs['title']), 0, 0, 'L', false);
170
                $this->Cell(150, 6, Functions::utf8_decode($rs['content']), 0, 'L', false);
15394 efrain 171
                $this->Ln();
172
            } else {
16768 efrain 173
                $this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 0, 'L', false);
15394 efrain 174
            }
15447 efrain 175
 
176
            $y = $this->getY();
177
            if($y >= self::MAX_Y_ADD_PAGE) {
178
                $this->addPage();
179
            }
15394 efrain 180
        }
181
        $this->Ln(5);
15447 efrain 182
 
183
        $y = $this->getY();
184
        if($y >= self::MAX_Y_ADD_PAGE) {
185
            $this->addPage();
186
        }
15394 efrain 187
    }
188
 
189
    /**
190
     * Create Competency Table
191
     * @param string $index
192
     * @param CompetencyType $competenceType
193
     * @param Competency $competency
194
     * @param Behavior[] $behaviors
15447 efrain 195
     * @param boolean $last
15394 efrain 196
     */
15447 efrain 197
    function competencyTable($index, $competenceType, $competency, $behaviors, $last ) {
15394 efrain 198
 
199
 
200
        // Header Table
201
        $this->SetFillColor(255, 255, 255);
202
        $this->SetDrawColor(0, 0, 0);
203
        $this->SetLineWidth(0);
204
        $this->SetFont('Arial', 'B', 9);
205
 
16768 efrain 206
        $this->MultiCell(190, 5, $index . '- ' . Functions::utf8_decode($competenceType->name) . ': ' . Functions::utf8_decode($competency->name), 0, 'L', false);
15394 efrain 207
 
208
 
209
 
210
        // Body Table
211
        $this->SetFillColor(225, 255, 255);
212
        $this->SetTextColor(0);
213
        $this->SetFont('Arial', '', 9);
214
 
16768 efrain 215
        $this->MultiCell(190, 6, Functions::utf8_decode(strip_tags($competency->description)), 0, 'L', false);
15394 efrain 216
 
217
        $this->Ln(3);
218
 
219
 
15447 efrain 220
 
15403 efrain 221
        if ($behaviors) {
15394 efrain 222
 
15447 efrain 223
            $first  = true;
224
 
225
 
226
            $max =  count($behaviors);
227
            for ($i = 0; $i <$max; $i++) {
228
 
229
                if($first) {
230
                    $this->SetFillColor(204, 204, 204);
231
                    $this->SetDrawColor(0, 0, 0);
232
                    $this->SetLineWidth(0);
233
                    $this->SetFont('Arial', 'B', 9);
234
 
235
                    /*
16768 efrain 236
                    $this->Cell(155, 6, Functions::utf8_decode('Conductas observables :'), 1, 0, 'L', true);
15447 efrain 237
                    $this->Cell(7, 6, '1', 1, 0, 'C', true);
238
                    $this->Cell(7, 6, '2', 1, 0, 'C', true);
239
                    $this->Cell(7, 6, '3', 1, 0, 'C', true);
240
                    $this->Cell(7, 6, '4', 1, 0, 'C', true);
241
                    $this->Cell(7, 6, 'N/A', 1, 0, 'C', true);
242
                    */
16768 efrain 243
                    $this->Cell(180, 6, Functions::utf8_decode('Conductas observables :'), 1, 0, 'L', true);
15447 efrain 244
                    $this->Cell(10, 6, 'Nivel', 1, 0, 'C', true);
245
                    $this->Ln();
246
 
247
                    // Body Table
248
                    $this->SetFillColor(225, 255, 255);
249
                    $this->SetTextColor(0);
250
                    $this->SetFont('Arial', '', 9);
251
                    $first = false;
252
                }
253
 
15394 efrain 254
 
16768 efrain 255
                $this->Cell(180, 6, Functions::utf8_decode($behaviors[$i]['description']), 1, 0, 'L', false);
15447 efrain 256
                $this->Cell(10, 6, $behaviors[$i]['level'], 1, 0, 'C', false);
257
                /*
16768 efrain 258
                $this->Cell(155, 6, Functions::utf8_decode($behaviors[$i]['description']), 1, 0, 'L', false);
15403 efrain 259
                $this->Cell(7, 6, $behaviors[$i]['level'] == '1' ? 'X' : '', 1, 0, 'C', false);
260
                $this->Cell(7, 6, $behaviors[$i]['level'] == '2' ? 'X' : '', 1, 0, 'C', false);
261
                $this->Cell(7, 6, $behaviors[$i]['level'] == '3' ? 'X' : '', 1, 0, 'C', false);
262
                $this->Cell(7, 6, $behaviors[$i]['level'] == '4' ? 'X' : '', 1, 0, 'C', false);
263
                $this->Cell(7, 6, $behaviors[$i]['level'] == '0' ? 'X' : '', 1, 0, 'C', false);
15447 efrain 264
                */
15394 efrain 265
                $this->Ln();
15447 efrain 266
 
267
 
268
                $y = $this->getY();
269
                if( ($y >= self::MAX_Y_ADD_PAGE) && ($max - 1 > $i)) {
270
                    $this->addPage();
271
                    $first  = true;
272
                }
15394 efrain 273
            }
274
        }
275
 
276
 
277
        $this->Ln();
15447 efrain 278
 
279
        if(!$last) {
280
 
281
            $y = $this->getY();
282
            if($y >= self::MAX_Y_ADD_PAGE) {
283
                $this->addPage();
284
            } else {
285
 
286
            }
287
        }
288
 
289
 
15394 efrain 290
    }
291
 
292
}