|
1
|
|
|
<?php |
|
2
|
|
|
namespace NFePHP\DA\NFe; |
|
3
|
|
|
|
|
4
|
|
|
use InvalidArgumentException; |
|
5
|
|
|
use NFePHP\DA\Legacy\Dom; |
|
6
|
|
|
use NFePHP\DA\Legacy\Pdf; |
|
7
|
|
|
use \NFePHP\DA\Common\DaCommon; |
|
8
|
|
|
|
|
9
|
|
|
class Danfe extends DaCommon |
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Posição |
|
14
|
|
|
* |
|
15
|
|
|
* @var float |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $yDados = 0; |
|
18
|
|
|
/** |
|
19
|
|
|
* Parâmetro para exibir ou ocultar os valores do PIS/COFINS. |
|
20
|
|
|
* |
|
21
|
|
|
* @var boolean |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $qCanhoto = 1; |
|
24
|
|
|
/** |
|
25
|
|
|
* Define a exbição dos valores de PIS e Cofins |
|
26
|
|
|
* |
|
27
|
|
|
* @var bool |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $exibirPIS = true; |
|
30
|
|
|
/** |
|
31
|
|
|
* Parâmetro para exibir ou ocultar os valores do ICMS Interestadual e Valor Total dos Impostos. |
|
32
|
|
|
* |
|
33
|
|
|
* @var boolean |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $exibirIcmsInterestadual = true; |
|
36
|
|
|
/** |
|
37
|
|
|
* Parâmetro para exibir ou ocultar o texto sobre valor aproximado dos tributos. |
|
38
|
|
|
* |
|
39
|
|
|
* @var boolean |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $exibirValorTributos = true; |
|
42
|
|
|
/** |
|
43
|
|
|
* Parâmetro para exibir ou ocultar o texto adicional sobre a forma de pagamento |
|
44
|
|
|
* e as informações de fatura/duplicata. |
|
45
|
|
|
* |
|
46
|
|
|
* @var boolean |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $exibirTextoFatura = false; |
|
49
|
|
|
/** |
|
50
|
|
|
* Parâmetro do controle se deve concatenar automaticamente informações complementares |
|
51
|
|
|
* na descrição do produto, como por exemplo, informações sobre impostos. |
|
52
|
|
|
* |
|
53
|
|
|
* @var boolean |
|
54
|
|
|
*/ |
|
55
|
|
|
public $descProdInfoComplemento = true; |
|
56
|
|
|
/** |
|
57
|
|
|
*`Parâmetro que habilita a geração de automatica de informações |
|
58
|
|
|
* |
|
59
|
|
|
* @var boolean |
|
60
|
|
|
*/ |
|
61
|
|
|
public $gerarInformacoesAutomaticas = true; |
|
62
|
|
|
/** |
|
63
|
|
|
* Parâmetro do controle se deve gerar quebras de linha com "\n" a partir de ";" na descrição do produto. |
|
64
|
|
|
* |
|
65
|
|
|
* @var boolean |
|
66
|
|
|
*/ |
|
67
|
|
|
protected $descProdQuebraLinha = true; |
|
68
|
|
|
/** |
|
69
|
|
|
* XML NFe |
|
70
|
|
|
* |
|
71
|
|
|
* @var string |
|
72
|
|
|
*/ |
|
73
|
|
|
protected $xml; |
|
74
|
|
|
/** |
|
75
|
|
|
* mesagens de erro |
|
76
|
|
|
* |
|
77
|
|
|
* @var string |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $errMsg = ''; |
|
80
|
|
|
/** |
|
81
|
|
|
* status de erro true um erro ocorreu false sem erros |
|
82
|
|
|
* |
|
83
|
|
|
* @var boolean |
|
84
|
|
|
*/ |
|
85
|
|
|
protected $errStatus = false; |
|
86
|
|
|
/** |
|
87
|
|
|
* Texto adicional da DANFE |
|
88
|
|
|
* |
|
89
|
|
|
* @var string |
|
90
|
|
|
*/ |
|
91
|
|
|
protected $textoAdic = ''; |
|
92
|
|
|
/** |
|
93
|
|
|
* Largura |
|
94
|
|
|
* |
|
95
|
|
|
* @var float |
|
96
|
|
|
*/ |
|
97
|
|
|
protected $wAdic = 0; |
|
98
|
|
|
/** |
|
99
|
|
|
* largura do canhoto (25mm) apenas para a formatação paisagem |
|
100
|
|
|
* |
|
101
|
|
|
* @var float |
|
102
|
|
|
*/ |
|
103
|
|
|
protected $wCanhoto = 25; |
|
104
|
|
|
/** |
|
105
|
|
|
* Formato chave |
|
106
|
|
|
* |
|
107
|
|
|
* @var string |
|
108
|
|
|
*/ |
|
109
|
|
|
protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####"; |
|
110
|
|
|
/** |
|
111
|
|
|
* quantidade de itens já processados na montagem do DANFE |
|
112
|
|
|
* |
|
113
|
|
|
* @var integer |
|
114
|
|
|
*/ |
|
115
|
|
|
protected $qtdeItensProc; |
|
116
|
|
|
/** |
|
117
|
|
|
* Dom Document |
|
118
|
|
|
* |
|
119
|
|
|
* @var \NFePHP\DA\Legacy\Dom |
|
120
|
|
|
*/ |
|
121
|
|
|
protected $dom; |
|
122
|
|
|
/** |
|
123
|
|
|
* Node |
|
124
|
|
|
* |
|
125
|
|
|
* @var \DOMNode |
|
126
|
|
|
*/ |
|
127
|
|
|
protected $infNFe; |
|
128
|
|
|
/** |
|
129
|
|
|
* Node |
|
130
|
|
|
* |
|
131
|
|
|
* @var \DOMNode |
|
132
|
|
|
*/ |
|
133
|
|
|
protected $ide; |
|
134
|
|
|
/** |
|
135
|
|
|
* Node |
|
136
|
|
|
* |
|
137
|
|
|
* @var \DOMNode |
|
138
|
|
|
*/ |
|
139
|
|
|
protected $entrega; |
|
140
|
|
|
/** |
|
141
|
|
|
* Node |
|
142
|
|
|
* |
|
143
|
|
|
* @var \DOMNode |
|
144
|
|
|
*/ |
|
145
|
|
|
protected $retirada; |
|
146
|
|
|
/** |
|
147
|
|
|
* Node |
|
148
|
|
|
* |
|
149
|
|
|
* @var \DOMNode |
|
150
|
|
|
*/ |
|
151
|
|
|
protected $emit; |
|
152
|
|
|
/** |
|
153
|
|
|
* Node |
|
154
|
|
|
* |
|
155
|
|
|
* @var \DOMNode |
|
156
|
|
|
*/ |
|
157
|
|
|
protected $dest; |
|
158
|
|
|
/** |
|
159
|
|
|
* Node |
|
160
|
|
|
* |
|
161
|
|
|
* @var \DOMNode |
|
162
|
|
|
*/ |
|
163
|
|
|
protected $enderEmit; |
|
164
|
|
|
/** |
|
165
|
|
|
* Node |
|
166
|
|
|
* |
|
167
|
|
|
* @var \DOMNode |
|
168
|
|
|
*/ |
|
169
|
|
|
protected $enderDest; |
|
170
|
|
|
/** |
|
171
|
|
|
* Node |
|
172
|
|
|
* |
|
173
|
|
|
* @var \DOMNode |
|
174
|
|
|
*/ |
|
175
|
|
|
protected $det; |
|
176
|
|
|
/** |
|
177
|
|
|
* Node |
|
178
|
|
|
* |
|
179
|
|
|
* @var \DOMNode |
|
180
|
|
|
*/ |
|
181
|
|
|
protected $cobr; |
|
182
|
|
|
/** |
|
183
|
|
|
* Node |
|
184
|
|
|
* |
|
185
|
|
|
* @var \DOMNode |
|
186
|
|
|
*/ |
|
187
|
|
|
protected $dup; |
|
188
|
|
|
/** |
|
189
|
|
|
* Node |
|
190
|
|
|
* |
|
191
|
|
|
* @var \DOMNode |
|
192
|
|
|
*/ |
|
193
|
|
|
protected $ICMSTot; |
|
194
|
|
|
/** |
|
195
|
|
|
* Node |
|
196
|
|
|
* |
|
197
|
|
|
* @var \DOMNode |
|
198
|
|
|
*/ |
|
199
|
|
|
protected $ISSQNtot; |
|
200
|
|
|
/** |
|
201
|
|
|
* Node |
|
202
|
|
|
* |
|
203
|
|
|
* @var \DOMNode |
|
204
|
|
|
*/ |
|
205
|
|
|
protected $transp; |
|
206
|
|
|
/** |
|
207
|
|
|
* Node |
|
208
|
|
|
* |
|
209
|
|
|
* @var \DOMNode |
|
210
|
|
|
*/ |
|
211
|
|
|
protected $transporta; |
|
212
|
|
|
/** |
|
213
|
|
|
* Node |
|
214
|
|
|
* |
|
215
|
|
|
* @var \DOMNode |
|
216
|
|
|
*/ |
|
217
|
|
|
protected $veicTransp; |
|
218
|
|
|
/** |
|
219
|
|
|
* Node reboque |
|
220
|
|
|
* |
|
221
|
|
|
* @var \DOMNode |
|
222
|
|
|
*/ |
|
223
|
|
|
protected $reboque; |
|
224
|
|
|
/** |
|
225
|
|
|
* Node infAdic |
|
226
|
|
|
* |
|
227
|
|
|
* @var \DOMNode |
|
228
|
|
|
*/ |
|
229
|
|
|
protected $infAdic; |
|
230
|
|
|
/** |
|
231
|
|
|
* Tipo de emissão |
|
232
|
|
|
* |
|
233
|
|
|
* @var integer |
|
234
|
|
|
*/ |
|
235
|
|
|
protected $tpEmis; |
|
236
|
|
|
/** |
|
237
|
|
|
* Node infProt |
|
238
|
|
|
* |
|
239
|
|
|
* @var \DOMNode |
|
240
|
|
|
*/ |
|
241
|
|
|
protected $infProt; |
|
242
|
|
|
/** |
|
243
|
|
|
* 1-Retrato/ 2-Paisagem |
|
244
|
|
|
* |
|
245
|
|
|
* @var integer |
|
246
|
|
|
*/ |
|
247
|
|
|
protected $tpImp; |
|
248
|
|
|
/** |
|
249
|
|
|
* Node compra |
|
250
|
|
|
* |
|
251
|
|
|
* @var \DOMNode |
|
252
|
|
|
*/ |
|
253
|
|
|
protected $compra; |
|
254
|
|
|
/** |
|
255
|
|
|
* @var int |
|
256
|
|
|
*/ |
|
257
|
|
|
protected $textadicfontsize; |
|
258
|
|
|
/** |
|
259
|
|
|
* Número de casas para a quantidade de itens da unidade comercial. |
|
260
|
|
|
* |
|
261
|
|
|
* @var integer |
|
262
|
|
|
*/ |
|
263
|
|
|
protected $qComCasasDec = 4; |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* Número de casas decimais para o valor da unidade comercial. |
|
267
|
|
|
* |
|
268
|
|
|
* @var integer |
|
269
|
|
|
*/ |
|
270
|
|
|
protected $vUnComCasasDec = 4; |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Configuração para determinar se irá exibir ou não informações |
|
274
|
|
|
* das unidades de medidas tributáveis. |
|
275
|
|
|
* |
|
276
|
|
|
* @var boolean |
|
277
|
|
|
*/ |
|
278
|
|
|
protected $mostrarUnidadeTributavel = false; |
|
279
|
|
|
/** |
|
280
|
|
|
* @var int |
|
281
|
|
|
*/ |
|
282
|
|
|
protected $hdadosadic = 10; |
|
283
|
|
|
|
|
284
|
|
|
/** |
|
285
|
|
|
* __construct |
|
286
|
|
|
* |
|
287
|
|
|
* @name __construct |
|
288
|
|
|
* |
|
289
|
|
|
* @param string $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc) |
|
290
|
|
|
*/ |
|
291
|
|
|
public function __construct($xml) { |
|
292
|
|
|
$this->loadDoc($xml); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
|
|
296
|
|
|
/** |
|
297
|
|
|
* Define se irá mostrar ou não dados as unidades de medidas tributaveis. |
|
298
|
|
|
* |
|
299
|
|
|
* @param boolean $mostrarUnidadeTributavel |
|
300
|
|
|
*/ |
|
301
|
|
|
public function setMostrarUnidadeTributavel($mostrarUnidadeTributavel) { |
|
302
|
|
|
$this->mostrarUnidadeTributavel = $mostrarUnidadeTributavel; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
/** |
|
306
|
|
|
* Define a quantidade de casas decimais para unidade comercial. |
|
307
|
|
|
* |
|
308
|
|
|
* @param integer $vUnComCasasDec |
|
309
|
|
|
*/ |
|
310
|
|
|
public function setVUnComCasasDec($vUnComCasasDec) { |
|
311
|
|
|
$this->vUnComCasasDec = $vUnComCasasDec; |
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
|
|
/** |
|
315
|
|
|
* Define a quantidade de casas decimais para unidade comercial. |
|
316
|
|
|
* |
|
317
|
|
|
* @param integer $qComCasasDec |
|
318
|
|
|
*/ |
|
319
|
|
|
public function setQComCasasDec($qComCasasDec) { |
|
320
|
|
|
$this->qComCasasDec = $qComCasasDec; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
protected function calculoEspacoVericalDadosAdicionais() { |
|
324
|
|
|
$this->textoAdic = ''; |
|
325
|
|
|
//informações adicionais |
|
326
|
|
|
$fontProduto = [ |
|
327
|
|
|
'font' => $this->fontePadrao, |
|
328
|
|
|
'size' => 8, |
|
329
|
|
|
'style' => '' |
|
330
|
|
|
]; |
|
331
|
|
|
$k = $this->pdf->k; |
|
332
|
|
|
$this->textadicfontsize = $fontProduto['size'] / $k; |
|
|
|
|
|
|
333
|
|
|
$this->textoAdic .= $this->geraInformacoesDasNotasReferenciadas(); |
|
334
|
|
|
if (isset($this->infAdic)) { |
|
335
|
|
|
$i = 0; |
|
336
|
|
|
if ($this->textoAdic != '') { |
|
337
|
|
|
$this->textoAdic .= ". \n"; |
|
338
|
|
|
} |
|
339
|
|
|
$this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infCpl")) |
|
340
|
|
|
? 'Inf. Contribuinte: ' . $this->anfaveaDANFE($this->getTagValue($this->infAdic, "infCpl")) |
|
341
|
|
|
: ''; |
|
342
|
|
|
$infPedido = $this->geraInformacoesDaTagCompra(); |
|
343
|
|
|
if ($infPedido != "") { |
|
344
|
|
|
$this->textoAdic .= $infPedido; |
|
345
|
|
|
} |
|
346
|
|
|
$this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: '); |
|
347
|
|
|
$this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infAdFisco")) |
|
348
|
|
|
? "\n Inf. fisco: " . $this->getTagValue($this->infAdic, "infAdFisco") |
|
349
|
|
|
: ''; |
|
350
|
|
|
$obsCont = $this->infAdic->getElementsByTagName("obsCont"); |
|
351
|
|
|
if (isset($obsCont)) { |
|
352
|
|
|
foreach ($obsCont as $obs) { |
|
353
|
|
|
$campo = $obsCont->item($i)->getAttribute("xCampo"); |
|
354
|
|
|
$xTexto = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue) |
|
355
|
|
|
? $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue |
|
356
|
|
|
: ''; |
|
357
|
|
|
$this->textoAdic .= "\n" . $campo . ': ' . trim($xTexto); |
|
358
|
|
|
$i ++; |
|
359
|
|
|
} |
|
360
|
|
|
} |
|
361
|
|
|
} |
|
362
|
|
|
//INCLUSO pela NT 2013.003 Lei da Transparência |
|
363
|
|
|
//verificar se a informação sobre o valor aproximado dos tributos |
|
364
|
|
|
//já se encontra no campo de informações adicionais |
|
365
|
|
|
if ($this->exibirValorTributos) { |
|
366
|
|
|
$flagVTT = strpos(strtolower(trim($this->textoAdic)), 'valor'); |
|
367
|
|
|
$flagVTT = $flagVTT || strpos(strtolower(trim($this->textoAdic)), 'vl'); |
|
368
|
|
|
$flagVTT = $flagVTT && strpos(strtolower(trim($this->textoAdic)), 'aprox'); |
|
369
|
|
|
$flagVTT = $flagVTT && (strpos(strtolower(trim($this->textoAdic)), 'trib') || |
|
370
|
|
|
strpos(strtolower(trim($this->textoAdic)), 'imp')); |
|
371
|
|
|
$vTotTrib = $this->getTagValue($this->ICMSTot, 'vTotTrib'); |
|
372
|
|
|
if ($vTotTrib != '' && ! $flagVTT) { |
|
373
|
|
|
$this->textoAdic .= "\n Valor Aproximado dos Tributos : R$ " |
|
374
|
|
|
. number_format($vTotTrib, 2, ",", "."); |
|
375
|
|
|
} |
|
376
|
|
|
} |
|
377
|
|
|
//fim da alteração NT 2013.003 Lei da Transparência |
|
378
|
|
|
$this->textoAdic = str_replace(";", "\n", $this->textoAdic); |
|
379
|
|
|
$alinhas = explode("\n", $this->textoAdic); |
|
|
|
|
|
|
380
|
|
|
$numlinhasdados = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 1.5; |
|
381
|
|
|
$this->textadicfontsize = $this->pdf->fontSize; |
|
|
|
|
|
|
382
|
|
|
$hdadosadic = ceil($numlinhasdados * ($this->textadicfontsize)); |
|
383
|
|
|
if ($hdadosadic > 70) { |
|
384
|
|
|
for ($f = 8; $f > 3; $f --) { |
|
385
|
|
|
$this->pdf->setFont($this->fontePadrao, '', $f); |
|
386
|
|
|
$fontProduto = [ |
|
387
|
|
|
'font' => $this->fontePadrao, |
|
388
|
|
|
'size' => $f, |
|
389
|
|
|
'style' => '' |
|
390
|
|
|
]; |
|
391
|
|
|
$numlinhasdados = $this->pdf->getNumLines($this->textoAdic, $this->wAdic, $fontProduto) + 3; |
|
392
|
|
|
$this->textadicfontsize = $this->pdf->fontSize; |
|
393
|
|
|
$hdadosadic = ceil($numlinhasdados * $this->textadicfontsize); |
|
394
|
|
|
echo $hdadosadic; |
|
395
|
|
|
if ($hdadosadic <= 90) { |
|
396
|
|
|
$hdadosadic = ceil($hdadosadic); |
|
397
|
|
|
break; |
|
398
|
|
|
} |
|
399
|
|
|
} |
|
400
|
|
|
} |
|
401
|
|
|
if ($hdadosadic < 10) { |
|
402
|
|
|
$hdadosadic = 10; |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
return $hdadosadic; |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
protected function calculoItensPorPagina() { |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
/** |
|
412
|
|
|
* monta |
|
413
|
|
|
* Monta a DANFE conforme as informações fornecidas para a classe durante sua |
|
414
|
|
|
* construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens. |
|
415
|
|
|
* A definição de margens e posições iniciais para a impressão são estabelecidas |
|
416
|
|
|
* pelo conteúdo da funçao e podem ser modificados. |
|
417
|
|
|
* |
|
418
|
|
|
* @return string O ID da NFe numero de 44 digitos extraido do arquivo XML |
|
419
|
|
|
*/ |
|
420
|
|
|
protected function monta( |
|
421
|
|
|
$logo = '' |
|
422
|
|
|
) { |
|
423
|
|
|
$this->pdf = ''; |
|
|
|
|
|
|
424
|
|
|
$this->logomarca = $this->adjustImage($logo); |
|
425
|
|
|
//se a orientação estiver em branco utilizar o padrão estabelecido na NF |
|
426
|
|
|
if (empty($this->orientacao)) { |
|
427
|
|
|
if ($this->tpImp == '2') { |
|
428
|
|
|
$this->orientacao = 'L'; |
|
429
|
|
|
} else { |
|
430
|
|
|
$this->orientacao = 'P'; |
|
431
|
|
|
} |
|
432
|
|
|
} |
|
433
|
|
|
//instancia a classe pdf |
|
434
|
|
|
$this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
|
|
|
|
|
435
|
|
|
//margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à |
|
436
|
|
|
//margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui |
|
437
|
|
|
//apenas para controle se necessário ser maior do que a margem superior |
|
438
|
|
|
// posição inicial do conteúdo, a partir do canto superior esquerdo da página |
|
439
|
|
|
$xInic = $this->margesq; |
|
440
|
|
|
if ($this->orientacao == 'P') { |
|
441
|
|
|
if ($this->papel == 'A4') { |
|
442
|
|
|
$this->maxW = 210; |
|
|
|
|
|
|
443
|
|
|
$this->maxH = 297; |
|
|
|
|
|
|
444
|
|
|
} |
|
445
|
|
|
} else { |
|
446
|
|
|
if ($this->papel == 'A4') { |
|
447
|
|
|
$this->maxW = 297; |
|
|
|
|
|
|
448
|
|
|
$this->maxH = 210; |
|
|
|
|
|
|
449
|
|
|
$xInic = $this->margesq + 10; |
|
450
|
|
|
//se paisagem multiplica a largura do canhoto pela quantidade de canhotos |
|
451
|
|
|
//$this->wCanhoto *= $this->qCanhoto; |
|
452
|
|
|
} |
|
453
|
|
|
} |
|
454
|
|
|
//total inicial de paginas |
|
455
|
|
|
$totPag = 1; |
|
|
|
|
|
|
456
|
|
|
//largura imprimivel em mm: largura da folha menos as margens esq/direita |
|
457
|
|
|
$this->wPrint = $this->maxW - ($this->margesq * 2); |
|
|
|
|
|
|
458
|
|
|
//comprimento (altura) imprimivel em mm: altura da folha menos as margens |
|
459
|
|
|
//superior e inferior |
|
460
|
|
|
$this->hPrint = $this->maxH - $this->margsup - $this->marginf; |
|
|
|
|
|
|
461
|
|
|
// estabelece contagem de paginas |
|
462
|
|
|
$this->pdf->aliasNbPages(); |
|
463
|
|
|
// fixa as margens |
|
464
|
|
|
$this->pdf->setMargins($this->margesq, $this->margsup); |
|
465
|
|
|
$this->pdf->setDrawColor(0, 0, 0); |
|
466
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
|
467
|
|
|
// inicia o documento |
|
468
|
|
|
$this->pdf->open(); |
|
469
|
|
|
// adiciona a primeira página |
|
470
|
|
|
$this->pdf->addPage($this->orientacao, $this->papel); |
|
|
|
|
|
|
471
|
|
|
$this->pdf->setLineWidth(0.1); |
|
472
|
|
|
$this->pdf->settextcolor(0, 0, 0); |
|
473
|
|
|
|
|
474
|
|
|
//################################################################## |
|
475
|
|
|
// CALCULO DO NUMERO DE PAGINAS A SEREM IMPRESSAS |
|
476
|
|
|
//################################################################## |
|
477
|
|
|
//Verificando quantas linhas serão usadas para impressão das duplicatas |
|
478
|
|
|
$linhasDup = 0; |
|
479
|
|
|
$qtdPag = 0; |
|
480
|
|
|
if (isset($this->dup) && $this->dup->length > 0) { |
|
481
|
|
|
$qtdPag = $this->dup->length; |
|
|
|
|
|
|
482
|
|
|
} elseif (isset($this->detPag) && $this->detPag->length > 0) { |
|
|
|
|
|
|
483
|
|
|
$qtdPag = $this->detPag->length; |
|
484
|
|
|
} |
|
485
|
|
|
if (($qtdPag > 0) && ($qtdPag <= 7)) { |
|
486
|
|
|
$linhasDup = 1; |
|
487
|
|
|
} elseif (($qtdPag > 7) && ($qtdPag <= 14)) { |
|
488
|
|
|
$linhasDup = 2; |
|
489
|
|
|
} elseif (($qtdPag > 14) && ($qtdPag <= 21)) { |
|
490
|
|
|
$linhasDup = 3; |
|
491
|
|
|
} elseif ($qtdPag > 21) { |
|
492
|
|
|
// chinnonsantos 11/05/2016: Limite máximo de impressão de duplicatas na NFe, |
|
493
|
|
|
// só vai ser exibito as 21 primeiras duplicatas (parcelas de pagamento), |
|
494
|
|
|
// se não oculpa espaço d+, cada linha comporta até 7 duplicatas. |
|
495
|
|
|
$linhasDup = 3; |
|
496
|
|
|
} |
|
497
|
|
|
//verifica se será impressa a linha dos serviços ISSQN |
|
498
|
|
|
$linhaISSQN = 0; |
|
499
|
|
|
if ((isset($this->ISSQNtot)) && ($this->getTagValue($this->ISSQNtot, 'vServ') > 0)) { |
|
500
|
|
|
$linhaISSQN = 1; |
|
501
|
|
|
} |
|
502
|
|
|
//calcular a altura necessária para os dados adicionais |
|
503
|
|
|
if ($this->orientacao == 'P') { |
|
504
|
|
|
$this->wAdic = round($this->wPrint * 0.66, 0); |
|
505
|
|
|
} else { |
|
506
|
|
|
$this->wAdic = round(($this->wPrint - $this->wCanhoto) * 0.5, 0); |
|
507
|
|
|
} |
|
508
|
|
|
$fontProduto = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
|
|
|
|
|
509
|
|
|
|
|
510
|
|
|
$this->hdadosadic = $this->calculoEspacoVericalDadosAdicionais(); |
|
|
|
|
|
|
511
|
|
|
|
|
512
|
|
|
//altura disponivel para os campos da DANFE |
|
513
|
|
|
$hcabecalho = 47;//para cabeçalho |
|
514
|
|
|
$hdestinatario = 25;//para destinatario |
|
515
|
|
|
$hduplicatas = 12;//para cada grupo de 7 duplicatas |
|
516
|
|
|
if (isset($this->entrega)) { |
|
517
|
|
|
$hlocalentrega = 25; |
|
518
|
|
|
} else { |
|
519
|
|
|
$hlocalentrega = 0; |
|
520
|
|
|
} |
|
521
|
|
|
if (isset($this->retirada)) { |
|
522
|
|
|
$hlocalretirada = 25; |
|
523
|
|
|
} else { |
|
524
|
|
|
$hlocalretirada = 0; |
|
525
|
|
|
} |
|
526
|
|
|
$himposto = 18;// para imposto |
|
527
|
|
|
$htransporte = 25;// para transporte |
|
528
|
|
|
$hissqn = 11;// para issqn |
|
529
|
|
|
$hfooter = 5;// para rodape |
|
530
|
|
|
$hCabecItens = 4;//cabeçalho dos itens |
|
531
|
|
|
$hOCUPADA = $hcabecalho |
|
532
|
|
|
+ $hdestinatario |
|
533
|
|
|
+ $hlocalentrega |
|
534
|
|
|
+ $hlocalretirada |
|
535
|
|
|
+ ($linhasDup * $hduplicatas) |
|
536
|
|
|
+ $himposto + $htransporte |
|
537
|
|
|
+ ($linhaISSQN * $hissqn) |
|
538
|
|
|
+ $this->hdadosadic |
|
539
|
|
|
+ $hfooter |
|
540
|
|
|
+ $hCabecItens |
|
541
|
|
|
+ $this->sizeExtraTextoFatura(); |
|
542
|
|
|
|
|
543
|
|
|
//alturas disponiveis para os dados |
|
544
|
|
|
$hDispo1 = $this->hPrint - $hOCUPADA; |
|
545
|
|
|
/*($hcabecalho + |
|
546
|
|
|
//$hdestinatario + ($linhasDup * $hduplicatas) + $himposto + $htransporte + |
|
547
|
|
|
$hdestinatario + $hlocalentrega + $hlocalretirada + |
|
548
|
|
|
($linhasDup * $hduplicatas) + $himposto + $htransporte + |
|
549
|
|
|
($linhaISSQN * $hissqn) + $this->hdadosadic + $hfooter + $hCabecItens + |
|
550
|
|
|
$this->sizeExtraTextoFatura());*/ |
|
551
|
|
|
|
|
552
|
|
|
if ($this->orientacao == 'P') { |
|
553
|
|
|
$hDispo1 -= 24 * $this->qCanhoto;//para canhoto |
|
554
|
|
|
$w = $this->wPrint; |
|
555
|
|
|
} else { |
|
556
|
|
|
$hcanhoto = $this->hPrint;//para canhoto |
|
|
|
|
|
|
557
|
|
|
$w = $this->wPrint - $this->wCanhoto; |
|
558
|
|
|
} |
|
559
|
|
|
//$hDispo1 += 14; |
|
560
|
|
|
$hDispo2 = $this->hPrint - ($hcabecalho + $hfooter + $hCabecItens); |
|
561
|
|
|
//Contagem da altura ocupada para impressão dos itens |
|
562
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
|
|
|
|
|
563
|
|
|
$numlinhas = 0; |
|
|
|
|
|
|
564
|
|
|
$hUsado = $hCabecItens; |
|
565
|
|
|
$w2 = round($w * 0.25, 0); |
|
|
|
|
|
|
566
|
|
|
$hDispo = $hDispo1; |
|
567
|
|
|
$totPag = 1; |
|
568
|
|
|
$i = 0; |
|
569
|
|
|
while ($i < $this->det->length) { |
|
570
|
|
|
$hUsado += $this->calculeHeight($this->det->item($i)); |
|
571
|
|
|
if ($hUsado > $hDispo) { |
|
572
|
|
|
$totPag ++; |
|
573
|
|
|
$hDispo = $hDispo2; |
|
574
|
|
|
$hUsado = $hCabecItens; |
|
575
|
|
|
$i --; // decrementa para readicionar o item que não coube nessa pagina na outra. |
|
576
|
|
|
} |
|
577
|
|
|
$i ++; |
|
578
|
|
|
} //fim da soma das areas de itens usadas |
|
579
|
|
|
$qtdeItens = $i; //controle da quantidade de itens no DANFE |
|
580
|
|
|
//montagem da primeira página |
|
581
|
|
|
$pag = 1; |
|
582
|
|
|
|
|
583
|
|
|
$x = $this->margesq; |
|
584
|
|
|
$y = $this->margsup; |
|
585
|
|
|
//coloca o(s) canhoto(s) da NFe |
|
586
|
|
|
if ($this->orientacao == 'P') { |
|
587
|
|
|
$y = $this->canhoto($this->margesq, $this->margsup); |
|
588
|
|
|
} else { |
|
589
|
|
|
$this->canhoto($this->margesq, $this->margsup); |
|
590
|
|
|
$x = 25; |
|
591
|
|
|
} |
|
592
|
|
|
//coloca o cabeçalho |
|
593
|
|
|
$y = $this->header($x, $y, $pag, $totPag); |
|
594
|
|
|
//coloca os dados do destinatário |
|
595
|
|
|
$y = $this->destinatarioDANFE($x, $y + 1); |
|
596
|
|
|
//coloca os dados do local de retirada |
|
597
|
|
|
if (isset($this->retirada)) { |
|
598
|
|
|
$y = $this->localRetiradaDANFE($x, $y + 1); |
|
599
|
|
|
} |
|
600
|
|
|
//coloca os dados do local de entrega |
|
601
|
|
|
if (isset($this->entrega)) { |
|
602
|
|
|
$y = $this->localEntregaDANFE($x, $y + 1); |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
//Verifica as formas de pagamento da nota fiscal |
|
606
|
|
|
$formaPag = []; |
|
607
|
|
|
if (isset($this->detPag) && $this->detPag->length > 0) { |
|
608
|
|
|
foreach ($this->detPag as $k => $d) { |
|
609
|
|
|
$fPag = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue) |
|
610
|
|
|
? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue |
|
611
|
|
|
: '0'; |
|
612
|
|
|
$formaPag[$fPag] = $fPag; |
|
613
|
|
|
} |
|
614
|
|
|
} |
|
615
|
|
|
//caso tenha boleto imprimir fatura |
|
616
|
|
|
if ($this->dup->length > 0) { |
|
617
|
|
|
$y = $this->fatura($x, $y + 1); |
|
618
|
|
|
} else { |
|
619
|
|
|
//Se somente tiver a forma de pagamento sem pagamento não imprimir nada |
|
620
|
|
|
if (count($formaPag) == '1' && isset($formaPag[90])) { |
|
621
|
|
|
$y = $y; |
|
|
|
|
|
|
622
|
|
|
} else { |
|
623
|
|
|
//caso tenha mais de uma forma de pagamento ou seja diferente de boleto exibe a |
|
624
|
|
|
//forma de pagamento e o valor |
|
625
|
|
|
$y = $this->pagamento($x, $y + 1); |
|
626
|
|
|
} |
|
627
|
|
|
} |
|
628
|
|
|
//coloca os dados dos impostos e totais da NFe |
|
629
|
|
|
$y = $this->imposto($x, $y + 1); |
|
630
|
|
|
//coloca os dados do trasnporte |
|
631
|
|
|
$y = $this->transporte($x, $y + 1); |
|
632
|
|
|
//itens da DANFE |
|
633
|
|
|
$nInicial = 0; |
|
634
|
|
|
|
|
635
|
|
|
$y = $this->itens($x, $y + 1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens); |
|
636
|
|
|
|
|
637
|
|
|
//coloca os dados do ISSQN |
|
638
|
|
|
if ($linhaISSQN == 1) { |
|
639
|
|
|
$y = $this->issqn($x, $y + 4); |
|
640
|
|
|
} else { |
|
641
|
|
|
$y += 4; |
|
642
|
|
|
} |
|
643
|
|
|
//coloca os dados adicionais da NFe |
|
644
|
|
|
$y = $this->dadosAdicionais($x, $y, $this->hdadosadic); |
|
|
|
|
|
|
645
|
|
|
//coloca o rodapé da página |
|
646
|
|
|
if ($this->orientacao == 'P') { |
|
647
|
|
|
$this->rodape($xInic); |
|
648
|
|
|
} else { |
|
649
|
|
|
$this->rodape($xInic); |
|
650
|
|
|
} |
|
651
|
|
|
|
|
652
|
|
|
//loop para páginas seguintes |
|
653
|
|
|
for ($n = 2; $n <= $totPag; $n ++) { |
|
654
|
|
|
// fixa as margens |
|
655
|
|
|
$this->pdf->setMargins($this->margesq, $this->margsup); |
|
656
|
|
|
//adiciona nova página |
|
657
|
|
|
$this->pdf->addPage($this->orientacao, $this->papel); |
|
|
|
|
|
|
658
|
|
|
//ajusta espessura das linhas |
|
659
|
|
|
$this->pdf->setLineWidth(0.1); |
|
660
|
|
|
//seta a cor do texto para petro |
|
661
|
|
|
$this->pdf->settextcolor(0, 0, 0); |
|
662
|
|
|
// posição inicial do relatorio |
|
663
|
|
|
$x = $this->margesq; |
|
664
|
|
|
$y = $this->margsup; |
|
665
|
|
|
//coloca o cabeçalho na página adicional |
|
666
|
|
|
$y = $this->header($x, $y, $n, $totPag); |
|
667
|
|
|
//coloca os itens na página adicional |
|
668
|
|
|
$y = $this->itens($x, $y + 1, $nInicial, $hDispo2, $n, $totPag, $hCabecItens); |
|
|
|
|
|
|
669
|
|
|
//coloca o rodapé da página |
|
670
|
|
|
if ($this->orientacao == 'P') { |
|
671
|
|
|
$this->rodape($this->margesq); |
|
672
|
|
|
} else { |
|
673
|
|
|
$this->rodape($this->margesq); |
|
674
|
|
|
} |
|
675
|
|
|
//se estiver na última página e ainda restar itens para inserir, adiciona mais uma página |
|
676
|
|
|
if ($n == $totPag && $this->qtdeItensProc < $qtdeItens) { |
|
677
|
|
|
$totPag ++; |
|
678
|
|
|
} |
|
679
|
|
|
} |
|
680
|
|
|
} |
|
681
|
|
|
|
|
682
|
|
|
/** |
|
683
|
|
|
* anfavea |
|
684
|
|
|
* Função para transformar o campo cdata do padrão ANFAVEA para |
|
685
|
|
|
* texto imprimível |
|
686
|
|
|
* |
|
687
|
|
|
* @param string $cdata campo CDATA |
|
688
|
|
|
* |
|
689
|
|
|
* @return string conteúdo do campo CDATA como string |
|
690
|
|
|
*/ |
|
691
|
|
|
protected function anfaveaDANFE($cdata = '') { |
|
692
|
|
|
if ($cdata == '') { |
|
693
|
|
|
return ''; |
|
694
|
|
|
} |
|
695
|
|
|
//remove qualquer texto antes ou depois da tag CDATA |
|
696
|
|
|
$cdata = str_replace('<![CDATA[', '<CDATA>', $cdata); |
|
697
|
|
|
$cdata = str_replace(']]>', '</CDATA>', $cdata); |
|
698
|
|
|
$cdata = preg_replace('/\s\s+/', ' ', $cdata); |
|
699
|
|
|
$cdata = str_replace("> <", "><", $cdata); |
|
700
|
|
|
$len = strlen($cdata); |
|
701
|
|
|
$startPos = strpos($cdata, '<'); |
|
702
|
|
|
if ($startPos === false) { |
|
703
|
|
|
return $cdata; |
|
704
|
|
|
} |
|
705
|
|
|
for ($x = $len; $x > 0; $x --) { |
|
706
|
|
|
if (substr($cdata, $x, 1) == '>') { |
|
707
|
|
|
$endPos = $x; |
|
708
|
|
|
break; |
|
709
|
|
|
} |
|
710
|
|
|
} |
|
711
|
|
|
if ($startPos > 0) { |
|
712
|
|
|
$parte1 = substr($cdata, 0, $startPos); |
|
713
|
|
|
} else { |
|
714
|
|
|
$parte1 = ''; |
|
715
|
|
|
} |
|
716
|
|
|
$parte2 = substr($cdata, $startPos, $endPos - $startPos + 1); |
|
|
|
|
|
|
717
|
|
|
if ($endPos < $len) { |
|
718
|
|
|
$parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1); |
|
719
|
|
|
} else { |
|
720
|
|
|
$parte3 = ''; |
|
721
|
|
|
} |
|
722
|
|
|
$texto = trim($parte1) . ' ' . trim($parte3); |
|
723
|
|
|
if (strpos($parte2, '<CDATA>') === false) { |
|
724
|
|
|
$cdata = '<CDATA>' . $parte2 . '</CDATA>'; |
|
725
|
|
|
} else { |
|
726
|
|
|
$cdata = $parte2; |
|
727
|
|
|
} |
|
728
|
|
|
//Retira a tag <FONTE IBPT> (caso existir) pois não é uma estrutura válida XML |
|
729
|
|
|
$cdata = str_replace('<FONTE IBPT>', '', $cdata); |
|
730
|
|
|
//carrega o xml CDATA em um objeto DOM |
|
731
|
|
|
$dom = new Dom(); |
|
732
|
|
|
$dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG); |
|
733
|
|
|
//$xml = $dom->saveXML(); |
|
734
|
|
|
//grupo CDATA infADprod |
|
735
|
|
|
$id = $dom->getElementsByTagName('id')->item(0); |
|
736
|
|
|
$div = $dom->getElementsByTagName('div')->item(0); |
|
737
|
|
|
$entg = $dom->getElementsByTagName('entg')->item(0); |
|
738
|
|
|
$dest = $dom->getElementsByTagName('dest')->item(0); |
|
739
|
|
|
$ctl = $dom->getElementsByTagName('ctl')->item(0); |
|
740
|
|
|
$ref = $dom->getElementsByTagName('ref')->item(0); |
|
741
|
|
|
if (isset($id)) { |
|
742
|
|
|
if ($id->hasAttributes()) { |
|
743
|
|
|
foreach ($id->attributes as $attr) { |
|
744
|
|
|
$name = $attr->nodeName; |
|
745
|
|
|
$value = $attr->nodeValue; |
|
746
|
|
|
$texto .= " $name : $value"; |
|
747
|
|
|
} |
|
748
|
|
|
} |
|
749
|
|
|
} |
|
750
|
|
|
if (isset($div)) { |
|
751
|
|
|
if ($div->hasAttributes()) { |
|
752
|
|
|
foreach ($div->attributes as $attr) { |
|
753
|
|
|
$name = $attr->nodeName; |
|
754
|
|
|
$value = $attr->nodeValue; |
|
755
|
|
|
$texto .= " $name : $value"; |
|
756
|
|
|
} |
|
757
|
|
|
} |
|
758
|
|
|
} |
|
759
|
|
|
if (isset($entg)) { |
|
760
|
|
|
if ($entg->hasAttributes()) { |
|
761
|
|
|
foreach ($entg->attributes as $attr) { |
|
762
|
|
|
$name = $attr->nodeName; |
|
763
|
|
|
$value = $attr->nodeValue; |
|
764
|
|
|
$texto .= " $name : $value"; |
|
765
|
|
|
} |
|
766
|
|
|
} |
|
767
|
|
|
} |
|
768
|
|
|
if (isset($dest)) { |
|
769
|
|
|
if ($dest->hasAttributes()) { |
|
770
|
|
|
foreach ($dest->attributes as $attr) { |
|
771
|
|
|
$name = $attr->nodeName; |
|
772
|
|
|
$value = $attr->nodeValue; |
|
773
|
|
|
$texto .= " $name : $value"; |
|
774
|
|
|
} |
|
775
|
|
|
} |
|
776
|
|
|
} |
|
777
|
|
|
if (isset($ctl)) { |
|
778
|
|
|
if ($ctl->hasAttributes()) { |
|
779
|
|
|
foreach ($ctl->attributes as $attr) { |
|
780
|
|
|
$name = $attr->nodeName; |
|
781
|
|
|
$value = $attr->nodeValue; |
|
782
|
|
|
$texto .= " $name : $value"; |
|
783
|
|
|
} |
|
784
|
|
|
} |
|
785
|
|
|
} |
|
786
|
|
|
if (isset($ref)) { |
|
787
|
|
|
if ($ref->hasAttributes()) { |
|
788
|
|
|
foreach ($ref->attributes as $attr) { |
|
789
|
|
|
$name = $attr->nodeName; |
|
790
|
|
|
$value = $attr->nodeValue; |
|
791
|
|
|
$texto .= " $name : $value"; |
|
792
|
|
|
} |
|
793
|
|
|
} |
|
794
|
|
|
} |
|
795
|
|
|
//grupo CADATA infCpl |
|
796
|
|
|
$t = $dom->getElementsByTagName('transmissor')->item(0); |
|
797
|
|
|
$r = $dom->getElementsByTagName('receptor')->item(0); |
|
798
|
|
|
$versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ? |
|
799
|
|
|
'Versao:' . $dom->getElementsByTagName('versao')->item(0)->nodeValue . ' ' : ''; |
|
800
|
|
|
$especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ? |
|
801
|
|
|
'Especie:' . $dom->getElementsByTagName('especieNF')->item(0)->nodeValue . ' ' : ''; |
|
802
|
|
|
$fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ? |
|
803
|
|
|
'Entrega:' . $dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue . ' ' : ''; |
|
804
|
|
|
$dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ? |
|
805
|
|
|
'dca:' . $dom->getElementsByTagName('dca')->item(0)->nodeValue . ' ' : ''; |
|
806
|
|
|
$texto .= "" . $versao . $especieNF . $fabEntrega . $dca; |
|
807
|
|
|
if (isset($t)) { |
|
808
|
|
|
if ($t->hasAttributes()) { |
|
809
|
|
|
$texto .= " Transmissor "; |
|
810
|
|
|
foreach ($t->attributes as $attr) { |
|
811
|
|
|
$name = $attr->nodeName; |
|
812
|
|
|
$value = $attr->nodeValue; |
|
813
|
|
|
$texto .= " $name : $value"; |
|
814
|
|
|
} |
|
815
|
|
|
} |
|
816
|
|
|
} |
|
817
|
|
|
if (isset($r)) { |
|
818
|
|
|
if ($r->hasAttributes()) { |
|
819
|
|
|
$texto .= " Receptor "; |
|
820
|
|
|
foreach ($r->attributes as $attr) { |
|
821
|
|
|
$name = $attr->nodeName; |
|
822
|
|
|
$value = $attr->nodeValue; |
|
823
|
|
|
$texto .= " $name : $value"; |
|
824
|
|
|
} |
|
825
|
|
|
} |
|
826
|
|
|
} |
|
827
|
|
|
|
|
828
|
|
|
return $texto; |
|
829
|
|
|
} |
|
830
|
|
|
|
|
831
|
|
|
/** |
|
832
|
|
|
* Verifica o status da NFe |
|
833
|
|
|
* |
|
834
|
|
|
* @return array |
|
835
|
|
|
*/ |
|
836
|
|
|
protected function statusNFe() { |
|
837
|
|
|
if (! isset($this->nfeProc)) { |
|
838
|
|
|
return ['status' => false, 'message' => 'NFe NÃO PROTOCOLADA']; |
|
839
|
|
|
} |
|
840
|
|
|
if ($this->getTagValue($this->ide, "tpAmb") == '2') { |
|
841
|
|
|
return ['status' => false, 'message' => 'NFe EMITIDA EM HOMOLOGAÇÃO']; |
|
842
|
|
|
} |
|
843
|
|
|
$cStat = $this->getTagValue($this->nfeProc, "cStat"); |
|
|
|
|
|
|
844
|
|
|
if ($cStat == '101' |
|
845
|
|
|
|| $cStat == '151' |
|
846
|
|
|
|| $cStat == '135' |
|
847
|
|
|
|| $cStat == '155' |
|
848
|
|
|
) { |
|
849
|
|
|
return ['status' => false, 'message' => 'NFe CANCELADA']; |
|
850
|
|
|
} |
|
851
|
|
|
|
|
852
|
|
|
if ($cStat == '110' || |
|
853
|
|
|
$cStat == '301' || |
|
854
|
|
|
$cStat == '302' |
|
855
|
|
|
|
|
856
|
|
|
) { |
|
857
|
|
|
return ['status' => false, 'message' => 'NFe DENEGADA']; |
|
858
|
|
|
} |
|
859
|
|
|
|
|
860
|
|
|
return ['status' => true, 'message' => '']; |
|
861
|
|
|
} |
|
862
|
|
|
|
|
863
|
|
|
protected function notaDPEC() { |
|
864
|
|
|
return ! empty($this->numdepec); |
|
865
|
|
|
} |
|
866
|
|
|
|
|
867
|
|
|
/** |
|
868
|
|
|
*header |
|
869
|
|
|
* Monta o cabelhalho da DANFE (retrato e paisagem) |
|
870
|
|
|
* |
|
871
|
|
|
* @param number $x Posição horizontal inicial, canto esquerdo |
|
872
|
|
|
* @param number $y Posição vertical inicial, canto superior |
|
873
|
|
|
* @param number $pag Número da Página |
|
874
|
|
|
* @param number $totPag Total de páginas |
|
875
|
|
|
* |
|
876
|
|
|
* @return number Posição vertical final |
|
877
|
|
|
*/ |
|
878
|
|
|
protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1') { |
|
879
|
|
|
$oldX = $x; |
|
880
|
|
|
$oldY = $y; |
|
881
|
|
|
if ($this->orientacao == 'P') { |
|
882
|
|
|
$maxW = $this->wPrint; |
|
883
|
|
|
} else { |
|
884
|
|
|
if ($pag == 1) { // primeira página |
|
885
|
|
|
$maxW = $this->wPrint - $this->wCanhoto; |
|
886
|
|
|
} else { // páginas seguintes |
|
887
|
|
|
$maxW = $this->wPrint; |
|
888
|
|
|
} |
|
889
|
|
|
} |
|
890
|
|
|
//#################################################################################### |
|
891
|
|
|
//coluna esquerda identificação do emitente |
|
892
|
|
|
$w = round($maxW * 0.41, 0); |
|
893
|
|
|
if ($this->orientacao == 'P') { |
|
894
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I']; |
|
895
|
|
|
} else { |
|
896
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B']; |
|
897
|
|
|
} |
|
898
|
|
|
$w1 = $w; |
|
899
|
|
|
$h = 32; |
|
900
|
|
|
$oldY += $h; |
|
901
|
|
|
$this->pdf->textBox($x, $y, $w, $h); |
|
902
|
|
|
$texto = 'IDENTIFICAÇÃO DO EMITENTE'; |
|
903
|
|
|
$this->pdf->textBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
904
|
|
|
//estabelecer o alinhamento |
|
905
|
|
|
//pode ser left L, center C, right R, full logo L |
|
906
|
|
|
//se for left separar 1/3 da largura para o tamanho da imagem |
|
907
|
|
|
//os outros 2/3 serão usados para os dados do emitente |
|
908
|
|
|
//se for center separar 1/2 da altura para o logo e 1/2 para os dados |
|
909
|
|
|
//se for right separa 2/3 para os dados e o terço seguinte para o logo |
|
910
|
|
|
//se não houver logo centraliza dos dados do emitente |
|
911
|
|
|
// coloca o logo |
|
912
|
|
|
if (! empty($this->logomarca)) { |
|
913
|
|
|
$logoInfo = getimagesize($this->logomarca); |
|
914
|
|
|
//largura da imagem em mm |
|
915
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
|
916
|
|
|
//altura da imagem em mm |
|
917
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
|
918
|
|
|
if ($this->logoAlign == 'L') { |
|
919
|
|
|
$nImgW = round($w / 3, 0); |
|
920
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
921
|
|
|
$xImg = $x + 1; |
|
922
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
923
|
|
|
//estabelecer posições do texto |
|
924
|
|
|
$x1 = round($xImg + $nImgW + 1, 0); |
|
925
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
926
|
|
|
$tw = round(2 * $w / 3, 0); |
|
927
|
|
|
} elseif ($this->logoAlign == 'C') { |
|
928
|
|
|
$nImgH = round($h / 3, 0); |
|
929
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
|
930
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
|
931
|
|
|
$yImg = $y + 3; |
|
932
|
|
|
$x1 = $x; |
|
933
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
|
934
|
|
|
$tw = $w; |
|
935
|
|
|
} elseif ($this->logoAlign == 'R') { |
|
936
|
|
|
$nImgW = round($w / 3, 0); |
|
937
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
938
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
|
939
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
940
|
|
|
$x1 = $x; |
|
941
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
942
|
|
|
$tw = round(2 * $w / 3, 0); |
|
943
|
|
|
} elseif ($this->logoAlign == 'F') { |
|
944
|
|
|
$nImgH = round($h - 5, 0); |
|
945
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
|
946
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
|
947
|
|
|
$yImg = $y + 3; |
|
948
|
|
|
$x1 = $x; |
|
949
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
|
950
|
|
|
$tw = $w; |
|
951
|
|
|
} |
|
952
|
|
|
$type = (substr($this->logomarca, 0, 7) === 'data://') ? 'jpg' : null; |
|
|
|
|
|
|
953
|
|
|
$this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg'); |
|
|
|
|
|
|
954
|
|
|
} else { |
|
955
|
|
|
$x1 = $x; |
|
956
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
957
|
|
|
$tw = $w; |
|
958
|
|
|
} |
|
959
|
|
|
// monta as informações apenas se diferente de full logo |
|
960
|
|
|
if ($this->logoAlign !== 'F') { |
|
961
|
|
|
//Nome emitente |
|
962
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B']; |
|
963
|
|
|
$texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue; |
|
964
|
|
|
$this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
965
|
|
|
//endereço |
|
966
|
|
|
$y1 = $y1 + 5; |
|
967
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => '']; |
|
968
|
|
|
$fone = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue) |
|
969
|
|
|
? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue |
|
970
|
|
|
: ''; |
|
971
|
|
|
$lgr = $this->getTagValue($this->enderEmit, "xLgr"); |
|
972
|
|
|
$nro = $this->getTagValue($this->enderEmit, "nro"); |
|
973
|
|
|
$cpl = $this->getTagValue($this->enderEmit, "xCpl", " - "); |
|
974
|
|
|
$bairro = $this->getTagValue($this->enderEmit, "xBairro"); |
|
975
|
|
|
$CEP = $this->getTagValue($this->enderEmit, "CEP"); |
|
976
|
|
|
$CEP = $this->formatField($CEP, "#####-###"); |
|
977
|
|
|
$mun = $this->getTagValue($this->enderEmit, "xMun"); |
|
978
|
|
|
$UF = $this->getTagValue($this->enderEmit, "UF"); |
|
979
|
|
|
$texto = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - " |
|
980
|
|
|
. $CEP . "\n" . $mun . " - " . $UF . " " |
|
981
|
|
|
. "Fone/Fax: " . $fone; |
|
982
|
|
|
$this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
983
|
|
|
} |
|
984
|
|
|
|
|
985
|
|
|
//#################################################################################### |
|
986
|
|
|
//coluna central Danfe |
|
987
|
|
|
$x += $w; |
|
988
|
|
|
$w = round($maxW * 0.17, 0);//35; |
|
989
|
|
|
$w2 = $w; |
|
990
|
|
|
$h = 32; |
|
991
|
|
|
$this->pdf->textBox($x, $y, $w, $h); |
|
992
|
|
|
|
|
993
|
|
|
$texto = "DANFE"; |
|
994
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B']; |
|
995
|
|
|
$this->pdf->textBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
996
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => '']; |
|
997
|
|
|
$texto = 'Documento Auxiliar da Nota Fiscal Eletrônica'; |
|
998
|
|
|
$h = 20; |
|
999
|
|
|
$this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false); |
|
|
|
|
|
|
1000
|
|
|
|
|
1001
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => '']; |
|
1002
|
|
|
$texto = '0 - ENTRADA'; |
|
1003
|
|
|
$y1 = $y + 14; |
|
1004
|
|
|
$h = 8; |
|
1005
|
|
|
$this->pdf->textBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1006
|
|
|
$texto = '1 - SAÍDA'; |
|
1007
|
|
|
$y1 = $y + 17; |
|
1008
|
|
|
$this->pdf->textBox($x + 2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1009
|
|
|
//tipo de nF |
|
1010
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 12, 'style' => 'B']; |
|
1011
|
|
|
$y1 = $y + 13; |
|
1012
|
|
|
$h = 7; |
|
1013
|
|
|
$texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue; |
|
1014
|
|
|
$this->pdf->textBox($x + 27, $y1, 5, $h, $texto, $aFont, 'C', 'C', 1, ''); |
|
|
|
|
|
|
1015
|
|
|
//numero da NF |
|
1016
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1017
|
|
|
$y1 = $y + 20; |
|
1018
|
|
|
$numNF = str_pad( |
|
1019
|
|
|
$this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, |
|
1020
|
|
|
9, |
|
1021
|
|
|
"0", |
|
1022
|
|
|
STR_PAD_LEFT |
|
1023
|
|
|
); |
|
1024
|
|
|
$numNF = $this->formatField($numNF, "###.###.###"); |
|
1025
|
|
|
$texto = "Nº. " . $numNF; |
|
1026
|
|
|
$this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
1027
|
|
|
//Série |
|
1028
|
|
|
$y1 = $y + 23; |
|
1029
|
|
|
$serie = str_pad( |
|
1030
|
|
|
$this->ide->getElementsByTagName('serie')->item(0)->nodeValue, |
|
1031
|
|
|
3, |
|
1032
|
|
|
"0", |
|
1033
|
|
|
STR_PAD_LEFT |
|
1034
|
|
|
); |
|
1035
|
|
|
$texto = "Série " . $serie; |
|
1036
|
|
|
$this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
1037
|
|
|
//numero paginas |
|
1038
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'I']; |
|
1039
|
|
|
$y1 = $y + 26; |
|
1040
|
|
|
$texto = "Folha " . $pag . "/" . $totPag; |
|
1041
|
|
|
$this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
1042
|
|
|
|
|
1043
|
|
|
//#################################################################################### |
|
1044
|
|
|
//coluna codigo de barras |
|
1045
|
|
|
$x += $w; |
|
1046
|
|
|
$w = ($maxW - $w1 - $w2);//85; |
|
1047
|
|
|
$w3 = $w; |
|
1048
|
|
|
$h = 32; |
|
1049
|
|
|
$this->pdf->textBox($x, $y, $w, $h); |
|
1050
|
|
|
$this->pdf->setFillColor(0, 0, 0); |
|
1051
|
|
|
$chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id")); |
|
1052
|
|
|
$bW = 75; |
|
1053
|
|
|
$bH = 12; |
|
1054
|
|
|
//codigo de barras |
|
1055
|
|
|
$this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH); |
|
1056
|
|
|
//linhas divisorias |
|
1057
|
|
|
$this->pdf->line($x, $y + 4 + $bH, $x + $w, $y + 4 + $bH); |
|
1058
|
|
|
$this->pdf->line($x, $y + 12 + $bH, $x + $w, $y + 12 + $bH); |
|
1059
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1060
|
|
|
$y1 = $y + 4 + $bH; |
|
1061
|
|
|
$h = 7; |
|
1062
|
|
|
$texto = 'CHAVE DE ACESSO'; |
|
1063
|
|
|
$this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1064
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B']; |
|
1065
|
|
|
$y1 = $y + 8 + $bH; |
|
1066
|
|
|
$texto = $this->formatField($chave_acesso, $this->formatoChave); |
|
1067
|
|
|
$this->pdf->textBox($x + 2, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
1068
|
|
|
$y1 = $y + 12 + $bH; |
|
1069
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => '']; |
|
1070
|
|
|
$chaveContingencia = ""; |
|
1071
|
|
|
if ($this->notaDpec()) { |
|
1072
|
|
|
$cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO DPEC'; |
|
1073
|
|
|
} else { |
|
1074
|
|
|
$cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO'; |
|
1075
|
|
|
} |
|
1076
|
|
|
if (($this->tpEmis == 2 || $this->tpEmis == 5) && ! $this->notaDpec()) { |
|
1077
|
|
|
$cabecalhoProtoAutorizacao = "DADOS DA NF-E"; |
|
1078
|
|
|
$chaveContingencia = $this->geraChaveAdicionalDeContingencia(); |
|
1079
|
|
|
$this->pdf->setFillColor(0, 0, 0); |
|
1080
|
|
|
//codigo de barras |
|
1081
|
|
|
$this->pdf->code128($x + 11, $y1 + 1, $chaveContingencia, $bW * .9, $bH / 2); |
|
1082
|
|
|
} else { |
|
1083
|
|
|
$texto = 'Consulta de autenticidade no portal nacional da NF-e'; |
|
1084
|
|
|
$this->pdf->textBox($x + 2, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
1085
|
|
|
$y1 = $y + 16 + $bH; |
|
1086
|
|
|
$texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'; |
|
1087
|
|
|
$this->pdf->textBox( |
|
1088
|
|
|
$x + 2, |
|
1089
|
|
|
$y1, |
|
1090
|
|
|
$w - 2, |
|
1091
|
|
|
$h, |
|
1092
|
|
|
$texto, |
|
1093
|
|
|
$aFont, |
|
1094
|
|
|
'T', |
|
1095
|
|
|
'C', |
|
1096
|
|
|
0, |
|
|
|
|
|
|
1097
|
|
|
'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora' |
|
1098
|
|
|
); |
|
1099
|
|
|
} |
|
1100
|
|
|
|
|
1101
|
|
|
//#################################################################################### |
|
1102
|
|
|
//Dados da NF do cabeçalho |
|
1103
|
|
|
//natureza da operação |
|
1104
|
|
|
$texto = 'NATUREZA DA OPERAÇÃO'; |
|
1105
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1106
|
|
|
$w = $w1 + $w2; |
|
1107
|
|
|
$y = $oldY; |
|
1108
|
|
|
$oldY += $h; |
|
1109
|
|
|
$x = $oldX; |
|
1110
|
|
|
$h = 7; |
|
1111
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1112
|
|
|
$texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue; |
|
1113
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1114
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1115
|
|
|
$x += $w; |
|
1116
|
|
|
$w = $w3; |
|
1117
|
|
|
//PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E |
|
1118
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1119
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $cabecalhoProtoAutorizacao, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1120
|
|
|
// algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser |
|
1121
|
|
|
// testada antes de tentar obter a informação. |
|
1122
|
|
|
// NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!! |
|
1123
|
|
|
// Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização. |
|
1124
|
|
|
// Na minha opinião, deveríamos mostra-lo, mas o manual da NFe v4.01 diz outra coisa... |
|
1125
|
|
|
if (($this->tpEmis == 2 || $this->tpEmis == 5) && ! $this->notaDpec()) { |
|
1126
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B']; |
|
1127
|
|
|
$texto = $this->formatField( |
|
1128
|
|
|
$chaveContingencia, |
|
1129
|
|
|
"#### #### #### #### #### #### #### #### ####" |
|
1130
|
|
|
); |
|
1131
|
|
|
$cStat = ''; |
|
|
|
|
|
|
1132
|
|
|
} else { |
|
1133
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1134
|
|
|
if ($this->notaDpec()) { |
|
1135
|
|
|
$texto = $this->numdepec; |
|
1136
|
|
|
$cStat = ''; |
|
|
|
|
|
|
1137
|
|
|
} else { |
|
1138
|
|
|
if (isset($this->nfeProc)) { |
|
1139
|
|
|
$texto = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) |
|
1140
|
|
|
? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue |
|
1141
|
|
|
: ''; |
|
1142
|
|
|
$tsHora = $this->toTimestamp( |
|
1143
|
|
|
$this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue |
|
1144
|
|
|
); |
|
1145
|
|
|
if ($texto != '') { |
|
1146
|
|
|
$texto .= " - " . date('d/m/Y H:i:s', $tsHora); |
|
1147
|
|
|
} |
|
1148
|
|
|
$cStat = $this->nfeProc->getElementsByTagName("cStat")->item(0)->nodeValue; |
|
|
|
|
|
|
1149
|
|
|
} else { |
|
1150
|
|
|
$texto = ''; |
|
1151
|
|
|
$cStat = ''; |
|
|
|
|
|
|
1152
|
|
|
} |
|
1153
|
|
|
} |
|
1154
|
|
|
} |
|
1155
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1156
|
|
|
//#################################################################################### |
|
1157
|
|
|
//INSCRIÇÃO ESTADUAL |
|
1158
|
|
|
$w = round($maxW * 0.250, 0); |
|
1159
|
|
|
$y += $h; |
|
1160
|
|
|
$oldY += $h; |
|
1161
|
|
|
$x = $oldX; |
|
1162
|
|
|
$texto = 'INSCRIÇÃO ESTADUAL'; |
|
1163
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1164
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1165
|
|
|
$texto = $this->getTagValue($this->emit, "IE"); |
|
1166
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1167
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1168
|
|
|
//INSCRIÇÃO MUNICIPAL |
|
1169
|
|
|
$x += $w; |
|
1170
|
|
|
$texto = 'INSCRIÇÃO MUNICIPAL'; |
|
1171
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1172
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1173
|
|
|
$texto = $this->getTagValue($this->emit, "IM"); |
|
1174
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1175
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1176
|
|
|
//INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT. |
|
1177
|
|
|
$x += $w; |
|
1178
|
|
|
$texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.'; |
|
1179
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1180
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1181
|
|
|
$texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue) |
|
1182
|
|
|
? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue |
|
1183
|
|
|
: ''; |
|
1184
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1185
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1186
|
|
|
//CNPJ |
|
1187
|
|
|
$x += $w; |
|
1188
|
|
|
$w = ($maxW - (3 * $w)); |
|
1189
|
|
|
$texto = 'CNPJ'; |
|
1190
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1191
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1192
|
|
|
//Pegando valor do CPF/CNPJ |
|
1193
|
|
|
if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) { |
|
1194
|
|
|
$texto = $this->formatField( |
|
1195
|
|
|
$this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
|
1196
|
|
|
"###.###.###/####-##" |
|
1197
|
|
|
); |
|
1198
|
|
|
} else { |
|
1199
|
|
|
$texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue) |
|
1200
|
|
|
? $this->formatField( |
|
1201
|
|
|
$this->emit->getElementsByTagName("CPF")->item(0)->nodeValue, |
|
1202
|
|
|
"###.###.###-##" |
|
1203
|
|
|
) |
|
1204
|
|
|
: ''; |
|
1205
|
|
|
} |
|
1206
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1207
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1208
|
|
|
|
|
1209
|
|
|
//#################################################################################### |
|
1210
|
|
|
//Indicação de NF Homologação, cancelamento e falta de protocolo |
|
1211
|
|
|
$tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue; |
|
|
|
|
|
|
1212
|
|
|
//indicar cancelamento |
|
1213
|
|
|
$resp = $this->statusNFe(); |
|
1214
|
|
|
if (! $resp['status']) { |
|
1215
|
|
|
$x = 10; |
|
1216
|
|
|
$y = $this->hPrint - 130; |
|
1217
|
|
|
$h = 25; |
|
1218
|
|
|
$w = $maxW - (2 * $x); |
|
1219
|
|
|
$this->pdf->settextcolor(90, 90, 90); |
|
1220
|
|
|
$texto = $resp['message']; |
|
1221
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B']; |
|
1222
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
1223
|
|
|
$y += $h; |
|
1224
|
|
|
$h = 5; |
|
1225
|
|
|
$w = $maxW - (2 * $x); |
|
1226
|
|
|
if (isset($this->infProt) && $resp['status']) { |
|
1227
|
|
|
$xMotivo = $this->infProt->getElementsByTagName("xMotivo")->item(0)->nodeValue; |
|
1228
|
|
|
} else { |
|
1229
|
|
|
$xMotivo = ''; |
|
1230
|
|
|
} |
|
1231
|
|
|
$texto = "SEM VALOR FISCAL\n" . $xMotivo; |
|
1232
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B']; |
|
1233
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
1234
|
|
|
$this->pdf->settextcolor(0, 0, 0); |
|
1235
|
|
|
} |
|
1236
|
|
|
if ($this->notaDpec() || $this->tpEmis == 4) { |
|
1237
|
|
|
//DPEC |
|
1238
|
|
|
$x = 10; |
|
1239
|
|
|
$y = $this->hPrint - 130; |
|
1240
|
|
|
$h = 25; |
|
1241
|
|
|
$w = $maxW - (2 * $x); |
|
1242
|
|
|
$this->pdf->SetTextColor(200, 200, 200); |
|
1243
|
|
|
$texto = "DANFE impresso em contingência -\n" . |
|
1244
|
|
|
"DPEC regularmente recebido pela Receita\n" . |
|
1245
|
|
|
"Federal do Brasil"; |
|
1246
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 48, 'style' => 'B']; |
|
1247
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
|
|
|
|
|
1248
|
|
|
$this->pdf->SetTextColor(0, 0, 0); |
|
1249
|
|
|
} |
|
1250
|
|
|
|
|
1251
|
|
|
return $oldY; |
|
1252
|
|
|
} //fim header |
|
1253
|
|
|
|
|
1254
|
|
|
/** |
|
1255
|
|
|
* destinatarioDANFE |
|
1256
|
|
|
* Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem) |
|
1257
|
|
|
* |
|
1258
|
|
|
* @name destinatarioDANFE |
|
1259
|
|
|
* |
|
1260
|
|
|
* @param number $x Posição horizontal canto esquerdo |
|
1261
|
|
|
* @param number $y Posição vertical canto superior |
|
1262
|
|
|
* |
|
1263
|
|
|
* @return number Posição vertical final |
|
1264
|
|
|
*/ |
|
1265
|
|
|
protected function destinatarioDANFE($x = 0, $y = 0) { |
|
1266
|
|
|
//#################################################################################### |
|
1267
|
|
|
//DESTINATÁRIO / REMETENTE |
|
1268
|
|
|
$oldX = $x; |
|
1269
|
|
|
$oldY = $y; |
|
|
|
|
|
|
1270
|
|
|
if ($this->orientacao == 'P') { |
|
1271
|
|
|
$maxW = $this->wPrint; |
|
1272
|
|
|
} else { |
|
1273
|
|
|
$maxW = $this->wPrint - $this->wCanhoto; |
|
1274
|
|
|
} |
|
1275
|
|
|
$w = $maxW; |
|
1276
|
|
|
$h = 7; |
|
1277
|
|
|
$texto = 'DESTINATÁRIO / REMETENTE'; |
|
1278
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1279
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1280
|
|
|
//NOME / RAZÃO SOCIAL |
|
1281
|
|
|
$w = round($maxW * 0.61, 0); |
|
1282
|
|
|
$w1 = $w; |
|
1283
|
|
|
$y += 3; |
|
1284
|
|
|
$texto = 'NOME / RAZÃO SOCIAL'; |
|
1285
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1286
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1287
|
|
|
$texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue; |
|
1288
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1289
|
|
|
if ($this->orientacao == 'P') { |
|
1290
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
1291
|
|
|
} else { |
|
1292
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, ''); |
|
|
|
|
|
|
1293
|
|
|
} |
|
1294
|
|
|
//CNPJ / CPF |
|
1295
|
|
|
$x += $w; |
|
1296
|
|
|
$w = round($maxW * 0.23, 0); |
|
1297
|
|
|
$w2 = $w; |
|
1298
|
|
|
$texto = 'CNPJ / CPF'; |
|
1299
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1300
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1301
|
|
|
//Pegando valor do CPF/CNPJ |
|
1302
|
|
|
if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) { |
|
1303
|
|
|
$texto = $this->formatField( |
|
1304
|
|
|
$this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
|
1305
|
|
|
"###.###.###/####-##" |
|
1306
|
|
|
); |
|
1307
|
|
|
} else { |
|
1308
|
|
|
$texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) |
|
1309
|
|
|
? $this->formatField( |
|
1310
|
|
|
$this->dest->getElementsByTagName("CPF")->item(0)->nodeValue, |
|
1311
|
|
|
"###.###.###-##" |
|
1312
|
|
|
) |
|
1313
|
|
|
: ''; |
|
1314
|
|
|
} |
|
1315
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1316
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1317
|
|
|
//DATA DA EMISSÃO |
|
1318
|
|
|
$x += $w; |
|
1319
|
|
|
$w = $maxW - ($w1 + $w2); |
|
1320
|
|
|
$wx = $w; |
|
1321
|
|
|
$texto = 'DATA DA EMISSÃO'; |
|
1322
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1323
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1324
|
|
|
$dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) |
|
1325
|
|
|
? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue |
|
1326
|
|
|
: ''; |
|
1327
|
|
|
if ($dEmi == '') { |
|
1328
|
|
|
$dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) |
|
1329
|
|
|
? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue |
|
1330
|
|
|
: ''; |
|
1331
|
|
|
$aDemi = explode('T', $dEmi); |
|
1332
|
|
|
$dEmi = $aDemi[0]; |
|
1333
|
|
|
} |
|
1334
|
|
|
$texto = $this->ymdTodmy($dEmi); |
|
1335
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1336
|
|
|
if ($this->orientacao == 'P') { |
|
1337
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1338
|
|
|
} else { |
|
1339
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, ''); |
|
|
|
|
|
|
1340
|
|
|
} |
|
1341
|
|
|
//ENDEREÇO |
|
1342
|
|
|
$w = round($maxW * 0.47, 0); |
|
1343
|
|
|
$w1 = $w; |
|
1344
|
|
|
$y += $h; |
|
1345
|
|
|
$x = $oldX; |
|
1346
|
|
|
$texto = 'ENDEREÇO'; |
|
1347
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1348
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1349
|
|
|
$texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue; |
|
1350
|
|
|
$texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue; |
|
1351
|
|
|
$texto .= $this->getTagValue($this->dest, "xCpl", " - "); |
|
1352
|
|
|
|
|
1353
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1354
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true); |
|
|
|
|
|
|
1355
|
|
|
//BAIRRO / DISTRITO |
|
1356
|
|
|
$x += $w; |
|
1357
|
|
|
$w = round($maxW * 0.21, 0); |
|
1358
|
|
|
$w2 = $w; |
|
1359
|
|
|
$texto = 'BAIRRO / DISTRITO'; |
|
1360
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1361
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1362
|
|
|
$texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue; |
|
1363
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1364
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1365
|
|
|
//CEP |
|
1366
|
|
|
$x += $w; |
|
1367
|
|
|
$w = $maxW - $w1 - $w2 - $wx; |
|
1368
|
|
|
$w2 = $w; |
|
|
|
|
|
|
1369
|
|
|
$texto = 'CEP'; |
|
1370
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1371
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1372
|
|
|
$texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue) |
|
1373
|
|
|
? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue |
|
1374
|
|
|
: ''; |
|
1375
|
|
|
$texto = $this->formatField($texto, "#####-###"); |
|
1376
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1377
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1378
|
|
|
//DATA DA SAÍDA |
|
1379
|
|
|
$x += $w; |
|
1380
|
|
|
$w = $wx; |
|
1381
|
|
|
$texto = 'DATA DA SAÍDA/ENTRADA'; |
|
1382
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1383
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1384
|
|
|
$dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue) |
|
1385
|
|
|
? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue |
|
1386
|
|
|
: ''; |
|
1387
|
|
|
if ($dSaiEnt == '') { |
|
1388
|
|
|
$dSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) |
|
1389
|
|
|
? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue |
|
1390
|
|
|
: ''; |
|
1391
|
|
|
$aDsaient = explode('T', $dSaiEnt); |
|
1392
|
|
|
$dSaiEnt = $aDsaient[0]; |
|
1393
|
|
|
} |
|
1394
|
|
|
$texto = $this->ymdTodmy($dSaiEnt); |
|
1395
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1396
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1397
|
|
|
//MUNICÍPIO |
|
1398
|
|
|
$w = $w1; |
|
1399
|
|
|
$y += $h; |
|
1400
|
|
|
$x = $oldX; |
|
1401
|
|
|
$texto = 'MUNICÍPIO'; |
|
1402
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1403
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1404
|
|
|
$texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue; |
|
1405
|
|
|
if (strtoupper(trim($texto)) == "EXTERIOR" |
|
1406
|
|
|
&& $this->dest->getElementsByTagName("xPais")->length > 0 |
|
1407
|
|
|
) { |
|
1408
|
|
|
$texto .= " - " . $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue; |
|
1409
|
|
|
} |
|
1410
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1411
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
1412
|
|
|
//UF |
|
1413
|
|
|
$x += $w; |
|
1414
|
|
|
$w = 8; |
|
1415
|
|
|
$texto = 'UF'; |
|
1416
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1417
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1418
|
|
|
$texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue; |
|
1419
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1420
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1421
|
|
|
//FONE / FAX |
|
1422
|
|
|
$x += $w; |
|
1423
|
|
|
$w = round(($maxW - $w1 - $wx - 8) / 2, 0); |
|
1424
|
|
|
$w3 = $w; |
|
1425
|
|
|
$texto = 'FONE / FAX'; |
|
1426
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1427
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1428
|
|
|
$texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue) |
|
1429
|
|
|
? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue |
|
1430
|
|
|
: ''; |
|
1431
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1432
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1433
|
|
|
//INSCRIÇÃO ESTADUAL |
|
1434
|
|
|
$x += $w; |
|
1435
|
|
|
$w = $maxW - $w1 - $wx - 8 - $w3; |
|
1436
|
|
|
$texto = 'INSCRIÇÃO ESTADUAL'; |
|
1437
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1438
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1439
|
|
|
$IE = $this->dest->getElementsByTagName("IE"); |
|
1440
|
|
|
$texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : ''; |
|
1441
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1442
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1443
|
|
|
//HORA DA SAÍDA |
|
1444
|
|
|
$x += $w; |
|
1445
|
|
|
$w = $wx; |
|
1446
|
|
|
$texto = 'HORA DA SAÍDA/ENTRADA'; |
|
1447
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1448
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1449
|
|
|
$hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue) |
|
1450
|
|
|
? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue |
|
1451
|
|
|
: ''; |
|
1452
|
|
|
if ($hSaiEnt == '') { |
|
1453
|
|
|
$dhSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue) |
|
1454
|
|
|
? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue |
|
1455
|
|
|
: ''; |
|
1456
|
|
|
$tsDhSaiEnt = $this->toTimestamp($dhSaiEnt); |
|
1457
|
|
|
if ($tsDhSaiEnt != '') { |
|
1458
|
|
|
$hSaiEnt = date('H:i:s', $tsDhSaiEnt); |
|
1459
|
|
|
} |
|
1460
|
|
|
} |
|
1461
|
|
|
$texto = $hSaiEnt; |
|
1462
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1463
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1464
|
|
|
|
|
1465
|
|
|
return ($y + $h); |
|
1466
|
|
|
} //fim da função destinatarioDANFE |
|
1467
|
|
|
|
|
1468
|
|
|
/** |
|
1469
|
|
|
* localEntregaDANFE |
|
1470
|
|
|
* Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem) |
|
1471
|
|
|
* |
|
1472
|
|
|
* @name localEntregaDANFE |
|
1473
|
|
|
* |
|
1474
|
|
|
* @param number $x Posição horizontal canto esquerdo |
|
1475
|
|
|
* @param number $y Posição vertical canto superior |
|
1476
|
|
|
* |
|
1477
|
|
|
* @return number Posição vertical final |
|
1478
|
|
|
*/ |
|
1479
|
|
|
protected function localEntregaDANFE($x = 0, $y = 0) { |
|
1480
|
|
|
//#################################################################################### |
|
1481
|
|
|
//LOCAL DE ENTREGA |
|
1482
|
|
|
$oldX = $x; |
|
1483
|
|
|
if ($this->orientacao == 'P') { |
|
1484
|
|
|
$maxW = $this->wPrint; |
|
1485
|
|
|
} else { |
|
1486
|
|
|
$maxW = $this->wPrint - $this->wCanhoto; |
|
1487
|
|
|
} |
|
1488
|
|
|
$w = $maxW; |
|
1489
|
|
|
$h = 7; |
|
1490
|
|
|
$texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA'; |
|
1491
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1492
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1493
|
|
|
//NOME / RAZÃO SOCIAL |
|
1494
|
|
|
$w = round($maxW * 0.61, 0); |
|
1495
|
|
|
$w1 = $w; |
|
1496
|
|
|
$y += 3; |
|
1497
|
|
|
$texto = 'NOME / RAZÃO SOCIAL'; |
|
1498
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1499
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1500
|
|
|
$texto = ''; |
|
1501
|
|
|
if ($this->entrega->getElementsByTagName("xNome")->item(0)) { |
|
1502
|
|
|
$texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue; |
|
1503
|
|
|
} |
|
1504
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1505
|
|
|
if ($this->orientacao == 'P') { |
|
1506
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
1507
|
|
|
} else { |
|
1508
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, ''); |
|
|
|
|
|
|
1509
|
|
|
} |
|
1510
|
|
|
//CNPJ / CPF |
|
1511
|
|
|
$x += $w; |
|
1512
|
|
|
$w = round($maxW * 0.23, 0); |
|
1513
|
|
|
$w2 = $w; |
|
1514
|
|
|
$texto = 'CNPJ / CPF'; |
|
1515
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1516
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1517
|
|
|
//Pegando valor do CPF/CNPJ |
|
1518
|
|
|
if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) { |
|
1519
|
|
|
$texto = $this->formatField( |
|
1520
|
|
|
$this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
|
1521
|
|
|
"###.###.###/####-##" |
|
1522
|
|
|
); |
|
1523
|
|
|
} else { |
|
1524
|
|
|
$texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ? |
|
1525
|
|
|
$this->formatField( |
|
1526
|
|
|
$this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue, |
|
1527
|
|
|
"###.###.###-##" |
|
1528
|
|
|
) : ''; |
|
1529
|
|
|
} |
|
1530
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1531
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1532
|
|
|
//INSCRIÇÃO ESTADUAL |
|
1533
|
|
|
$x += $w; |
|
1534
|
|
|
$w = $maxW - ($w1 + $w2); |
|
1535
|
|
|
$wx = $w; |
|
1536
|
|
|
$texto = 'INSCRIÇÃO ESTADUAL'; |
|
1537
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1538
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1539
|
|
|
$texto = ''; |
|
1540
|
|
|
if ($this->entrega->getElementsByTagName("IE")->item(0)) { |
|
1541
|
|
|
$texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue; |
|
1542
|
|
|
} |
|
1543
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1544
|
|
|
if ($this->orientacao == 'P') { |
|
1545
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1546
|
|
|
} else { |
|
1547
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, ''); |
|
|
|
|
|
|
1548
|
|
|
} |
|
1549
|
|
|
//ENDEREÇO |
|
1550
|
|
|
$w = round($maxW * 0.355, 0) + $wx; |
|
1551
|
|
|
$w1 = $w; |
|
1552
|
|
|
$y += $h; |
|
1553
|
|
|
$x = $oldX; |
|
1554
|
|
|
$texto = 'ENDEREÇO'; |
|
1555
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1556
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1557
|
|
|
$texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue; |
|
1558
|
|
|
$texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue; |
|
1559
|
|
|
$texto .= $this->getTagValue($this->entrega, "xCpl", " - "); |
|
1560
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1561
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true); |
|
|
|
|
|
|
1562
|
|
|
//BAIRRO / DISTRITO |
|
1563
|
|
|
$x += $w; |
|
1564
|
|
|
$w = round($maxW * 0.335, 0); |
|
1565
|
|
|
$w2 = $w; |
|
1566
|
|
|
$texto = 'BAIRRO / DISTRITO'; |
|
1567
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1568
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1569
|
|
|
$texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue; |
|
1570
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1571
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1572
|
|
|
//CEP |
|
1573
|
|
|
$x += $w; |
|
1574
|
|
|
$w = $maxW - ($w1 + $w2); |
|
1575
|
|
|
$texto = 'CEP'; |
|
1576
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1577
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1578
|
|
|
$texto = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ? |
|
1579
|
|
|
$this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : ''; |
|
1580
|
|
|
$texto = $this->formatField($texto, "#####-###"); |
|
1581
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1582
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1583
|
|
|
//MUNICÍPIO |
|
1584
|
|
|
$w = round($maxW * 0.805, 0); |
|
1585
|
|
|
$w1 = $w; |
|
1586
|
|
|
$y += $h; |
|
1587
|
|
|
$x = $oldX; |
|
1588
|
|
|
$texto = 'MUNICÍPIO'; |
|
1589
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1590
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1591
|
|
|
$texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue; |
|
1592
|
|
|
if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) { |
|
1593
|
|
|
$texto .= " - " . $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue; |
|
1594
|
|
|
} |
|
1595
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1596
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
1597
|
|
|
//UF |
|
1598
|
|
|
$x += $w; |
|
1599
|
|
|
$w = 8; |
|
1600
|
|
|
$texto = 'UF'; |
|
1601
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1602
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1603
|
|
|
$texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue; |
|
1604
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1605
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1606
|
|
|
//FONE / FAX |
|
1607
|
|
|
$x += $w; |
|
1608
|
|
|
$w = $maxW - $w - $w1; |
|
1609
|
|
|
$texto = 'FONE / FAX'; |
|
1610
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1611
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1612
|
|
|
$texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ? |
|
1613
|
|
|
$this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : ''; |
|
1614
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1615
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1616
|
|
|
|
|
1617
|
|
|
return ($y + $h); |
|
1618
|
|
|
} //fim da função localEntregaDANFE |
|
1619
|
|
|
|
|
1620
|
|
|
/** |
|
1621
|
|
|
* localretiradaDANFE |
|
1622
|
|
|
* Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem) |
|
1623
|
|
|
* |
|
1624
|
|
|
* @name localretiradaDANFE |
|
1625
|
|
|
* |
|
1626
|
|
|
* @param number $x Posição horizontal canto esquerdo |
|
1627
|
|
|
* @param number $y Posição vertical canto superior |
|
1628
|
|
|
* |
|
1629
|
|
|
* @return number Posição vertical final |
|
1630
|
|
|
*/ |
|
1631
|
|
|
protected function localRetiradaDANFE($x = 0, $y = 0) { |
|
1632
|
|
|
//#################################################################################### |
|
1633
|
|
|
//LOCAL DE RETIRADA |
|
1634
|
|
|
$oldX = $x; |
|
1635
|
|
|
if ($this->orientacao == 'P') { |
|
1636
|
|
|
$maxW = $this->wPrint; |
|
1637
|
|
|
} else { |
|
1638
|
|
|
$maxW = $this->wPrint - $this->wCanhoto; |
|
1639
|
|
|
} |
|
1640
|
|
|
$w = $maxW; |
|
1641
|
|
|
$h = 7; |
|
1642
|
|
|
$texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA'; |
|
1643
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1644
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1645
|
|
|
//NOME / RAZÃO SOCIAL |
|
1646
|
|
|
$w = round($maxW * 0.61, 0); |
|
1647
|
|
|
$w1 = $w; |
|
1648
|
|
|
$y += 3; |
|
1649
|
|
|
$texto = 'NOME / RAZÃO SOCIAL'; |
|
1650
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1651
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1652
|
|
|
$texto = ''; |
|
1653
|
|
|
if ($this->retirada->getElementsByTagName("xNome")->item(0)) { |
|
1654
|
|
|
$texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue; |
|
1655
|
|
|
} |
|
1656
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1657
|
|
|
if ($this->orientacao == 'P') { |
|
1658
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
1659
|
|
|
} else { |
|
1660
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, ''); |
|
|
|
|
|
|
1661
|
|
|
} |
|
1662
|
|
|
//CNPJ / CPF |
|
1663
|
|
|
$x += $w; |
|
1664
|
|
|
$w = round($maxW * 0.23, 0); |
|
1665
|
|
|
$w2 = $w; |
|
1666
|
|
|
$texto = 'CNPJ / CPF'; |
|
1667
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1668
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1669
|
|
|
//Pegando valor do CPF/CNPJ |
|
1670
|
|
|
if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) { |
|
1671
|
|
|
$texto = $this->formatField( |
|
1672
|
|
|
$this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
|
1673
|
|
|
"###.###.###/####-##" |
|
1674
|
|
|
); |
|
1675
|
|
|
} else { |
|
1676
|
|
|
$texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ? |
|
1677
|
|
|
$this->formatField( |
|
1678
|
|
|
$this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue, |
|
1679
|
|
|
"###.###.###-##" |
|
1680
|
|
|
) : ''; |
|
1681
|
|
|
} |
|
1682
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1683
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1684
|
|
|
//INSCRIÇÃO ESTADUAL |
|
1685
|
|
|
$x += $w; |
|
1686
|
|
|
$w = $maxW - ($w1 + $w2); |
|
1687
|
|
|
$wx = $w; |
|
1688
|
|
|
$texto = 'INSCRIÇÃO ESTADUAL'; |
|
1689
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1690
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1691
|
|
|
$texto = ''; |
|
1692
|
|
|
if ($this->retirada->getElementsByTagName("IE")->item(0)) { |
|
1693
|
|
|
$texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue; |
|
1694
|
|
|
} |
|
1695
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1696
|
|
|
if ($this->orientacao == 'P') { |
|
1697
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1698
|
|
|
} else { |
|
1699
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, ''); |
|
|
|
|
|
|
1700
|
|
|
} |
|
1701
|
|
|
//ENDEREÇO |
|
1702
|
|
|
$w = round($maxW * 0.355, 0) + $wx; |
|
1703
|
|
|
$w1 = $w; |
|
1704
|
|
|
$y += $h; |
|
1705
|
|
|
$x = $oldX; |
|
1706
|
|
|
$texto = 'ENDEREÇO'; |
|
1707
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1708
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1709
|
|
|
$texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue; |
|
1710
|
|
|
$texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue; |
|
1711
|
|
|
$texto .= $this->getTagValue($this->retirada, "xCpl", " - "); |
|
1712
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1713
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true); |
|
|
|
|
|
|
1714
|
|
|
//BAIRRO / DISTRITO |
|
1715
|
|
|
$x += $w; |
|
1716
|
|
|
$w = round($maxW * 0.335, 0); |
|
1717
|
|
|
$w2 = $w; |
|
1718
|
|
|
$texto = 'BAIRRO / DISTRITO'; |
|
1719
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1720
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1721
|
|
|
$texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue; |
|
1722
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1723
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1724
|
|
|
//CEP |
|
1725
|
|
|
$x += $w; |
|
1726
|
|
|
$w = $maxW - ($w1 + $w2); |
|
1727
|
|
|
$texto = 'CEP'; |
|
1728
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1729
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1730
|
|
|
$texto = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ? |
|
1731
|
|
|
$this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : ''; |
|
1732
|
|
|
$texto = $this->formatField($texto, "#####-###"); |
|
1733
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1734
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1735
|
|
|
//MUNICÍPIO |
|
1736
|
|
|
$w = round($maxW * 0.805, 0); |
|
1737
|
|
|
$w1 = $w; |
|
1738
|
|
|
$y += $h; |
|
1739
|
|
|
$x = $oldX; |
|
1740
|
|
|
$texto = 'MUNICÍPIO'; |
|
1741
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1742
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1743
|
|
|
$texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue; |
|
1744
|
|
|
if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) { |
|
1745
|
|
|
$texto .= " - " . $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue; |
|
1746
|
|
|
} |
|
1747
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1748
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
1749
|
|
|
//UF |
|
1750
|
|
|
$x += $w; |
|
1751
|
|
|
$w = 8; |
|
1752
|
|
|
$texto = 'UF'; |
|
1753
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1754
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1755
|
|
|
$texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue; |
|
1756
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1757
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1758
|
|
|
//FONE / FAX |
|
1759
|
|
|
$x += $w; |
|
1760
|
|
|
$w = $maxW - $w - $w1; |
|
1761
|
|
|
$texto = 'FONE / FAX'; |
|
1762
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1763
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1764
|
|
|
$texto = ! empty($this->retirada->getElementsByTagName("fone")->item(0)->nodeValue) ? |
|
1765
|
|
|
$this->retirada->getElementsByTagName("fone")->item(0)->nodeValue : ''; |
|
1766
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
1767
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
1768
|
|
|
|
|
1769
|
|
|
return ($y + $h); |
|
1770
|
|
|
} //fim da função localRetiradaDANFE |
|
1771
|
|
|
|
|
1772
|
|
|
/** |
|
1773
|
|
|
* getTextoFatura |
|
1774
|
|
|
* Gera a String do Texto da Fatura |
|
1775
|
|
|
* |
|
1776
|
|
|
* @name getTextoFatura |
|
1777
|
|
|
* @return uma String com o texto ou ""; |
|
1778
|
|
|
*/ |
|
1779
|
|
|
protected function getTextoFatura() { |
|
1780
|
|
|
if (isset($this->cobr)) { |
|
1781
|
|
|
$fat = $this->cobr->getElementsByTagName("fat")->item(0); |
|
1782
|
|
|
if (isset($fat)) { |
|
1783
|
|
|
if (! empty($this->getTagValue($this->ide, "indPag"))) { |
|
1784
|
|
|
$textoIndPag = ""; |
|
1785
|
|
|
$indPag = $this->getTagValue($this->ide, "indPag"); |
|
1786
|
|
|
if ($indPag === "0") { |
|
1787
|
|
|
$textoIndPag = "Pagamento à Vista - "; |
|
1788
|
|
|
} elseif ($indPag === "1") { |
|
1789
|
|
|
$textoIndPag = "Pagamento à Prazo - "; |
|
1790
|
|
|
} |
|
1791
|
|
|
$nFat = $this->getTagValue($fat, "nFat", "Fatura: "); |
|
1792
|
|
|
$vOrig = $this->getTagValue($fat, "vOrig", " Valor Original: "); |
|
1793
|
|
|
$vDesc = $this->getTagValue($fat, "vDesc", " Desconto: "); |
|
1794
|
|
|
$vLiq = $this->getTagValue($fat, "vLiq", " Valor Líquido: "); |
|
1795
|
|
|
$texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq; |
|
1796
|
|
|
|
|
1797
|
|
|
return $texto; |
|
1798
|
|
|
} else { |
|
1799
|
|
|
$pag = $this->dom->getElementsByTagName("pag"); |
|
1800
|
|
|
if ($tPag = $this->getTagValue($pag->item(0), "tPag")) { |
|
1801
|
|
|
return $this->tipoPag($tPag); |
|
1802
|
|
|
} |
|
1803
|
|
|
} |
|
1804
|
|
|
} |
|
1805
|
|
|
} |
|
1806
|
|
|
|
|
1807
|
|
|
return ""; |
|
1808
|
|
|
} |
|
1809
|
|
|
|
|
1810
|
|
|
/** |
|
1811
|
|
|
* sizeExtraTextoFatura |
|
1812
|
|
|
* Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata. |
|
1813
|
|
|
* |
|
1814
|
|
|
* @name sizeExtraTextoFatura |
|
1815
|
|
|
* @return integer |
|
1816
|
|
|
*/ |
|
1817
|
|
|
protected function sizeExtraTextoFatura() { |
|
1818
|
|
|
$textoFatura = $this->getTextoFatura(); |
|
1819
|
|
|
//verificar se existem duplicatas |
|
1820
|
|
|
if ($this->dup->length == 0 && $textoFatura !== "") { |
|
|
|
|
|
|
1821
|
|
|
return 10; |
|
1822
|
|
|
} |
|
1823
|
|
|
|
|
1824
|
|
|
return 0; |
|
1825
|
|
|
} |
|
1826
|
|
|
|
|
1827
|
|
|
/** |
|
1828
|
|
|
* fatura |
|
1829
|
|
|
* Monta o campo de duplicatas da DANFE (retrato e paisagem) |
|
1830
|
|
|
* |
|
1831
|
|
|
* @name fatura |
|
1832
|
|
|
* |
|
1833
|
|
|
* @param number $x Posição horizontal canto esquerdo |
|
1834
|
|
|
* @param number $y Posição vertical canto superior |
|
1835
|
|
|
* |
|
1836
|
|
|
* @return number Posição vertical final |
|
1837
|
|
|
*/ |
|
1838
|
|
|
protected function fatura($x, $y) { |
|
1839
|
|
|
$linha = 1; |
|
1840
|
|
|
$h = 8 + 3; |
|
|
|
|
|
|
1841
|
|
|
$oldx = $x; |
|
1842
|
|
|
$textoFatura = $this->getTextoFatura(); |
|
1843
|
|
|
//verificar se existem duplicatas |
|
1844
|
|
|
if ($this->dup->length > 0 || $textoFatura !== "") { |
|
1845
|
|
|
//##################################################################### |
|
1846
|
|
|
//FATURA / DUPLICATA |
|
1847
|
|
|
$texto = $y . " - FATURA / DUPLICATA"; |
|
1848
|
|
|
if ($this->orientacao == 'P') { |
|
1849
|
|
|
$w = $this->wPrint; |
|
1850
|
|
|
} else { |
|
1851
|
|
|
$w = 271; |
|
1852
|
|
|
} |
|
1853
|
|
|
$h = 8; |
|
1854
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1855
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1856
|
|
|
$y += 3; |
|
1857
|
|
|
$dups = ""; |
|
|
|
|
|
|
1858
|
|
|
$dupcont = 0; |
|
1859
|
|
|
$nFat = $this->dup->length; |
|
|
|
|
|
|
1860
|
|
|
if ($nFat > 7) { |
|
1861
|
|
|
$myH = 6; |
|
1862
|
|
|
$myW = $this->wPrint; |
|
1863
|
|
|
if ($this->orientacao == 'L') { |
|
1864
|
|
|
$myW -= $this->wCanhoto; |
|
1865
|
|
|
} |
|
1866
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 9, 'style' => '']; |
|
1867
|
|
|
$texto = "Existem mais de 7 duplicatas registradas, portanto não " |
|
1868
|
|
|
. "serão exibidas, confira diretamente pelo XML."; |
|
1869
|
|
|
$this->pdf->textBox($x, $y, $myW, $myH, $texto, $aFont, 'C', 'C', 1, ''); |
|
|
|
|
|
|
1870
|
|
|
|
|
1871
|
|
|
return ($y + $h - 3); |
|
1872
|
|
|
} |
|
1873
|
|
|
if ($textoFatura !== "" && $this->exibirTextoFatura) { |
|
1874
|
|
|
$myH = 6; |
|
1875
|
|
|
$myW = $this->wPrint; |
|
1876
|
|
|
if ($this->orientacao == 'L') { |
|
1877
|
|
|
$myW -= $this->wCanhoto; |
|
1878
|
|
|
} |
|
1879
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => '']; |
|
1880
|
|
|
$this->pdf->textBox($x, $y, $myW, $myH, $textoFatura, $aFont, 'C', 'L', 1, ''); |
|
|
|
|
|
|
1881
|
|
|
$y += $myH + 1; |
|
1882
|
|
|
} |
|
1883
|
|
|
if ($this->orientacao == 'P') { |
|
1884
|
|
|
$w = round($this->wPrint / 7.018, 0) - 1; |
|
1885
|
|
|
} else { |
|
1886
|
|
|
$w = 28; |
|
1887
|
|
|
} |
|
1888
|
|
|
$increm = 1; |
|
1889
|
|
|
foreach ($this->dup as $k => $d) { |
|
|
|
|
|
|
1890
|
|
|
$nDup = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue) |
|
1891
|
|
|
? $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue |
|
1892
|
|
|
: ''; |
|
1893
|
|
|
$dDup = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue) |
|
1894
|
|
|
? $this->ymdTodmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue) |
|
1895
|
|
|
: ''; |
|
1896
|
|
|
$vDup = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue) |
|
1897
|
|
|
? 'R$ ' . number_format( |
|
1898
|
|
|
$this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue, |
|
1899
|
|
|
2, |
|
1900
|
|
|
",", |
|
1901
|
|
|
"." |
|
1902
|
|
|
) |
|
1903
|
|
|
: ''; |
|
1904
|
|
|
$h = 8; |
|
1905
|
|
|
$texto = ''; |
|
|
|
|
|
|
1906
|
|
|
if ($nDup != '0' && $nDup != '') { |
|
1907
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1908
|
|
|
$this->pdf->textBox($x, $y, $w, $h, 'Num.', $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1909
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1910
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $nDup, $aFont, 'T', 'R', 0, ''); |
|
|
|
|
|
|
1911
|
|
|
} else { |
|
1912
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1913
|
|
|
$this->pdf->textBox($x, $y, $w, $h, ($dupcont + 1) . "", $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
1914
|
|
|
} |
|
1915
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1916
|
|
|
$this->pdf->textBox($x, $y, $w, $h, 'Venc.', $aFont, 'C', 'L', 0, ''); |
|
|
|
|
|
|
1917
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1918
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $dDup, $aFont, 'C', 'R', 0, ''); |
|
|
|
|
|
|
1919
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
1920
|
|
|
$this->pdf->textBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
1921
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1922
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $vDup, $aFont, 'B', 'R', 0, ''); |
|
|
|
|
|
|
1923
|
|
|
$x += $w + $increm; |
|
1924
|
|
|
$dupcont += 1; |
|
1925
|
|
|
if ($this->orientacao == 'P') { |
|
1926
|
|
|
$maxDupCont = 6; |
|
1927
|
|
|
} else { |
|
1928
|
|
|
$maxDupCont = 8; |
|
1929
|
|
|
} |
|
1930
|
|
|
if ($dupcont > $maxDupCont) { |
|
1931
|
|
|
$y += 9; |
|
1932
|
|
|
$x = $oldx; |
|
1933
|
|
|
$dupcont = 0; |
|
1934
|
|
|
$linha += 1; |
|
1935
|
|
|
} |
|
1936
|
|
|
if ($linha == 5) { |
|
1937
|
|
|
$linha = 4; |
|
1938
|
|
|
break; |
|
1939
|
|
|
} |
|
1940
|
|
|
} |
|
1941
|
|
|
if ($dupcont == 0) { |
|
1942
|
|
|
$y -= 9; |
|
1943
|
|
|
$linha --; |
|
1944
|
|
|
} |
|
1945
|
|
|
|
|
1946
|
|
|
return ($y + $h); |
|
1947
|
|
|
} else { |
|
1948
|
|
|
$linha = 0; |
|
|
|
|
|
|
1949
|
|
|
|
|
1950
|
|
|
return ($y - 2); |
|
1951
|
|
|
} |
|
1952
|
|
|
} |
|
1953
|
|
|
|
|
1954
|
|
|
/** |
|
1955
|
|
|
* pagamento |
|
1956
|
|
|
* Monta o campo de pagamentos da DANFE (retrato e paisagem) (foi baseada na fatura) |
|
1957
|
|
|
* |
|
1958
|
|
|
* @name pagamento |
|
1959
|
|
|
* |
|
1960
|
|
|
* @param number $x Posição horizontal canto esquerdo |
|
1961
|
|
|
* @param number $y Posição vertical canto superior |
|
1962
|
|
|
* |
|
1963
|
|
|
* @return number Posição vertical final |
|
1964
|
|
|
*/ |
|
1965
|
|
|
protected function pagamento($x, $y) { |
|
1966
|
|
|
$linha = 1; |
|
1967
|
|
|
$h = 8 + 3; |
|
|
|
|
|
|
1968
|
|
|
$oldx = $x; |
|
1969
|
|
|
//verificar se existem cobranças definidas |
|
1970
|
|
|
if (isset($this->detPag) && $this->detPag->length > 0) { |
|
1971
|
|
|
//##################################################################### |
|
1972
|
|
|
//Tipo de pagamento |
|
1973
|
|
|
$texto = "PAGAMENTO"; |
|
1974
|
|
|
if ($this->orientacao == 'P') { |
|
1975
|
|
|
$w = $this->wPrint; |
|
1976
|
|
|
} else { |
|
1977
|
|
|
$w = 271; |
|
1978
|
|
|
} |
|
1979
|
|
|
$h = 8; |
|
1980
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
1981
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
1982
|
|
|
$y += 3; |
|
1983
|
|
|
$dups = ""; |
|
|
|
|
|
|
1984
|
|
|
$dupcont = 0; |
|
1985
|
|
|
if ($this->orientacao == 'P') { |
|
1986
|
|
|
$w = round($this->wPrint / 7.018, 0) - 1; |
|
1987
|
|
|
} else { |
|
1988
|
|
|
$w = 28; |
|
1989
|
|
|
} |
|
1990
|
|
|
if ($this->orientacao == 'P') { |
|
1991
|
|
|
$maxDupCont = 6; |
|
1992
|
|
|
} else { |
|
1993
|
|
|
$maxDupCont = 8; |
|
1994
|
|
|
} |
|
1995
|
|
|
$increm = 1; |
|
1996
|
|
|
$formaPagamento = [ |
|
1997
|
|
|
'01' => 'Dinheiro', |
|
1998
|
|
|
'02' => 'Cheque', |
|
1999
|
|
|
'03' => 'Cartão de Crédito', |
|
2000
|
|
|
'04' => 'Cartão de Débito', |
|
2001
|
|
|
'05' => 'Crédito Loja', |
|
2002
|
|
|
'10' => 'Vale Alimentação', |
|
2003
|
|
|
'11' => 'Vale Refeição', |
|
2004
|
|
|
'12' => 'Vale Presente', |
|
2005
|
|
|
'13' => 'Vale Combustível', |
|
2006
|
|
|
'14' => 'Duplicata Mercantil', |
|
2007
|
|
|
'15' => 'Boleto', |
|
2008
|
|
|
'90' => 'Sem pagamento', |
|
2009
|
|
|
'99' => 'Outros' |
|
2010
|
|
|
]; |
|
2011
|
|
|
$bandeira = [ |
|
|
|
|
|
|
2012
|
|
|
'01' => 'Visa', |
|
2013
|
|
|
'02' => 'Mastercard', |
|
2014
|
|
|
'03' => 'American', |
|
2015
|
|
|
'04' => 'Sorocred', |
|
2016
|
|
|
'05' => 'Diners', |
|
2017
|
|
|
'06' => 'Elo', |
|
2018
|
|
|
'07' => 'Hipercard', |
|
2019
|
|
|
'08' => 'Aura', |
|
2020
|
|
|
'09' => 'Cabal', |
|
2021
|
|
|
'99' => 'Outros' |
|
2022
|
|
|
]; |
|
2023
|
|
|
foreach ($this->detPag as $k => $d) { |
|
2024
|
|
|
$fPag = ! empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue) |
|
2025
|
|
|
? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue |
|
2026
|
|
|
: '0'; |
|
2027
|
|
|
$vPag = ! empty($this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue) |
|
2028
|
|
|
? 'R$ ' . number_format( |
|
2029
|
|
|
$this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue, |
|
2030
|
|
|
2, |
|
2031
|
|
|
",", |
|
2032
|
|
|
"." |
|
2033
|
|
|
) |
|
2034
|
|
|
: ''; |
|
2035
|
|
|
$h = 6; |
|
2036
|
|
|
$texto = ''; |
|
|
|
|
|
|
2037
|
|
|
if (isset($formaPagamento[$fPag])) { |
|
2038
|
|
|
/*Exibir Item sem pagamento*/ |
|
2039
|
|
|
if ($fPag == '90') { |
|
2040
|
|
|
continue; |
|
2041
|
|
|
} |
|
2042
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2043
|
|
|
$this->pdf->textBox($x, $y, $w, $h, 'Forma', $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2044
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
2045
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $formaPagamento[$fPag], $aFont, 'T', 'R', 0, ''); |
|
|
|
|
|
|
2046
|
|
|
} else { |
|
2047
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
2048
|
|
|
$this->pdf->textBox($x, $y, $w, $h, "Forma " . $fPag . " não encontrado", $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2049
|
|
|
} |
|
2050
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2051
|
|
|
$this->pdf->textBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
2052
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
2053
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $vPag, $aFont, 'B', 'R', 0, ''); |
|
|
|
|
|
|
2054
|
|
|
$x += $w + $increm; |
|
2055
|
|
|
$dupcont += 1; |
|
2056
|
|
|
|
|
2057
|
|
|
if ($dupcont > $maxDupCont) { |
|
2058
|
|
|
$y += 9; |
|
2059
|
|
|
$x = $oldx; |
|
2060
|
|
|
$dupcont = 0; |
|
2061
|
|
|
$linha += 1; |
|
2062
|
|
|
} |
|
2063
|
|
|
if ($linha == 5) { |
|
2064
|
|
|
$linha = 4; |
|
2065
|
|
|
break; |
|
2066
|
|
|
} |
|
2067
|
|
|
} |
|
2068
|
|
|
if ($dupcont == 0) { |
|
2069
|
|
|
$y -= 9; |
|
2070
|
|
|
$linha --; |
|
2071
|
|
|
} |
|
2072
|
|
|
|
|
2073
|
|
|
return ($y + $h); |
|
2074
|
|
|
} else { |
|
2075
|
|
|
$linha = 0; |
|
|
|
|
|
|
2076
|
|
|
|
|
2077
|
|
|
return ($y - 2); |
|
2078
|
|
|
} |
|
2079
|
|
|
} //fim da função pagamento |
|
2080
|
|
|
|
|
2081
|
|
|
/** |
|
2082
|
|
|
* impostoHelper |
|
2083
|
|
|
* Auxilia a montagem dos campos de impostos e totais da DANFE |
|
2084
|
|
|
* |
|
2085
|
|
|
* @name impostoHelper |
|
2086
|
|
|
* |
|
2087
|
|
|
* @param float $x Posição horizontal canto esquerdo |
|
2088
|
|
|
* @param float $y Posição vertical canto superior |
|
2089
|
|
|
* @param float $w Largura do campo |
|
2090
|
|
|
* @param float $h Altura do campo |
|
2091
|
|
|
* @param float $h Título do campo |
|
2092
|
|
|
* @param float $h Valor do imposto |
|
2093
|
|
|
* |
|
2094
|
|
|
* @return float Sugestão do $x do próximo imposto |
|
2095
|
|
|
*/ |
|
2096
|
|
|
protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto) { |
|
2097
|
|
|
$valorImposto = '0,00'; |
|
2098
|
|
|
$the_field = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0); |
|
2099
|
|
|
if (isset($the_field)) { |
|
2100
|
|
|
$the_value = $the_field->nodeValue; |
|
2101
|
|
|
if (! empty($the_value)) { |
|
2102
|
|
|
$valorImposto = number_format($the_value, 2, ",", "."); |
|
2103
|
|
|
} |
|
2104
|
|
|
} |
|
2105
|
|
|
|
|
2106
|
|
|
$fontTitulo = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2107
|
|
|
$fontValor = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2108
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $titulo, $fontTitulo, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2109
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $valorImposto, $fontValor, 'B', 'R', 0, ''); |
|
|
|
|
|
|
2110
|
|
|
|
|
2111
|
|
|
$next_x = $x + $w; |
|
2112
|
|
|
|
|
2113
|
|
|
return $next_x; |
|
2114
|
|
|
} |
|
2115
|
|
|
|
|
2116
|
|
|
/** |
|
2117
|
|
|
* imposto |
|
2118
|
|
|
* Monta o campo de impostos e totais da DANFE (retrato e paisagem) |
|
2119
|
|
|
* |
|
2120
|
|
|
* @param number $x Posição horizontal canto esquerdo |
|
2121
|
|
|
* @param number $y Posição vertical canto superior |
|
2122
|
|
|
* |
|
2123
|
|
|
* @return number Posição vertical final |
|
2124
|
|
|
*/ |
|
2125
|
|
|
protected function imposto($x, $y) { |
|
2126
|
|
|
$x_inicial = $x; |
|
2127
|
|
|
//##################################################################### |
|
2128
|
|
|
$campos_por_linha = 9; |
|
2129
|
|
|
if (! $this->exibirPIS) { |
|
2130
|
|
|
$campos_por_linha --; |
|
2131
|
|
|
} |
|
2132
|
|
|
if (! $this->exibirIcmsInterestadual) { |
|
2133
|
|
|
$campos_por_linha -= 2; |
|
2134
|
|
|
} |
|
2135
|
|
|
|
|
2136
|
|
|
if ($this->orientacao == 'P') { |
|
2137
|
|
|
$maxW = $this->wPrint; |
|
2138
|
|
|
$title_size = 31; |
|
2139
|
|
|
} else { |
|
2140
|
|
|
$maxW = $this->wPrint - $this->wCanhoto; |
|
2141
|
|
|
$title_size = 40; |
|
2142
|
|
|
} |
|
2143
|
|
|
$w = $maxW / $campos_por_linha; |
|
2144
|
|
|
|
|
2145
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
2146
|
|
|
$texto = "CÁLCULO DO IMPOSTO"; |
|
2147
|
|
|
$this->pdf->textBox($x, $y, $title_size, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
2148
|
|
|
$y += 3; |
|
2149
|
|
|
$h = 7; |
|
2150
|
|
|
|
|
2151
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC"); |
|
2152
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS"); |
|
2153
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST"); |
|
2154
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST"); |
|
2155
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII"); |
|
2156
|
|
|
|
|
2157
|
|
|
if ($this->exibirIcmsInterestadual) { |
|
2158
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet"); |
|
2159
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "V. FCP UF DEST.", "vFCPUFDest"); |
|
2160
|
|
|
} |
|
2161
|
|
|
|
|
2162
|
|
|
if ($this->exibirPIS) { |
|
2163
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS"); |
|
2164
|
|
|
} |
|
2165
|
|
|
|
|
2166
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "V. TOTAL PRODUTOS", "vProd"); |
|
|
|
|
|
|
2167
|
|
|
|
|
2168
|
|
|
// |
|
2169
|
|
|
|
|
2170
|
|
|
$y += $h; |
|
2171
|
|
|
$x = $x_inicial; |
|
2172
|
|
|
|
|
2173
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete"); |
|
2174
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg"); |
|
2175
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "DESCONTO", "vDesc"); |
|
2176
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro"); |
|
2177
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI"); |
|
2178
|
|
|
|
|
2179
|
|
|
if ($this->exibirIcmsInterestadual) { |
|
2180
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest"); |
|
2181
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib"); |
|
2182
|
|
|
} |
|
2183
|
|
|
if ($this->exibirPIS) { |
|
2184
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS"); |
|
2185
|
|
|
} |
|
2186
|
|
|
$x = $this->impostoHelper($x, $y, $w, $h, "V. TOTAL DA NOTA", "vNF"); |
|
|
|
|
|
|
2187
|
|
|
|
|
2188
|
|
|
return ($y + $h); |
|
2189
|
|
|
} //fim imposto |
|
2190
|
|
|
|
|
2191
|
|
|
/** |
|
2192
|
|
|
* transporte |
|
2193
|
|
|
* Monta o campo de transportes da DANFE (retrato e paisagem) |
|
2194
|
|
|
* |
|
2195
|
|
|
* @name transporte |
|
2196
|
|
|
* |
|
2197
|
|
|
* @param float $x Posição horizontal canto esquerdo |
|
2198
|
|
|
* @param float $y Posição vertical canto superior |
|
2199
|
|
|
* |
|
2200
|
|
|
* @return float Posição vertical final |
|
2201
|
|
|
*/ |
|
2202
|
|
|
protected function transporte($x, $y) { |
|
2203
|
|
|
$oldX = $x; |
|
2204
|
|
|
if ($this->orientacao == 'P') { |
|
2205
|
|
|
$maxW = $this->wPrint; |
|
2206
|
|
|
} else { |
|
2207
|
|
|
$maxW = $this->wPrint - $this->wCanhoto; |
|
2208
|
|
|
} |
|
2209
|
|
|
//##################################################################### |
|
2210
|
|
|
//TRANSPORTADOR / VOLUMES TRANSPORTADOS |
|
2211
|
|
|
$texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS"; |
|
2212
|
|
|
$w = $maxW; |
|
2213
|
|
|
$h = 7; |
|
2214
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
2215
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
2216
|
|
|
//NOME / RAZÃO SOCIAL |
|
2217
|
|
|
$w1 = $maxW * 0.29; |
|
2218
|
|
|
$y += 3; |
|
2219
|
|
|
$texto = 'NOME / RAZÃO SOCIAL'; |
|
2220
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2221
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2222
|
|
|
if (isset($this->transporta)) { |
|
2223
|
|
|
$texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) |
|
2224
|
|
|
? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue |
|
2225
|
|
|
: ''; |
|
2226
|
|
|
} else { |
|
2227
|
|
|
$texto = ''; |
|
2228
|
|
|
} |
|
2229
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2230
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
2231
|
|
|
//FRETE POR CONTA |
|
2232
|
|
|
$x += $w1; |
|
2233
|
|
|
$w2 = $maxW * 0.15; |
|
2234
|
|
|
$texto = 'FRETE'; |
|
2235
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2236
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2237
|
|
|
$tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue) |
|
2238
|
|
|
? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue |
|
2239
|
|
|
: '0'; |
|
2240
|
|
|
switch ($tipoFrete) { |
|
2241
|
|
|
case 0: |
|
2242
|
|
|
$texto = "0-Por conta do Rem"; |
|
2243
|
|
|
break; |
|
2244
|
|
|
case 1: |
|
2245
|
|
|
$texto = "1-Por conta do Dest"; |
|
2246
|
|
|
break; |
|
2247
|
|
|
case 2: |
|
2248
|
|
|
$texto = "2-Por conta de Terceiros"; |
|
2249
|
|
|
break; |
|
2250
|
|
|
case 3: |
|
2251
|
|
|
$texto = "3-Próprio por conta do Rem"; |
|
2252
|
|
|
break; |
|
2253
|
|
|
case 4: |
|
2254
|
|
|
$texto = "4-Próprio por conta do Dest"; |
|
2255
|
|
|
break; |
|
2256
|
|
|
case 9: |
|
2257
|
|
|
$texto = "9-Sem Transporte"; |
|
2258
|
|
|
break; |
|
2259
|
|
|
} |
|
2260
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2261
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 1, ''); |
|
|
|
|
|
|
2262
|
|
|
//CÓDIGO ANTT |
|
2263
|
|
|
$x += $w2; |
|
2264
|
|
|
$texto = 'CÓDIGO ANTT'; |
|
2265
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2266
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2267
|
|
|
if (isset($this->veicTransp)) { |
|
2268
|
|
|
$texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue) |
|
2269
|
|
|
? $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue |
|
2270
|
|
|
: ''; |
|
2271
|
|
|
} else { |
|
2272
|
|
|
$texto = ''; |
|
2273
|
|
|
} |
|
2274
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2275
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2276
|
|
|
//PLACA DO VEÍC |
|
2277
|
|
|
$x += $w2; |
|
2278
|
|
|
$texto = 'PLACA DO VEÍCULO'; |
|
2279
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2280
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2281
|
|
|
if (isset($this->veicTransp)) { |
|
2282
|
|
|
$texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue) |
|
2283
|
|
|
? $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue |
|
2284
|
|
|
: ''; |
|
2285
|
|
|
} elseif (isset($this->reboque)) { |
|
2286
|
|
|
$texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue) |
|
2287
|
|
|
? $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue |
|
2288
|
|
|
: ''; |
|
2289
|
|
|
} else { |
|
2290
|
|
|
$texto = ''; |
|
2291
|
|
|
} |
|
2292
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2293
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2294
|
|
|
//UF |
|
2295
|
|
|
$x += $w2; |
|
2296
|
|
|
$w3 = round($maxW * 0.04, 0); |
|
2297
|
|
|
$texto = 'UF'; |
|
2298
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2299
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2300
|
|
|
if (isset($this->veicTransp)) { |
|
2301
|
|
|
$texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue) |
|
2302
|
|
|
? $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue |
|
2303
|
|
|
: ''; |
|
2304
|
|
|
} elseif (isset($this->reboque)) { |
|
2305
|
|
|
$texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue) |
|
2306
|
|
|
? $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue |
|
2307
|
|
|
: ''; |
|
2308
|
|
|
} else { |
|
2309
|
|
|
$texto = ''; |
|
2310
|
|
|
} |
|
2311
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2312
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2313
|
|
|
//CNPJ / CPF |
|
2314
|
|
|
$x += $w3; |
|
2315
|
|
|
$w = $maxW - ($w1 + 3 * $w2 + $w3); |
|
2316
|
|
|
$texto = 'CNPJ / CPF'; |
|
2317
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2318
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2319
|
|
|
if (isset($this->transporta)) { |
|
2320
|
|
|
$texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue) |
|
2321
|
|
|
? $this->formatField( |
|
2322
|
|
|
$this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue, |
|
2323
|
|
|
"##.###.###/####-##" |
|
2324
|
|
|
) |
|
2325
|
|
|
: ''; |
|
2326
|
|
|
if ($texto == '') { |
|
2327
|
|
|
$texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue) |
|
2328
|
|
|
? $this->formatField( |
|
2329
|
|
|
$this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue, |
|
2330
|
|
|
"###.###.###-##" |
|
2331
|
|
|
) |
|
2332
|
|
|
: ''; |
|
2333
|
|
|
} |
|
2334
|
|
|
} else { |
|
2335
|
|
|
$texto = ''; |
|
2336
|
|
|
} |
|
2337
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2338
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2339
|
|
|
//##################################################################### |
|
2340
|
|
|
//ENDEREÇO |
|
2341
|
|
|
$y += $h; |
|
2342
|
|
|
$x = $oldX; |
|
2343
|
|
|
$h = 7; |
|
2344
|
|
|
$w1 = $maxW * 0.44; |
|
2345
|
|
|
$texto = 'ENDEREÇO'; |
|
2346
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2347
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2348
|
|
|
if (isset($this->transporta)) { |
|
2349
|
|
|
$texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) |
|
2350
|
|
|
? $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue |
|
2351
|
|
|
: ''; |
|
2352
|
|
|
} else { |
|
2353
|
|
|
$texto = ''; |
|
2354
|
|
|
} |
|
2355
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2356
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
2357
|
|
|
//MUNICÍPIO |
|
2358
|
|
|
$x += $w1; |
|
2359
|
|
|
$w2 = round($maxW * 0.30, 0); |
|
2360
|
|
|
$texto = 'MUNICÍPIO'; |
|
2361
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2362
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2363
|
|
|
if (isset($this->transporta)) { |
|
2364
|
|
|
$texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue) |
|
2365
|
|
|
? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue |
|
2366
|
|
|
: ''; |
|
2367
|
|
|
} else { |
|
2368
|
|
|
$texto = ''; |
|
2369
|
|
|
} |
|
2370
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2371
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2372
|
|
|
//UF |
|
2373
|
|
|
$x += $w2; |
|
2374
|
|
|
$w3 = round($maxW * 0.04, 0); |
|
2375
|
|
|
$texto = 'UF'; |
|
2376
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2377
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2378
|
|
|
if (isset($this->transporta)) { |
|
2379
|
|
|
$texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) |
|
2380
|
|
|
? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue |
|
2381
|
|
|
: ''; |
|
2382
|
|
|
} else { |
|
2383
|
|
|
$texto = ''; |
|
2384
|
|
|
} |
|
2385
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2386
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2387
|
|
|
//INSCRIÇÃO ESTADUAL |
|
2388
|
|
|
$x += $w3; |
|
2389
|
|
|
$w = $maxW - ($w1 + $w2 + $w3); |
|
2390
|
|
|
$texto = 'INSCRIÇÃO ESTADUAL'; |
|
2391
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2392
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2393
|
|
|
$texto = ''; |
|
2394
|
|
|
if (isset($this->transporta)) { |
|
2395
|
|
|
if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) { |
|
2396
|
|
|
$texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue; |
|
2397
|
|
|
} |
|
2398
|
|
|
} |
|
2399
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2400
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2401
|
|
|
//Tratar Multiplos volumes |
|
2402
|
|
|
$volumes = $this->transp->getElementsByTagName('vol'); |
|
2403
|
|
|
$quantidade = 0; |
|
2404
|
|
|
$especie = ''; |
|
2405
|
|
|
$marca = ''; |
|
2406
|
|
|
$numero = ''; |
|
2407
|
|
|
$texto = ''; |
|
|
|
|
|
|
2408
|
|
|
$pesoBruto = 0; |
|
2409
|
|
|
$pesoLiquido = 0; |
|
2410
|
|
|
foreach ($volumes as $volume) { |
|
2411
|
|
|
$quantidade += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ? |
|
2412
|
|
|
$volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0; |
|
2413
|
|
|
$pesoBruto += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ? |
|
2414
|
|
|
$volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0; |
|
2415
|
|
|
$pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ? |
|
2416
|
|
|
$volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0; |
|
2417
|
|
|
$texto = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? |
|
2418
|
|
|
$this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; |
|
2419
|
|
|
if ($texto != $especie && $especie != '') { |
|
2420
|
|
|
//tem várias especies |
|
2421
|
|
|
$especie = 'VARIAS'; |
|
2422
|
|
|
} else { |
|
2423
|
|
|
$especie = $texto; |
|
2424
|
|
|
} |
|
2425
|
|
|
$texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) |
|
2426
|
|
|
? $this->transp->getElementsByTagName("marca")->item(0)->nodeValue |
|
2427
|
|
|
: ''; |
|
2428
|
|
|
if ($texto != $marca && $marca != '') { |
|
2429
|
|
|
//tem várias especies |
|
2430
|
|
|
$marca = 'VARIAS'; |
|
2431
|
|
|
} else { |
|
2432
|
|
|
$marca = $texto; |
|
2433
|
|
|
} |
|
2434
|
|
|
$texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue) |
|
2435
|
|
|
? $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue |
|
2436
|
|
|
: ''; |
|
2437
|
|
|
if ($texto != $numero && $numero != '') { |
|
2438
|
|
|
//tem várias especies |
|
2439
|
|
|
$numero = 'VARIOS'; |
|
2440
|
|
|
} else { |
|
2441
|
|
|
$numero = $texto; |
|
2442
|
|
|
} |
|
2443
|
|
|
} |
|
2444
|
|
|
|
|
2445
|
|
|
//##################################################################### |
|
2446
|
|
|
//QUANTIDADE |
|
2447
|
|
|
$y += $h; |
|
2448
|
|
|
$x = $oldX; |
|
2449
|
|
|
$h = 7; |
|
2450
|
|
|
$w1 = round($maxW * 0.10, 0); |
|
2451
|
|
|
$texto = 'QUANTIDADE'; |
|
2452
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2453
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2454
|
|
|
if (! empty($quantidade)) { |
|
2455
|
|
|
$texto = $quantidade; |
|
2456
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2457
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2458
|
|
|
} |
|
2459
|
|
|
//ESPÉCIE |
|
2460
|
|
|
$x += $w1; |
|
2461
|
|
|
$w2 = round($maxW * 0.17, 0); |
|
2462
|
|
|
$texto = 'ESPÉCIE'; |
|
2463
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2464
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2465
|
|
|
$texto = $especie; |
|
2466
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2467
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2468
|
|
|
//MARCA |
|
2469
|
|
|
$x += $w2; |
|
2470
|
|
|
$texto = 'MARCA'; |
|
2471
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2472
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2473
|
|
|
$texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ? |
|
2474
|
|
|
$this->transp->getElementsByTagName("marca")->item(0)->nodeValue : ''; |
|
2475
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2476
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2477
|
|
|
//NUMERAÇÃO |
|
2478
|
|
|
$x += $w2; |
|
2479
|
|
|
$texto = 'NUMERAÇÃO'; |
|
2480
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2481
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2482
|
|
|
$texto = $numero; |
|
2483
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2484
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, ''); |
|
|
|
|
|
|
2485
|
|
|
//PESO BRUTO |
|
2486
|
|
|
$x += $w2; |
|
2487
|
|
|
$w3 = round($maxW * 0.20, 0); |
|
2488
|
|
|
$texto = 'PESO BRUTO'; |
|
2489
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2490
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2491
|
|
|
if (is_numeric($pesoBruto) && $pesoBruto > 0) { |
|
2492
|
|
|
$texto = number_format($pesoBruto, 3, ",", "."); |
|
2493
|
|
|
} else { |
|
2494
|
|
|
$texto = ''; |
|
2495
|
|
|
} |
|
2496
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2497
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'R', 0, ''); |
|
|
|
|
|
|
2498
|
|
|
//PESO LÍQUIDO |
|
2499
|
|
|
$x += $w3; |
|
2500
|
|
|
$w = $maxW - ($w1 + 3 * $w2 + $w3); |
|
2501
|
|
|
$texto = 'PESO LÍQUIDO'; |
|
2502
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2503
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
2504
|
|
|
if (is_numeric($pesoLiquido) && $pesoLiquido > 0) { |
|
2505
|
|
|
$texto = number_format($pesoLiquido, 3, ",", "."); |
|
2506
|
|
|
} else { |
|
2507
|
|
|
$texto = ''; |
|
2508
|
|
|
} |
|
2509
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
2510
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, ''); |
|
|
|
|
|
|
2511
|
|
|
|
|
2512
|
|
|
return ($y + $h); |
|
2513
|
|
|
} //fim transporte |
|
2514
|
|
|
|
|
2515
|
|
|
|
|
2516
|
|
|
protected function descricaoProdutoHelper($origem, $campo, $formato) { |
|
2517
|
|
|
$valor_original = $origem->getElementsByTagName($campo)->item(0); |
|
2518
|
|
|
if (! isset($valor_original)) { |
|
2519
|
|
|
return ""; |
|
2520
|
|
|
} |
|
2521
|
|
|
$valor_original = $valor_original->nodeValue; |
|
2522
|
|
|
$valor = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : ''; |
|
2523
|
|
|
|
|
2524
|
|
|
if ($valor != "") { |
|
2525
|
|
|
return sprintf($formato, $valor); |
|
2526
|
|
|
} |
|
2527
|
|
|
|
|
2528
|
|
|
return ""; |
|
2529
|
|
|
} |
|
2530
|
|
|
|
|
2531
|
|
|
/** |
|
2532
|
|
|
* descricaoProduto |
|
2533
|
|
|
* Monta a string de descrição de cada Produto |
|
2534
|
|
|
* |
|
2535
|
|
|
* @name descricaoProduto |
|
2536
|
|
|
* |
|
2537
|
|
|
* @param DOMNode itemProd |
|
2538
|
|
|
* |
|
2539
|
|
|
* @return string descricao do produto |
|
2540
|
|
|
*/ |
|
2541
|
|
|
protected function descricaoProduto($itemProd) { |
|
2542
|
|
|
$prod = $itemProd->getElementsByTagName('prod')->item(0); |
|
2543
|
|
|
$ICMS = $itemProd->getElementsByTagName("ICMS")->item(0); |
|
2544
|
|
|
$ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0); |
|
2545
|
|
|
$impostos = ''; |
|
2546
|
|
|
|
|
2547
|
|
|
if (! empty($ICMS)) { |
|
2548
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCP", " BcFcp=%s"); |
|
2549
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "pFCP", " pFcp=%s%%"); |
|
2550
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vFCP", " vFcp=%s"); |
|
2551
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%"); |
|
2552
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%"); |
|
2553
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%"); |
|
2554
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s"); |
|
2555
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s"); |
|
2556
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCPST", " BcFcpSt=%s"); |
|
2557
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "pFCPST", " pFcpSt=%s%%"); |
|
2558
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vFCPST", " vFcpSt=%s"); |
|
2559
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vBCSTRet", " Retido na compra: BASE ICMS ST=%s"); |
|
2560
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "pST", " pSt=%s"); |
|
2561
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSSTRet", " VALOR ICMS ST=%s"); |
|
2562
|
|
|
} |
|
2563
|
|
|
if (! empty($ICMSUFDest)) { |
|
2564
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%"); |
|
2565
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%"); |
|
2566
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%"); |
|
2567
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s"); |
|
2568
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s"); |
|
2569
|
|
|
$impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s"); |
|
2570
|
|
|
} |
|
2571
|
|
|
$infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue) |
|
2572
|
|
|
? substr( |
|
2573
|
|
|
$this->anfaveaDANFE($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue), |
|
2574
|
|
|
0, |
|
2575
|
|
|
500 |
|
2576
|
|
|
) |
|
2577
|
|
|
: ''; |
|
2578
|
|
|
if (! empty($infAdProd)) { |
|
2579
|
|
|
$infAdProd = trim($infAdProd); |
|
2580
|
|
|
$infAdProd .= ' '; |
|
2581
|
|
|
} |
|
2582
|
|
|
$loteTxt = ''; |
|
2583
|
|
|
$rastro = $prod->getElementsByTagName("med"); |
|
|
|
|
|
|
2584
|
|
|
if (! empty($prod->getElementsByTagName("rastro"))) { |
|
2585
|
|
|
$rastro = $prod->getElementsByTagName("rastro"); |
|
2586
|
|
|
$i = 0; |
|
2587
|
|
|
while ($i < $rastro->length) { |
|
2588
|
|
|
$loteTxt .= $this->getTagValue($rastro->item($i), 'nLote', ' Lote: '); |
|
2589
|
|
|
$loteTxt .= $this->getTagValue($rastro->item($i), 'qLote', ' Quant: '); |
|
2590
|
|
|
$loteTxt .= $this->getTagDate($rastro->item($i), 'dFab', ' Fab: '); |
|
2591
|
|
|
$loteTxt .= $this->getTagDate($rastro->item($i), 'dVal', ' Val: '); |
|
2592
|
|
|
$loteTxt .= $this->getTagValue($rastro->item($i), 'vPMC', ' PMC: '); |
|
2593
|
|
|
$i ++; |
|
2594
|
|
|
} |
|
2595
|
|
|
if ($loteTxt != '') { |
|
2596
|
|
|
$loteTxt .= ' '; |
|
2597
|
|
|
} |
|
2598
|
|
|
} |
|
2599
|
|
|
//NT2013.006 FCI |
|
2600
|
|
|
$nFCI = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ? |
|
2601
|
|
|
' FCI:' . $itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : ''; |
|
2602
|
|
|
$tmp_ad = $infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : ''); |
|
2603
|
|
|
$texto = $prod->getElementsByTagName("xProd")->item(0)->nodeValue |
|
2604
|
|
|
. (strlen($tmp_ad) != 0 ? "\n " . $tmp_ad : ''); |
|
2605
|
|
|
//decodifica os caracteres html no xml |
|
2606
|
|
|
$texto = html_entity_decode($texto); |
|
2607
|
|
|
if ($this->descProdQuebraLinha) { |
|
2608
|
|
|
$texto = str_replace(";", "\n", $texto); |
|
2609
|
|
|
} |
|
2610
|
|
|
|
|
2611
|
|
|
return $texto; |
|
2612
|
|
|
} |
|
2613
|
|
|
|
|
2614
|
|
|
/** |
|
2615
|
|
|
* itens |
|
2616
|
|
|
* Monta o campo de itens da DANFE (retrato e paisagem) |
|
2617
|
|
|
* |
|
2618
|
|
|
* @name itens |
|
2619
|
|
|
* |
|
2620
|
|
|
* @param float $x Posição horizontal canto esquerdo |
|
2621
|
|
|
* @param float $y Posição vertical canto superior |
|
2622
|
|
|
* @param float $nInicio Número do item inicial |
|
2623
|
|
|
* @param float $max Número do item final |
|
|
|
|
|
|
2624
|
|
|
* @param float $hmax Altura máxima do campo de itens em mm |
|
2625
|
|
|
* |
|
2626
|
|
|
* @return float Posição vertical final |
|
2627
|
|
|
*/ |
|
2628
|
|
|
protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7) { |
|
2629
|
|
|
|
|
2630
|
|
|
$oldX = $x; |
|
2631
|
|
|
$oldY = $y; |
|
2632
|
|
|
$totItens = $this->det->length; |
|
|
|
|
|
|
2633
|
|
|
//##################################################################### |
|
2634
|
|
|
//DADOS DOS PRODUTOS / SERVIÇOS |
|
2635
|
|
|
$texto = "DADOS DOS PRODUTOS / SERVIÇOS"; |
|
2636
|
|
|
if ($this->orientacao == 'P') { |
|
2637
|
|
|
$w = $this->wPrint; |
|
2638
|
|
|
} else { |
|
2639
|
|
|
if ($nInicio < 2) { // primeira página |
|
2640
|
|
|
$w = $this->wPrint - $this->wCanhoto; |
|
2641
|
|
|
} else { // páginas seguintes |
|
2642
|
|
|
$w = $this->wPrint; |
|
2643
|
|
|
} |
|
2644
|
|
|
} |
|
2645
|
|
|
$h = 4; |
|
2646
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
2647
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
2648
|
|
|
$y += 3; |
|
2649
|
|
|
//desenha a caixa dos dados dos itens da NF |
|
2650
|
|
|
$hmax += 1; |
|
2651
|
|
|
$texto = ''; |
|
|
|
|
|
|
2652
|
|
|
$this->pdf->textBox($x, $y, $w, $hmax); |
|
2653
|
|
|
//################################################################################## |
|
2654
|
|
|
// cabecalho LOOP COM OS DADOS DOS PRODUTOS |
|
2655
|
|
|
//CÓDIGO PRODUTO |
|
2656
|
|
|
$texto = "CÓDIGO PRODUTO"; |
|
2657
|
|
|
$w1 = round($w * 0.09, 0); |
|
2658
|
|
|
$h = 4; |
|
2659
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2660
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2661
|
|
|
$this->pdf->line($x + $w1, $y, $x + $w1, $y + $hmax); |
|
2662
|
|
|
//DESCRIÇÃO DO PRODUTO / SERVIÇO |
|
2663
|
|
|
$x += $w1; |
|
2664
|
|
|
$w2 = round($w * 0.25, 0); |
|
2665
|
|
|
$texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO'; |
|
2666
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2667
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2668
|
|
|
$this->pdf->line($x + $w2, $y, $x + $w2, $y + $hmax); |
|
2669
|
|
|
//NCM/SH |
|
2670
|
|
|
$x += $w2; |
|
2671
|
|
|
$w3 = round($w * 0.06, 0); |
|
2672
|
|
|
$texto = 'NCM/SH'; |
|
2673
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2674
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2675
|
|
|
$this->pdf->line($x + $w3, $y, $x + $w3, $y + $hmax); |
|
2676
|
|
|
//O/CST ou O/CSOSN |
|
2677
|
|
|
$x += $w3; |
|
2678
|
|
|
$w4 = round($w * 0.05, 0); |
|
2679
|
|
|
$texto = 'O/CSOSN';//Regime do Simples CRT = 1 ou CRT = 2 |
|
2680
|
|
|
if ($this->getTagValue($this->emit, 'CRT') == '3') { |
|
2681
|
|
|
$texto = 'O/CST';//Regime Normal |
|
2682
|
|
|
} |
|
2683
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2684
|
|
|
$this->pdf->textBox($x, $y, $w4, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2685
|
|
|
$this->pdf->line($x + $w4, $y, $x + $w4, $y + $hmax); |
|
2686
|
|
|
//CFOP |
|
2687
|
|
|
$x += $w4; |
|
2688
|
|
|
$w5 = round($w * 0.04, 0); |
|
2689
|
|
|
$texto = 'CFOP'; |
|
2690
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2691
|
|
|
$this->pdf->textBox($x, $y, $w5, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2692
|
|
|
$this->pdf->line($x + $w5, $y, $x + $w5, $y + $hmax); |
|
2693
|
|
|
//UN |
|
2694
|
|
|
$x += $w5; |
|
2695
|
|
|
$w6 = round($w * 0.03, 0); |
|
2696
|
|
|
$texto = 'UN'; |
|
2697
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2698
|
|
|
$this->pdf->textBox($x, $y, $w6, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2699
|
|
|
$this->pdf->line($x + $w6, $y, $x + $w6, $y + $hmax); |
|
2700
|
|
|
//QUANT |
|
2701
|
|
|
$x += $w6; |
|
2702
|
|
|
$w7 = round($w * 0.08, 0); |
|
2703
|
|
|
$texto = 'QUANT'; |
|
2704
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2705
|
|
|
$this->pdf->textBox($x, $y, $w7, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2706
|
|
|
$this->pdf->line($x + $w7, $y, $x + $w7, $y + $hmax); |
|
2707
|
|
|
//VALOR UNIT |
|
2708
|
|
|
$x += $w7; |
|
2709
|
|
|
$w8 = round($w * 0.06, 0); |
|
2710
|
|
|
$texto = 'VALOR UNIT'; |
|
2711
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2712
|
|
|
$this->pdf->textBox($x, $y, $w8, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2713
|
|
|
$this->pdf->line($x + $w8, $y, $x + $w8, $y + $hmax); |
|
2714
|
|
|
//VALOR TOTAL |
|
2715
|
|
|
$x += $w8; |
|
2716
|
|
|
$w9 = round($w * 0.06, 0); |
|
2717
|
|
|
$texto = 'VALOR TOTAL'; |
|
2718
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2719
|
|
|
$this->pdf->textBox($x, $y, $w9, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2720
|
|
|
$this->pdf->line($x + $w9, $y, $x + $w9, $y + $hmax); |
|
2721
|
|
|
//VALOR DESCONTO |
|
2722
|
|
|
$x += $w9; |
|
2723
|
|
|
$w10 = round($w * 0.05, 0); |
|
2724
|
|
|
$texto = 'VALOR DESC'; |
|
2725
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2726
|
|
|
$this->pdf->textBox($x, $y, $w10, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2727
|
|
|
$this->pdf->line($x + $w10, $y, $x + $w10, $y + $hmax); |
|
2728
|
|
|
//B.CÁLC ICMS |
|
2729
|
|
|
$x += $w10; |
|
2730
|
|
|
$w11 = round($w * 0.06, 0); |
|
2731
|
|
|
$texto = 'B.CÁLC ICMS'; |
|
2732
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2733
|
|
|
$this->pdf->textBox($x, $y, $w11, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2734
|
|
|
$this->pdf->line($x + $w11, $y, $x + $w11, $y + $hmax); |
|
2735
|
|
|
//VALOR ICMS |
|
2736
|
|
|
$x += $w11; |
|
2737
|
|
|
$w12 = round($w * 0.06, 0); |
|
2738
|
|
|
$texto = 'VALOR ICMS'; |
|
2739
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2740
|
|
|
$this->pdf->textBox($x, $y, $w12, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2741
|
|
|
$this->pdf->line($x + $w12, $y, $x + $w12, $y + $hmax); |
|
2742
|
|
|
//VALOR IPI |
|
2743
|
|
|
$x += $w12; |
|
2744
|
|
|
$w13 = round($w * 0.05, 0); |
|
2745
|
|
|
$texto = 'VALOR IPI'; |
|
2746
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2747
|
|
|
$this->pdf->textBox($x, $y, $w13, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2748
|
|
|
$this->pdf->line($x + $w13, $y, $x + $w13, $y + $hmax); |
|
2749
|
|
|
//ALÍQ. ICMS |
|
2750
|
|
|
$x += $w13; |
|
2751
|
|
|
$w14 = round($w * 0.04, 0); |
|
2752
|
|
|
$texto = 'ALÍQ. ICMS'; |
|
2753
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
2754
|
|
|
$this->pdf->textBox($x, $y, $w14, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2755
|
|
|
$this->pdf->line($x + $w14, $y, $x + $w14, $y + $hmax); |
|
2756
|
|
|
//ALÍQ. IPI |
|
2757
|
|
|
$x += $w14; |
|
2758
|
|
|
$w15 = $w - ($w1 + $w2 + $w3 + $w4 + $w5 + $w6 + $w7 + $w8 + $w9 + $w10 + $w11 + $w12 + $w13 + $w14); |
|
2759
|
|
|
$texto = 'ALÍQ. IPI'; |
|
2760
|
|
|
$this->pdf->textBox($x, $y, $w15, $h, $texto, $aFont, 'C', 'C', 0, '', false); |
|
|
|
|
|
|
2761
|
|
|
$this->pdf->line($oldX, $y + $h + 1, $oldX + $w, $y + $h + 1); |
|
2762
|
|
|
$y += 5; |
|
2763
|
|
|
//################################################################################## |
|
2764
|
|
|
// LOOP COM OS DADOS DOS PRODUTOS |
|
2765
|
|
|
$i = 0; |
|
2766
|
|
|
$hUsado = $hCabecItens; |
|
2767
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
2768
|
|
|
|
|
2769
|
|
|
foreach ($this->det as $d) { |
|
|
|
|
|
|
2770
|
|
|
if ($i >= $nInicio) { |
|
2771
|
|
|
$thisItem = $this->det->item($i); |
|
2772
|
|
|
//carrega as tags do item |
|
2773
|
|
|
$prod = $thisItem->getElementsByTagName("prod")->item(0); |
|
2774
|
|
|
$imposto = $this->det->item($i)->getElementsByTagName("imposto")->item(0); |
|
2775
|
|
|
$ICMS = $imposto->getElementsByTagName("ICMS")->item(0); |
|
2776
|
|
|
$IPI = $imposto->getElementsByTagName("IPI")->item(0); |
|
2777
|
|
|
$textoProduto = $this->descricaoProduto($thisItem); |
|
2778
|
|
|
|
|
2779
|
|
|
// Posição y dos dados das unidades tributaveis. |
|
2780
|
|
|
$yTrib = $this->pdf->fontSize + .5; |
|
2781
|
|
|
if (! $this->mostrarUnidadeTributavel) { |
|
2782
|
|
|
$yTrib = 0; |
|
2783
|
|
|
} |
|
2784
|
|
|
$h = $this->calculeHeight($thisItem); |
|
2785
|
|
|
$hUsado += $h; |
|
2786
|
|
|
|
|
2787
|
|
|
$yTrib += $y; |
|
2788
|
|
|
$diffH = $hmax - $hUsado; |
|
2789
|
|
|
|
|
2790
|
|
|
if ($pag != $totpag) { |
|
2791
|
|
|
if (1 > $diffH && $i < $totItens) { |
|
2792
|
|
|
//ultrapassa a capacidade para uma única página |
|
2793
|
|
|
//o restante dos dados serão usados nas proximas paginas |
|
2794
|
|
|
$nInicio = $i; |
|
2795
|
|
|
break; |
|
2796
|
|
|
} |
|
2797
|
|
|
} |
|
2798
|
|
|
$y_linha = $y + $h; |
|
2799
|
|
|
// linha entre itens |
|
2800
|
|
|
$this->pdf->dashedHLine($oldX, $y_linha, $w, 0.1, 120); |
|
2801
|
|
|
//corrige o x |
|
2802
|
|
|
$x = $oldX; |
|
2803
|
|
|
//codigo do produto |
|
2804
|
|
|
$guup = $i + 1; |
|
|
|
|
|
|
2805
|
|
|
$texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue; |
|
2806
|
|
|
$this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2807
|
|
|
$x += $w1; |
|
2808
|
|
|
//DESCRIÇÃO |
|
2809
|
|
|
if ($this->orientacao == 'P') { |
|
2810
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $textoProduto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
2811
|
|
|
} else { |
|
2812
|
|
|
$this->pdf->textBox($x, $y, $w2, $h, $textoProduto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
2813
|
|
|
} |
|
2814
|
|
|
$x += $w2; |
|
2815
|
|
|
//NCM |
|
2816
|
|
|
$texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ? |
|
2817
|
|
|
$prod->getElementsByTagName("NCM")->item(0)->nodeValue : ''; |
|
2818
|
|
|
$this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2819
|
|
|
$x += $w3; |
|
2820
|
|
|
//CST |
|
2821
|
|
|
if (isset($ICMS)) { |
|
2822
|
|
|
$origem = $this->getTagValue($ICMS, "orig"); |
|
2823
|
|
|
$cst = $this->getTagValue($ICMS, "CST"); |
|
2824
|
|
|
$csosn = $this->getTagValue($ICMS, "CSOSN"); |
|
2825
|
|
|
$texto = $origem . $cst . $csosn; |
|
2826
|
|
|
$this->pdf->textBox($x, $y, $w4, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2827
|
|
|
} |
|
2828
|
|
|
//CFOP |
|
2829
|
|
|
$x += $w4; |
|
2830
|
|
|
$texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue; |
|
2831
|
|
|
$this->pdf->textBox($x, $y, $w5, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2832
|
|
|
//Unidade |
|
2833
|
|
|
$x += $w5; |
|
2834
|
|
|
$texto = $prod->getElementsByTagName("uCom")->item(0)->nodeValue; |
|
2835
|
|
|
$this->pdf->textBox($x, $y, $w6, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2836
|
|
|
//Unidade de medida tributável |
|
2837
|
|
|
if ($this->mostrarUnidadeTributavel) { |
|
2838
|
|
|
$uTrib = $prod->getElementsByTagName("uTrib")->item(0); |
|
2839
|
|
|
if (! empty($uTrib)) { |
|
2840
|
|
|
$texto = $uTrib->nodeValue; |
|
2841
|
|
|
$this->pdf->textBox($x, $yTrib, $w6, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2842
|
|
|
} |
|
2843
|
|
|
} |
|
2844
|
|
|
$x += $w6; |
|
2845
|
|
|
if ($this->orientacao == 'P') { |
|
2846
|
|
|
$alinhamento = 'R'; |
|
2847
|
|
|
} else { |
|
2848
|
|
|
$alinhamento = 'R'; |
|
2849
|
|
|
} |
|
2850
|
|
|
// QTDADE |
|
2851
|
|
|
$qCom = $prod->getElementsByTagName("qCom")->item(0); |
|
2852
|
|
|
$texto = number_format($qCom->nodeValue, $this->qComCasasDec, ",", "."); |
|
2853
|
|
|
$this->pdf->textBox($x, $y, $w7, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2854
|
|
|
// QTDADE Tributável |
|
2855
|
|
|
if ($this->mostrarUnidadeTributavel) { |
|
2856
|
|
|
$qTrib = $prod->getElementsByTagName("qTrib")->item(0); |
|
2857
|
|
|
if (! empty($qTrib)) { |
|
2858
|
|
|
$texto = number_format($qTrib->nodeValue, $this->qComCasasDec, ",", "."); |
|
2859
|
|
|
$this->pdf->textBox($x, $yTrib, $w7, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2860
|
|
|
} |
|
2861
|
|
|
} |
|
2862
|
|
|
$x += $w7; |
|
2863
|
|
|
// Valor Unitário |
|
2864
|
|
|
$vUnCom = $prod->getElementsByTagName("vUnCom")->item(0); |
|
2865
|
|
|
$texto = number_format($vUnCom->nodeValue, $this->vUnComCasasDec, ",", "."); |
|
2866
|
|
|
$this->pdf->textBox($x, $y, $w8, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2867
|
|
|
// Valor Unitário Tributável |
|
2868
|
|
|
if ($this->mostrarUnidadeTributavel) { |
|
2869
|
|
|
$vUnTrib = $prod->getElementsByTagName("vUnTrib")->item(0); |
|
2870
|
|
|
if (! empty($vUnTrib)) { |
|
2871
|
|
|
$texto = number_format($vUnTrib->nodeValue, $this->vUnComCasasDec, ",", "."); |
|
2872
|
|
|
$this->pdf->textBox($x, $yTrib, $w8, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2873
|
|
|
} |
|
2874
|
|
|
} |
|
2875
|
|
|
$x += $w8; |
|
2876
|
|
|
// Valor do Produto |
|
2877
|
|
|
$texto = ""; |
|
2878
|
|
|
if (is_numeric($prod->getElementsByTagName("vProd")->item(0)->nodeValue)) { |
|
2879
|
|
|
$texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", "."); |
|
2880
|
|
|
} |
|
2881
|
|
|
$this->pdf->textBox($x, $y, $w9, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2882
|
|
|
$x += $w9; |
|
2883
|
|
|
//Valor do Desconto |
|
2884
|
|
|
$vdesc = ! empty($prod->getElementsByTagName("vDesc")->item(0)->nodeValue) |
|
2885
|
|
|
? $prod->getElementsByTagName("vDesc")->item(0)->nodeValue : 0; |
|
2886
|
|
|
|
|
2887
|
|
|
$texto = number_format($vdesc, 2, ",", "."); |
|
2888
|
|
|
$this->pdf->textBox($x, $y, $w10, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2889
|
|
|
//Valor da Base de calculo |
|
2890
|
|
|
$x += $w10; |
|
2891
|
|
|
if (isset($ICMS)) { |
|
2892
|
|
|
$texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) |
|
2893
|
|
|
? number_format( |
|
2894
|
|
|
$ICMS->getElementsByTagName("vBC")->item(0)->nodeValue, |
|
2895
|
|
|
2, |
|
2896
|
|
|
",", |
|
2897
|
|
|
"." |
|
2898
|
|
|
) |
|
2899
|
|
|
: '0,00'; |
|
2900
|
|
|
$this->pdf->textBox($x, $y, $w11, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2901
|
|
|
} |
|
2902
|
|
|
//Valor do ICMS |
|
2903
|
|
|
$x += $w11; |
|
2904
|
|
|
if (isset($ICMS)) { |
|
2905
|
|
|
$texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) |
|
2906
|
|
|
? number_format( |
|
2907
|
|
|
$ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue, |
|
2908
|
|
|
2, |
|
2909
|
|
|
",", |
|
2910
|
|
|
"." |
|
2911
|
|
|
) |
|
2912
|
|
|
: '0,00'; |
|
2913
|
|
|
$this->pdf->textBox($x, $y, $w12, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2914
|
|
|
} |
|
2915
|
|
|
//Valor do IPI |
|
2916
|
|
|
$x += $w12; |
|
2917
|
|
|
if (isset($IPI)) { |
|
2918
|
|
|
$texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue) |
|
2919
|
|
|
? number_format( |
|
2920
|
|
|
$IPI->getElementsByTagName("vIPI")->item(0)->nodeValue, |
|
2921
|
|
|
2, |
|
2922
|
|
|
",", |
|
2923
|
|
|
"." |
|
2924
|
|
|
) |
|
2925
|
|
|
: ''; |
|
2926
|
|
|
} else { |
|
2927
|
|
|
$texto = ''; |
|
2928
|
|
|
} |
|
2929
|
|
|
$this->pdf->textBox($x, $y, $w13, $h, $texto, $aFont, 'T', $alinhamento, 0, ''); |
|
|
|
|
|
|
2930
|
|
|
// %ICMS |
|
2931
|
|
|
$x += $w13; |
|
2932
|
|
|
if (isset($ICMS)) { |
|
2933
|
|
|
$texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) |
|
2934
|
|
|
? number_format( |
|
2935
|
|
|
$ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue, |
|
2936
|
|
|
2, |
|
2937
|
|
|
",", |
|
2938
|
|
|
"." |
|
2939
|
|
|
) |
|
2940
|
|
|
: '0,00'; |
|
2941
|
|
|
$this->pdf->textBox($x, $y, $w14, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2942
|
|
|
} |
|
2943
|
|
|
//%IPI |
|
2944
|
|
|
$x += $w14; |
|
2945
|
|
|
if (isset($IPI)) { |
|
2946
|
|
|
$texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue) |
|
2947
|
|
|
? number_format( |
|
2948
|
|
|
$IPI->getElementsByTagName("pIPI")->item(0)->nodeValue, |
|
2949
|
|
|
2, |
|
2950
|
|
|
",", |
|
2951
|
|
|
"." |
|
2952
|
|
|
) |
|
2953
|
|
|
: ''; |
|
2954
|
|
|
} else { |
|
2955
|
|
|
$texto = ''; |
|
2956
|
|
|
} |
|
2957
|
|
|
$this->pdf->textBox($x, $y, $w15, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
2958
|
|
|
|
|
2959
|
|
|
|
|
2960
|
|
|
// Dados do Veiculo Somente para veiculo 0 Km |
|
2961
|
|
|
$veicProd = $prod->getElementsByTagName("veicProd")->item(0); |
|
2962
|
|
|
// Tag somente é gerada para veiculo 0k, e só é permitido um veiculo por NF-e por conta do detran |
|
2963
|
|
|
// Verifica se a Tag existe |
|
2964
|
|
|
if (! empty($veicProd)) { |
|
2965
|
|
|
$this->dadosItenVeiculoDANFE($oldX, $y, $nInicio, $h, $prod); |
|
2966
|
|
|
} |
|
2967
|
|
|
|
|
2968
|
|
|
|
|
2969
|
|
|
$y += $h; |
|
2970
|
|
|
$i ++; |
|
2971
|
|
|
//incrementa o controle dos itens processados. |
|
2972
|
|
|
$this->qtdeItensProc ++; |
|
2973
|
|
|
} else { |
|
2974
|
|
|
$i ++; |
|
2975
|
|
|
} |
|
2976
|
|
|
} |
|
2977
|
|
|
|
|
2978
|
|
|
return $oldY + $hmax; |
|
2979
|
|
|
} |
|
2980
|
|
|
|
|
2981
|
|
|
|
|
2982
|
|
|
/** |
|
2983
|
|
|
* dadosItenVeiculoDANFE |
|
2984
|
|
|
* Coloca os dados do veiculo abaixo do item da NFe. (retrato e paisagem) |
|
2985
|
|
|
* |
|
2986
|
|
|
* @param float $x Posição horizontal |
|
2987
|
|
|
* canto esquerdo |
|
2988
|
|
|
* @param float $y Posição vertical |
|
2989
|
|
|
* canto superior |
|
2990
|
|
|
* @param $nInicio |
|
2991
|
|
|
* @param float $h altura do campo |
|
2992
|
|
|
* @param object $prod Contendo todos os dados do item |
|
2993
|
|
|
*/ |
|
2994
|
|
|
|
|
2995
|
|
|
protected function dadosItenVeiculoDANFE($x, $y, &$nInicio, $h, $prod) { |
|
2996
|
|
|
$oldX = $x; |
|
2997
|
|
|
$oldY = $y; |
|
|
|
|
|
|
2998
|
|
|
|
|
2999
|
|
|
if ($this->orientacao == 'P') { |
|
3000
|
|
|
$w = $this->wPrint; |
|
3001
|
|
|
} else { |
|
3002
|
|
|
if ($nInicio < 2) { // primeira página |
|
3003
|
|
|
$w = $this->wPrint - $this->wCanhoto; |
|
3004
|
|
|
} else { // páginas seguintes |
|
3005
|
|
|
$w = $this->wPrint; |
|
3006
|
|
|
} |
|
3007
|
|
|
} |
|
3008
|
|
|
|
|
3009
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
3010
|
|
|
|
|
3011
|
|
|
$w1 = round($w * 0.09, 0); |
|
3012
|
|
|
|
|
3013
|
|
|
// Tabela Renavam Combustivel |
|
3014
|
|
|
$renavamCombustivel = [ |
|
3015
|
|
|
1 => 'ALCOOL', |
|
3016
|
|
|
2 => 'GASOLINA', |
|
3017
|
|
|
3 => 'DIESEL', |
|
3018
|
|
|
4 => 'GASOGENIO', |
|
3019
|
|
|
5 => 'GAS METANO', |
|
3020
|
|
|
6 => 'ELETRICO/FONTE INTERNA', |
|
3021
|
|
|
7 => 'ELETRICO/FONTE EXTERNA', |
|
3022
|
|
|
8 => 'GASOL/GAS NATURAL COMBUSTIVEL', |
|
3023
|
|
|
9 => 'ALCOOL/GAS NATURAL COMBUSTIVEL', |
|
3024
|
|
|
10 => 'DIESEL/GAS NATURAL COMBUSTIVEL', |
|
3025
|
|
|
11 => 'VIDE/CAMPO/OBSERVACAO', |
|
3026
|
|
|
12 => 'ALCOOL/GAS NATURAL VEICULAR', |
|
3027
|
|
|
13 => 'GASOLINA/GAS NATURAL VEICULAR', |
|
3028
|
|
|
14 => 'DIESEL/GAS NATURAL VEICULAR', |
|
3029
|
|
|
15 => 'GAS NATURAL VEICULAR', |
|
3030
|
|
|
16 => 'ALCOOL/GASOLINA', |
|
3031
|
|
|
17 => 'GASOLINA/ALCOOL/GAS NATURAL', |
|
3032
|
|
|
18 => 'GASOLINA/ELETRICO' |
|
3033
|
|
|
]; |
|
3034
|
|
|
|
|
3035
|
|
|
$renavamEspecie = [ |
|
3036
|
|
|
1 => 'PASSAGEIRO', |
|
3037
|
|
|
2 => 'CARGA', |
|
3038
|
|
|
3 => 'MISTO', |
|
3039
|
|
|
4 => 'CORRIDA', |
|
3040
|
|
|
5 => 'TRACAO', |
|
3041
|
|
|
6 => 'ESPECIAL', |
|
3042
|
|
|
7 => 'COLECAO' |
|
3043
|
|
|
]; |
|
3044
|
|
|
|
|
3045
|
|
|
$renavamTiposVeiculos = [ |
|
3046
|
|
|
1 => 'BICICLETA', |
|
3047
|
|
|
2 => 'CICLOMOTOR', |
|
3048
|
|
|
3 => 'MOTONETA', |
|
3049
|
|
|
4 => 'MOTOCICLETA', |
|
3050
|
|
|
5 => 'TRICICLO', |
|
3051
|
|
|
6 => 'AUTOMOVEL', |
|
3052
|
|
|
7 => 'MICROONIBUS', |
|
3053
|
|
|
8 => 'ONIBUS', |
|
3054
|
|
|
9 => 'BONDE', |
|
3055
|
|
|
10 => 'REBOQUE', |
|
3056
|
|
|
11 => 'SEMI-REBOQUE', |
|
3057
|
|
|
12 => 'CHARRETE', |
|
3058
|
|
|
13 => 'CAMIONETA', |
|
3059
|
|
|
14 => 'CAMINHAO', |
|
3060
|
|
|
15 => 'CARROCA', |
|
3061
|
|
|
16 => 'CARRO DE MAO', |
|
3062
|
|
|
17 => 'CAMINHAO TRATOR', |
|
3063
|
|
|
18 => 'TRATOR DE RODAS', |
|
3064
|
|
|
19 => 'TRATOR DE ESTEIRAS', |
|
3065
|
|
|
20 => 'TRATOR MISTO', |
|
3066
|
|
|
21 => 'QUADRICICLO', |
|
3067
|
|
|
22 => 'CHASSI/PLATAFORMA', |
|
3068
|
|
|
23 => 'CAMINHONETE', |
|
3069
|
|
|
24 => 'SIDE-CAR', |
|
3070
|
|
|
25 => 'UTILITARIO', |
|
3071
|
|
|
26 => 'MOTOR-CASA' |
|
3072
|
|
|
]; |
|
3073
|
|
|
|
|
3074
|
|
|
$renavamTipoPintura = [ |
|
|
|
|
|
|
3075
|
|
|
'F' => 'FOSCA', |
|
3076
|
|
|
'S' => 'SÓLIDA', |
|
3077
|
|
|
'P' => 'PEROLIZADA', |
|
3078
|
|
|
'M' => 'METALICA', |
|
3079
|
|
|
]; |
|
3080
|
|
|
|
|
3081
|
|
|
$veicProd = $prod->getElementsByTagName("veicProd")->item(0); |
|
3082
|
|
|
|
|
3083
|
|
|
$veiculoChassi = $veicProd->getElementsByTagName("chassi")->item(0)->nodeValue; |
|
3084
|
|
|
$veiculoCor = $veicProd->getElementsByTagName("xCor")->item(0)->nodeValue; |
|
3085
|
|
|
$veiculoCilindrada = $veicProd->getElementsByTagName("cilin")->item(0)->nodeValue; |
|
3086
|
|
|
$veiculoCmkg = $veicProd->getElementsByTagName("CMT")->item(0)->nodeValue; |
|
3087
|
|
|
$veiculoTipo = $veicProd->getElementsByTagName("tpVeic")->item(0)->nodeValue; |
|
3088
|
|
|
|
|
3089
|
|
|
$veiculoMotor = $veicProd->getElementsByTagName("nMotor")->item(0)->nodeValue; |
|
3090
|
|
|
$veiculoRenavam = $veicProd->getElementsByTagName("cMod")->item(0)->nodeValue; |
|
3091
|
|
|
$veiculoHp = $veicProd->getElementsByTagName("pot")->item(0)->nodeValue; |
|
3092
|
|
|
$veiculoPlaca = ''; //$veiculo->getElementsByTagName("CMT")->item(0)->nodeValue; |
|
3093
|
|
|
$veiculoTipoPintura = $veicProd->getElementsByTagName("tpPint")->item(0)->nodeValue; |
|
3094
|
|
|
$veiculoMarcaModelo = $prod->getElementsByTagName("xProd")->item(0)->nodeValue; |
|
3095
|
|
|
$veiculoEspecie = $veicProd->getElementsByTagName("espVeic")->item(0)->nodeValue; |
|
3096
|
|
|
$veiculoCombustivel = $veicProd->getElementsByTagName("tpComb")->item(0)->nodeValue; |
|
3097
|
|
|
$veiculoSerial = $veicProd->getElementsByTagName("nSerie")->item(0)->nodeValue; |
|
3098
|
|
|
$veiculoFabricacao = $veicProd->getElementsByTagName("anoFab")->item(0)->nodeValue; |
|
3099
|
|
|
$veiculoModelo = $veicProd->getElementsByTagName("anoMod")->item(0)->nodeValue; |
|
3100
|
|
|
$veiculoDistancia = $veicProd->getElementsByTagName("dist")->item(0)->nodeValue; |
|
3101
|
|
|
|
|
3102
|
|
|
$x = $oldX; |
|
3103
|
|
|
|
|
3104
|
|
|
$yVeic = $y + $h; |
|
3105
|
|
|
$texto = 'Chassi: ............: ' . $veiculoChassi; |
|
3106
|
|
|
$this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3107
|
|
|
$yVeic += $h; |
|
3108
|
|
|
$texto = 'Cor...................: ' . $veiculoCor; |
|
3109
|
|
|
$this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3110
|
|
|
$yVeic += $h; |
|
3111
|
|
|
$texto = 'Cilindrada........: ' . $veiculoCilindrada; |
|
3112
|
|
|
$this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3113
|
|
|
$yVeic += $h; |
|
3114
|
|
|
$texto = 'Cmkg...............: ' . $veiculoCmkg; |
|
3115
|
|
|
$this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3116
|
|
|
$yVeic += $h; |
|
3117
|
|
|
$texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo); |
|
3118
|
|
|
$this->pdf->textBox($x, $yVeic, $w1 + 40, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3119
|
|
|
$yVeic = $y + $h; |
|
3120
|
|
|
$xVeic = $x + 65; |
|
3121
|
|
|
$texto = 'Nº Motor: .........: ' . $veiculoMotor; |
|
3122
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3123
|
|
|
$yVeic += $h; |
|
3124
|
|
|
$texto = 'Renavam...........: ' . $veiculoRenavam; |
|
3125
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3126
|
|
|
$yVeic += $h; |
|
3127
|
|
|
$texto = 'HP.....................: ' . $veiculoHp; |
|
3128
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3129
|
|
|
$yVeic += $h; |
|
3130
|
|
|
$texto = 'Placa.................: ' . $veiculoPlaca; |
|
3131
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3132
|
|
|
$yVeic += $h; |
|
3133
|
|
|
$texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura); |
|
3134
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3135
|
|
|
$yVeic = $y + $h; |
|
3136
|
|
|
$xVeic = $xVeic + 55; |
|
3137
|
|
|
$texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo; |
|
3138
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3139
|
|
|
$yVeic += $h; |
|
3140
|
|
|
$texto = 'Especie..................: ' . ($renavamEspecie[intval($veiculoEspecie)] ?? $veiculoEspecie); |
|
3141
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3142
|
|
|
$yVeic += $h; |
|
3143
|
|
|
$texto = 'Combustivel..........: ' . ($renavamCombustivel[intval($veiculoCombustivel)] ?? $veiculoCombustivel); |
|
3144
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3145
|
|
|
$yVeic += $h; |
|
3146
|
|
|
$texto = 'Serial.....................: ' . $veiculoSerial; |
|
3147
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3148
|
|
|
$yVeic += $h; |
|
3149
|
|
|
$texto = 'Ano Fab/Mod........: ' . $veiculoFabricacao . '/' . $veiculoModelo; |
|
3150
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3151
|
|
|
$yVeic += $h; |
|
3152
|
|
|
$texto = 'Distancia Entre Eixos(mm)..: ' . $veiculoDistancia; |
|
3153
|
|
|
$this->pdf->textBox($xVeic, $yVeic, $w1 + 50, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3154
|
|
|
} |
|
3155
|
|
|
|
|
3156
|
|
|
/** |
|
3157
|
|
|
* issqn |
|
3158
|
|
|
* Monta o campo de serviços do DANFE |
|
3159
|
|
|
* |
|
3160
|
|
|
* @name issqn (retrato e paisagem) |
|
3161
|
|
|
* |
|
3162
|
|
|
* @param float $x Posição horizontal canto esquerdo |
|
3163
|
|
|
* @param float $y Posição vertical canto superior |
|
3164
|
|
|
* |
|
3165
|
|
|
* @return float Posição vertical final |
|
3166
|
|
|
*/ |
|
3167
|
|
|
protected function issqn($x, $y) { |
|
3168
|
|
|
$oldX = $x; |
|
|
|
|
|
|
3169
|
|
|
//##################################################################### |
|
3170
|
|
|
//CÁLCULO DO ISSQN |
|
3171
|
|
|
$texto = "CÁLCULO DO ISSQN"; |
|
3172
|
|
|
$w = $this->wPrint; |
|
3173
|
|
|
$h = 7; |
|
3174
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
3175
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3176
|
|
|
//INSCRIÇÃO MUNICIPAL |
|
3177
|
|
|
$y += 3; |
|
3178
|
|
|
$w = round($this->wPrint * 0.23, 0); |
|
3179
|
|
|
$texto = 'INSCRIÇÃO MUNICIPAL'; |
|
3180
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
3181
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3182
|
|
|
//inscrição municipal |
|
3183
|
|
|
$texto = ! empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ? |
|
3184
|
|
|
$this->emit->getElementsByTagName("IM")->item(0)->nodeValue : ''; |
|
3185
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
3186
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, ''); |
|
|
|
|
|
|
3187
|
|
|
//VALOR TOTAL DOS SERVIÇOS |
|
3188
|
|
|
$x += $w; |
|
3189
|
|
|
$texto = 'VALOR TOTAL DOS SERVIÇOS'; |
|
3190
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
3191
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3192
|
|
|
if (isset($this->ISSQNtot)) { |
|
3193
|
|
|
$texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ? |
|
3194
|
|
|
$this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : ''; |
|
3195
|
|
|
$texto = number_format($texto, 2, ",", "."); |
|
3196
|
|
|
} else { |
|
3197
|
|
|
$texto = ''; |
|
3198
|
|
|
} |
|
3199
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
3200
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, ''); |
|
|
|
|
|
|
3201
|
|
|
//BASE DE CÁLCULO DO ISSQN |
|
3202
|
|
|
$x += $w; |
|
3203
|
|
|
$texto = 'BASE DE CÁLCULO DO ISSQN'; |
|
3204
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
3205
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3206
|
|
|
if (isset($this->ISSQNtot)) { |
|
3207
|
|
|
$texto = ! empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ? |
|
3208
|
|
|
$this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : ''; |
|
3209
|
|
|
$texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : ''; |
|
3210
|
|
|
} else { |
|
3211
|
|
|
$texto = ''; |
|
3212
|
|
|
} |
|
3213
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
3214
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, ''); |
|
|
|
|
|
|
3215
|
|
|
//VALOR TOTAL DO ISSQN |
|
3216
|
|
|
$x += $w; |
|
3217
|
|
|
if ($this->orientacao == 'P') { |
|
3218
|
|
|
$w = $this->wPrint - (3 * $w); |
|
3219
|
|
|
} else { |
|
3220
|
|
|
$w = $this->wPrint - (3 * $w) - $this->wCanhoto; |
|
3221
|
|
|
} |
|
3222
|
|
|
$texto = 'VALOR TOTAL DO ISSQN'; |
|
3223
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
3224
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3225
|
|
|
if (isset($this->ISSQNtot)) { |
|
3226
|
|
|
$texto = ! empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ? |
|
3227
|
|
|
$this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : ''; |
|
3228
|
|
|
$texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : ''; |
|
3229
|
|
|
} else { |
|
3230
|
|
|
$texto = ''; |
|
3231
|
|
|
} |
|
3232
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
3233
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, ''); |
|
|
|
|
|
|
3234
|
|
|
|
|
3235
|
|
|
return ($y + $h + 1); |
|
3236
|
|
|
} |
|
3237
|
|
|
|
|
3238
|
|
|
/** |
|
3239
|
|
|
*dadosAdicionais |
|
3240
|
|
|
* Coloca o grupo de dados adicionais da NFe. (retrato e paisagem) |
|
3241
|
|
|
* |
|
3242
|
|
|
* @name dadosAdicionais |
|
3243
|
|
|
* |
|
3244
|
|
|
* @param float $x Posição horizontal canto esquerdo |
|
3245
|
|
|
* @param float $y Posição vertical canto superior |
|
3246
|
|
|
* @param float $h altura do campo |
|
3247
|
|
|
* |
|
3248
|
|
|
* @return float Posição vertical final (eixo Y) |
|
3249
|
|
|
*/ |
|
3250
|
|
|
protected function dadosAdicionais($x, $y, $h) { |
|
|
|
|
|
|
3251
|
|
|
$y = $this->maxH - (7 + $h); |
|
3252
|
|
|
//$y = $this->maxH - 20; |
|
3253
|
|
|
//################################################################################## |
|
3254
|
|
|
//DADOS ADICIONAIS |
|
3255
|
|
|
$texto = "DADOS ADICIONAIS"; |
|
3256
|
|
|
if ($this->orientacao == 'P') { |
|
3257
|
|
|
$w = $this->wPrint; |
|
3258
|
|
|
} else { |
|
3259
|
|
|
$w = $this->wPrint - $this->wCanhoto; |
|
3260
|
|
|
} |
|
3261
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => 'B']; |
|
3262
|
|
|
$this->pdf->textBox($x, $y, $w, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
|
|
|
|
|
3263
|
|
|
|
|
3264
|
|
|
//INFORMAÇÕES COMPLEMENTARES |
|
3265
|
|
|
$texto = "INFORMAÇÕES COMPLEMENTARES"; |
|
3266
|
|
|
$y += 3; |
|
3267
|
|
|
$w = $this->wAdic; |
|
3268
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B']; |
|
3269
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3270
|
|
|
//o texto com os dados adicionais foi obtido na função montaDANFE |
|
3271
|
|
|
//e carregado em uma propriedade privada da classe |
|
3272
|
|
|
//$this->wAdic com a largura do campo |
|
3273
|
|
|
//$this->textoAdic com o texto completo do campo |
|
3274
|
|
|
//echo str_replace("\n", "<br>",$this->textoAdic); |
|
3275
|
|
|
//die; |
|
3276
|
|
|
$y += 1; |
|
3277
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => $this->textadicfontsize * $this->pdf->k, 'style' => '']; |
|
3278
|
|
|
//$aFont = ['font'=>$this->fontePadrao, 'size'=> 5, 'style'=>'']; |
|
3279
|
|
|
$this->pdf->textBox($x, $y + 2, $w - 2, $h, $this->textoAdic, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
3280
|
|
|
//RESERVADO AO FISCO |
|
3281
|
|
|
$texto = "RESERVADO AO FISCO"; |
|
3282
|
|
|
if (isset($this->nfeProc) && $this->nfeProc->getElementsByTagName("xMsg")->length) { |
|
3283
|
|
|
$texto = $texto . ' ' . $this->nfeProc->getElementsByTagName("xMsg")->item(0)->nodeValue; |
|
3284
|
|
|
} |
|
3285
|
|
|
$x += $w; |
|
3286
|
|
|
$y -= 1; |
|
3287
|
|
|
if ($this->orientacao == 'P') { |
|
3288
|
|
|
$w = $this->wPrint - $w; |
|
3289
|
|
|
} else { |
|
3290
|
|
|
$w = $this->wPrint - $w - $this->wCanhoto; |
|
3291
|
|
|
} |
|
3292
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'B']; |
|
3293
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3294
|
|
|
//inserir texto informando caso de contingência |
|
3295
|
|
|
// 1 - Normal - emissão normal; |
|
3296
|
|
|
// 2 - Contingência FS - emissão em contingência com impressão do DANFE em Formulário de Segurança; |
|
3297
|
|
|
// 3 - Contingência SCAN - emissão em contingência no Sistema de Contingência do Ambiente Nacional; |
|
3298
|
|
|
// 4 - Contingência DPEC - emissão em contingência com envio da Declaração |
|
3299
|
|
|
// Prévia de Emissão em Contingência; |
|
3300
|
|
|
// 5 - Contingência FS-DA - emissão em contingência com impressão do DANFE em Formulário de |
|
3301
|
|
|
// Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA); |
|
3302
|
|
|
// 6 - Contingência SVC-AN |
|
3303
|
|
|
// 7 - Contingência SVC-RS |
|
3304
|
|
|
$xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: '); |
|
3305
|
|
|
$dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : '); |
|
3306
|
|
|
$texto = ''; |
|
3307
|
|
|
switch ($this->tpEmis) { |
|
3308
|
|
|
case 2: |
|
3309
|
|
|
$texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust; |
|
3310
|
|
|
break; |
|
3311
|
|
|
case 3: |
|
3312
|
|
|
$texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust; |
|
3313
|
|
|
break; |
|
3314
|
|
|
case 4: |
|
3315
|
|
|
$texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust; |
|
3316
|
|
|
break; |
|
3317
|
|
|
case 5: |
|
3318
|
|
|
$texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust; |
|
3319
|
|
|
break; |
|
3320
|
|
|
case 6: |
|
3321
|
|
|
$texto = 'CONTINGÊNCIA SVC-AN' . $dhCont . $xJust; |
|
3322
|
|
|
break; |
|
3323
|
|
|
case 7: |
|
3324
|
|
|
$texto = 'CONTINGÊNCIA SVC-RS' . $dhCont . $xJust; |
|
3325
|
|
|
break; |
|
3326
|
|
|
} |
|
3327
|
|
|
$y += 2; |
|
3328
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
3329
|
|
|
$this->pdf->textBox($x, $y, $w - 2, $h, $texto, $aFont, 'T', 'L', 0, '', false); |
|
|
|
|
|
|
3330
|
|
|
|
|
3331
|
|
|
return $y + $h; |
|
3332
|
|
|
} |
|
3333
|
|
|
|
|
3334
|
|
|
/** |
|
3335
|
|
|
* rodape |
|
3336
|
|
|
* Monta o rodapé no final da DANFE com a data/hora de impressão e informações |
|
3337
|
|
|
* sobre a API NfePHP |
|
3338
|
|
|
* |
|
3339
|
|
|
* @param float $x Posição horizontal canto esquerdo |
|
3340
|
|
|
* |
|
3341
|
|
|
* @return void |
|
3342
|
|
|
*/ |
|
3343
|
|
|
protected function rodape($x) { |
|
3344
|
|
|
$y = $this->maxH - 4; |
|
3345
|
|
|
if ($this->orientacao == 'P') { |
|
3346
|
|
|
$w = $this->wPrint; |
|
3347
|
|
|
} else { |
|
3348
|
|
|
$w = $this->wPrint - $this->wCanhoto; |
|
3349
|
|
|
$x = $this->wCanhoto; |
|
3350
|
|
|
} |
|
3351
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => 'I']; |
|
3352
|
|
|
$texto = "Impresso em " . date('d/m/Y') . " as " . date('H:i:s') |
|
3353
|
|
|
. ' ' . $this->creditos; |
|
3354
|
|
|
$this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'L', false); |
|
3355
|
|
|
$texto = $this->powered ? "Powered by NFePHP®" : ''; |
|
3356
|
|
|
$this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, ''); |
|
3357
|
|
|
} |
|
3358
|
|
|
|
|
3359
|
|
|
/** |
|
3360
|
|
|
* Monta o canhoto da DANFE (retrato e paisagem) |
|
3361
|
|
|
* |
|
3362
|
|
|
* @name canhotoDANFE |
|
3363
|
|
|
* |
|
3364
|
|
|
* @param number $x Posição horizontal canto esquerdo |
|
3365
|
|
|
* @param number $y Posição vertical canto superior |
|
3366
|
|
|
* |
|
3367
|
|
|
* @return number Posição vertical final |
|
3368
|
|
|
* |
|
3369
|
|
|
* TODO 21/07/14 fmertins: quando orientação L-paisagem, o canhoto está sendo gerado incorretamente |
|
3370
|
|
|
*/ |
|
3371
|
|
|
protected function canhoto($x, $y) { |
|
3372
|
|
|
$oldX = $x; |
|
3373
|
|
|
$oldY = $y; |
|
3374
|
|
|
//################################################################################# |
|
3375
|
|
|
//canhoto |
|
3376
|
|
|
//identificação do tipo de nf entrada ou saida |
|
3377
|
|
|
$tpNF = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue; |
|
3378
|
|
|
if ($tpNF == '0') { |
|
3379
|
|
|
//NFe de Entrada |
|
3380
|
|
|
$emitente = ''; |
|
3381
|
|
|
$emitente .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - "; |
|
3382
|
|
|
$emitente .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", "; |
|
3383
|
|
|
$emitente .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - "; |
|
3384
|
|
|
$emitente .= $this->getTagValue($this->enderDest, "xCpl", " - ", " "); |
|
3385
|
|
|
$emitente .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " "; |
|
3386
|
|
|
$emitente .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-"; |
|
3387
|
|
|
$emitente .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . ""; |
|
3388
|
|
|
$destinatario = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " "; |
|
3389
|
|
|
} else { |
|
3390
|
|
|
//NFe de Saída |
|
3391
|
|
|
$emitente = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " "; |
|
3392
|
|
|
$destinatario = ''; |
|
3393
|
|
|
$destinatario .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - "; |
|
3394
|
|
|
$destinatario .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", "; |
|
3395
|
|
|
$destinatario .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " "; |
|
3396
|
|
|
$destinatario .= $this->getTagValue($this->enderDest, "xCpl", " - ", " "); |
|
3397
|
|
|
$destinatario .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " "; |
|
3398
|
|
|
$destinatario .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-"; |
|
3399
|
|
|
$destinatario .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . " "; |
|
3400
|
|
|
} |
|
3401
|
|
|
//identificação do sistema emissor |
|
3402
|
|
|
//linha separadora do canhoto |
|
3403
|
|
|
if ($this->orientacao == 'P') { |
|
3404
|
|
|
$w = round($this->wPrint * 0.81, 0); |
|
3405
|
|
|
} else { |
|
3406
|
|
|
//linha separadora do canhoto - 238 |
|
3407
|
|
|
//posicao altura |
|
3408
|
|
|
$y = $this->wPrint - 85; |
|
3409
|
|
|
//altura |
|
3410
|
|
|
$w = $this->wPrint - 85 - 24; |
|
3411
|
|
|
} |
|
3412
|
|
|
$h = 10; |
|
3413
|
|
|
//desenha caixa |
|
3414
|
|
|
$texto = ''; |
|
3415
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
3416
|
|
|
$aFontSmall = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
3417
|
|
|
if ($this->orientacao == 'P') { |
|
3418
|
|
|
$this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false); |
|
|
|
|
|
|
3419
|
|
|
} else { |
|
3420
|
|
|
$this->pdf->textBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false); |
|
3421
|
|
|
} |
|
3422
|
|
|
$numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT); |
|
3423
|
|
|
$serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT); |
|
3424
|
|
|
$texto = "RECEBEMOS DE "; |
|
3425
|
|
|
$texto .= $emitente; |
|
3426
|
|
|
$texto .= " OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA "; |
|
3427
|
|
|
if ($this->orientacao == 'P') { |
|
3428
|
|
|
$texto .= "ABAIXO"; |
|
3429
|
|
|
} else { |
|
3430
|
|
|
$texto .= "AO LADO"; |
|
3431
|
|
|
} |
|
3432
|
|
|
$texto .= ". EMISSÃO: "; |
|
3433
|
|
|
$dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ? |
|
3434
|
|
|
$this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : ''; |
|
3435
|
|
|
if ($dEmi == '') { |
|
3436
|
|
|
$dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ? |
|
3437
|
|
|
$this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : ''; |
|
3438
|
|
|
$aDemi = explode('T', $dEmi); |
|
3439
|
|
|
$dEmi = $aDemi[0]; |
|
3440
|
|
|
} |
|
3441
|
|
|
$texto .= $this->ymdTodmy($dEmi) . " "; |
|
3442
|
|
|
$texto .= "VALOR TOTAL: R$ "; |
|
3443
|
|
|
$texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " "; |
|
3444
|
|
|
$texto .= "DESTINATÁRIO: "; |
|
3445
|
|
|
$texto .= $destinatario; |
|
3446
|
|
|
if ($this->orientacao == 'P') { |
|
3447
|
|
|
$this->pdf->textBox($x, $y, $w - 1, $h, $texto, $aFont, 'C', 'L', 0, '', false); |
|
|
|
|
|
|
3448
|
|
|
$x1 = $x + $w; |
|
3449
|
|
|
$w1 = $this->wPrint - $w; |
|
3450
|
|
|
$texto = "NF-e"; |
|
3451
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B']; |
|
3452
|
|
|
$this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
3453
|
|
|
$texto = "Nº. " . $this->formatField($numNF, "###.###.###") . " \n"; |
|
3454
|
|
|
$texto .= "Série $serie"; |
|
3455
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
3456
|
|
|
$this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'C', 'C', 1, ''); |
|
|
|
|
|
|
3457
|
|
|
//DATA DE RECEBIMENTO |
|
3458
|
|
|
$texto = "DATA DE RECEBIMENTO"; |
|
3459
|
|
|
$y += $h; |
|
3460
|
|
|
$w2 = round($this->wPrint * 0.17, 0); //35; |
|
3461
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
3462
|
|
|
$this->pdf->textBox($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3463
|
|
|
//IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR |
|
3464
|
|
|
$x += $w2; |
|
3465
|
|
|
$w3 = $w - $w2; |
|
3466
|
|
|
$texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR"; |
|
3467
|
|
|
$this->pdf->textBox($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, ''); |
|
|
|
|
|
|
3468
|
|
|
$x = $oldX; |
|
3469
|
|
|
$y += 9; |
|
3470
|
|
|
$this->pdf->dashedHLine($x, $y, $this->wPrint, 0.1, 80); |
|
3471
|
|
|
$y += 2; |
|
3472
|
|
|
|
|
3473
|
|
|
return $y; |
|
3474
|
|
|
} else { |
|
3475
|
|
|
$x --; |
|
3476
|
|
|
$x = $this->pdf->textBox90($x, $y, $w - 1, $h, $texto, $aFontSmall, 'C', 'L', 0, '', false); |
|
|
|
|
|
|
3477
|
|
|
//NUMERO DA NOTA FISCAL LOGO NFE |
|
3478
|
|
|
$w1 = 18; |
|
3479
|
|
|
$x1 = $oldX; |
|
3480
|
|
|
$y = $oldY; |
|
3481
|
|
|
$texto = "NF-e"; |
|
3482
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 14, 'style' => 'B']; |
|
3483
|
|
|
$this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
3484
|
|
|
$texto = "Nº.\n" . $this->formatField($numNF, "###.###.###") . " \n"; |
|
3485
|
|
|
$texto .= "Série $serie"; |
|
3486
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B']; |
|
3487
|
|
|
$this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'C', 'C', 1, ''); |
|
|
|
|
|
|
3488
|
|
|
//DATA DO RECEBIMENTO |
|
3489
|
|
|
$texto = "DATA DO RECEBIMENTO"; |
|
3490
|
|
|
$y = $this->wPrint - 85; |
|
3491
|
|
|
$x = 12; |
|
3492
|
|
|
$w2 = round($this->wPrint * 0.17, 0); //35; |
|
3493
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 6, 'style' => '']; |
|
3494
|
|
|
$this->pdf->textBox90($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, ''); |
|
3495
|
|
|
//IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR |
|
3496
|
|
|
$y -= $w2; |
|
3497
|
|
|
$w3 = $w - $w2; |
|
3498
|
|
|
$texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR"; |
|
3499
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 5.7, 'style' => '']; |
|
3500
|
|
|
$x = $this->pdf->textBox90($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, ''); |
|
3501
|
|
|
$this->pdf->dashedVLine(22, $oldY, 0.1, $this->wPrint, 69); |
|
3502
|
|
|
|
|
3503
|
|
|
return $x; |
|
3504
|
|
|
} |
|
3505
|
|
|
} |
|
3506
|
|
|
|
|
3507
|
|
|
/** |
|
3508
|
|
|
* geraInformacoesDaTagCompra |
|
3509
|
|
|
* Devolve uma string contendo informação sobre as tag <compra><xNEmp>, <xPed> e <xCont> ou string vazia. |
|
3510
|
|
|
* Aviso: Esta função não leva em consideração dados na tag xPed do item. |
|
3511
|
|
|
* |
|
3512
|
|
|
* @name pGeraInformacoesDaTagCompra |
|
3513
|
|
|
* @return string com as informacoes dos pedidos. |
|
3514
|
|
|
*/ |
|
3515
|
|
|
protected function geraInformacoesDaTagCompra() { |
|
3516
|
|
|
if (! $this->gerarInformacoesAutomaticas) { |
|
3517
|
|
|
return ''; |
|
3518
|
|
|
} |
|
3519
|
|
|
$saida = ""; |
|
3520
|
|
|
if (isset($this->compra)) { |
|
3521
|
|
|
if (! empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) { |
|
3522
|
|
|
$saida .= " Nota de Empenho: " . $this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue; |
|
3523
|
|
|
} |
|
3524
|
|
|
if (! empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) { |
|
3525
|
|
|
$saida .= " Pedido: " . $this->compra->getElementsByTagName("xPed")->item(0)->nodeValue; |
|
3526
|
|
|
} |
|
3527
|
|
|
if (! empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) { |
|
3528
|
|
|
$saida .= " Contrato: " . $this->compra->getElementsByTagName("xCont")->item(0)->nodeValue; |
|
3529
|
|
|
} |
|
3530
|
|
|
} |
|
3531
|
|
|
|
|
3532
|
|
|
return $saida; |
|
3533
|
|
|
} |
|
3534
|
|
|
|
|
3535
|
|
|
/** |
|
3536
|
|
|
* geraChaveAdicionalDeContingencia |
|
3537
|
|
|
* |
|
3538
|
|
|
* @name geraChaveAdicionalDeContingencia |
|
3539
|
|
|
* @return string chave |
|
3540
|
|
|
*/ |
|
3541
|
|
|
protected function geraChaveAdicionalDeContingencia() { |
|
3542
|
|
|
//cUF tpEmis CNPJ vNF ICMSp ICMSs DD DV |
|
3543
|
|
|
// Quantidade de caracteres 02 01 14 14 01 01 02 01 |
|
3544
|
|
|
$forma = "%02d%d%s%014d%01d%01d%02d"; |
|
3545
|
|
|
$cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue; |
|
3546
|
|
|
$CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
|
3547
|
|
|
$CNPJ = substr($CNPJ, - 14); |
|
3548
|
|
|
$vNF = $this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue * 100; |
|
3549
|
|
|
$vICMS = $this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue; |
|
3550
|
|
|
if ($vICMS > 0) { |
|
3551
|
|
|
$vICMS = 1; |
|
3552
|
|
|
} |
|
3553
|
|
|
$icmss = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue; |
|
3554
|
|
|
if ($icmss > 0) { |
|
3555
|
|
|
$icmss = 1; |
|
3556
|
|
|
} |
|
3557
|
|
|
$dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ? |
|
3558
|
|
|
$this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : ''; |
|
3559
|
|
|
if ($dEmi == '') { |
|
3560
|
|
|
$dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ? |
|
3561
|
|
|
$this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : ''; |
|
3562
|
|
|
$aDemi = explode('T', $dEmi); |
|
3563
|
|
|
$dEmi = $aDemi[0]; |
|
3564
|
|
|
} |
|
3565
|
|
|
$dd = $dEmi; |
|
3566
|
|
|
$rpos = strrpos($dd, '-'); |
|
3567
|
|
|
$dd = substr($dd, $rpos + 1); |
|
3568
|
|
|
$chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vNF, $vICMS, $icmss, $dd); |
|
3569
|
|
|
$chave = $chave . $this->modulo11($chave); |
|
3570
|
|
|
|
|
3571
|
|
|
return $chave; |
|
3572
|
|
|
} |
|
3573
|
|
|
|
|
3574
|
|
|
/** |
|
3575
|
|
|
* geraInformacoesDasNotasReferenciadas |
|
3576
|
|
|
* Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não |
|
3577
|
|
|
* Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01 |
|
3578
|
|
|
* em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000] |
|
3579
|
|
|
* |
|
3580
|
|
|
* @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas. |
|
3581
|
|
|
*/ |
|
3582
|
|
|
protected function geraInformacoesDasNotasReferenciadas() { |
|
3583
|
|
|
if (! $this->gerarInformacoesAutomaticas) { |
|
3584
|
|
|
return ''; |
|
3585
|
|
|
} |
|
3586
|
|
|
$formaNfeRef = "\r\nNFe Ref.: série:%d número:%d emit:%s em %s [%s]"; |
|
3587
|
|
|
$formaCTeRef = "\r\nCTe Ref.: série:%d número:%d emit:%s em %s [%s]"; |
|
3588
|
|
|
$formaNfRef = "\r\nNF Ref.: série:%d numero:%d emit:%s em %s modelo: %d"; |
|
3589
|
|
|
$formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d"; |
|
3590
|
|
|
$formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s"; |
|
3591
|
|
|
$saida = ''; |
|
3592
|
|
|
$nfRefs = $this->ide->getElementsByTagName('NFref'); |
|
3593
|
|
|
if (0 === $nfRefs->length) { |
|
3594
|
|
|
return $saida; |
|
3595
|
|
|
} |
|
3596
|
|
|
if ($nfRefs->length > 2) { |
|
3597
|
|
|
return 'Existem mais de 2 NF/NFe/ECF/NFP/CTe referenciadas, não serão exibidas na DANFE.'; |
|
3598
|
|
|
} |
|
3599
|
|
|
foreach ($nfRefs as $nfRef) { |
|
3600
|
|
|
if (empty($nfRef)) { |
|
3601
|
|
|
continue; |
|
3602
|
|
|
} |
|
3603
|
|
|
$refNFe = $nfRef->getElementsByTagName('refNFe'); |
|
3604
|
|
|
foreach ($refNFe as $chave_acessoRef) { |
|
3605
|
|
|
$chave_acesso = $chave_acessoRef->nodeValue; |
|
3606
|
|
|
$chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave); |
|
3607
|
|
|
$data = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2); |
|
3608
|
|
|
$cnpj = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##"); |
|
3609
|
|
|
$serie = substr($chave_acesso, 22, 3); |
|
3610
|
|
|
$numero = substr($chave_acesso, 25, 9); |
|
3611
|
|
|
$saida .= sprintf($formaNfeRef, $serie, $numero, $cnpj, $data, $chave_acessoF); |
|
3612
|
|
|
} |
|
3613
|
|
|
$refNF = $nfRef->getElementsByTagName('refNF'); |
|
3614
|
|
|
foreach ($refNF as $umaRefNFe) { |
|
3615
|
|
|
$data = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue; |
|
3616
|
|
|
$cnpj = $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
|
3617
|
|
|
$mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue; |
|
3618
|
|
|
$serie = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue; |
|
3619
|
|
|
$numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue; |
|
3620
|
|
|
$data = substr($data, 2, 2) . "/20" . substr($data, 0, 2); |
|
3621
|
|
|
$cnpj = $this->formatField($cnpj, "##.###.###/####-##"); |
|
3622
|
|
|
$saida .= sprintf($formaNfRef, $serie, $numero, $cnpj, $data, $mod); |
|
3623
|
|
|
} |
|
3624
|
|
|
$refCTe = $nfRef->getElementsByTagName('refCTe'); |
|
3625
|
|
|
foreach ($refCTe as $chave_acessoRef) { |
|
3626
|
|
|
$chave_acesso = $chave_acessoRef->nodeValue; |
|
3627
|
|
|
$chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave); |
|
3628
|
|
|
$data = substr($chave_acesso, 4, 2) . "/20" . substr($chave_acesso, 2, 2); |
|
3629
|
|
|
$cnpj = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##"); |
|
3630
|
|
|
$serie = substr($chave_acesso, 22, 3); |
|
3631
|
|
|
$numero = substr($chave_acesso, 25, 9); |
|
3632
|
|
|
$saida .= sprintf($formaCTeRef, $serie, $numero, $cnpj, $data, $chave_acessoF); |
|
3633
|
|
|
} |
|
3634
|
|
|
$refECF = $nfRef->getElementsByTagName('refECF'); |
|
3635
|
|
|
foreach ($refECF as $umaRefNFe) { |
|
3636
|
|
|
$mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue; |
|
3637
|
|
|
$nECF = $umaRefNFe->getElementsByTagName('nECF')->item(0)->nodeValue; |
|
3638
|
|
|
$nCOO = $umaRefNFe->getElementsByTagName('nCOO')->item(0)->nodeValue; |
|
3639
|
|
|
$saida .= sprintf($formaECFRef, $mod, $nECF, $nCOO); |
|
3640
|
|
|
} |
|
3641
|
|
|
$refNFP = $nfRef->getElementsByTagName('refNFP'); |
|
3642
|
|
|
foreach ($refNFP as $umaRefNFe) { |
|
3643
|
|
|
$data = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue; |
|
3644
|
|
|
$cnpj = ! empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ? |
|
3645
|
|
|
$umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue : |
|
3646
|
|
|
''; |
|
3647
|
|
|
$cpf = ! empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ? |
|
3648
|
|
|
$umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : ''; |
|
3649
|
|
|
$mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue; |
|
3650
|
|
|
$serie = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue; |
|
3651
|
|
|
$numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue; |
|
3652
|
|
|
$ie = $umaRefNFe->getElementsByTagName('IE')->item(0)->nodeValue; |
|
3653
|
|
|
$data = substr($data, 2, 2) . "/20" . substr($data, 0, 2); |
|
3654
|
|
|
if ($cnpj == '') { |
|
3655
|
|
|
$cpf_cnpj = $this->formatField($cpf, "###.###.###-##"); |
|
3656
|
|
|
} else { |
|
3657
|
|
|
$cpf_cnpj = $this->formatField($cnpj, "##.###.###/####-##"); |
|
3658
|
|
|
} |
|
3659
|
|
|
$saida .= sprintf($formaNfpRef, $serie, $numero, $cpf_cnpj, $data, $mod, $ie); |
|
3660
|
|
|
} |
|
3661
|
|
|
} |
|
3662
|
|
|
|
|
3663
|
|
|
return $saida; |
|
3664
|
|
|
} |
|
3665
|
|
|
|
|
3666
|
|
|
private function loadDoc($xml) { |
|
3667
|
|
|
$this->xml = $xml; |
|
3668
|
|
|
if (! empty($xml)) { |
|
3669
|
|
|
$this->dom = new Dom(); |
|
3670
|
|
|
$this->dom->loadXML($this->xml); |
|
3671
|
|
|
if (empty($this->dom->getElementsByTagName("infNFe")->item(0))) { |
|
3672
|
|
|
throw new \Exception('Isso não é um NFe.'); |
|
3673
|
|
|
} |
|
3674
|
|
|
$this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0); |
|
3675
|
|
|
$this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0); |
|
3676
|
|
|
$this->ide = $this->dom->getElementsByTagName("ide")->item(0); |
|
3677
|
|
|
if ($this->getTagValue($this->ide, "mod") != '55') { |
|
3678
|
|
|
throw new \Exception("O xml deve ser NF-e modelo 55."); |
|
3679
|
|
|
} |
|
3680
|
|
|
$this->entrega = $this->dom->getElementsByTagName("entrega")->item(0); |
|
3681
|
|
|
$this->retirada = $this->dom->getElementsByTagName("retirada")->item(0); |
|
3682
|
|
|
$this->emit = $this->dom->getElementsByTagName("emit")->item(0); |
|
3683
|
|
|
$this->dest = $this->dom->getElementsByTagName("dest")->item(0); |
|
3684
|
|
|
$this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0); |
|
3685
|
|
|
$this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0); |
|
3686
|
|
|
$this->det = $this->dom->getElementsByTagName("det"); |
|
|
|
|
|
|
3687
|
|
|
$this->cobr = $this->dom->getElementsByTagName("cobr")->item(0); |
|
3688
|
|
|
$this->dup = $this->dom->getElementsByTagName('dup'); |
|
|
|
|
|
|
3689
|
|
|
$this->ICMSTot = $this->dom->getElementsByTagName("ICMSTot")->item(0); |
|
3690
|
|
|
$this->ISSQNtot = $this->dom->getElementsByTagName("ISSQNtot")->item(0); |
|
3691
|
|
|
$this->transp = $this->dom->getElementsByTagName("transp")->item(0); |
|
3692
|
|
|
$this->transporta = $this->dom->getElementsByTagName("transporta")->item(0); |
|
3693
|
|
|
$this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0); |
|
3694
|
|
|
$this->detPag = $this->dom->getElementsByTagName("detPag"); |
|
3695
|
|
|
$this->reboque = $this->dom->getElementsByTagName("reboque")->item(0); |
|
3696
|
|
|
$this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0); |
|
3697
|
|
|
$this->compra = $this->dom->getElementsByTagName("compra")->item(0); |
|
3698
|
|
|
$this->tpEmis = $this->getTagValue($this->ide, "tpEmis"); |
|
|
|
|
|
|
3699
|
|
|
$this->tpImp = $this->getTagValue($this->ide, "tpImp"); |
|
|
|
|
|
|
3700
|
|
|
$this->infProt = $this->dom->getElementsByTagName("infProt")->item(0); |
|
3701
|
|
|
} |
|
3702
|
|
|
} |
|
3703
|
|
|
|
|
3704
|
|
|
/** |
|
3705
|
|
|
* @param $item |
|
3706
|
|
|
* |
|
3707
|
|
|
* @return float |
|
3708
|
|
|
*/ |
|
3709
|
|
|
protected function calculeHeight($item) { |
|
3710
|
|
|
if ($this->orientacao == 'P') { |
|
3711
|
|
|
$w = $this->wPrint; |
|
3712
|
|
|
} else { |
|
3713
|
|
|
$w = $this->wPrint - $this->wCanhoto; |
|
3714
|
|
|
} |
|
3715
|
|
|
$w2 = round($w * 0.25, 0); |
|
3716
|
|
|
$aFont = ['font' => $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
3717
|
|
|
$textoProduto = $this->descricaoProduto($item); |
|
3718
|
|
|
$numlinhas = $this->pdf->getNumLines($textoProduto, $w2, $aFont); |
|
3719
|
|
|
|
|
3720
|
|
|
return round(($numlinhas * $this->pdf->fontSize) + ($numlinhas * 0.5), 2); |
|
3721
|
|
|
} |
|
3722
|
|
|
} |
|
3723
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.