|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\DA\CTe; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Classe para geração do envento do CTe em PDF |
|
7
|
|
|
* NOTA: Este documento não está NORMALIZADO, nem é requerido pela SEFAZ |
|
8
|
|
|
* |
|
9
|
|
|
* @category Library |
|
10
|
|
|
* @package nfephp-org/sped-da |
|
11
|
|
|
* @name Daevento.php |
|
12
|
|
|
* @copyright 2009-2019 NFePHP |
|
13
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU/LGPL v.3 |
|
14
|
|
|
* @link http://github.com/nfephp-org/sped-da for the canonical source repository |
|
15
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
use Exception; |
|
19
|
|
|
use NFePHP\DA\Legacy\Dom; |
|
20
|
|
|
use NFePHP\DA\Legacy\Pdf; |
|
21
|
|
|
use NFePHP\DA\Common\DaCommon; |
|
22
|
|
|
|
|
23
|
|
|
class Daevento extends DaCommon |
|
24
|
|
|
{ |
|
25
|
|
|
public $chCTe; |
|
26
|
|
|
protected $yDados = 0; |
|
27
|
|
|
|
|
28
|
|
|
protected $xml; |
|
29
|
|
|
protected $errMsg = ''; |
|
30
|
|
|
protected $errStatus = false; |
|
31
|
|
|
protected $destino = 'I'; |
|
32
|
|
|
protected $pdfDir = ''; |
|
33
|
|
|
protected $version = '0.1.1'; |
|
34
|
|
|
protected $wCanhoto; |
|
35
|
|
|
protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####"; |
|
36
|
|
|
|
|
37
|
|
|
protected $id; |
|
38
|
|
|
protected $dadosEmitente = array(); |
|
39
|
|
|
private $dom; |
|
40
|
|
|
private $procEventoCTe; |
|
41
|
|
|
private $evento; |
|
42
|
|
|
private $infEvento; |
|
43
|
|
|
private $retEvento; |
|
44
|
|
|
private $rinfEvento; |
|
45
|
|
|
protected $tpAmb; |
|
46
|
|
|
protected $cOrgao; |
|
47
|
|
|
protected $infCorrecao; |
|
48
|
|
|
protected $xCondUso; |
|
49
|
|
|
protected $dhEvento; |
|
50
|
|
|
protected $cStat; |
|
51
|
|
|
protected $xMotivo; |
|
52
|
|
|
protected $xJust; |
|
53
|
|
|
protected $CNPJDest = ''; |
|
54
|
|
|
protected $CPFDest = ''; |
|
55
|
|
|
protected $dhRegEvento; |
|
56
|
|
|
protected $nProt; |
|
57
|
|
|
protected $tpEvento; |
|
58
|
|
|
protected $creditos; |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* __construct |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $xml Arquivo XML (diretório ou string) |
|
65
|
|
|
* @param array $dadosEmitente Dados do endereço do emitente |
|
66
|
|
|
*/ |
|
67
|
|
|
public function __construct($xml, $dadosEmitente) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->dadosEmitente = $dadosEmitente; |
|
70
|
|
|
$this->loadDoc($xml); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
protected function loadDoc($xml) |
|
74
|
|
|
{ |
|
75
|
|
|
$this->dom = new \DomDocument; |
|
76
|
|
|
$this->dom->loadXML($xml); |
|
77
|
|
|
$this->procEventoCTe = $this->dom->getElementsByTagName("procEventoCTe")->item(0); |
|
78
|
|
|
$this->evento = $this->dom->getElementsByTagName("eventoCTe")->item(0); |
|
79
|
|
|
$this->infEvento = $this->evento->getElementsByTagName("infEvento")->item(0); |
|
80
|
|
|
$this->retEvento = $this->dom->getElementsByTagName("retEventoCTe")->item(0); |
|
81
|
|
|
$this->rinfEvento = $this->retEvento->getElementsByTagName("infEvento")->item(0); |
|
82
|
|
|
$this->tpEvento = $this->infEvento->getElementsByTagName("tpEvento")->item(0)->nodeValue; |
|
83
|
|
|
if (!in_array($this->tpEvento, array('110110', '110111'))) { |
|
84
|
|
|
$this->errMsg = 'Evento não implementado ' . $this->tpEvento . ' !!'; |
|
85
|
|
|
$this->errStatus = true; |
|
86
|
|
|
return false; |
|
87
|
|
|
} |
|
88
|
|
|
$this->id = str_replace('ID', '', $this->infEvento->getAttribute("Id")); |
|
89
|
|
|
$this->chCTe = $this->infEvento->getElementsByTagName("chCTe")->item(0)->nodeValue; |
|
90
|
|
|
$this->dadosEmitente['CNPJ'] = substr($this->chCTe, 6, 14); |
|
91
|
|
|
$this->tpAmb = $this->infEvento->getElementsByTagName("tpAmb")->item(0)->nodeValue; |
|
92
|
|
|
$this->cOrgao = $this->infEvento->getElementsByTagName("cOrgao")->item(0)->nodeValue; |
|
93
|
|
|
$this->infCorrecao = $this->infEvento->getElementsByTagName("infCorrecao"); |
|
94
|
|
|
$this->xCondUso = $this->infEvento->getElementsByTagName("xCondUso")->item(0); |
|
95
|
|
|
$this->xCondUso = (empty($this->xCondUso) ? '' : $this->xCondUso->nodeValue); |
|
96
|
|
|
$this->xJust = $this->infEvento->getElementsByTagName("xJust")->item(0); |
|
97
|
|
|
$this->xJust = (empty($this->xJust) ? '' : $this->xJust->nodeValue); |
|
98
|
|
|
$this->dhEvento = $this->infEvento->getElementsByTagName("dhEvento")->item(0)->nodeValue; |
|
99
|
|
|
$this->cStat = $this->rinfEvento->getElementsByTagName("cStat")->item(0)->nodeValue; |
|
100
|
|
|
$this->xMotivo = $this->rinfEvento->getElementsByTagName("xMotivo")->item(0)->nodeValue; |
|
101
|
|
|
$this->CNPJDest = !empty($this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue) ? |
|
102
|
|
|
$this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue : ''; |
|
103
|
|
|
$this->CPFDest = !empty($this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue) ? |
|
104
|
|
|
$this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue : ''; |
|
105
|
|
|
$this->dhRegEvento = $this->rinfEvento->getElementsByTagName("dhRegEvento")->item(0)->nodeValue; |
|
106
|
|
|
$this->nProt = $this->rinfEvento->getElementsByTagName("nProt")->item(0)->nodeValue; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* monta |
|
112
|
|
|
* Esta função monta a DAEventoCTe conforme as informações fornecidas para a classe |
|
113
|
|
|
* durante sua construção. |
|
114
|
|
|
* A definição de margens e posições iniciais para a impressão são estabelecidas no |
|
115
|
|
|
* pelo conteúdo da funçao e podem ser modificados. |
|
116
|
|
|
* |
|
117
|
|
|
* @param string $logo base64 da logomarca |
|
118
|
|
|
* @return string O ID do evento extraido do arquivo XML |
|
119
|
|
|
*/ |
|
120
|
|
|
protected function monta( |
|
121
|
|
|
$logo = '' |
|
122
|
|
|
) { |
|
123
|
|
|
if (!empty($logo)) { |
|
124
|
|
|
$this->logomarca = $this->adjustImage($logo); |
|
125
|
|
|
} |
|
126
|
|
|
if (empty($this->orientacao)) { |
|
127
|
|
|
$this->orientacao = 'P'; |
|
128
|
|
|
} |
|
129
|
|
|
// margens do PDF |
|
130
|
|
|
$margSup = $this->margsup; |
|
131
|
|
|
$margEsq = $this->margesq; |
|
132
|
|
|
$margDir = $this->margesq; |
|
133
|
|
|
$this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
|
|
|
|
|
134
|
|
|
if ($this->orientacao == 'P') { |
|
135
|
|
|
// posição inicial do relatorio |
|
136
|
|
|
$xInic = 1; |
|
137
|
|
|
$yInic = 1; |
|
138
|
|
|
if ($this->papel == 'A4') { //A4 210x297mm |
|
139
|
|
|
$maxW = 210; |
|
140
|
|
|
$maxH = 297; |
|
141
|
|
|
} |
|
142
|
|
|
} else { |
|
143
|
|
|
// posição inicial do relatorio |
|
144
|
|
|
$xInic = 5; |
|
145
|
|
|
$yInic = 5; |
|
146
|
|
|
if ($papel == 'A4') { |
|
|
|
|
|
|
147
|
|
|
//A4 210x297mm |
|
148
|
|
|
$maxH = 210; |
|
149
|
|
|
$maxW = 297; |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
//largura imprimivel em mm |
|
153
|
|
|
$this->wPrint = $maxW - ($margEsq + $xInic); |
|
|
|
|
|
|
154
|
|
|
//comprimento imprimivel em mm |
|
155
|
|
|
$this->hPrint = $maxH - ($margSup + $yInic); |
|
|
|
|
|
|
156
|
|
|
// estabelece contagem de paginas |
|
157
|
|
|
$this->pdf->aliasNbPages(); |
|
158
|
|
|
// fixa as margens |
|
159
|
|
|
$this->pdf->setMargins($margEsq, $margSup, $margDir); |
|
160
|
|
|
$this->pdf->setDrawColor(0, 0, 0); |
|
161
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
|
162
|
|
|
// inicia o documento |
|
163
|
|
|
$this->pdf->open(); |
|
164
|
|
|
// adiciona a primeira página |
|
165
|
|
|
$this->pdf->addPage($this->orientacao, $this->papel); |
|
|
|
|
|
|
166
|
|
|
$this->pdf->setLineWidth(0.1); |
|
167
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
|
168
|
|
|
//montagem da página |
|
169
|
|
|
$pag = 1; |
|
170
|
|
|
$x = $xInic; |
|
171
|
|
|
$y = $yInic; |
|
172
|
|
|
//coloca o cabeçalho |
|
173
|
|
|
$y = $this->header($x, $y, $pag); |
|
174
|
|
|
//coloca os dados da CCe |
|
175
|
|
|
$y = $this->body($x, $y + 15); |
|
|
|
|
|
|
176
|
|
|
//coloca os dados da CCe |
|
177
|
|
|
$y = $this->footer($x, $y + $this->hPrint - 20); |
|
|
|
|
|
|
178
|
|
|
//retorna o ID do evento |
|
179
|
|
|
return $this->id; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* header |
|
184
|
|
|
* @param integer $x |
|
185
|
|
|
* @param integer $y |
|
186
|
|
|
* @param integer $pag |
|
187
|
|
|
* @return integer |
|
188
|
|
|
*/ |
|
189
|
|
|
private function header( |
|
190
|
|
|
$x, |
|
191
|
|
|
$y, |
|
192
|
|
|
$pag |
|
|
|
|
|
|
193
|
|
|
) { |
|
194
|
|
|
$oldX = $x; |
|
195
|
|
|
$oldY = $y; |
|
196
|
|
|
$maxW = $this->wPrint; |
|
197
|
|
|
//#################################################################################### |
|
198
|
|
|
//coluna esquerda identificação do emitente |
|
199
|
|
|
$w = round($maxW * 0.41, 0);// 80; |
|
200
|
|
|
if ($this->orientacao == 'P') { |
|
201
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'); |
|
202
|
|
|
} else { |
|
203
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'); |
|
204
|
|
|
} |
|
205
|
|
|
$w1 = $w; |
|
|
|
|
|
|
206
|
|
|
$h = 32; |
|
207
|
|
|
$oldY += $h; |
|
208
|
|
|
$this->pdf->textBox($x, $y, $w, $h); |
|
209
|
|
|
$texto = 'IDENTIFICAÇÃO DO EMITENTE'; |
|
210
|
|
|
$this->pdf->textBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
211
|
|
|
if (!empty($this->logomarca)) { |
|
212
|
|
|
$logoInfo = getimagesize($this->logomarca); |
|
213
|
|
|
//largura da imagem em mm |
|
214
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
|
215
|
|
|
//altura da imagem em mm |
|
216
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
|
217
|
|
|
if ($this->logoAlign == 'L') { |
|
218
|
|
|
$nImgW = round($w / 3, 0); |
|
219
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
220
|
|
|
$xImg = $x + 1; |
|
221
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
222
|
|
|
//estabelecer posições do texto |
|
223
|
|
|
$x1 = round($xImg + $nImgW + 1, 0); |
|
224
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
225
|
|
|
$tw = round(2 * $w / 3, 0); |
|
226
|
|
|
} |
|
227
|
|
|
if ($this->logoAlign == 'C') { |
|
228
|
|
|
$nImgH = round($h / 3, 0); |
|
229
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
|
230
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
|
231
|
|
|
$yImg = $y + 3; |
|
232
|
|
|
$x1 = $x; |
|
233
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
|
234
|
|
|
$tw = $w; |
|
235
|
|
|
} |
|
236
|
|
|
if ($this->logoAlign == 'R') { |
|
237
|
|
|
$nImgW = round($w / 3, 0); |
|
238
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
239
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
|
240
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
241
|
|
|
$x1 = $x; |
|
242
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
243
|
|
|
$tw = round(2 * $w / 3, 0); |
|
244
|
|
|
} |
|
245
|
|
|
$this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
|
|
246
|
|
|
} else { |
|
247
|
|
|
$x1 = $x; |
|
248
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
249
|
|
|
$tw = $w; |
|
250
|
|
|
} |
|
251
|
|
|
//Nome emitente |
|
252
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'); |
|
253
|
|
|
$texto = (isset($this->dadosEmitente['razao']) ? $this->dadosEmitente['razao'] : ''); |
|
254
|
|
|
$this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
255
|
|
|
//endereço |
|
256
|
|
|
$y1 = $y1 + 6; |
|
257
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => ''); |
|
258
|
|
|
$lgr = (isset($this->dadosEmitente['logradouro']) ? $this->dadosEmitente['logradouro'] : ''); |
|
259
|
|
|
$nro = (isset($this->dadosEmitente['numero']) ? $this->dadosEmitente['numero'] : ''); |
|
260
|
|
|
$cpl = (isset($this->dadosEmitente['complemento']) ? $this->dadosEmitente['complemento'] : ''); |
|
261
|
|
|
$bairro = (isset($this->dadosEmitente['bairro']) ? $this->dadosEmitente['bairro'] : ''); |
|
262
|
|
|
$CEP = (isset($this->dadosEmitente['CEP']) ? $this->dadosEmitente['CEP'] : ''); |
|
263
|
|
|
$CEP = $this->formatField($CEP, "#####-###"); |
|
264
|
|
|
$mun = (isset($this->dadosEmitente['municipio']) ? $this->dadosEmitente['municipio'] : ''); |
|
265
|
|
|
$UF = (isset($this->dadosEmitente['UF']) ? $this->dadosEmitente['UF'] : ''); |
|
266
|
|
|
$fone = (isset($this->dadosEmitente['telefone']) ? $this->dadosEmitente['telefone'] : ''); |
|
267
|
|
|
$email = (isset($this->dadosEmitente['email']) ? $this->dadosEmitente['email'] : ''); |
|
268
|
|
|
$foneLen = strlen($fone); |
|
269
|
|
|
if ($foneLen > 0) { |
|
270
|
|
|
$fone2 = substr($fone, 0, $foneLen - 4); |
|
271
|
|
|
$fone1 = substr($fone, 0, $foneLen - 8); |
|
272
|
|
|
$fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4); |
|
273
|
|
|
} else { |
|
274
|
|
|
$fone = ''; |
|
275
|
|
|
} |
|
276
|
|
|
if ($email != '') { |
|
277
|
|
|
$email = 'Email: ' . $email; |
|
278
|
|
|
} |
|
279
|
|
|
$texto = ""; |
|
280
|
|
|
$tmp_txt = trim(($lgr != '' ? "$lgr, " : '') . ($nro != 0 ? $nro : "SN") . ($cpl != '' ? " - $cpl" : '')); |
|
281
|
|
|
$tmp_txt = ($tmp_txt == 'SN' ? '' : $tmp_txt); |
|
282
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
283
|
|
|
$tmp_txt = trim($bairro . ($bairro != '' && $CEP != '' ? " - " : '') . $CEP); |
|
284
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
285
|
|
|
$tmp_txt = $mun; |
|
286
|
|
|
$tmp_txt .= ($tmp_txt != '' && $UF != '' ? " - " : '') . $UF; |
|
287
|
|
|
$tmp_txt .= ($tmp_txt != '' && $fone != '' ? " - " : '') . $fone; |
|
288
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
289
|
|
|
$tmp_txt = $email; |
|
290
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
291
|
|
|
$this->pdf->textBox($x1, $y1 - 2, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
292
|
|
|
//################################################## |
|
293
|
|
|
$w2 = round($maxW - $w, 0); |
|
294
|
|
|
$x += $w; |
|
295
|
|
|
$this->pdf->textBox($x, $y, $w2, $h); |
|
296
|
|
|
$y1 = $y + $h; |
|
297
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 16, 'style' => 'B'); |
|
298
|
|
|
if ($this->tpEvento == '110110') { |
|
299
|
|
|
$texto = 'Representação Gráfica de CCe'; |
|
300
|
|
|
} else { |
|
301
|
|
|
$texto = 'Representação Gráfica de Evento'; |
|
302
|
|
|
} |
|
303
|
|
|
$this->pdf->textBox($x, $y + 2, $w2, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
304
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I'); |
|
305
|
|
|
if ($this->tpEvento == '110110') { |
|
306
|
|
|
$texto = '(Carta de Correção Eletrônica)'; |
|
307
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
308
|
|
|
$texto = '(Cancelamento de CTe)'; |
|
309
|
|
|
} |
|
310
|
|
|
$this->pdf->textBox($x, $y + 7, $w2, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
311
|
|
|
$texto = 'ID do Evento: ' . $this->id; |
|
312
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
313
|
|
|
$this->pdf->textBox($x, $y + 15, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
314
|
|
|
$tsHora = $this->toTimestamp($this->dhEvento); |
|
315
|
|
|
$texto = 'Criado em : ' . date('d/m/Y H:i:s', $tsHora); |
|
316
|
|
|
$this->pdf->textBox($x, $y + 20, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
317
|
|
|
$tsHora = $this->toTimestamp($this->dhRegEvento); |
|
318
|
|
|
$texto = 'Prococolo: ' . $this->nProt . ' - Registrado na SEFAZ em: ' . date('d/m/Y H:i:s', $tsHora); |
|
319
|
|
|
$this->pdf->textBox($x, $y + 25, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
320
|
|
|
//#################################################### |
|
321
|
|
|
$x = $oldX; |
|
322
|
|
|
$this->pdf->textBox($x, $y1, $maxW, 40); |
|
323
|
|
|
$sY = $y1 + 40; |
|
324
|
|
|
if ($this->tpEvento == '110110') { |
|
325
|
|
|
$texto = 'De acordo com as determinações legais vigentes, vimos por meio ' |
|
326
|
|
|
. 'desta comunicar-lhe que o Conhecimento de Transporte, abaixo referenciado, ' |
|
327
|
|
|
. 'contêm irregularidades que estão destacadas e suas respectivas ' |
|
328
|
|
|
. 'correções, solicitamos que sejam aplicadas essas correções ao ' |
|
329
|
|
|
. 'executar seus lançamentos fiscais.'; |
|
330
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
331
|
|
|
$texto = 'De acordo com as determinações legais vigentes, vimos por meio ' |
|
332
|
|
|
. 'desta comunicar-lhe que o Conhecimento de Transporte, abaixo referenciado, está ' |
|
333
|
|
|
. 'cancelado, solicitamos que sejam aplicadas essas correções ao ' |
|
334
|
|
|
. 'executar seus lançamentos fiscais.'; |
|
335
|
|
|
} |
|
336
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
337
|
|
|
$this->pdf->textBox($x + 5, $y1, $maxW - 5, 20, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
338
|
|
|
//############################################ |
|
339
|
|
|
$x = $oldX; |
|
340
|
|
|
$y = $y1; |
|
341
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'); |
|
342
|
|
|
$numNF = substr($this->chCTe, 25, 9); |
|
343
|
|
|
$serie = substr($this->chCTe, 22, 3); |
|
344
|
|
|
$numNF = $this->formatField($numNF, "###.###.###"); |
|
345
|
|
|
$texto = "Conhecimento: " . $numNF . ' - Série: ' . $serie; |
|
346
|
|
|
$this->pdf->textBox($x + 2, $y + 19, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
347
|
|
|
$bW = 87; |
|
348
|
|
|
$bH = 15; |
|
349
|
|
|
$x = 55; |
|
350
|
|
|
$y = $y1 + 13; |
|
351
|
|
|
$w = $maxW; |
|
352
|
|
|
$this->pdf->setFillColor(0, 0, 0); |
|
353
|
|
|
$this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $this->chCTe, $bW, $bH); |
|
354
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
|
355
|
|
|
$y1 = $y + 2 + $bH; |
|
356
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => ''); |
|
357
|
|
|
$texto = $this->formatField($this->chCTe, $this->formatoChave); |
|
358
|
|
|
$this->pdf->textBox($x, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
359
|
|
|
$retVal = $sY + 2; |
|
360
|
|
|
if ($this->tpEvento == '110110') { |
|
361
|
|
|
$x = $oldX; |
|
362
|
|
|
$this->pdf->textBox($x, $sY, $maxW, 15); |
|
363
|
|
|
$texto = $this->xCondUso; |
|
364
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I'); |
|
365
|
|
|
$this->pdf->textBox($x + 2, $sY + 2, $maxW - 2, 15, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
366
|
|
|
$retVal = $sY + 2; |
|
367
|
|
|
} |
|
368
|
|
|
if ($this->tpAmb != 1) { |
|
369
|
|
|
$x = 10; |
|
370
|
|
|
if ($this->orientacao == 'P') { |
|
371
|
|
|
$y = round($this->hPrint * 2 / 3, 0); |
|
372
|
|
|
} else { |
|
373
|
|
|
$y = round($this->hPrint / 2, 0); |
|
374
|
|
|
} |
|
375
|
|
|
$h = 5; |
|
376
|
|
|
$w = $maxW - (2 * $x); |
|
377
|
|
|
$this->pdf->setTextColor(90, 90, 90); |
|
378
|
|
|
$texto = "SEM VALOR FISCAL"; |
|
379
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B'); |
|
380
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
381
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B'); |
|
382
|
|
|
$texto = "AMBIENTE DE HOMOLOGAÇÃO"; |
|
383
|
|
|
$this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
384
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
|
385
|
|
|
} |
|
386
|
|
|
return $retVal; |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
/** |
|
390
|
|
|
* body |
|
391
|
|
|
* @param integer $x |
|
392
|
|
|
* @param integer $y |
|
393
|
|
|
*/ |
|
394
|
|
|
private function body($x, $y) |
|
395
|
|
|
{ |
|
396
|
|
|
$maxW = $this->wPrint; |
|
397
|
|
|
if ($this->tpEvento == '110110') { |
|
398
|
|
|
$texto = 'CORREÇÕES A SEREM CONSIDERADAS'; |
|
399
|
|
|
} else { |
|
400
|
|
|
$texto = 'JUSTIFICATIVA DO CANCELAMENTO'; |
|
401
|
|
|
} |
|
402
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B'); |
|
403
|
|
|
$this->pdf->textBox($x, $y, $maxW, 5, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
404
|
|
|
$y += 5; |
|
405
|
|
|
$this->pdf->textBox($x, $y, $maxW, 190); |
|
406
|
|
|
if ($this->tpEvento == '110110') { |
|
407
|
|
|
$this->pdf->textBox($x, $y, $maxW = ($maxW / 5), 5, "Grupo", $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
408
|
|
|
$this->pdf->textBox($x = $maxW, $y, $maxW, 5, "Campo", $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
409
|
|
|
$this->pdf->textBox($x = ($maxW * 2), $y, $maxW, 5, "Número", $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
410
|
|
|
$this->pdf->textBox($x = ($maxW * 3), $y, ($this->wPrint - $x), 5, "Valor", $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
411
|
|
|
|
|
412
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 9, 'style' => ''); |
|
413
|
|
|
$i = 0; |
|
414
|
|
|
$numlinhas = 1; |
|
415
|
|
|
while ($i < $this->infCorrecao->length) { |
|
416
|
|
|
$x = 0; |
|
417
|
|
|
$y = $numlinhas == 1 ? ($y + 5) : ($y + (5 * $numlinhas)); |
|
418
|
|
|
$maxW = $this->wPrint; |
|
419
|
|
|
$grupo = $this->infCorrecao->item($i)->getElementsByTagName('grupoAlterado')->item(0)->nodeValue; |
|
420
|
|
|
$campo = $this->infCorrecao->item($i)->getElementsByTagName('campoAlterado')->item(0)->nodeValue; |
|
421
|
|
|
$numero = 1; |
|
422
|
|
|
if (!empty($this->infCorrecao->item($i)->getElementsByTagName('nroItemAlterado')->item(0))) { |
|
423
|
|
|
$numero =$this->infCorrecao->item($i)->getElementsByTagName('nroItemAlterado')->item(0)->nodeValue; |
|
424
|
|
|
} |
|
425
|
|
|
$valor = $this->infCorrecao->item($i)->getElementsByTagName('valorAlterado')->item(0)->nodeValue; |
|
426
|
|
|
|
|
427
|
|
|
$i++; |
|
428
|
|
|
$this->pdf->textBox($x, $y, $maxW = ($maxW / 5), 5, $grupo, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
429
|
|
|
$this->pdf->textBox($x = $maxW, $y, $maxW, 5, $campo, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
430
|
|
|
$this->pdf->textBox($x = ($maxW * 2), $y, $maxW, 5, $numero, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
431
|
|
|
$this->pdf->textBox($x = ($maxW * 3), $y, ($this->wPrint - $x), 5, $valor, $aFont, 'T', 'C', 0); |
|
|
|
|
|
|
432
|
|
|
} |
|
433
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
434
|
|
|
$texto = $this->xJust; |
|
435
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B'); |
|
436
|
|
|
$this->pdf->textBox($x + 2, $y + 2, $maxW - 2, 150, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
437
|
|
|
} |
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
/** |
|
441
|
|
|
* footer |
|
442
|
|
|
* @param integer $x |
|
443
|
|
|
* @param integer $y |
|
444
|
|
|
*/ |
|
445
|
|
|
private function footer($x, $y) |
|
446
|
|
|
{ |
|
447
|
|
|
$w = $this->wPrint; |
|
448
|
|
|
if ($this->tpEvento == '110110') { |
|
449
|
|
|
$texto = "Este documento é uma representação gráfica da CCe e foi " |
|
450
|
|
|
. "impresso apenas para sua informação e não possue validade fiscal." |
|
451
|
|
|
. "\n A CCe deve ser recebida e mantida em arquivo eletrônico XML e " |
|
452
|
|
|
. "pode ser consultada através dos Portais das SEFAZ."; |
|
453
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
454
|
|
|
$texto = "Este documento é uma representação gráfica do evento de CTe e foi " |
|
455
|
|
|
. "impresso apenas para sua informação e não possue validade fiscal." |
|
456
|
|
|
. "\n O Evento deve ser recebido e mantido em arquivo eletrônico XML e " |
|
457
|
|
|
. "pode ser consultada através dos Portais das SEFAZ."; |
|
458
|
|
|
} |
|
459
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'I'); |
|
460
|
|
|
$this->pdf->textBox($x, $y, $w, 20, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
461
|
|
|
$y = $this->hPrint - 4; |
|
462
|
|
|
$texto = "Impresso em " . date('d/m/Y H:i:s') . ' ' . $this->creditos; |
|
463
|
|
|
$w = $this->wPrint - 4; |
|
464
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'); |
|
465
|
|
|
$this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
466
|
|
|
$texto = $this->powered ? "Powered by NFePHP®" : ''; |
|
467
|
|
|
$aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I'); |
|
468
|
|
|
$this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org'); |
|
|
|
|
|
|
469
|
|
|
} |
|
470
|
|
|
} |
|
471
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.