|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
GESTCONV - Aplicación web para la gestión de la convivencia en centros educativos |
|
4
|
|
|
|
|
5
|
|
|
Copyright (C) 2015: Luis Ramón López López |
|
6
|
|
|
|
|
7
|
|
|
This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
it under the terms of the GNU Affero General Public License as published by |
|
9
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
(at your option) any later version. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
GNU Affero General Public License for more details. |
|
16
|
|
|
|
|
17
|
|
|
You should have received a copy of the GNU Affero General Public License |
|
18
|
|
|
along with this program. If not, see [http://www.gnu.org/licenses/]. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppBundle\Utils; |
|
22
|
|
|
|
|
23
|
|
|
class InformePDF extends \TCPDF |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Header image logos. |
|
27
|
|
|
* @protected |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $header_logos = array(); |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Header contents |
|
33
|
|
|
* @protected |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $header_texts = array(); |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Set header data. |
|
39
|
|
|
* @param $ln (array) header image logos |
|
40
|
|
|
* @param $texts (string) header image logo width in mm |
|
41
|
|
|
* @public |
|
42
|
|
|
*/ |
|
43
|
|
|
public function setExtendedHeaderData($ln = array(), $texts = array()) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->header_logos = $ln; |
|
46
|
|
|
$this->header_texts = $texts; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Returns header data |
|
51
|
|
|
* @return array |
|
52
|
|
|
* @public |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getExtendedHeaderData() |
|
55
|
|
|
{ |
|
56
|
|
|
$ret = array(); |
|
57
|
|
|
$ret['logos'] = $this->header_logos; |
|
58
|
|
|
$ret['header_texts'] = $this->header_texts; |
|
59
|
|
|
return $ret; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
// Cabecera |
|
63
|
|
|
public function header() |
|
64
|
|
|
{ |
|
65
|
|
|
$headerfont = $this->getHeaderFont(); |
|
66
|
|
|
$headerdata = $this->getExtendedHeaderData(); |
|
67
|
|
|
$this->y = $this->header_margin; |
|
68
|
|
|
if ($this->rtl) { |
|
69
|
|
|
$this->x = $this->w - $this->original_rMargin; |
|
70
|
|
|
} else { |
|
71
|
|
|
$this->x = $this->original_lMargin; |
|
72
|
|
|
} |
|
73
|
|
|
$logos = $headerdata['logos']; |
|
74
|
|
|
$captions = $headerdata['header_texts']; |
|
75
|
|
|
|
|
76
|
|
|
foreach ($logos as $i => $logo) { |
|
77
|
|
|
$logos[$i] = K_PATH_IMAGES.$logo; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$this->SetFont($headerfont[0], $headerfont[1], $headerfont[2]); |
|
81
|
|
|
$w_page = isset($this->l['w_page']) ? $this->l['w_page'].' ' : 'Pág. '; |
|
82
|
|
|
if (empty($this->pagegroups)) { |
|
83
|
|
|
$pagenumtxt = $w_page.$this->PageNo().' de '.$this->getAliasNbPages(); |
|
84
|
|
|
} else { |
|
85
|
|
|
$pagenumtxt = $w_page.$this->getPageNumGroupAlias().' de '.$this->getPageGroupAlias(); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$tbl = <<<EOD |
|
89
|
|
|
<table cellspacing="0" cellpadding="1" border="0.75" align="center"> |
|
90
|
|
|
<tr> |
|
91
|
|
|
<td rowspan="3" width="15%"></td> |
|
92
|
|
|
<td colspan="3" width="70%">{$captions[0]}</td> |
|
93
|
|
|
<td rowspan="3" width="15%"></td> |
|
94
|
|
|
</tr> |
|
95
|
|
|
<tr> |
|
96
|
|
|
<td>{$captions[1]}</td> |
|
97
|
|
|
<td colspan="2">{$captions[2]}</td> |
|
98
|
|
|
</tr> |
|
99
|
|
|
<tr> |
|
100
|
|
|
<td>{$captions[3]}</td> |
|
101
|
|
|
<td>{$captions[4]}</td> |
|
102
|
|
|
<td>{$pagenumtxt}</td> |
|
103
|
|
|
</tr> |
|
104
|
|
|
</table> |
|
105
|
|
|
EOD; |
|
106
|
|
|
$this->writeHTML($tbl, true, false, false, false, ''); |
|
107
|
|
|
$this->x = $this->original_lMargin + 1; |
|
108
|
|
|
$this->y = $this->header_margin + 4; |
|
109
|
|
|
$this->Image($logos[0], '', '', 10); |
|
110
|
|
|
$this->x = $this->original_lMargin + 15; |
|
111
|
|
|
$this->Image($logos[1], '', '', 10); |
|
112
|
|
|
$this->x = $this->w - $this->rMargin - 23; |
|
113
|
|
|
$this->y = $this->header_margin + 0.5; |
|
114
|
|
|
$this->Image($logos[2], '', '', 20, 0, '', '', '', '', 300, '', false, false, 0, ''); |
|
115
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function footer() |
|
119
|
|
|
{ |
|
120
|
|
|
$cur_y = $this->y; |
|
121
|
|
|
$this->SetTextColorArray($this->footer_text_color); |
|
122
|
|
|
//set style for cell border |
|
123
|
|
|
$line_width = (0.85 / $this->k); |
|
124
|
|
|
$this->SetLineStyle(array('width' => $line_width, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => $this->footer_line_color)); |
|
125
|
|
|
//print document barcode |
|
126
|
|
|
$barcode = $this->getBarcode(); |
|
127
|
|
|
if (!empty($barcode)) { |
|
128
|
|
|
$this->Ln($line_width); |
|
129
|
|
|
$style = array( |
|
130
|
|
|
'position' => $this->rtl?'R':'L', |
|
131
|
|
|
'align' => $this->rtl?'R':'L', |
|
132
|
|
|
'stretch' => false, |
|
133
|
|
|
'fitwidth' => true, |
|
134
|
|
|
'cellfitalign' => '', |
|
135
|
|
|
'border' => false, |
|
136
|
|
|
'padding' => 0, |
|
137
|
|
|
'fgcolor' => array(0,0,0), |
|
138
|
|
|
'bgcolor' => false, |
|
139
|
|
|
'text' => false |
|
140
|
|
|
); |
|
141
|
|
|
$this->write1DBarcode($barcode, 'C128', '', $cur_y + $line_width, '', (($this->footer_margin / 3) - $line_width), 0.3, $style, ''); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
$headerdata = $this->getExtendedHeaderData(); |
|
145
|
|
|
$captions = $headerdata['header_texts']; |
|
146
|
|
|
$pagenumtxt = $captions[3] . ' ' . $captions[4]; |
|
147
|
|
|
|
|
148
|
|
|
$this->SetY($cur_y); |
|
149
|
|
|
//Print page number |
|
150
|
|
|
if ($this->getRTL()) { |
|
151
|
|
|
$this->SetX($this->original_rMargin); |
|
152
|
|
|
$this->Cell(0, 0, $pagenumtxt, 'T', 0, 'L'); |
|
153
|
|
|
} else { |
|
154
|
|
|
$this->SetX($this->original_lMargin); |
|
155
|
|
|
$this->Cell(0, 0, $pagenumtxt, 'T', 0, 'R'); |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|