|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\DA\NFe; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Esta classe gera a representação em PDF de um evento de NFe |
|
7
|
|
|
* NOTA: Esse documento NÃO É 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 $chNFe; |
|
26
|
|
|
|
|
27
|
|
|
protected $yDados = 0; |
|
28
|
|
|
protected $dadosEmitente = array(); |
|
29
|
|
|
protected $xml; |
|
30
|
|
|
protected $errMsg = ''; |
|
31
|
|
|
protected $errStatus = false; |
|
32
|
|
|
protected $version = '0.1.4'; |
|
33
|
|
|
protected $wCanhoto; |
|
34
|
|
|
protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####"; |
|
35
|
|
|
protected $id; |
|
36
|
|
|
protected $tpAmb; |
|
37
|
|
|
protected $cOrgao; |
|
38
|
|
|
protected $xCorrecao; |
|
39
|
|
|
protected $xCondUso; |
|
40
|
|
|
protected $dhEvento; |
|
41
|
|
|
protected $cStat; |
|
42
|
|
|
protected $xMotivo; |
|
43
|
|
|
protected $xJust; |
|
44
|
|
|
protected $CNPJDest = ''; |
|
45
|
|
|
protected $CPFDest = ''; |
|
46
|
|
|
protected $dhRegEvento; |
|
47
|
|
|
protected $nProt; |
|
48
|
|
|
protected $tpEvento; |
|
49
|
|
|
|
|
50
|
|
|
private $dom; |
|
51
|
|
|
private $procEventoNFe; |
|
52
|
|
|
private $evento; |
|
53
|
|
|
private $infEvento; |
|
54
|
|
|
private $retEvento; |
|
55
|
|
|
private $rinfEvento; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* __construct |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $xml Arquivo XML (diretório ou string) |
|
61
|
|
|
* @param array $dadosEmitente Dados do endereço do emitente |
|
62
|
|
|
*/ |
|
63
|
|
|
public function __construct($xml, $dadosEmitente) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->dadosEmitente = $dadosEmitente; |
|
66
|
|
|
$this->debugMode(); |
|
67
|
|
|
$this->loadDoc($xml); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Ativa ou desativa o modo debug |
|
72
|
|
|
* @param bool $activate |
|
73
|
|
|
* @return bool |
|
74
|
|
|
*/ |
|
75
|
|
|
public function debugMode($activate = null) |
|
76
|
|
|
{ |
|
77
|
|
|
if (isset($activate) && is_bool($activate)) { |
|
78
|
|
|
$this->debugmode = $activate; |
|
79
|
|
|
} |
|
80
|
|
|
if ($this->debugmode) { |
|
81
|
|
|
//ativar modo debug |
|
82
|
|
|
error_reporting(E_ALL); |
|
83
|
|
|
ini_set('display_errors', 'On'); |
|
84
|
|
|
} else { |
|
85
|
|
|
//desativar modo debug |
|
86
|
|
|
error_reporting(0); |
|
87
|
|
|
ini_set('display_errors', 'Off'); |
|
88
|
|
|
} |
|
89
|
|
|
return $this->debugmode; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Dados brutos do PDF |
|
94
|
|
|
* @return string |
|
95
|
|
|
*/ |
|
96
|
|
|
public function render( |
|
97
|
|
|
$logo = null, |
|
98
|
|
|
$orientacao = 'P', |
|
99
|
|
|
$papel = 'A4', |
|
100
|
|
|
$logoAlign = 'C' |
|
101
|
|
|
) { |
|
102
|
|
|
if (empty($this->pdf)) { |
|
103
|
|
|
$this->monta($logo, $orientacao, $papel, $logoAlign); |
|
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
return $this->pdf->getPdf(); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
protected function loadDoc($xml) |
|
109
|
|
|
{ |
|
110
|
|
|
$this->dom = new Dom(); |
|
111
|
|
|
$this->dom->loadXML($xml); |
|
112
|
|
|
$this->procEventoNFe = $this->dom->getElementsByTagName("procEventoNFe")->item(0); |
|
113
|
|
|
$this->evento = $this->dom->getElementsByTagName("evento")->item(0); |
|
114
|
|
|
$this->infEvento = $this->evento->getElementsByTagName("infEvento")->item(0); |
|
115
|
|
|
$this->retEvento = $this->dom->getElementsByTagName("retEvento")->item(0); |
|
116
|
|
|
$this->rinfEvento = $this->retEvento->getElementsByTagName("infEvento")->item(0); |
|
117
|
|
|
$this->tpEvento = $this->infEvento->getElementsByTagName("tpEvento")->item(0)->nodeValue; |
|
118
|
|
|
if (!in_array($this->tpEvento, ['110110','110111'])) { |
|
119
|
|
|
$this->errMsg = 'Evento não implementado ' . $tpEvento . ' !!'; |
|
|
|
|
|
|
120
|
|
|
$this->errStatus = true; |
|
121
|
|
|
return false; |
|
122
|
|
|
} |
|
123
|
|
|
$this->id = str_replace('ID', '', $this->infEvento->getAttribute("Id")); |
|
124
|
|
|
$this->chNFe = $this->infEvento->getElementsByTagName("chNFe")->item(0)->nodeValue; |
|
125
|
|
|
$this->dadosEmitente['CNPJ'] = $this->infEvento->getElementsByTagName("CNPJ")->item(0)->nodeValue; |
|
126
|
|
|
$this->tpAmb = $this->infEvento->getElementsByTagName("tpAmb")->item(0)->nodeValue; |
|
127
|
|
|
$this->cOrgao = $this->infEvento->getElementsByTagName("cOrgao")->item(0)->nodeValue; |
|
128
|
|
|
$this->xCorrecao = $this->infEvento->getElementsByTagName("xCorrecao")->item(0); |
|
129
|
|
|
$this->xCorrecao = (empty($this->xCorrecao) ? '' : $this->xCorrecao->nodeValue); |
|
130
|
|
|
$this->xCondUso = $this->infEvento->getElementsByTagName("xCondUso")->item(0); |
|
131
|
|
|
$this->xCondUso = (empty($this->xCondUso) ? '' : $this->xCondUso->nodeValue); |
|
132
|
|
|
$this->xJust = $this->infEvento->getElementsByTagName("xJust")->item(0); |
|
133
|
|
|
$this->xJust = (empty($this->xJust) ? '' : $this->xJust->nodeValue); |
|
134
|
|
|
$this->dhEvento = $this->infEvento->getElementsByTagName("dhEvento")->item(0)->nodeValue; |
|
135
|
|
|
$this->cStat = $this->rinfEvento->getElementsByTagName("cStat")->item(0)->nodeValue; |
|
136
|
|
|
$this->xMotivo = $this->rinfEvento->getElementsByTagName("xMotivo")->item(0)->nodeValue; |
|
137
|
|
|
$this->CNPJDest = !empty($this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue) ? |
|
138
|
|
|
$this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue : |
|
139
|
|
|
''; |
|
140
|
|
|
$this->CPFDest = !empty($this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue) ? |
|
141
|
|
|
$this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue : |
|
142
|
|
|
''; |
|
143
|
|
|
$this->dhRegEvento = $this->rinfEvento->getElementsByTagName("dhRegEvento")->item(0)->nodeValue; |
|
144
|
|
|
$this->nProt = $this->rinfEvento->getElementsByTagName("nProt")->item(0)->nodeValue; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* monta |
|
149
|
|
|
* |
|
150
|
|
|
* Esta função monta a DaEventoNFe conforme as informações fornecidas para a classe |
|
151
|
|
|
* durante sua construção. |
|
152
|
|
|
* A definição de margens e posições iniciais para a impressão são estabelecidas no |
|
153
|
|
|
* pelo conteúdo da funçao e podem ser modificados. |
|
154
|
|
|
* |
|
155
|
|
|
* @param string $logo |
|
156
|
|
|
* @return string O ID do evento extraido do arquivo XML |
|
157
|
|
|
*/ |
|
158
|
|
|
protected function monta( |
|
159
|
|
|
$logo = '' |
|
160
|
|
|
) { |
|
161
|
|
|
if (!empty($logo)) { |
|
162
|
|
|
$this->logomarca = $this->adjustImage($logo); |
|
163
|
|
|
} |
|
164
|
|
|
if (empty($this->orientacao)) { |
|
165
|
|
|
$this->orientacao = 'P'; |
|
166
|
|
|
} |
|
167
|
|
|
$this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
|
|
|
|
|
168
|
|
|
if ($this->orientacao == 'P') { |
|
169
|
|
|
// margens do PDF |
|
170
|
|
|
$margSup = 2; |
|
171
|
|
|
$margEsq = 2; |
|
172
|
|
|
$margDir = 2; |
|
173
|
|
|
// posição inicial do relatorio |
|
174
|
|
|
$xInic = 1; |
|
175
|
|
|
$yInic = 1; |
|
176
|
|
|
if ($this->papel == 'A4') { // A4 210x297mm |
|
177
|
|
|
$maxW = 210; |
|
178
|
|
|
$maxH = 297; |
|
179
|
|
|
} |
|
180
|
|
|
} else { |
|
181
|
|
|
// margens do PDF |
|
182
|
|
|
$margSup = 3; |
|
183
|
|
|
$margEsq = 3; |
|
184
|
|
|
$margDir = 3; |
|
185
|
|
|
// posição inicial do relatorio |
|
186
|
|
|
$xInic = 5; |
|
187
|
|
|
$yInic = 5; |
|
188
|
|
|
if ($papel == 'A4') { // A4 210x297mm |
|
|
|
|
|
|
189
|
|
|
$maxH = 210; |
|
190
|
|
|
$maxW = 297; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
// largura imprimivel em mm |
|
194
|
|
|
$this->wPrint = $maxW - ($margEsq + $xInic); |
|
|
|
|
|
|
195
|
|
|
// comprimento imprimivel em mm |
|
196
|
|
|
$this->hPrint = $maxH - ($margSup + $yInic); |
|
|
|
|
|
|
197
|
|
|
// estabelece contagem de paginas |
|
198
|
|
|
$this->pdf->aliasNbPages(); |
|
199
|
|
|
// fixa as margens |
|
200
|
|
|
$this->pdf->setMargins($margEsq, $margSup, $margDir); |
|
201
|
|
|
$this->pdf->setDrawColor(0, 0, 0); |
|
202
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
|
203
|
|
|
// inicia o documento |
|
204
|
|
|
$this->pdf->open(); |
|
205
|
|
|
// adiciona a primeira página |
|
206
|
|
|
$this->pdf->addPage($this->orientacao, $this->papel); |
|
|
|
|
|
|
207
|
|
|
$this->pdf->setLineWidth(0.1); |
|
208
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
|
209
|
|
|
// montagem da página |
|
210
|
|
|
$pag = 1; |
|
211
|
|
|
$x = $xInic; |
|
212
|
|
|
$y = $yInic; |
|
213
|
|
|
// coloca o cabeçalho |
|
214
|
|
|
$y = $this->header($x, $y, $pag); |
|
215
|
|
|
// coloca os dados da CCe |
|
216
|
|
|
$y = $this->body($x, $y + 15); |
|
|
|
|
|
|
217
|
|
|
// coloca os dados da CCe |
|
218
|
|
|
$y = $this->footer($x, $y + $this->hPrint - 20); |
|
|
|
|
|
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* header |
|
223
|
|
|
* @param number $x |
|
224
|
|
|
* @param number $y |
|
225
|
|
|
* @param number $pag |
|
226
|
|
|
* @return number |
|
227
|
|
|
*/ |
|
228
|
|
|
private function header($x, $y, $pag) |
|
|
|
|
|
|
229
|
|
|
{ |
|
230
|
|
|
$oldX = $x; |
|
231
|
|
|
$oldY = $y; |
|
232
|
|
|
$maxW = $this->wPrint; |
|
233
|
|
|
// ###################################################################### |
|
234
|
|
|
// coluna esquerda identificação do emitente |
|
235
|
|
|
$w = round($maxW * 0.41, 0); // 80; |
|
236
|
|
|
if ($this->orientacao == 'P') { |
|
237
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I']; |
|
238
|
|
|
} else { |
|
239
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 8,'style' => 'B']; |
|
240
|
|
|
} |
|
241
|
|
|
$w1 = $w; |
|
|
|
|
|
|
242
|
|
|
$h = 32; |
|
243
|
|
|
$oldY += $h; |
|
244
|
|
|
$this->pdf->textBox($x, $y, $w, $h); |
|
245
|
|
|
$texto = 'IDENTIFICAÇÃO DO EMITENTE'; |
|
246
|
|
|
$this->pdf->textBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
247
|
|
|
if (!empty($this->logomarca)) { |
|
248
|
|
|
$logoInfo = getimagesize($this->logomarca); |
|
249
|
|
|
// largura da imagem em mm |
|
250
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
|
251
|
|
|
// altura da imagem em mm |
|
252
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
|
253
|
|
|
if ($this->logoAlign == 'L') { |
|
254
|
|
|
$nImgW = round($w / 3, 0); |
|
255
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
256
|
|
|
$xImg = $x + 1; |
|
257
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
258
|
|
|
// estabelecer posições do texto |
|
259
|
|
|
$x1 = round($xImg + $nImgW + 1, 0); |
|
260
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
261
|
|
|
$tw = round(2 * $w / 3, 0); |
|
262
|
|
|
} |
|
263
|
|
|
if ($this->logoAlign == 'C') { |
|
264
|
|
|
$nImgH = round($h / 3, 0); |
|
265
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
|
266
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
|
267
|
|
|
$yImg = $y + 3; |
|
268
|
|
|
$x1 = $x; |
|
269
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
|
270
|
|
|
$tw = $w; |
|
271
|
|
|
} |
|
272
|
|
|
if ($this->logoAlign == 'R') { |
|
273
|
|
|
$nImgW = round($w / 3, 0); |
|
274
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
275
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
|
276
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
277
|
|
|
$x1 = $x; |
|
278
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
279
|
|
|
$tw = round(2 * $w / 3, 0); |
|
280
|
|
|
} |
|
281
|
|
|
$type = (substr($this->logomarca, 0, 7) === 'data://') ? 'jpg' : null; |
|
|
|
|
|
|
282
|
|
|
$this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
|
|
283
|
|
|
} else { |
|
284
|
|
|
$x1 = $x; |
|
285
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
286
|
|
|
$tw = $w; |
|
287
|
|
|
} |
|
288
|
|
|
// Nome emitente |
|
289
|
|
|
$aFont = array( |
|
290
|
|
|
'font' => $this->fontePadrao, |
|
291
|
|
|
'size' => 12, |
|
292
|
|
|
'style' => 'B' |
|
293
|
|
|
); |
|
294
|
|
|
$texto = (isset($this->dadosEmitente['razao']) ? $this->dadosEmitente['razao'] : ''); |
|
295
|
|
|
$this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
296
|
|
|
// endereço |
|
297
|
|
|
$y1 = $y1 + 6; |
|
298
|
|
|
$aFont = array( |
|
299
|
|
|
'font' => $this->fontePadrao, |
|
300
|
|
|
'size' => 8, |
|
301
|
|
|
'style' => '' |
|
302
|
|
|
); |
|
303
|
|
|
$lgr = (isset($this->dadosEmitente['logradouro']) ? $this->dadosEmitente['logradouro'] : ''); |
|
304
|
|
|
$nro = (isset($this->dadosEmitente['numero']) ? $this->dadosEmitente['numero'] : ''); |
|
305
|
|
|
$cpl = (isset($this->dadosEmitente['complemento']) ? $this->dadosEmitente['complemento'] : ''); |
|
306
|
|
|
$bairro = (isset($this->dadosEmitente['bairro']) ? $this->dadosEmitente['bairro'] : ''); |
|
307
|
|
|
$CEP = (isset($this->dadosEmitente['CEP']) ? $this->dadosEmitente['CEP'] : ''); |
|
308
|
|
|
$CEP = $this->formatField($CEP, "#####-###"); |
|
309
|
|
|
$mun = (isset($this->dadosEmitente['municipio']) ? $this->dadosEmitente['municipio'] : ''); |
|
310
|
|
|
$UF = (isset($this->dadosEmitente['UF']) ? $this->dadosEmitente['UF'] : ''); |
|
311
|
|
|
$fone = (isset($this->dadosEmitente['telefone']) ? $this->dadosEmitente['telefone'] : ''); |
|
312
|
|
|
$email = (isset($this->dadosEmitente['email']) ? $this->dadosEmitente['email'] : ''); |
|
313
|
|
|
$foneLen = strlen($fone); |
|
314
|
|
|
if ($foneLen > 0) { |
|
315
|
|
|
$fone2 = substr($fone, 0, $foneLen - 4); |
|
316
|
|
|
$fone1 = substr($fone, 0, $foneLen - 8); |
|
317
|
|
|
$fone = '(' . $fone1 . ') ' . substr($fone2, - 4) . '-' . substr($fone, - 4); |
|
318
|
|
|
} else { |
|
319
|
|
|
$fone = ''; |
|
320
|
|
|
} |
|
321
|
|
|
if ($email != '') { |
|
322
|
|
|
$email = 'Email: ' . $email; |
|
323
|
|
|
} |
|
324
|
|
|
$texto = ""; |
|
325
|
|
|
$tmp_txt = trim(($lgr != '' ? "$lgr, " : '') . ($nro != 0 ? $nro : "SN") . ($cpl != '' ? " - $cpl" : '')); |
|
326
|
|
|
$tmp_txt = ($tmp_txt == 'SN' ? '' : $tmp_txt); |
|
327
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
328
|
|
|
$tmp_txt = trim($bairro . ($bairro != '' && $CEP != '' ? " - " : '') . $CEP); |
|
329
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
330
|
|
|
$tmp_txt = $mun; |
|
331
|
|
|
$tmp_txt .= ($tmp_txt != '' && $UF != '' ? " - " : '') . $UF; |
|
332
|
|
|
$tmp_txt .= ($tmp_txt != '' && $fone != '' ? " " : '') . $fone; |
|
333
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
334
|
|
|
$tmp_txt = $email; |
|
335
|
|
|
$texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt; |
|
336
|
|
|
$this->pdf->textBox($x1, $y1 - 2, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
337
|
|
|
// ################################################## |
|
338
|
|
|
$w2 = round($maxW - $w, 0); |
|
339
|
|
|
$x += $w; |
|
340
|
|
|
$this->pdf->textBox($x, $y, $w2, $h); |
|
341
|
|
|
$y1 = $y + $h; |
|
342
|
|
|
$aFont = array( |
|
343
|
|
|
'font' => $this->fontePadrao, |
|
344
|
|
|
'size' => 16, |
|
345
|
|
|
'style' => 'B' |
|
346
|
|
|
); |
|
347
|
|
|
if ($this->tpEvento == '110110') { |
|
348
|
|
|
$texto = 'Representação Gráfica de CC-e'; |
|
349
|
|
|
} else { |
|
350
|
|
|
$texto = 'Representação Gráfica de Evento'; |
|
351
|
|
|
} |
|
352
|
|
|
$this->pdf->textBox($x, $y + 2, $w2, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
353
|
|
|
$aFont = array( |
|
354
|
|
|
'font' => $this->fontePadrao, |
|
355
|
|
|
'size' => 12, |
|
356
|
|
|
'style' => 'I' |
|
357
|
|
|
); |
|
358
|
|
|
if ($this->tpEvento == '110110') { |
|
359
|
|
|
$texto = '(Carta de Correção Eletrônica)'; |
|
360
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
361
|
|
|
$texto = '(Cancelamento de NFe)'; |
|
362
|
|
|
} |
|
363
|
|
|
$this->pdf->textBox($x, $y + 7, $w2, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
364
|
|
|
$texto = 'ID do Evento: ' . $this->id; |
|
365
|
|
|
$aFont = array( |
|
366
|
|
|
'font' => $this->fontePadrao, |
|
367
|
|
|
'size' => 10, |
|
368
|
|
|
'style' => '' |
|
369
|
|
|
); |
|
370
|
|
|
$this->pdf->textBox($x, $y + 15, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
371
|
|
|
$tsHora = $this->toTimestamp($this->dhEvento); |
|
372
|
|
|
$texto = 'Criado em : ' . date('d/m/Y H:i:s', $tsHora); |
|
373
|
|
|
$this->pdf->textBox($x, $y + 20, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
374
|
|
|
$tsHora = $this->toTimestamp($this->dhRegEvento); |
|
375
|
|
|
$texto = 'Prococolo: ' . $this->nProt . ' - Registrado na SEFAZ em: ' . date('d/m/Y H:i:s', $tsHora); |
|
376
|
|
|
$this->pdf->textBox($x, $y + 25, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
377
|
|
|
// #################################################### |
|
378
|
|
|
$x = $oldX; |
|
379
|
|
|
$this->pdf->textBox($x, $y1, $maxW, 40); |
|
380
|
|
|
$sY = $y1 + 40; |
|
381
|
|
|
if ($this->tpEvento == '110110') { |
|
382
|
|
|
$texto = 'De acordo com as determinações legais vigentes, vimos por meio desta ' |
|
383
|
|
|
. 'comunicar-lhe que a Nota Fiscal, abaixo referenciada, contém irregularidades' |
|
384
|
|
|
. ' que estão destacadas e suas respectivas correções, solicitamos que sejam aplicadas ' |
|
385
|
|
|
. 'essas correções ao executar seus lançamentos fiscais.'; |
|
386
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
387
|
|
|
$texto = 'De acordo com as determinações legais vigentes, ' |
|
388
|
|
|
. 'vimos por meio desta comunicar-lhe que a Nota Fiscal, ' |
|
389
|
|
|
. 'abaixo referenciada, está cancelada, solicitamos que sejam ' |
|
390
|
|
|
. 'aplicadas essas correções ao executar seus lançamentos fiscais.'; |
|
391
|
|
|
} |
|
392
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => '']; |
|
393
|
|
|
$this->pdf->textBox($x + 5, $y1, $maxW - 5, 20, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
394
|
|
|
// ############################################ |
|
395
|
|
|
$x = $oldX; |
|
396
|
|
|
$y = $y1; |
|
397
|
|
|
if ($this->CNPJDest != '') { |
|
398
|
|
|
$texto = 'CNPJ do Destinatário: ' . $this->formatField($this->CNPJDest, "##.###.###/####-##"); |
|
399
|
|
|
} |
|
400
|
|
|
if ($this->CPFDest != '') { |
|
401
|
|
|
$texto = 'CPF do Destinatário: ' . $this->formatField($this->CPFDest, "###.###.###-##"); |
|
402
|
|
|
} |
|
403
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 12,'style' => 'B']; |
|
404
|
|
|
$this->pdf->textBox($x + 2, $y + 13, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
405
|
|
|
$numNF = substr($this->chNFe, 25, 9); |
|
406
|
|
|
$serie = substr($this->chNFe, 22, 3); |
|
407
|
|
|
$numNF = $this->formatField($numNF, "###.###.###"); |
|
408
|
|
|
$texto = "Nota Fiscal: " . $numNF . ' - Série: ' . $serie; |
|
409
|
|
|
$this->pdf->textBox($x + 2, $y + 19, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
410
|
|
|
$bW = 87; |
|
411
|
|
|
$bH = 15; |
|
412
|
|
|
$x = 55; |
|
413
|
|
|
$y = $y1 + 13; |
|
414
|
|
|
$w = $maxW; |
|
415
|
|
|
$this->pdf->setFillColor(0, 0, 0); |
|
416
|
|
|
$this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $this->chNFe, $bW, $bH); |
|
417
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
|
418
|
|
|
$y1 = $y + 2 + $bH; |
|
419
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => '']; |
|
420
|
|
|
$texto = $this->formatField($this->chNFe, $this->formatoChave); |
|
421
|
|
|
$this->pdf->textBox($x, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
422
|
|
|
$retVal = $sY + 2; |
|
423
|
|
|
if ($this->tpEvento == '110110') { |
|
424
|
|
|
$x = $oldX; |
|
425
|
|
|
$this->pdf->textBox($x, $sY, $maxW, 15); |
|
426
|
|
|
$texto = $this->xCondUso; |
|
427
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 8,'style' => 'I']; |
|
428
|
|
|
$this->pdf->textBox($x + 2, $sY + 2, $maxW - 2, 15, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
429
|
|
|
$retVal = $sY + 2; |
|
430
|
|
|
} |
|
431
|
|
|
// indicar sem valor |
|
432
|
|
|
if ($this->tpAmb != 1) { |
|
433
|
|
|
$x = 10; |
|
434
|
|
|
if ($this->orientacao == 'P') { |
|
435
|
|
|
$y = round($this->hPrint * 2 / 3, 0); |
|
436
|
|
|
} else { |
|
437
|
|
|
$y = round($this->hPrint / 2, 0); |
|
438
|
|
|
} |
|
439
|
|
|
$h = 5; |
|
440
|
|
|
$w = $maxW - (2 * $x); |
|
441
|
|
|
$this->pdf->setTextColor(90, 90, 90); |
|
442
|
|
|
$texto = "SEM VALOR FISCAL"; |
|
443
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 48,'style' => 'B']; |
|
444
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
445
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 30,'style' => 'B']; |
|
446
|
|
|
$texto = "AMBIENTE DE HOMOLOGAÇÃO"; |
|
447
|
|
|
$this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
448
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
|
449
|
|
|
} |
|
450
|
|
|
return $retVal; |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
/** |
|
454
|
|
|
* body |
|
455
|
|
|
* |
|
456
|
|
|
* @param number $x |
|
457
|
|
|
* @param number $y |
|
458
|
|
|
*/ |
|
459
|
|
|
private function body($x, $y) |
|
460
|
|
|
{ |
|
461
|
|
|
$maxW = $this->wPrint; |
|
462
|
|
|
if ($this->tpEvento == '110110') { |
|
463
|
|
|
$texto = 'CORREÇÕES A SEREM CONSIDERADAS'; |
|
464
|
|
|
} else { |
|
465
|
|
|
$texto = 'JUSTIFICATIVA DO CANCELAMENTO'; |
|
466
|
|
|
} |
|
467
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => 'B']; |
|
468
|
|
|
$this->pdf->textBox($x, $y, $maxW, 5, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
469
|
|
|
$y += 5; |
|
470
|
|
|
$this->pdf->textBox($x, $y, $maxW, 190); |
|
471
|
|
|
if ($this->tpEvento == '110110') { |
|
472
|
|
|
$texto = $this->xCorrecao; |
|
473
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
474
|
|
|
$texto = $this->xJust; |
|
475
|
|
|
} |
|
476
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 12,'style' => 'B']; |
|
477
|
|
|
$this->pdf->textBox($x + 2, $y + 2, $maxW - 2, 150, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
/** |
|
481
|
|
|
* footer |
|
482
|
|
|
* |
|
483
|
|
|
* @param number $x |
|
484
|
|
|
* @param number $y |
|
485
|
|
|
*/ |
|
486
|
|
|
private function footer($x, $y) |
|
487
|
|
|
{ |
|
488
|
|
|
$w = $this->wPrint; |
|
489
|
|
|
if ($this->tpEvento == '110110') { |
|
490
|
|
|
$texto = "Este documento é uma representação gráfica da CC-e " |
|
491
|
|
|
. "e foi impresso apenas para sua informação e não possui validade " |
|
492
|
|
|
. "fiscal.\n A CC-e deve ser recebida e mantida em arquivo eletrônico XML " |
|
493
|
|
|
. "e pode ser consultada através dos Portais das SEFAZ."; |
|
494
|
|
|
} elseif ($this->tpEvento == '110111') { |
|
495
|
|
|
$texto = "Este documento é uma representação gráfica do evento de NFe e " |
|
496
|
|
|
. "foi impresso apenas para sua informação e não possui validade " |
|
497
|
|
|
. "fiscal.\n O Evento deve ser recebido e mantido em arquivo " |
|
498
|
|
|
. "eletrônico XML e pode ser consultada através dos Portais " |
|
499
|
|
|
. "das SEFAZ."; |
|
500
|
|
|
} |
|
501
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => 'I']; |
|
502
|
|
|
$this->pdf->textBox($x, $y, $w, 20, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
503
|
|
|
$y = $this->hPrint - 4; |
|
504
|
|
|
$texto = "Impresso em " . date('d/m/Y H:i:s') . ' ' . $this->creditos; |
|
505
|
|
|
$w = $this->wPrint - 4; |
|
506
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I']; |
|
507
|
|
|
$this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
508
|
|
|
$texto = $this->powered ? "Powered by NFePHP®" : ''; |
|
509
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I']; |
|
510
|
|
|
$this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org'); |
|
|
|
|
|
|
511
|
|
|
} |
|
512
|
|
|
} |
|
513
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.