These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace NFePHP\MDFe; |
||
4 | |||
5 | /** |
||
6 | * Classe a construção do xml do Manifesto Eletrônico de Documentos Fiscais (MDF-e) |
||
7 | * NOTA: Esta classe foi construida conforme estabelecido no |
||
8 | * Manual de Orientação do Contribuinte |
||
9 | * Padrões Técnicos de Comunicação do Manifesto Eletrônico de Documentos Fiscais |
||
10 | * versão 1.00 de Junho de 2012 |
||
11 | * |
||
12 | * @category Library |
||
13 | * @package nfephp-org/sped-mdfe |
||
14 | * @name Make.php |
||
15 | * @copyright 2009-2016 NFePHP |
||
16 | * @license http://www.gnu.org/licenses/lesser.html LGPL v3 |
||
17 | * @link http://github.com/nfephp-org/sped-mdfe for the canonical source repository |
||
18 | * @author Roberto L. Machado <linux.rlm at gmail dot com> |
||
19 | */ |
||
20 | |||
21 | use NFePHP\Common\DateTime\DateTime; |
||
22 | use NFePHP\Common\Base\BaseMake; |
||
23 | use \DOMDocument; |
||
24 | use \DOMElement; |
||
25 | |||
26 | class Make extends BaseMake |
||
27 | { |
||
28 | /** |
||
29 | * versao |
||
30 | * numero da versão do xml da MDFe |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | public $versao = '1.00'; |
||
35 | /** |
||
36 | * mod |
||
37 | * modelo da MDFe 58 |
||
38 | * |
||
39 | * @var integer |
||
40 | */ |
||
41 | public $mod = '58'; |
||
42 | /** |
||
43 | * chave da MDFe |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | public $chMDFe = ''; |
||
48 | |||
49 | //propriedades privadas utilizadas internamente pela classe |
||
50 | private $MDFe = ''; //DOMNode |
||
51 | private $infMDFe = ''; //DOMNode |
||
52 | private $ide = ''; //DOMNode |
||
53 | private $emit = ''; //DOMNode |
||
54 | private $enderEmit = ''; //DOMNode |
||
55 | private $infModal = ''; //DOMNode |
||
56 | private $tot = ''; //DOMNode |
||
57 | private $infAdic = ''; //DOMNode |
||
58 | private $rodo = ''; //DOMNode |
||
59 | private $veicTracao = ''; //DOMNode |
||
60 | private $aereo = ''; //DOMNode |
||
61 | private $trem = ''; //DOMNode |
||
62 | private $aqua = ''; //DOMNode |
||
63 | |||
64 | // Arrays |
||
65 | private $aInfMunCarrega = array(); //array de DOMNode |
||
66 | private $aInfPercurso = array(); //array de DOMNode |
||
67 | private $aInfMunDescarga = array(); //array de DOMNode |
||
68 | private $aInfCTe = array(); //array de DOMNode |
||
69 | private $aInfNFe = array(); //array de DOMNode |
||
70 | private $aInfMDFe = array(); //array de DOMNode |
||
71 | private $aLacres = array(); //array de DOMNode |
||
72 | private $aCondutor = array(); //array de DOMNode |
||
73 | private $aReboque = array(); //array de DOMNode |
||
74 | private $aDisp = array(); //array de DOMNode |
||
75 | private $aVag = array(); //array de DOMNode |
||
76 | private $aInfTermCarreg = array(); //array de DOMNode |
||
77 | private $aInfTermDescarreg = array(); //array de DOMNode |
||
78 | private $aInfEmbComb = array(); //array de DOMNode |
||
79 | private $aCountDoc = array(); //contador de documentos fiscais |
||
80 | |||
81 | /** |
||
82 | * |
||
83 | * @return boolean |
||
84 | */ |
||
85 | public function montaMDFe() |
||
86 | { |
||
87 | if (count($this->erros) > 0) { |
||
88 | return false; |
||
89 | } |
||
90 | //cria a tag raiz da MDFe |
||
91 | $this->zTagMDFe(); |
||
92 | //monta a tag ide com as tags adicionais |
||
93 | $this->zTagIde(); |
||
94 | //tag ide [4] |
||
95 | $this->dom->appChild($this->infMDFe, $this->ide, 'Falta tag "infMDFe"'); |
||
96 | //tag enderemit [30] |
||
97 | $this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "emit"'); |
||
98 | //tag emit [25] |
||
99 | $this->dom->appChild($this->infMDFe, $this->emit, 'Falta tag "infMDFe"'); |
||
100 | //tag infModal [41] |
||
101 | $this->zTagRodo(); |
||
102 | $this->zTagAereo(); |
||
103 | $this->zTagFerrov(); |
||
104 | $this->zTagAqua(); |
||
105 | $this->dom->appChild($this->infMDFe, $this->infModal, 'Falta tag "infMDFe"'); |
||
106 | //tag indDoc [44] |
||
107 | $this->zTagInfDoc(); |
||
108 | //tag tot [68] |
||
109 | $this->dom->appChild($this->infMDFe, $this->tot, 'Falta tag "infMDFe"'); |
||
110 | //tag lacres [76] |
||
111 | $this->zTagLacres(); |
||
112 | //tag infAdic [78] |
||
113 | $this->dom->appChild($this->infMDFe, $this->infAdic, 'Falta tag "infMDFe"'); |
||
114 | //[1] tag infMDFe (1 A01) |
||
115 | $this->dom->appChild($this->MDFe, $this->infMDFe, 'Falta tag "MDFe"'); |
||
116 | //[0] tag MDFe |
||
117 | $this->dom->appChild($this->dom, $this->MDFe, 'Falta DOMDocument'); |
||
118 | // testa da chave |
||
119 | $this->zTestaChaveXML($this->dom); |
||
120 | //convert DOMDocument para string |
||
121 | $this->xml = $this->dom->saveXML(); |
||
122 | return true; |
||
123 | } |
||
124 | |||
125 | |||
126 | /** |
||
127 | * taginfMDFe |
||
128 | * Informações da MDFe 1 pai MDFe |
||
129 | * tag MDFe/infMDFe |
||
130 | * |
||
131 | * @param string $chave |
||
132 | * @param string $versao |
||
133 | * @return DOMElement |
||
134 | */ |
||
135 | public function taginfMDFe($chave = '', $versao = '') |
||
136 | { |
||
137 | $this->infMDFe = $this->dom->createElement("infMDFe"); |
||
138 | $this->infMDFe->setAttribute("Id", 'MDFe'.$chave); |
||
139 | $this->infMDFe->setAttribute("versao", $versao); |
||
140 | $this->versao = $versao; |
||
141 | $this->chMDFe = $chave; |
||
142 | return $this->infMDFe; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * tgaide |
||
147 | * Informações de identificação da MDFe 4 pai 1 |
||
148 | * tag MDFe/infMDFe/ide |
||
149 | * |
||
150 | * @param string $cUF |
||
151 | * @param string $tbAmb |
||
152 | * @param string $tpEmit |
||
153 | * @param string $mod |
||
154 | * @param string $serie |
||
155 | * @param string $nMDF |
||
156 | * @param string $cMDF |
||
157 | * @param string $cDV |
||
158 | * @param string $modal |
||
159 | * @param string $dhEmi |
||
160 | * @param string $tpEmis |
||
161 | * @param string $procEmi |
||
162 | * @param string $verProc |
||
163 | * @param string $ufIni |
||
164 | * @param string $ufFim |
||
165 | * @return DOMElement |
||
166 | */ |
||
167 | public function tagide( |
||
168 | $cUF = '', |
||
169 | $tpAmb = '', |
||
170 | $tpEmit = '', |
||
171 | $mod = '58', |
||
172 | $serie = '', |
||
173 | $nMDF = '', |
||
174 | $cMDF = '', |
||
175 | $cDV = '', |
||
176 | $modal = '', |
||
177 | $dhEmi = '', |
||
178 | $tpEmis = '', |
||
179 | $procEmi = '', |
||
180 | $verProc = '', |
||
181 | $ufIni = '', |
||
182 | $ufFim = '' |
||
183 | ) { |
||
184 | $this->tpAmb = $tpAmb; |
||
185 | if ($dhEmi == '') { |
||
186 | $dhEmi = DateTime::convertTimestampToSefazTime(); |
||
187 | } |
||
188 | $identificador = '[4] <ide> - '; |
||
189 | $ide = $this->dom->createElement("ide"); |
||
190 | $this->dom->addChild( |
||
191 | $ide, |
||
192 | "cUF", |
||
193 | $cUF, |
||
194 | true, |
||
195 | $identificador . "Código da UF do emitente do Documento Fiscal" |
||
196 | ); |
||
197 | $this->dom->addChild( |
||
198 | $ide, |
||
199 | "tpAmb", |
||
200 | $tpAmb, |
||
201 | true, |
||
202 | $identificador . "Identificação do Ambiente" |
||
203 | ); |
||
204 | $this->dom->addChild( |
||
205 | $ide, |
||
206 | "tpEmit", |
||
207 | $tpEmit, |
||
208 | true, |
||
209 | $identificador . "Indicador da tipo de emitente" |
||
210 | ); |
||
211 | $this->dom->addChild( |
||
212 | $ide, |
||
213 | "mod", |
||
214 | $mod, |
||
215 | true, |
||
216 | $identificador . "Código do Modelo do Documento Fiscal" |
||
217 | ); |
||
218 | $this->dom->addChild( |
||
219 | $ide, |
||
220 | "serie", |
||
221 | $serie, |
||
222 | true, |
||
223 | $identificador . "Série do Documento Fiscal" |
||
224 | ); |
||
225 | $this->dom->addChild( |
||
226 | $ide, |
||
227 | "nMDF", |
||
228 | $nMDF, |
||
229 | true, |
||
230 | $identificador . "Número do Documento Fiscal" |
||
231 | ); |
||
232 | $this->dom->addChild( |
||
233 | $ide, |
||
234 | "cMDF", |
||
235 | $cMDF, |
||
236 | true, |
||
237 | $identificador . "Código do numérico do MDF" |
||
238 | ); |
||
239 | $this->dom->addChild( |
||
240 | $ide, |
||
241 | "cDV", |
||
242 | $cDV, |
||
243 | true, |
||
244 | $identificador . "Dígito Verificador da Chave de Acesso da NF-e" |
||
245 | ); |
||
246 | $this->dom->addChild( |
||
247 | $ide, |
||
248 | "modal", |
||
249 | $modal, |
||
250 | true, |
||
251 | $identificador . "Modalidade de transporte" |
||
252 | ); |
||
253 | $this->dom->addChild( |
||
254 | $ide, |
||
255 | "dhEmi", |
||
256 | $dhEmi, |
||
257 | true, |
||
258 | $identificador . "Data e hora de emissão do Documento Fiscal" |
||
259 | ); |
||
260 | $this->dom->addChild( |
||
261 | $ide, |
||
262 | "tpEmis", |
||
263 | $tpEmis, |
||
264 | true, |
||
265 | $identificador . "Tipo de Emissão do Documento Fiscal" |
||
266 | ); |
||
267 | $this->dom->addChild( |
||
268 | $ide, |
||
269 | "procEmi", |
||
270 | $procEmi, |
||
271 | true, |
||
272 | $identificador . "Processo de emissão" |
||
273 | ); |
||
274 | $this->dom->addChild( |
||
275 | $ide, |
||
276 | "verProc", |
||
277 | $verProc, |
||
278 | true, |
||
279 | $identificador . "Versão do Processo de emissão" |
||
280 | ); |
||
281 | $this->dom->addChild( |
||
282 | $ide, |
||
283 | "UFIni", |
||
284 | $ufIni, |
||
285 | true, |
||
286 | $identificador . "Sigla da UF do Carregamento" |
||
287 | ); |
||
288 | $this->dom->addChild( |
||
289 | $ide, |
||
290 | "UFFim", |
||
291 | $ufFim, |
||
292 | true, |
||
293 | $identificador . "Sigla da UF do Descarregamento" |
||
294 | ); |
||
295 | $this->mod = $mod; |
||
296 | $this->ide = $ide; |
||
297 | return $ide; |
||
298 | } |
||
299 | |||
300 | /** |
||
301 | * tagInfMunCarrega |
||
302 | * |
||
303 | * tag MDFe/infMDFe/ide/infMunCarrega |
||
304 | * |
||
305 | * @param string $cMunCarrega |
||
306 | * @param string $xMunCarrega |
||
307 | * @return DOMElement |
||
308 | */ |
||
309 | public function tagInfMunCarrega( |
||
310 | $cMunCarrega = '', |
||
311 | $xMunCarrega = '' |
||
312 | ) { |
||
313 | $infMunCarrega = $this->dom->createElement("infMunCarrega"); |
||
314 | $this->dom->addChild( |
||
315 | $infMunCarrega, |
||
316 | "cMunCarrega", |
||
317 | $cMunCarrega, |
||
318 | true, |
||
319 | "Código do Município de Carregamento" |
||
320 | ); |
||
321 | $this->dom->addChild( |
||
322 | $infMunCarrega, |
||
323 | "xMunCarrega", |
||
324 | $xMunCarrega, |
||
325 | true, |
||
326 | "Nome do Município de Carregamento" |
||
327 | ); |
||
328 | $this->aInfMunCarrega[] = $infMunCarrega; |
||
329 | return $infMunCarrega; |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * tagInfPercurso |
||
334 | * |
||
335 | * tag MDFe/infMDFe/ide/infPercurso |
||
336 | * |
||
337 | * @param string $ufPer |
||
338 | * @return DOMElement |
||
339 | */ |
||
340 | public function tagInfPercurso($ufPer = '') |
||
341 | { |
||
342 | $infPercurso = $this->dom->createElement("infPercurso"); |
||
343 | $this->dom->addChild( |
||
344 | $infPercurso, |
||
345 | "UFPer", |
||
346 | $ufPer, |
||
347 | true, |
||
348 | "Sigla das Unidades da Federação do percurso" |
||
349 | ); |
||
350 | $this->aInfPercurso[] = $infPercurso; |
||
351 | return $infPercurso; |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * tagemit |
||
356 | * Identificação do emitente da MDFe [25] pai 1 |
||
357 | * tag MDFe/infMDFe/emit |
||
358 | * |
||
359 | * @param string $cnpj |
||
360 | * @param string $cpf |
||
361 | * @param string $xNome |
||
362 | * @param string $xFant |
||
363 | * @param string $numIE |
||
364 | * @param string $numIEST |
||
365 | * @param string $numIM |
||
366 | * @param string $cnae |
||
367 | * @param string $crt |
||
368 | * @return DOMElement |
||
369 | */ |
||
370 | public function tagemit( |
||
371 | $cnpj = '', |
||
372 | $numIE = '', |
||
373 | $xNome = '', |
||
374 | $xFant = '' |
||
375 | ) { |
||
376 | $identificador = '[25] <emit> - '; |
||
377 | $this->emit = $this->dom->createElement("emit"); |
||
378 | $this->dom->addChild($this->emit, "CNPJ", $cnpj, true, $identificador . "CNPJ do emitente"); |
||
379 | $this->dom->addChild($this->emit, "IE", $numIE, true, $identificador . "Inscrição Estadual do emitente"); |
||
380 | $this->dom->addChild($this->emit, "xNome", $xNome, true, $identificador . "Razão Social ou Nome do emitente"); |
||
381 | $this->dom->addChild($this->emit, "xFant", $xFant, false, $identificador . "Nome fantasia do emitente"); |
||
382 | return $this->emit; |
||
383 | } |
||
384 | |||
385 | /** |
||
386 | * tagenderEmit |
||
387 | * Endereço do emitente [30] pai [25] |
||
388 | * tag MDFe/infMDFe/emit/endEmit |
||
389 | * |
||
390 | * @param string $xLgr |
||
391 | * @param string $nro |
||
392 | * @param string $xCpl |
||
393 | * @param string $xBairro |
||
394 | * @param string $cMun |
||
395 | * @param string $xMun |
||
396 | * @param string $cep |
||
397 | * @param string $siglaUF |
||
398 | * @param string $fone |
||
399 | * @param string $email |
||
400 | * @return DOMElement |
||
401 | */ |
||
402 | public function tagenderEmit( |
||
403 | $xLgr = '', |
||
404 | $nro = '', |
||
405 | $xCpl = '', |
||
406 | $xBairro = '', |
||
407 | $cMun = '', |
||
408 | $xMun = '', |
||
409 | $cep = '', |
||
410 | $siglaUF = '', |
||
411 | $fone = '', |
||
412 | $email = '' |
||
413 | ) { |
||
414 | $identificador = '[30] <enderEmit> - '; |
||
415 | $this->enderEmit = $this->dom->createElement("enderEmit"); |
||
416 | $this->dom->addChild( |
||
417 | $this->enderEmit, |
||
418 | "xLgr", |
||
419 | $xLgr, |
||
420 | true, |
||
421 | $identificador . "Logradouro do Endereço do emitente" |
||
422 | ); |
||
423 | $this->dom->addChild( |
||
424 | $this->enderEmit, |
||
425 | "nro", |
||
426 | $nro, |
||
427 | true, |
||
428 | $identificador . "Número do Endereço do emitente" |
||
429 | ); |
||
430 | $this->dom->addChild( |
||
431 | $this->enderEmit, |
||
432 | "xCpl", |
||
433 | $xCpl, |
||
434 | false, |
||
435 | $identificador . "Complemento do Endereço do emitente" |
||
436 | ); |
||
437 | $this->dom->addChild( |
||
438 | $this->enderEmit, |
||
439 | "xBairro", |
||
440 | $xBairro, |
||
441 | true, |
||
442 | $identificador . "Bairro do Endereço do emitente" |
||
443 | ); |
||
444 | $this->dom->addChild( |
||
445 | $this->enderEmit, |
||
446 | "cMun", |
||
447 | $cMun, |
||
448 | true, |
||
449 | $identificador . "Código do município do Endereço do emitente" |
||
450 | ); |
||
451 | $this->dom->addChild( |
||
452 | $this->enderEmit, |
||
453 | "xMun", |
||
454 | $xMun, |
||
455 | true, |
||
456 | $identificador . "Nome do município do Endereço do emitente" |
||
457 | ); |
||
458 | $this->dom->addChild( |
||
459 | $this->enderEmit, |
||
460 | "CEP", |
||
461 | $cep, |
||
462 | true, |
||
463 | $identificador . "Código do CEP do Endereço do emitente" |
||
464 | ); |
||
465 | $this->dom->addChild( |
||
466 | $this->enderEmit, |
||
467 | "UF", |
||
468 | $siglaUF, |
||
469 | true, |
||
470 | $identificador . "Sigla da UF do Endereço do emitente" |
||
471 | ); |
||
472 | $this->dom->addChild( |
||
473 | $this->enderEmit, |
||
474 | "fone", |
||
475 | $fone, |
||
476 | false, |
||
477 | $identificador . "Número de telefone do emitente" |
||
478 | ); |
||
479 | $this->dom->addChild( |
||
480 | $this->enderEmit, |
||
481 | "email", |
||
482 | $email, |
||
483 | false, |
||
484 | $identificador . "Endereço de email do emitente" |
||
485 | ); |
||
486 | return $this->enderEmit; |
||
487 | } |
||
488 | |||
489 | /** |
||
490 | * tagInfMunDescarga |
||
491 | * tag MDFe/infMDFe/infDoc/infMunDescarga |
||
492 | * |
||
493 | * @param integer $item |
||
494 | * @param string $cMunDescarga |
||
495 | * @param string $xMunDescarga |
||
496 | * @return DOMElement |
||
497 | */ |
||
498 | public function tagInfMunDescarga( |
||
499 | $nItem = 0, |
||
500 | $cMunDescarga = '', |
||
501 | $xMunDescarga = '' |
||
502 | ) { |
||
503 | $infMunDescarga = $this->dom->createElement("infMunDescarga"); |
||
504 | $this->dom->addChild( |
||
505 | $infMunDescarga, |
||
506 | "cMunDescarga", |
||
507 | $cMunDescarga, |
||
508 | true, |
||
509 | "Código do Município de Descarga" |
||
510 | ); |
||
511 | $this->dom->addChild( |
||
512 | $infMunDescarga, |
||
513 | "xMunDescarga", |
||
514 | $xMunDescarga, |
||
515 | true, |
||
516 | "Nome do Município de Descarga" |
||
517 | ); |
||
518 | $this->aInfMunDescarga[$nItem] = $infMunDescarga; |
||
519 | return $infMunDescarga; |
||
520 | } |
||
521 | |||
522 | /** |
||
523 | * tagInfCTe |
||
524 | * tag MDFe/infMDFe/infDoc/infMunDescarga/infCTe |
||
525 | * |
||
526 | * @param integer $nItem |
||
527 | * @param string $chCTe |
||
528 | * @param string $segCodBarra |
||
529 | * @return DOMElement |
||
530 | */ |
||
531 | View Code Duplication | public function tagInfCTe( |
|
532 | $nItem = 0, |
||
533 | $chCTe = '', |
||
534 | $segCodBarra = '' |
||
535 | ) { |
||
536 | $infCTe = $this->dom->createElement("infCTe"); |
||
537 | $this->dom->addChild( |
||
538 | $infCTe, |
||
539 | "chCTe", |
||
540 | $chCTe, |
||
541 | true, |
||
542 | "Chave de Acesso CTe" |
||
543 | ); |
||
544 | $this->dom->addChild( |
||
545 | $infCTe, |
||
546 | "SegCodBarra", |
||
547 | $segCodBarra, |
||
548 | false, |
||
549 | "Segundo código de barras do CTe" |
||
550 | ); |
||
551 | $this->aInfCTe[$nItem][] = $infCTe; |
||
552 | return $infCTe; |
||
553 | } |
||
554 | |||
555 | /** |
||
556 | * tagInfNFe |
||
557 | * tag MDFe/infMDFe/infDoc/infMunDescarga/infNFe |
||
558 | * |
||
559 | * @param integer $nItem |
||
560 | * @param string $chNFe |
||
561 | * @param string $segCodBarra |
||
562 | * @return DOMElement |
||
563 | */ |
||
564 | View Code Duplication | public function tagInfNFe( |
|
565 | $nItem = 0, |
||
566 | $chNFe = '', |
||
567 | $segCodBarra = '' |
||
568 | ) { |
||
569 | $infNFe = $this->dom->createElement("infNFe"); |
||
570 | $this->dom->addChild( |
||
571 | $infNFe, |
||
572 | "chNFe", |
||
573 | $chNFe, |
||
574 | true, |
||
575 | "Chave de Acesso da NFe" |
||
576 | ); |
||
577 | $this->dom->addChild( |
||
578 | $infNFe, |
||
579 | "SegCodBarra", |
||
580 | $segCodBarra, |
||
581 | false, |
||
582 | "Segundo código de barras da NFe" |
||
583 | ); |
||
584 | $this->aInfNFe[$nItem][] = $infNFe; |
||
585 | return $infNFe; |
||
586 | } |
||
587 | |||
588 | /** |
||
589 | * tagInfMDFeTransp |
||
590 | * tag MDFe/infMDFeTransp/infDoc/infMunDescarga/infMDFeTranspTransp |
||
591 | * |
||
592 | * @param integer $nItem |
||
593 | * @param string $chMDFe |
||
594 | * @return DOMElement |
||
595 | */ |
||
596 | public function tagInfMDFeTransp( |
||
597 | $nItem = 0, |
||
598 | $chMDFe = '' |
||
599 | ) { |
||
600 | $infMDFeTransp = $this->dom->createElement("infMDFeTransp"); |
||
601 | $this->dom->addChild( |
||
602 | $infMDFeTransp, |
||
603 | "chMDFe", |
||
604 | $chMDFe, |
||
605 | true, |
||
606 | "Chave de Acesso da MDFe" |
||
607 | ); |
||
608 | $this->aInfMDFe[$nItem][] = $infMDFeTransp; |
||
609 | return $infMDFeTransp; |
||
610 | } |
||
611 | |||
612 | /** |
||
613 | * tagTot |
||
614 | * tag MDFe/infMDFe/tot |
||
615 | * |
||
616 | * @param string $qCTe |
||
617 | * @param string $qNFe |
||
618 | * @param string $qMDFe |
||
619 | * @param string $vCarga |
||
620 | * @param string $cUnid |
||
621 | * @param string $qCarga |
||
622 | * @return DOMElement |
||
623 | */ |
||
624 | public function tagTot( |
||
625 | $qCTe = '', |
||
626 | $qNFe = '', |
||
627 | $qMDFe = '', |
||
628 | $vCarga = '', |
||
629 | $cUnid = '', |
||
630 | $qCarga = '' |
||
631 | ) { |
||
632 | $tot = $this->dom->createElement("tot"); |
||
633 | $this->dom->addChild( |
||
634 | $tot, |
||
635 | "qCTe", |
||
636 | $qCTe, |
||
637 | false, |
||
638 | "Quantidade total de CT-e relacionados no Manifesto" |
||
639 | ); |
||
640 | $this->dom->addChild( |
||
641 | $tot, |
||
642 | "qNFe", |
||
643 | $qNFe, |
||
644 | false, |
||
645 | "Quantidade total de NF-e relacionados no Manifesto" |
||
646 | ); |
||
647 | $this->dom->addChild( |
||
648 | $tot, |
||
649 | "qMDFe", |
||
650 | $qMDFe, |
||
651 | false, |
||
652 | "Quantidade total de MDF-e relacionados no Manifesto" |
||
653 | ); |
||
654 | $this->dom->addChild( |
||
655 | $tot, |
||
656 | "vCarga", |
||
657 | $vCarga, |
||
658 | true, |
||
659 | "Valor total da mercadoria/carga transportada" |
||
660 | ); |
||
661 | $this->dom->addChild( |
||
662 | $tot, |
||
663 | "cUnid", |
||
664 | $cUnid, |
||
665 | true, |
||
666 | "Código da unidade de medida do Peso Bruto da Carga / Mercadoria Transportada" |
||
667 | ); |
||
668 | $this->dom->addChild( |
||
669 | $tot, |
||
670 | "qCarga", |
||
671 | $qCarga, |
||
672 | true, |
||
673 | "Peso Bruto Total da Carga / Mercadoria Transportada" |
||
674 | ); |
||
675 | $this->tot = $tot; |
||
676 | return $tot; |
||
677 | } |
||
678 | |||
679 | /** |
||
680 | * tagLacres |
||
681 | * tag MDFe/infMDFe/lacres |
||
682 | * |
||
683 | * @param string $nLacre |
||
684 | * @return DOMElement |
||
685 | */ |
||
686 | public function tagLacres( |
||
687 | $nLacre = '' |
||
688 | ) { |
||
689 | $lacres = $this->dom->createElement("lacres"); |
||
690 | $this->dom->addChild( |
||
691 | $lacres, |
||
692 | "nLacre", |
||
693 | $nLacre, |
||
694 | false, |
||
695 | "Número do lacre" |
||
696 | ); |
||
697 | $this->aLacres[] = $lacres; |
||
698 | return $lacres; |
||
699 | } |
||
700 | |||
701 | /** |
||
702 | * taginfAdic |
||
703 | * Grupo de Informações Adicionais Z01 pai A01 |
||
704 | * tag MDFe/infMDFe/infAdic (opcional) |
||
705 | * |
||
706 | * @param string $infAdFisco |
||
707 | * @param string $infCpl |
||
708 | * @return DOMElement |
||
709 | */ |
||
710 | public function taginfAdic( |
||
711 | $infAdFisco = '', |
||
712 | $infCpl = '' |
||
713 | ) { |
||
714 | $infAdic = $this->dom->createElement("infAdic"); |
||
715 | $this->dom->addChild( |
||
716 | $infAdic, |
||
717 | "infAdFisco", |
||
718 | $infAdFisco, |
||
719 | false, |
||
720 | "Informações Adicionais de Interesse do Fisco" |
||
721 | ); |
||
722 | $this->dom->addChild( |
||
723 | $infAdic, |
||
724 | "infCpl", |
||
725 | $infCpl, |
||
726 | false, |
||
727 | "Informações Complementares de interesse do Contribuinte" |
||
728 | ); |
||
729 | $this->infAdic = $infAdic; |
||
730 | return $infAdic; |
||
731 | } |
||
732 | |||
733 | /** |
||
734 | * tagInfModal |
||
735 | * tag MDFe/infMDFe/infModal |
||
736 | * |
||
737 | * @param type $versaoModal |
||
738 | * @return DOMElement |
||
739 | */ |
||
740 | public function tagInfModal($versaoModal = '') |
||
741 | { |
||
742 | $infModal = $this->dom->createElement("infModal"); |
||
743 | $infModal->setAttribute("versaoModal", $versaoModal); |
||
744 | $this->infModal = $infModal; |
||
745 | return $infModal; |
||
746 | } |
||
747 | |||
748 | /** |
||
749 | * tagAereo |
||
750 | * tag MDFe/infMDFe/infModal/aereo |
||
751 | * |
||
752 | * @param string $nac |
||
753 | * @param string $matr |
||
754 | * @param string $nVoo |
||
755 | * @param string $cAerEmb |
||
756 | * @param string $cAerDes |
||
757 | * @param string $dVoo |
||
758 | * @return DOMElement |
||
759 | */ |
||
760 | public function tagAereo( |
||
761 | $nac = '', |
||
762 | $matr = '', |
||
763 | $nVoo = '', |
||
764 | $cAerEmb = '', |
||
765 | $cAerDes = '', |
||
766 | $dVoo = '' |
||
767 | ) { |
||
768 | $aereo = $this->dom->createElement("aereo"); |
||
769 | $this->dom->addChild( |
||
770 | $aereo, |
||
771 | "nac", |
||
772 | $nac, |
||
773 | true, |
||
774 | "Marca da Nacionalidade da aeronave" |
||
775 | ); |
||
776 | $this->dom->addChild( |
||
777 | $aereo, |
||
778 | "matr", |
||
779 | $matr, |
||
780 | true, |
||
781 | "Marca de Matrícula da aeronave" |
||
782 | ); |
||
783 | $this->dom->addChild( |
||
784 | $aereo, |
||
785 | "nVoo", |
||
786 | $nVoo, |
||
787 | true, |
||
788 | "Número do Vôo" |
||
789 | ); |
||
790 | $this->dom->addChild( |
||
791 | $aereo, |
||
792 | "cAerEmb", |
||
793 | $cAerEmb, |
||
794 | true, |
||
795 | "Aeródromo de Embarque - Código IATA" |
||
796 | ); |
||
797 | $this->dom->addChild( |
||
798 | $aereo, |
||
799 | "cAerDes", |
||
800 | $cAerDes, |
||
801 | true, |
||
802 | "Aeródromo de Destino - Código IATA" |
||
803 | ); |
||
804 | $this->dom->addChild( |
||
805 | $aereo, |
||
806 | "dVoo", |
||
807 | $dVoo, |
||
808 | true, |
||
809 | "Data do Vôo" |
||
810 | ); |
||
811 | $this->aereo = $aereo; |
||
812 | return $aereo; |
||
813 | } |
||
814 | |||
815 | /** |
||
816 | * tagTrem |
||
817 | * tag MDFe/infMDFe/infModal/ferrov/trem |
||
818 | * |
||
819 | * @param string $xPref |
||
820 | * @param string $dhTrem |
||
821 | * @param string $xOri |
||
822 | * @param string $xDest |
||
823 | * @param string $qVag |
||
824 | * @return DOMElement |
||
825 | */ |
||
826 | public function tagTrem( |
||
827 | $xPref = '', |
||
828 | $dhTrem = '', |
||
829 | $xOri = '', |
||
830 | $xDest = '', |
||
831 | $qVag = '' |
||
832 | ) { |
||
833 | $trem = $this->dom->createElement("trem"); |
||
834 | $this->dom->addChild( |
||
835 | $trem, |
||
836 | "xPref", |
||
837 | $xPref, |
||
838 | true, |
||
839 | "Prefixo do Trem" |
||
840 | ); |
||
841 | $this->dom->addChild( |
||
842 | $trem, |
||
843 | "dhTrem", |
||
844 | $dhTrem, |
||
845 | false, |
||
846 | "Data e hora de liberação do trem na origem" |
||
847 | ); |
||
848 | $this->dom->addChild( |
||
849 | $trem, |
||
850 | "xOri", |
||
851 | $xOri, |
||
852 | true, |
||
853 | "Origem do Trem" |
||
854 | ); |
||
855 | $this->dom->addChild( |
||
856 | $trem, |
||
857 | "xDest", |
||
858 | $xDest, |
||
859 | true, |
||
860 | "Destino do Trem" |
||
861 | ); |
||
862 | $this->dom->addChild( |
||
863 | $trem, |
||
864 | "qVag", |
||
865 | $qVag, |
||
866 | true, |
||
867 | "Quantidade de vagões" |
||
868 | ); |
||
869 | $this->trem = $trem; |
||
870 | return $trem; |
||
871 | } |
||
872 | |||
873 | /** |
||
874 | * tagVag |
||
875 | * tag MDFe/infMDFe/infModal/ferrov/trem/vag |
||
876 | * |
||
877 | * @param string $serie |
||
878 | * @param string $nVag |
||
879 | * @param string $nSeq |
||
880 | * @param string $tUtil |
||
881 | * @return DOMElement |
||
882 | */ |
||
883 | public function tagVag( |
||
884 | $serie = '', |
||
885 | $nVag = '', |
||
886 | $nSeq = '', |
||
887 | $tonUtil = '' |
||
888 | ) { |
||
889 | $vag = $this->dom->createElement("vag"); |
||
890 | $this->dom->addChild( |
||
891 | $vag, |
||
892 | "serie", |
||
893 | $serie, |
||
894 | true, |
||
895 | "Série de Identificação do vagão" |
||
896 | ); |
||
897 | $this->dom->addChild( |
||
898 | $vag, |
||
899 | "nVag", |
||
900 | $nVag, |
||
901 | true, |
||
902 | "Número de Identificação do vagão" |
||
903 | ); |
||
904 | $this->dom->addChild( |
||
905 | $vag, |
||
906 | "nSeq", |
||
907 | $nSeq, |
||
908 | false, |
||
909 | "Sequência do vagão na composição" |
||
910 | ); |
||
911 | $this->dom->addChild( |
||
912 | $vag, |
||
913 | "TU", |
||
914 | $tonUtil, |
||
915 | true, |
||
916 | "Tonelada Útil" |
||
917 | ); |
||
918 | $this->aVag[] = $vag; |
||
919 | return $vag; |
||
920 | } |
||
921 | |||
922 | /** |
||
923 | * tagAqua |
||
924 | * tag MDFe/infMDFe/infModal/Aqua |
||
925 | * |
||
926 | * @param string $cnpjAgeNav |
||
927 | * @param string $tpEmb |
||
928 | * @param string $cEmbar |
||
929 | * @param string $nViagem |
||
930 | * @param string $cPrtEmb |
||
931 | * @param string $cPrtDest |
||
932 | * @return DOMElement |
||
933 | */ |
||
934 | public function tagAqua( |
||
935 | $cnpjAgeNav = '', |
||
936 | $tpEmb = '', |
||
937 | $cEmbar = '', |
||
938 | $nViagem = '', |
||
939 | $cPrtEmb = '', |
||
940 | $cPrtDest = '' |
||
941 | ) { |
||
942 | $aqua = $this->dom->createElement("Aqua"); |
||
943 | $this->dom->addChild( |
||
944 | $aqua, |
||
945 | "CNPJAgeNav", |
||
946 | $cnpjAgeNav, |
||
947 | true, |
||
948 | "CNPJ da Agência de Navegação" |
||
949 | ); |
||
950 | $this->dom->addChild( |
||
951 | $aqua, |
||
952 | "tpEmb", |
||
953 | $tpEmb, |
||
954 | true, |
||
955 | "Código do tipo de embarcação" |
||
956 | ); |
||
957 | $this->dom->addChild( |
||
958 | $aqua, |
||
959 | "cEmbar", |
||
960 | $cEmbar, |
||
961 | true, |
||
962 | "Código da Embarcação" |
||
963 | ); |
||
964 | $this->dom->addChild( |
||
965 | $aqua, |
||
966 | "nViagem", |
||
967 | $nViagem, |
||
968 | true, |
||
969 | "Número da Viagem" |
||
970 | ); |
||
971 | $this->dom->addChild( |
||
972 | $aqua, |
||
973 | "cPrtEmb", |
||
974 | $cPrtEmb, |
||
975 | true, |
||
976 | "Código do Porto de Embarque" |
||
977 | ); |
||
978 | $this->dom->addChild( |
||
979 | $aqua, |
||
980 | "cPrtDest", |
||
981 | $cPrtDest, |
||
982 | true, |
||
983 | "Código do Porto de Destino" |
||
984 | ); |
||
985 | $this->aqua = $aqua; |
||
986 | return $aqua; |
||
987 | } |
||
988 | |||
989 | /** |
||
990 | * tagInfTermCarreg |
||
991 | * tag MDFe/infMDFe/infModal/Aqua/infTermCarreg |
||
992 | * |
||
993 | * @param string $cTermCarreg |
||
994 | * @return DOMElement |
||
995 | */ |
||
996 | public function tagInfTermCarreg( |
||
997 | $cTermCarreg = '' |
||
998 | ) { |
||
999 | $infTermCarreg = $this->dom->createElement("infTermCarreg"); |
||
1000 | $this->dom->addChild( |
||
1001 | $infTermCarreg, |
||
1002 | "cTermCarreg", |
||
1003 | $cTermCarreg, |
||
1004 | true, |
||
1005 | "Código do Terminal de Carregamento" |
||
1006 | ); |
||
1007 | $this->aInfTermCarreg[] = $infTermCarreg; |
||
1008 | return $infTermCarreg; |
||
1009 | } |
||
1010 | |||
1011 | /** |
||
1012 | * tagInfTermDescarreg |
||
1013 | * tag MDFe/infMDFe/infModal/Aqua/infTermDescarreg |
||
1014 | * |
||
1015 | * @param string $cTermDescarreg |
||
1016 | * @return DOMElement |
||
1017 | */ |
||
1018 | public function tagInfTermDescarreg( |
||
1019 | $cTermDescarreg = '' |
||
1020 | ) { |
||
1021 | $infTermDescarreg = $this->dom->createElement("infTermDescarreg"); |
||
1022 | $this->dom->addChild( |
||
1023 | $infTermDescarreg, |
||
1024 | "cTermCarreg", |
||
1025 | $cTermDescarreg, |
||
1026 | true, |
||
1027 | "Código do Terminal de Descarregamento" |
||
1028 | ); |
||
1029 | $this->aInfTermDescarreg[] = $infTermDescarreg; |
||
1030 | return $infTermDescarreg; |
||
1031 | } |
||
1032 | |||
1033 | /** |
||
1034 | * tagInfEmbComb |
||
1035 | * tag MDFe/infMDFe/infModal/Aqua/infEmbComb |
||
1036 | * |
||
1037 | * @param string $$cEmbComb |
||
1038 | * @return DOMElement |
||
1039 | */ |
||
1040 | public function tagInfEmbComb( |
||
1041 | $cEmbComb = '' |
||
1042 | ) { |
||
1043 | $infEmbComb = $this->dom->createElement("infEmbComb"); |
||
1044 | $this->dom->addChild( |
||
1045 | $infEmbComb, |
||
1046 | "cEmbComb", |
||
1047 | $cEmbComb, |
||
1048 | true, |
||
1049 | "Código da embarcação do comboio" |
||
1050 | ); |
||
1051 | $this->aInfEmbComb[] = $infEmbComb; |
||
1052 | return $infEmbComb; |
||
1053 | } |
||
1054 | |||
1055 | /** |
||
1056 | * tagRodo |
||
1057 | * tag MDFe/infMDFe/infModal/rodo |
||
1058 | * |
||
1059 | * @param string $rntrc |
||
1060 | * @param string $ciot |
||
1061 | * @return DOMElement |
||
1062 | */ |
||
1063 | public function tagRodo( |
||
1064 | $rntrc = '', |
||
1065 | $ciot = '' |
||
1066 | ) { |
||
1067 | $rodo = $this->dom->createElement("rodo"); |
||
1068 | $this->dom->addChild( |
||
1069 | $rodo, |
||
1070 | "RNTRC", |
||
1071 | $rntrc, |
||
1072 | false, |
||
1073 | "Registro Nacional de Transportadores Rodoviários de Carga" |
||
1074 | ); |
||
1075 | $this->dom->addChild( |
||
1076 | $rodo, |
||
1077 | "CIOT", |
||
1078 | $ciot, |
||
1079 | false, |
||
1080 | "Código Identificador da Operação de Transporte" |
||
1081 | ); |
||
1082 | $this->rodo = $rodo; |
||
1083 | return $rodo; |
||
1084 | } |
||
1085 | |||
1086 | /** |
||
1087 | * tagVeicTracao |
||
1088 | * tag MDFe/infMDFe/infModal/rodo/veicTracao |
||
1089 | * |
||
1090 | * @param string $cInt |
||
1091 | * @param string $placa |
||
1092 | * @param string $tara |
||
1093 | * @param string $capKG |
||
1094 | * @param string $capM3 |
||
1095 | * @param string $propRNTRC |
||
1096 | * @return DOMElement |
||
1097 | */ |
||
1098 | public function tagVeicTracao( |
||
1099 | $cInt = '', |
||
1100 | $placa = '', |
||
1101 | $tara = '', |
||
1102 | $capKG = '', |
||
1103 | $capM3 = '', |
||
1104 | $tpRod = '', |
||
1105 | $tpCar = '', |
||
1106 | $UF = '', |
||
1107 | $propRNTRC = '' |
||
1108 | ) { |
||
1109 | $veicTracao = $this->zTagVeiculo( |
||
1110 | 'veicTracao', |
||
1111 | $cInt, |
||
1112 | $placa, |
||
1113 | $tara, |
||
1114 | $capKG, |
||
1115 | $capM3, |
||
1116 | $tpRod, |
||
1117 | $tpCar, |
||
1118 | $UF, |
||
1119 | $propRNTRC |
||
1120 | ); |
||
1121 | $this->veicTracao = $veicTracao; |
||
1122 | return $veicTracao; |
||
1123 | } |
||
1124 | |||
1125 | /** |
||
1126 | * tagCondutor |
||
1127 | * tag MDFe/infMDFe/infModal/rodo/veicTracao/condutor |
||
1128 | * |
||
1129 | * @param string $xNome |
||
1130 | * @param string $cpf |
||
1131 | * @return DOMElement |
||
1132 | */ |
||
1133 | public function tagCondutor( |
||
1134 | $xNome = '', |
||
1135 | $cpf = '' |
||
1136 | ) { |
||
1137 | $condutor = $this->dom->createElement("condutor"); |
||
1138 | $this->dom->addChild( |
||
1139 | $condutor, |
||
1140 | "xNome", |
||
1141 | $xNome, |
||
1142 | true, |
||
1143 | "Nome do condutor" |
||
1144 | ); |
||
1145 | $this->dom->addChild( |
||
1146 | $condutor, |
||
1147 | "CPF", |
||
1148 | $cpf, |
||
1149 | true, |
||
1150 | "CPF do condutor" |
||
1151 | ); |
||
1152 | $this->aCondutor[] = $condutor; |
||
1153 | return $condutor; |
||
1154 | } |
||
1155 | |||
1156 | /** |
||
1157 | * tagVeicReboque |
||
1158 | * tag MDFe/infMDFe/infModal/rodo/reboque |
||
1159 | * |
||
1160 | * @param type $cInt |
||
1161 | * @param type $placa |
||
1162 | * @param type $tara |
||
1163 | * @param type $capKG |
||
1164 | * @param type $capM3 |
||
1165 | * @param type $propRNTRC |
||
1166 | * @return DOMElement |
||
1167 | */ |
||
1168 | public function tagVeicReboque( |
||
1169 | $cInt = '', |
||
1170 | $placa = '', |
||
1171 | $tara = '', |
||
1172 | $capKG = '', |
||
1173 | $capM3 = '', |
||
1174 | $propRNTRC = '' |
||
1175 | ) { |
||
1176 | $reboque = $this->zTagVeiculo('reboque', $cInt, $placa, $tara, $capKG, $capM3, $propRNTRC); |
||
1177 | $this->aReboque[] = $reboque; |
||
1178 | return $reboque; |
||
1179 | } |
||
1180 | |||
1181 | /** |
||
1182 | * tagValePed |
||
1183 | * tag MDFe/infMDFe/infModal/rodo/valePed |
||
1184 | * |
||
1185 | * @param type $cnpjForn |
||
1186 | * @param type $cnpjPg |
||
1187 | * @param type $nCompra |
||
1188 | * @return DOMElement |
||
1189 | */ |
||
1190 | public function tagValePed( |
||
1191 | $cnpjForn = '', |
||
1192 | $cnpjPg = '', |
||
1193 | $nCompra = '' |
||
1194 | ) { |
||
1195 | $disp = $this->dom->createElement($disp); |
||
1196 | $this->dom->addChild( |
||
1197 | $disp, |
||
1198 | "CNPJForn", |
||
1199 | $cnpjForn, |
||
1200 | true, |
||
1201 | "CNPJ da empresa fornecedora do Vale-Pedágio" |
||
1202 | ); |
||
1203 | $this->dom->addChild( |
||
1204 | $disp, |
||
1205 | "CNPJPg", |
||
1206 | $cnpjPg, |
||
1207 | false, |
||
1208 | "CNPJ do responsável pelo pagamento do Vale-Pedágio" |
||
1209 | ); |
||
1210 | $this->dom->addChild( |
||
1211 | $disp, |
||
1212 | "nCompra", |
||
1213 | $nCompra, |
||
1214 | true, |
||
1215 | "Número do comprovante de compra" |
||
1216 | ); |
||
1217 | $this->aDisp[] = $disp; |
||
1218 | return $disp; |
||
1219 | } |
||
1220 | |||
1221 | /** |
||
1222 | * zTagVeiculo |
||
1223 | * |
||
1224 | * @param string $cInt |
||
1225 | * @param string $placa |
||
1226 | * @param string $tara |
||
1227 | * @param string $capKG |
||
1228 | * @param string $capM3 |
||
1229 | * @param string $propRNTRC |
||
1230 | * @return DOMElement |
||
1231 | */ |
||
1232 | protected function zTagVeiculo( |
||
1233 | $tag = '', |
||
1234 | $cInt = '', |
||
1235 | $placa = '', |
||
1236 | $tara = '', |
||
1237 | $capKG = '', |
||
1238 | $capM3 = '', |
||
1239 | $tpRod = '', |
||
1240 | $tpCar = '', |
||
1241 | $UF = '', |
||
1242 | $propRNTRC = '' |
||
1243 | ) { |
||
1244 | $node = $this->dom->createElement($tag); |
||
1245 | $this->dom->addChild( |
||
1246 | $node, |
||
1247 | "cInt", |
||
1248 | $cInt, |
||
1249 | false, |
||
1250 | "Código interno do veículo" |
||
1251 | ); |
||
1252 | $this->dom->addChild( |
||
1253 | $node, |
||
1254 | "placa", |
||
1255 | $placa, |
||
1256 | true, |
||
1257 | "Placa do veículo" |
||
1258 | ); |
||
1259 | $this->dom->addChild( |
||
1260 | $node, |
||
1261 | "tara", |
||
1262 | $tara, |
||
1263 | true, |
||
1264 | "Tara em KG" |
||
1265 | ); |
||
1266 | $this->dom->addChild( |
||
1267 | $node, |
||
1268 | "capKG", |
||
1269 | $capKG, |
||
1270 | false, |
||
1271 | "Capacidade em KG" |
||
1272 | ); |
||
1273 | $this->dom->addChild( |
||
1274 | $node, |
||
1275 | "capM3", |
||
1276 | $capM3, |
||
1277 | false, |
||
1278 | "Capacidade em M3" |
||
1279 | ); |
||
1280 | $this->dom->addArrayChild( |
||
1281 | $node, |
||
1282 | $this->aCondutor |
||
1283 | ); |
||
1284 | $this->dom->addChild( |
||
1285 | $node, |
||
1286 | "tpRod", |
||
1287 | $tpRod, |
||
1288 | true, |
||
1289 | "Tipo de rodado" |
||
1290 | ); |
||
1291 | $this->dom->addChild( |
||
1292 | $node, |
||
1293 | "tpCar", |
||
1294 | $tpCar, |
||
1295 | true, |
||
1296 | "Tipo de carroceria" |
||
1297 | ); |
||
1298 | $this->dom->addChild( |
||
1299 | $node, |
||
1300 | "UF", |
||
1301 | $UF, |
||
1302 | true, |
||
1303 | "UF de licenciamento do veículo" |
||
1304 | ); |
||
1305 | if ($propRNTRC != '') { |
||
1306 | $prop = $this->dom->createElement("prop"); |
||
1307 | $this->dom->addChild( |
||
1308 | $prop, |
||
1309 | "RNTRC", |
||
1310 | $propRNTRC, |
||
1311 | true, |
||
1312 | "Registro Nacional dos Transportadores Rodoviários de Carga" |
||
1313 | ); |
||
1314 | $this->dom->appChild($node, $prop, ''); |
||
1315 | } |
||
1316 | return $node; |
||
1317 | } |
||
1318 | |||
1319 | /** |
||
1320 | * zTagMDFe |
||
1321 | * Tag raiz da MDFe |
||
1322 | * tag MDFe DOMNode |
||
1323 | * Função chamada pelo método [ monta ] |
||
1324 | * |
||
1325 | * @return DOMElement |
||
1326 | */ |
||
1327 | protected function zTagMDFe() |
||
1328 | { |
||
1329 | if (empty($this->MDFe)) { |
||
1330 | $this->MDFe = $this->dom->createElement("MDFe"); |
||
1331 | $this->MDFe->setAttribute("xmlns", "http://www.portalfiscal.inf.br/mdfe"); |
||
1332 | } |
||
1333 | return $this->MDFe; |
||
1334 | } |
||
1335 | |||
1336 | /** |
||
1337 | * Adiciona as tags |
||
1338 | * infMunCarrega e infPercurso |
||
1339 | * a tag ide |
||
1340 | */ |
||
1341 | protected function zTagIde() |
||
1342 | { |
||
1343 | $this->dom->addArrayChild($this->ide, $this->aInfMunCarrega); |
||
1344 | $this->dom->addArrayChild($this->ide, $this->aInfPercurso); |
||
1345 | } |
||
1346 | |||
1347 | /** |
||
1348 | * Processa lacres |
||
1349 | */ |
||
1350 | protected function zTagLacres() |
||
1351 | { |
||
1352 | $this->dom->addArrayChild($this->infMDFe, $this->aLacres); |
||
1353 | } |
||
1354 | |||
1355 | /** |
||
1356 | * Proecessa documentos fiscais |
||
1357 | */ |
||
1358 | protected function zTagInfDoc() |
||
1359 | { |
||
1360 | $this->aCountDoc = array('CTe'=>0, 'NFe'=>0, 'MDFe'=>0); |
||
1361 | if (! empty($this->aInfMunDescarga)) { |
||
1362 | $infDoc = $this->dom->createElement("infDoc"); |
||
1363 | foreach ($this->aInfMunDescarga as $nItem => $node) { |
||
1364 | View Code Duplication | if (isset($this->aInfCTe[$nItem])) { |
|
0 ignored issues
–
show
|
|||
1365 | $this->aCountDoc['CTe'] = $this->dom->addArrayChild($node, $this->aInfCTe[$nItem]); |
||
1366 | } |
||
1367 | View Code Duplication | if (isset($this->aInfNFe[$nItem])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
1368 | $this->aCountDoc['NFe'] = $this->dom->addArrayChild($node, $this->aInfNFe[$nItem]); |
||
1369 | } |
||
1370 | View Code Duplication | if (isset($this->aInfMDFe[$nItem])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
1371 | $this->aCountDoc['MDFe'] = $this->dom->addArrayChild($node, $this->aInfMDFe[$nItem]); |
||
1372 | } |
||
1373 | $this->dom->appChild($infDoc, $node, ''); |
||
1374 | } |
||
1375 | $this->dom->appChild($this->infMDFe, $infDoc, 'Falta tag "infMDFe"'); |
||
1376 | } |
||
1377 | //ajusta quantidades em tot |
||
1378 | $this->tot->getElementsByTagName('qCTe')->item(0)->nodeValue = $this->aCountDoc['CTe']; |
||
1379 | $this->tot->getElementsByTagName('qNFe')->item(0)->nodeValue = $this->aCountDoc['NFe']; |
||
1380 | $this->tot->getElementsByTagName('qMDFe')->item(0)->nodeValue = $this->aCountDoc['MDFe']; |
||
1381 | } |
||
1382 | |||
1383 | /** |
||
1384 | * Processa modal rodoviario |
||
1385 | */ |
||
1386 | protected function zTagRodo() |
||
1387 | { |
||
1388 | if (! empty($this->rodo)) { |
||
1389 | $this->dom->appChild($this->rodo, $this->veicTracao, 'Falta tag "rodo"'); |
||
1390 | $this->dom->addArrayChild($this->rodo, $this->aReboque); |
||
1391 | if (! empty($this->aDisp)) { |
||
1392 | $valePed = $this->dom->createElement("valePed"); |
||
1393 | foreach ($this->aDisp as $node) { |
||
1394 | $this->dom->appChild($valePed, $node, ''); |
||
1395 | } |
||
1396 | $this->dom->appChild($this->rodo, $valePed, ''); |
||
1397 | } |
||
1398 | $this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "infModal"'); |
||
1399 | } |
||
1400 | } |
||
1401 | |||
1402 | /** |
||
1403 | * Proecessa modal ferroviario |
||
1404 | */ |
||
1405 | protected function zTagFerrov() |
||
1406 | { |
||
1407 | if (! empty($this->trem)) { |
||
1408 | $this->dom->addArrayChild($this->trem, $this->aVag); |
||
1409 | $ferrov = $this->dom->createElement("ferrov"); |
||
1410 | $this->dom->appChild($ferrov, $this->trem, ''); |
||
1411 | $this->dom->appChild($this->infModal, $ferrov, 'Falta tag "infModal"'); |
||
1412 | } |
||
1413 | } |
||
1414 | |||
1415 | /** |
||
1416 | * Processa modal aereo |
||
1417 | */ |
||
1418 | protected function zTagAereo() |
||
1419 | { |
||
1420 | if (! empty($this->aereo)) { |
||
1421 | $this->dom->appChild($this->infModal, $this->aereo, 'Falta tag "infModal"'); |
||
1422 | } |
||
1423 | } |
||
1424 | |||
1425 | /** |
||
1426 | * Processa modal aquaviário |
||
1427 | */ |
||
1428 | protected function zTagAqua() |
||
1429 | { |
||
1430 | if (! empty($this->aqua)) { |
||
1431 | $this->dom->addArrayChild($this->aqua, $this->aInfTermCarreg); |
||
1432 | $this->dom->addArrayChild($this->aqua, $this->aInfTermDescarreg); |
||
1433 | $this->dom->addArrayChild($this->aqua, $this->aInfEmbComb); |
||
1434 | $this->dom->appChild($this->infModal, $this->aqua, 'Falta tag "infModal"'); |
||
1435 | } |
||
1436 | } |
||
1437 | |||
1438 | /** |
||
1439 | * zTestaChaveXML |
||
1440 | * Remonta a chave da NFe de 44 digitos com base em seus dados |
||
1441 | * Isso é útil no caso da chave informada estar errada |
||
1442 | * se a chave estiver errada a mesma é substituida |
||
1443 | * |
||
1444 | * @param object $dom |
||
1445 | */ |
||
1446 | private function zTestaChaveXML($dom) |
||
1447 | { |
||
1448 | $infMDFe = $dom->getElementsByTagName("infMDFe")->item(0); |
||
1449 | $ide = $dom->getElementsByTagName("ide")->item(0); |
||
1450 | $emit = $dom->getElementsByTagName("emit")->item(0); |
||
1451 | $cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue; |
||
1452 | $dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue; |
||
1453 | $cnpj = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
||
1454 | $mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue; |
||
1455 | $serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue; |
||
1456 | $nNF = $ide->getElementsByTagName('nMDF')->item(0)->nodeValue; |
||
1457 | $tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue; |
||
1458 | $cNF = $ide->getElementsByTagName('cMDF')->item(0)->nodeValue; |
||
1459 | $chave = str_replace('MDFe', '', $infMDFe->getAttribute("Id")); |
||
1460 | $tempData = explode("-", $dhEmi); |
||
1461 | $chaveMontada = $this->montaChave( |
||
1462 | $cUF, |
||
1463 | $tempData[0] - 2000, |
||
1464 | $tempData[1], |
||
1465 | $cnpj, |
||
1466 | $mod, |
||
1467 | $serie, |
||
1468 | $nNF, |
||
1469 | $tpEmis, |
||
1470 | $cNF |
||
1471 | ); |
||
1472 | //caso a chave contida na NFe esteja errada |
||
1473 | //substituir a chave |
||
1474 | if ($chaveMontada != $chave) { |
||
1475 | $ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chaveMontada, -1); |
||
1476 | $infMDFe = $dom->getElementsByTagName("infMDFe")->item(0); |
||
1477 | $infMDFe->setAttribute("Id", "MDFe" . $chaveMontada); |
||
1478 | $this->chMDFe = $chaveMontada; |
||
1479 | } |
||
1480 | } |
||
1481 | } |
||
1482 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.