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 3.00a |
11
|
|
|
* |
12
|
|
|
* @category Library |
13
|
|
|
* @package nfephp-org/sped-mdfe |
14
|
|
|
* @name Make.php |
15
|
|
|
* @copyright 2009-2019 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\Keys; |
22
|
|
|
use NFePHP\Common\DOMImproved as Dom; |
23
|
|
|
use NFePHP\Common\Strings; |
24
|
|
|
use stdClass; |
25
|
|
|
use RuntimeException; |
26
|
|
|
use InvalidArgumentException; |
27
|
|
|
use DOMElement; |
28
|
|
|
use DateTime; |
29
|
|
|
|
30
|
|
|
class Make |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
public $errors = []; |
36
|
|
|
/** |
37
|
|
|
* versao |
38
|
|
|
* numero da versão do xml da MDFe |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $versao = '3.00'; |
43
|
|
|
/** |
44
|
|
|
* mod |
45
|
|
|
* modelo da MDFe 58 |
46
|
|
|
* |
47
|
|
|
* @var integer |
48
|
|
|
*/ |
49
|
|
|
public $mod = '58'; |
50
|
|
|
/** |
51
|
|
|
* chave da MDFe |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
public $chMDFe = ''; |
56
|
|
|
|
57
|
|
|
//propriedades privadas utilizadas internamente pela classe |
58
|
|
|
/** |
59
|
|
|
* @type string|\DOMNode |
60
|
|
|
*/ |
61
|
|
|
private $MDFe = ''; |
62
|
|
|
/** |
63
|
|
|
* @type string|\DOMNode |
64
|
|
|
*/ |
65
|
|
|
private $infMDFe = ''; |
66
|
|
|
/** |
67
|
|
|
* @type string|\DOMNode |
68
|
|
|
*/ |
69
|
|
|
private $ide = ''; |
70
|
|
|
/** |
71
|
|
|
* @type string|\DOMNode |
72
|
|
|
*/ |
73
|
|
|
private $emit = ''; |
74
|
|
|
/** |
75
|
|
|
* @type string|\DOMNode |
76
|
|
|
*/ |
77
|
|
|
private $enderEmit = ''; |
78
|
|
|
/** |
79
|
|
|
* @type string|\DOMNode |
80
|
|
|
*/ |
81
|
|
|
private $infModal = ''; |
82
|
|
|
/** |
83
|
|
|
* @type string|\DOMNode |
84
|
|
|
*/ |
85
|
|
|
private $tot = ''; |
86
|
|
|
/** |
87
|
|
|
* @type string|\DOMNode |
88
|
|
|
*/ |
89
|
|
|
private $seg = ''; |
90
|
|
|
/** |
91
|
|
|
* @type string|\DOMNode |
92
|
|
|
*/ |
93
|
|
|
private $aLacres = []; |
94
|
|
|
/** |
95
|
|
|
* @type string|\DOMNode |
96
|
|
|
*/ |
97
|
|
|
private $autXML = []; |
98
|
|
|
/** |
99
|
|
|
* @type string|\DOMNode |
100
|
|
|
*/ |
101
|
|
|
private $infAdic = ''; |
102
|
|
|
/** |
103
|
|
|
* @type string|\DOMNode |
104
|
|
|
*/ |
105
|
|
|
private $rodo = ''; |
106
|
|
|
/** |
107
|
|
|
* @type string|\DOMNode |
108
|
|
|
*/ |
109
|
|
|
private $infDoc = ''; |
110
|
|
|
/** |
111
|
|
|
* @type string|\DOMNode |
112
|
|
|
*/ |
113
|
|
|
private $infUnidTransp = ''; |
114
|
|
|
/** |
115
|
|
|
* @type array|\DOMNode |
116
|
|
|
*/ |
117
|
|
|
private $aInfMunDescarga = []; |
118
|
|
|
/** |
119
|
|
|
* @type array|\DOMNode |
120
|
|
|
*/ |
121
|
|
|
private $aInfMunCarrega = []; |
122
|
|
|
/** |
123
|
|
|
* @type array|\DOMNode |
124
|
|
|
*/ |
125
|
|
|
private $aInfPercurso = []; |
126
|
|
|
/** |
127
|
|
|
* @type string|\DOMNode |
128
|
|
|
*/ |
129
|
|
|
private $veicTracao = ''; |
130
|
|
|
/** |
131
|
|
|
* @type string|\DOMNode |
132
|
|
|
*/ |
133
|
|
|
private $aereo = ''; |
134
|
|
|
/** |
135
|
|
|
* @type string|\DOMNode |
136
|
|
|
*/ |
137
|
|
|
private $trem = ''; |
138
|
|
|
/** |
139
|
|
|
* @type string|\DOMNode |
140
|
|
|
*/ |
141
|
|
|
private $aqua = ''; |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @var boolean |
145
|
|
|
*/ |
146
|
|
|
protected $replaceAccentedChars = false; |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Função construtora cria um objeto DOMDocument |
150
|
|
|
* que será carregado com o documento fiscal |
151
|
|
|
*/ |
152
|
|
|
public function __construct() |
153
|
|
|
{ |
154
|
|
|
$this->dom = new Dom('1.0', 'UTF-8'); |
|
|
|
|
155
|
|
|
$this->dom->preserveWhiteSpace = false; |
156
|
|
|
$this->dom->formatOutput = false; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Retorns the xml |
161
|
|
|
* @return xml |
162
|
|
|
*/ |
163
|
|
|
public function getXML() |
164
|
|
|
{ |
165
|
|
|
if (empty($this->xml)) { |
|
|
|
|
166
|
|
|
$this->montaMDFe(); |
167
|
|
|
} |
168
|
|
|
return $this->xml; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Retorns the key number of NFe (44 digits) |
173
|
|
|
* @return string |
174
|
|
|
*/ |
175
|
|
|
public function getChave() |
176
|
|
|
{ |
177
|
|
|
return $this->chMDFe; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Returns the model of MDFe |
182
|
|
|
* @return int |
183
|
|
|
*/ |
184
|
|
|
public function getModelo() |
185
|
|
|
{ |
186
|
|
|
return $this->mod; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Call method of xml assembly. For compatibility only. |
191
|
|
|
* @return boolean |
192
|
|
|
*/ |
193
|
|
|
public function montaMDFe() |
194
|
|
|
{ |
195
|
|
|
return $this->monta(); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* MDFe xml mount method |
200
|
|
|
* this function returns TRUE on success or FALSE on error |
201
|
|
|
* The xml of the MDFe must be retrieved by the getXML() function or |
202
|
|
|
* directly by the public property $xml |
203
|
|
|
* @return boolean |
204
|
|
|
*/ |
205
|
|
|
public function monta() |
206
|
|
|
{ |
207
|
|
|
$this->errors = $this->dom->errors; |
208
|
|
|
if (count($this->errors) > 0) { |
209
|
|
|
return false; |
210
|
|
|
} |
211
|
|
|
//cria a tag raiz da MDFe |
212
|
|
|
$this->buildMDFe(); |
213
|
|
|
$this->buildInfModal(); |
214
|
|
|
|
215
|
|
|
$this->infMDFe = $this->dom->createElement("infMDFe"); |
216
|
|
|
|
217
|
|
|
$this->dom->appChild($this->infMDFe, $this->ide, 'Falta tag "infMDFe"'); |
218
|
|
|
$this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "emit"'); |
219
|
|
|
$this->dom->appChild($this->infMDFe, $this->emit, 'Falta tag "infMDFe"'); |
220
|
|
|
if (! empty($this->rodo)) { |
221
|
|
|
$this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "infModal"'); |
222
|
|
|
} |
223
|
|
|
$this->dom->appChild($this->infMDFe, $this->infModal, 'Falta tag "infMDFe"'); |
224
|
|
|
$this->dom->appChild($this->infMDFe, $this->infDoc, 'Falta tag "infMDFe"'); |
225
|
|
|
$this->dom->appChild($this->infMDFe, $this->seg, 'Falta tag "infMDFe"'); |
226
|
|
|
$this->dom->appChild($this->infMDFe, $this->tot, 'Falta tag "infMDFe"'); |
227
|
|
|
foreach ($this->aLacres as $lacre) { |
|
|
|
|
228
|
|
|
$this->dom->appChild($this->infMDFe, $lacre, 'Falta tag "infMDFe"'); |
229
|
|
|
} |
230
|
|
|
foreach ($this->autXML as $autXML) { |
|
|
|
|
231
|
|
|
$this->dom->appChild($this->infMDFe, $autXML, 'Falta tag "infMDFe"'); |
232
|
|
|
} |
233
|
|
|
$this->dom->appChild($this->infMDFe, $this->infAdic, 'Falta tag "infMDFe"'); |
234
|
|
|
|
235
|
|
|
$this->dom->appChild($this->MDFe, $this->infMDFe, 'Falta tag "MDFe"'); |
236
|
|
|
|
237
|
|
|
$this->dom->appendChild($this->MDFe); |
238
|
|
|
// testa da chave |
239
|
|
|
$this->checkMDFKey($this->dom); |
240
|
|
|
$this->xml = $this->dom->saveXML(); |
241
|
|
|
|
242
|
|
|
return true; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Informações de identificação da MDFe |
247
|
|
|
* tag MDFe/infMDFe/ide |
248
|
|
|
* @param stdClass $std |
249
|
|
|
* @return DOMElement |
250
|
|
|
*/ |
251
|
|
|
public function tagide(stdClass $std) |
252
|
|
|
{ |
253
|
|
|
|
254
|
|
|
$possible = [ |
255
|
|
|
'cUF', |
256
|
|
|
'tpAmb', |
257
|
|
|
'tpEmit', |
258
|
|
|
'tpTransp', |
259
|
|
|
'mod', |
260
|
|
|
'serie', |
261
|
|
|
'nMDF', |
262
|
|
|
'cMDF', |
263
|
|
|
'cDV', |
264
|
|
|
'modal', |
265
|
|
|
'dhEmi', |
266
|
|
|
'tpEmis', |
267
|
|
|
'procEmi', |
268
|
|
|
'verProc', |
269
|
|
|
'ufIni', |
270
|
|
|
'ufFim' |
271
|
|
|
]; |
272
|
|
|
|
273
|
|
|
$std = $this->equilizeParameters($std, $possible); |
274
|
|
|
|
275
|
|
|
$this->tpAmb = $std->tpAmb; |
|
|
|
|
276
|
|
|
$identificador = '[4] <ide> - '; |
277
|
|
|
$ide = $this->dom->createElement("ide"); |
278
|
|
|
$this->dom->addChild( |
279
|
|
|
$ide, |
280
|
|
|
"cUF", |
281
|
|
|
$std->cUF, |
282
|
|
|
true, |
283
|
|
|
$identificador . "Código da UF do emitente do Documento Fiscal" |
284
|
|
|
); |
285
|
|
|
$this->dom->addChild( |
286
|
|
|
$ide, |
287
|
|
|
"tpAmb", |
288
|
|
|
$std->tpAmb, |
289
|
|
|
true, |
290
|
|
|
$identificador . "Identificação do Ambiente" |
291
|
|
|
); |
292
|
|
|
$this->dom->addChild( |
293
|
|
|
$ide, |
294
|
|
|
"tpEmit", |
295
|
|
|
$std->tpEmit, |
296
|
|
|
true, |
297
|
|
|
$identificador . "Indicador da tipo de emitente" |
298
|
|
|
); |
299
|
|
|
$this->dom->addChild( |
300
|
|
|
$ide, |
301
|
|
|
"tpTransp", |
302
|
|
|
$std->tpTransp, |
303
|
|
|
false, |
304
|
|
|
$identificador . "Tipo do Transportador" |
305
|
|
|
); |
306
|
|
|
$this->dom->addChild( |
307
|
|
|
$ide, |
308
|
|
|
"mod", |
309
|
|
|
$std->mod, |
310
|
|
|
true, |
311
|
|
|
$identificador . "Código do Modelo do Documento Fiscal" |
312
|
|
|
); |
313
|
|
|
$this->dom->addChild( |
314
|
|
|
$ide, |
315
|
|
|
"serie", |
316
|
|
|
$std->serie, |
317
|
|
|
true, |
318
|
|
|
$identificador . "Série do Documento Fiscal" |
319
|
|
|
); |
320
|
|
|
$this->dom->addChild( |
321
|
|
|
$ide, |
322
|
|
|
"nMDF", |
323
|
|
|
$std->nMDF, |
324
|
|
|
true, |
325
|
|
|
$identificador . "Número do Documento Fiscal" |
326
|
|
|
); |
327
|
|
|
$this->dom->addChild( |
328
|
|
|
$ide, |
329
|
|
|
"cMDF", |
330
|
|
|
$std->cMDF, |
331
|
|
|
true, |
332
|
|
|
$identificador . "Código do numérico do MDF" |
333
|
|
|
); |
334
|
|
|
$this->dom->addChild( |
335
|
|
|
$ide, |
336
|
|
|
"cDV", |
337
|
|
|
$std->cDV, |
338
|
|
|
true, |
339
|
|
|
$identificador . "Dígito Verificador da Chave de Acesso da NF-e" |
340
|
|
|
); |
341
|
|
|
$this->dom->addChild( |
342
|
|
|
$ide, |
343
|
|
|
"modal", |
344
|
|
|
$std->modal, |
345
|
|
|
true, |
346
|
|
|
$identificador . "Modalidade de transporte" |
347
|
|
|
); |
348
|
|
|
$this->dom->addChild( |
349
|
|
|
$ide, |
350
|
|
|
"dhEmi", |
351
|
|
|
$std->dhEmi, |
352
|
|
|
true, |
353
|
|
|
$identificador . "Data e hora de emissão do Documento Fiscal" |
354
|
|
|
); |
355
|
|
|
$this->dom->addChild( |
356
|
|
|
$ide, |
357
|
|
|
"tpEmis", |
358
|
|
|
$std->tpEmis, |
359
|
|
|
true, |
360
|
|
|
$identificador . "Tipo de Emissão do Documento Fiscal" |
361
|
|
|
); |
362
|
|
|
$this->dom->addChild( |
363
|
|
|
$ide, |
364
|
|
|
"procEmi", |
365
|
|
|
$std->procEmi, |
366
|
|
|
true, |
367
|
|
|
$identificador . "Processo de emissão" |
368
|
|
|
); |
369
|
|
|
$this->dom->addChild( |
370
|
|
|
$ide, |
371
|
|
|
"verProc", |
372
|
|
|
$std->verProc, |
373
|
|
|
true, |
374
|
|
|
$identificador . "Versão do Processo de emissão" |
375
|
|
|
); |
376
|
|
|
$this->dom->addChild( |
377
|
|
|
$ide, |
378
|
|
|
"UFIni", |
379
|
|
|
$std->UFIni, |
380
|
|
|
true, |
381
|
|
|
$identificador . "Sigla da UF do Carregamento" |
382
|
|
|
); |
383
|
|
|
$this->dom->addChild( |
384
|
|
|
$ide, |
385
|
|
|
"UFFim", |
386
|
|
|
$std->UFFim, |
387
|
|
|
true, |
388
|
|
|
$identificador . "Sigla da UF do Descarregamento" |
389
|
|
|
); |
390
|
|
|
|
391
|
|
|
$this->mod = $std->mod; |
392
|
|
|
$this->ide = $ide; |
393
|
|
|
$this->buildTagIde(); |
394
|
|
|
return $ide; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* taginfMunCarrega |
399
|
|
|
* |
400
|
|
|
* tag MDFe/infMDFe/ide/infMunCarrega |
401
|
|
|
* |
402
|
|
|
* @param stdClass $std |
403
|
|
|
* @return DOMElement |
404
|
|
|
*/ |
405
|
|
View Code Duplication |
public function taginfMunCarrega(stdClass $std) |
|
|
|
|
406
|
|
|
{ |
407
|
|
|
$possible = [ |
408
|
|
|
'cMunCarrega', |
409
|
|
|
'xMunCarrega' |
410
|
|
|
]; |
411
|
|
|
|
412
|
|
|
$std = $this->equilizeParameters($std, $possible); |
413
|
|
|
$infMunCarrega = $this->dom->createElement("infMunCarrega"); |
414
|
|
|
$this->dom->addChild( |
415
|
|
|
$infMunCarrega, |
416
|
|
|
"cMunCarrega", |
417
|
|
|
$std->cMunCarrega, |
418
|
|
|
true, |
419
|
|
|
"Código do Município de Carregamento" |
420
|
|
|
); |
421
|
|
|
$this->dom->addChild( |
422
|
|
|
$infMunCarrega, |
423
|
|
|
"xMunCarrega", |
424
|
|
|
$std->xMunCarrega, |
425
|
|
|
true, |
426
|
|
|
"Nome do Município de Carregamento" |
427
|
|
|
); |
428
|
|
|
$this->aInfMunCarrega[] = $infMunCarrega; |
429
|
|
|
return $infMunCarrega; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* tagInfPercurso |
434
|
|
|
* |
435
|
|
|
* tag MDFe/infMDFe/ide/infPercurso |
436
|
|
|
* |
437
|
|
|
* @param stdClass $std |
438
|
|
|
* @return DOMElement |
439
|
|
|
*/ |
440
|
|
View Code Duplication |
public function taginfPercurso(stdClass $std) |
|
|
|
|
441
|
|
|
{ |
442
|
|
|
$possible = [ |
443
|
|
|
'UFPer' |
444
|
|
|
]; |
445
|
|
|
|
446
|
|
|
$std = $this->equilizeParameters($std, $possible); |
447
|
|
|
foreach ($std->UFPer as $UFPer) { |
448
|
|
|
$infPercurso = $this->dom->createElement("infPercurso"); |
449
|
|
|
$this->dom->addChild( |
450
|
|
|
$infPercurso, |
451
|
|
|
"UFPer", |
452
|
|
|
$UFPer, |
453
|
|
|
true, |
454
|
|
|
"Sigla das Unidades da Federação do percurso" |
455
|
|
|
); |
456
|
|
|
$this->aInfPercurso[] = $infPercurso; |
457
|
|
|
} |
458
|
|
|
return $this->aInfPercurso; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* tagemit |
463
|
|
|
* Identificação do emitente da MDFe |
464
|
|
|
* tag MDFe/infMDFe/emit |
465
|
|
|
* |
466
|
|
|
* @param stdClass $std |
467
|
|
|
* @return DOMElement |
468
|
|
|
*/ |
469
|
|
|
public function tagemit(stdClass $std) |
470
|
|
|
{ |
471
|
|
|
$possible = [ |
472
|
|
|
'CNPJ', |
473
|
|
|
'IE', |
474
|
|
|
'xNome', |
475
|
|
|
'xFant' |
476
|
|
|
]; |
477
|
|
|
$std = $this->equilizeParameters($std, $possible); |
478
|
|
|
|
479
|
|
|
$identificador = '[25] <emit> - '; |
480
|
|
|
$this->emit = $this->dom->createElement("emit"); |
481
|
|
|
$this->dom->addChild( |
482
|
|
|
$this->emit, |
483
|
|
|
"CNPJ", |
484
|
|
|
$std->CNPJ, |
485
|
|
|
true, |
486
|
|
|
$identificador . "CNPJ do emitente" |
487
|
|
|
); |
488
|
|
|
$this->dom->addChild( |
489
|
|
|
$this->emit, |
490
|
|
|
"IE", |
491
|
|
|
$std->IE, |
492
|
|
|
true, |
493
|
|
|
$identificador . "Inscrição Estadual do emitente" |
494
|
|
|
); |
495
|
|
|
$this->dom->addChild( |
496
|
|
|
$this->emit, |
497
|
|
|
"xNome", |
498
|
|
|
$std->xNome, |
499
|
|
|
true, |
500
|
|
|
$identificador . "Razão Social ou Nome do emitente" |
501
|
|
|
); |
502
|
|
|
$this->dom->addChild( |
503
|
|
|
$this->emit, |
504
|
|
|
"xFant", |
505
|
|
|
$std->xFant, |
506
|
|
|
false, |
507
|
|
|
$identificador . "Nome fantasia do emitente" |
508
|
|
|
); |
509
|
|
|
return $this->emit; |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* tagenderEmit |
514
|
|
|
* Endereço do emitente [30] pai [25] |
515
|
|
|
* tag MDFe/infMDFe/emit/endEmit |
516
|
|
|
* |
517
|
|
|
* @param stdClass $std |
518
|
|
|
* @return DOMElement |
519
|
|
|
*/ |
520
|
|
|
public function tagenderEmit(stdClass $std) |
521
|
|
|
{ |
522
|
|
|
$possible = [ |
523
|
|
|
'xLgr', |
524
|
|
|
'nro', |
525
|
|
|
'xCpl', |
526
|
|
|
'xBairro', |
527
|
|
|
'cMun', |
528
|
|
|
'xMun', |
529
|
|
|
'CEP', |
530
|
|
|
'UF', |
531
|
|
|
'fone', |
532
|
|
|
'email' |
533
|
|
|
]; |
534
|
|
|
$std = $this->equilizeParameters($std, $possible); |
535
|
|
|
|
536
|
|
|
$identificador = '[30] <enderEmit> - '; |
537
|
|
|
$this->enderEmit = $this->dom->createElement("enderEmit"); |
538
|
|
|
|
539
|
|
|
$this->dom->addChild( |
540
|
|
|
$this->enderEmit, |
541
|
|
|
"xLgr", |
542
|
|
|
$std->xLgr, |
543
|
|
|
true, |
544
|
|
|
$identificador . "Logradouro do Endereço do emitente" |
545
|
|
|
); |
546
|
|
|
$this->dom->addChild( |
547
|
|
|
$this->enderEmit, |
548
|
|
|
"nro", |
549
|
|
|
$std->nro, |
550
|
|
|
true, |
551
|
|
|
$identificador . "Número do Endereço do emitente" |
552
|
|
|
); |
553
|
|
|
$this->dom->addChild( |
554
|
|
|
$this->enderEmit, |
555
|
|
|
"xCpl", |
556
|
|
|
$std->xCpl, |
557
|
|
|
false, |
558
|
|
|
$identificador . "Complemento do Endereço do emitente" |
559
|
|
|
); |
560
|
|
|
$this->dom->addChild( |
561
|
|
|
$this->enderEmit, |
562
|
|
|
"xBairro", |
563
|
|
|
$std->xBairro, |
564
|
|
|
true, |
565
|
|
|
$identificador . "Bairro do Endereço do emitente" |
566
|
|
|
); |
567
|
|
|
$this->dom->addChild( |
568
|
|
|
$this->enderEmit, |
569
|
|
|
"cMun", |
570
|
|
|
$std->cMun, |
571
|
|
|
true, |
572
|
|
|
$identificador . "Código do município do Endereço do emitente" |
573
|
|
|
); |
574
|
|
|
$this->dom->addChild( |
575
|
|
|
$this->enderEmit, |
576
|
|
|
"xMun", |
577
|
|
|
$std->xMun, |
578
|
|
|
true, |
579
|
|
|
$identificador . "Nome do município do Endereço do emitente" |
580
|
|
|
); |
581
|
|
|
$this->dom->addChild( |
582
|
|
|
$this->enderEmit, |
583
|
|
|
"CEP", |
584
|
|
|
$std->CEP, |
585
|
|
|
true, |
586
|
|
|
$identificador . "Código do CEP do Endereço do emitente" |
587
|
|
|
); |
588
|
|
|
$this->dom->addChild( |
589
|
|
|
$this->enderEmit, |
590
|
|
|
"UF", |
591
|
|
|
$std->UF, |
592
|
|
|
true, |
593
|
|
|
$identificador . "Sigla da UF do Endereço do emitente" |
594
|
|
|
); |
595
|
|
|
$this->dom->addChild( |
596
|
|
|
$this->enderEmit, |
597
|
|
|
"fone", |
598
|
|
|
$std->fone, |
599
|
|
|
false, |
600
|
|
|
$identificador . "Número de telefone do emitente" |
601
|
|
|
); |
602
|
|
|
$this->dom->addChild( |
603
|
|
|
$this->enderEmit, |
604
|
|
|
"email", |
605
|
|
|
$std->email, |
606
|
|
|
false, |
607
|
|
|
$identificador . "Endereço de email do emitente" |
608
|
|
|
); |
609
|
|
|
return $this->enderEmit; |
610
|
|
|
} |
611
|
|
|
|
612
|
|
|
/** |
613
|
|
|
* tagInfMunDescarga |
614
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga |
615
|
|
|
* |
616
|
|
|
* @param stdClass $std |
617
|
|
|
* @return DOMElement |
618
|
|
|
*/ |
619
|
|
|
public function taginfMunDescarga(stdClass $std) |
620
|
|
|
{ |
621
|
|
|
$possible = [ |
622
|
|
|
'cMunDescarga', |
623
|
|
|
'xMunDescarga' |
624
|
|
|
]; |
625
|
|
|
$std = $this->equilizeParameters($std, $possible); |
626
|
|
|
|
627
|
|
|
if (empty($this->infDoc)) { |
628
|
|
|
$infDoc = $this->dom->createElement("infDoc"); |
629
|
|
|
} else { |
630
|
|
|
$infDoc = $this->infDoc; |
631
|
|
|
} |
632
|
|
|
$infMunDescarga = $this->dom->createElement("infMunDescarga"); |
633
|
|
|
$this->dom->addChild( |
634
|
|
|
$infMunDescarga, |
635
|
|
|
"cMunDescarga", |
636
|
|
|
$std->cMunDescarga, |
637
|
|
|
true, |
638
|
|
|
"Código do Município de Descarga" |
639
|
|
|
); |
640
|
|
|
$this->dom->addChild( |
641
|
|
|
$infMunDescarga, |
642
|
|
|
"xMunDescarga", |
643
|
|
|
$std->xMunDescarga, |
644
|
|
|
true, |
645
|
|
|
"Nome do Município de Descarga" |
646
|
|
|
); |
647
|
|
|
$this->dom->appChild($infDoc, $infMunDescarga, 'Falta tag "infDoc"'); |
648
|
|
|
$this->infDoc = $infDoc; |
649
|
|
|
$this->aInfMunDescarga = $infMunDescarga; |
650
|
|
|
return $infMunDescarga; |
651
|
|
|
} |
652
|
|
|
|
653
|
|
|
/** |
654
|
|
|
* taginfANTT |
655
|
|
|
* tag MDFe/infMDFe/rodo/taginfANTT |
656
|
|
|
* |
657
|
|
|
* @param stdClass $std |
658
|
|
|
* @return DOMElement |
659
|
|
|
*/ |
660
|
|
|
public function taginfANTT(stdClass $std) |
661
|
|
|
{ |
662
|
|
|
$possible = [ |
663
|
|
|
'RNTRC', |
664
|
|
|
'infCIOT', |
665
|
|
|
'valePed', |
666
|
|
|
'infContratante' |
667
|
|
|
]; |
668
|
|
|
$std = $this->equilizeParameters($std, $possible); |
669
|
|
|
$rodo = $this->dom->createElement("rodo"); |
670
|
|
|
$infANTT = $this->dom->createElement("infANTT"); |
671
|
|
|
$this->dom->addChild( |
672
|
|
|
$infANTT, |
673
|
|
|
"RNTRC", |
674
|
|
|
$std->RNTRC, |
675
|
|
|
false, |
676
|
|
|
"RNTRC" |
677
|
|
|
); |
678
|
|
|
|
679
|
|
|
if ($std->infCIOT != null) { |
680
|
|
|
$possible = [ |
681
|
|
|
'CIOT', |
682
|
|
|
'CPF', |
683
|
|
|
'CNPJ' |
684
|
|
|
]; |
685
|
|
|
foreach ($std->infCIOT as $infCIOT) { |
686
|
|
|
$stdinfCIOT = $this->equilizeParameters($infCIOT, $possible); |
687
|
|
|
$infCIOT = $this->dom->createElement("infCIOT"); |
688
|
|
|
$this->dom->addChild( |
689
|
|
|
$infCIOT, |
690
|
|
|
"CIOT", |
691
|
|
|
$stdinfCIOT->CIOT, |
692
|
|
|
true, |
693
|
|
|
"CIOT" |
694
|
|
|
); |
695
|
|
|
|
696
|
|
|
$this->dom->addChild( |
697
|
|
|
$infCIOT, |
698
|
|
|
"CPF", |
699
|
|
|
$stdinfCIOT->CPF, |
700
|
|
|
false, |
701
|
|
|
"CPF" |
702
|
|
|
); |
703
|
|
|
$this->dom->addChild( |
704
|
|
|
$infCIOT, |
705
|
|
|
"CNPJ", |
706
|
|
|
$stdinfCIOT->CNPJ, |
707
|
|
|
false, |
708
|
|
|
"CNPJ" |
709
|
|
|
); |
710
|
|
|
$this->dom->appChild($infANTT, $infCIOT, 'Falta tag "$infANTT"'); |
711
|
|
|
} |
712
|
|
|
} |
713
|
|
|
if ($std->valePed != null) { |
714
|
|
|
$possible = [ |
715
|
|
|
'CNPJForn', |
716
|
|
|
'CNPJPg', |
717
|
|
|
'CPFPg', |
718
|
|
|
'nCompra', |
719
|
|
|
'vValePed' |
720
|
|
|
]; |
721
|
|
|
foreach ($std->valePed as $valePed) { |
722
|
|
|
$stdvalePed = $this->equilizeParameters($valePed, $possible); |
723
|
|
|
$valePed = $this->dom->createElement("valePed"); |
724
|
|
|
$disp = $this->dom->createElement("disp"); |
725
|
|
|
$this->dom->addChild( |
726
|
|
|
$disp, |
727
|
|
|
"CNPJForn", |
728
|
|
|
$stdvalePed->CNPJForn, |
729
|
|
|
false, |
730
|
|
|
"CNPJForn" |
731
|
|
|
); |
732
|
|
|
$this->dom->addChild( |
733
|
|
|
$disp, |
734
|
|
|
"CNPJPg", |
735
|
|
|
$stdvalePed->CNPJPg, |
736
|
|
|
false, |
737
|
|
|
"CNPJPg" |
738
|
|
|
); |
739
|
|
|
$this->dom->addChild( |
740
|
|
|
$disp, |
741
|
|
|
"CPFPg", |
742
|
|
|
$stdvalePed->CPFPg, |
743
|
|
|
false, |
744
|
|
|
"CPFPg" |
745
|
|
|
); |
746
|
|
|
$this->dom->addChild( |
747
|
|
|
$disp, |
748
|
|
|
"nCompra", |
749
|
|
|
$stdvalePed->nCompra, |
750
|
|
|
false, |
751
|
|
|
"nCompra" |
752
|
|
|
); |
753
|
|
|
$this->dom->addChild( |
754
|
|
|
$disp, |
755
|
|
|
"vValePed", |
756
|
|
|
$stdvalePed->vValePed, |
757
|
|
|
false, |
758
|
|
|
"vValePed" |
759
|
|
|
); |
760
|
|
|
$this->dom->appChild($valePed, $disp, 'Falta tag "valePed"'); |
761
|
|
|
$this->dom->appChild($infANTT, $valePed, 'Falta tag "infANTT"'); |
762
|
|
|
} |
763
|
|
|
} |
764
|
|
View Code Duplication |
if ($std->infContratante != null) { |
|
|
|
|
765
|
|
|
$possible = [ |
766
|
|
|
'CPF', |
767
|
|
|
'CNPJ' |
768
|
|
|
]; |
769
|
|
|
foreach ($std->infContratante as $infContratante) { |
770
|
|
|
$stdinfContratante = $this->equilizeParameters($infContratante, $possible); |
771
|
|
|
$infContratante = $this->dom->createElement("infContratante"); |
772
|
|
|
$this->dom->addChild( |
773
|
|
|
$infContratante, |
774
|
|
|
"CPF", |
775
|
|
|
$stdinfContratante->CPF, |
776
|
|
|
false, |
777
|
|
|
"CPF" |
778
|
|
|
); |
779
|
|
|
$this->dom->addChild( |
780
|
|
|
$infContratante, |
781
|
|
|
"CNPJ", |
782
|
|
|
$stdinfContratante->CNPJ, |
783
|
|
|
false, |
784
|
|
|
"CNPJ" |
785
|
|
|
); |
786
|
|
|
$this->dom->appChild($infANTT, $infContratante, 'Falta tag "infANTT"'); |
787
|
|
|
} |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
$this->dom->appChild($rodo, $infANTT, 'Falta tag "rodo"'); |
791
|
|
|
$this->rodo = $rodo; |
792
|
|
|
return $this->rodo; |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
/** |
796
|
|
|
* taginfCTe |
797
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/infCTe |
798
|
|
|
* |
799
|
|
|
* @param stdClass $std |
800
|
|
|
* @return DOMElement |
801
|
|
|
*/ |
802
|
|
|
public function taginfCTe(stdClass $std) |
803
|
|
|
{ |
804
|
|
|
$possible = [ |
805
|
|
|
'chCTe', |
806
|
|
|
'SegCodBarra', |
807
|
|
|
'indReentrega', |
808
|
|
|
'infUnidTransp', |
809
|
|
|
'peri', |
810
|
|
|
'infEntregaParcial' |
811
|
|
|
]; |
812
|
|
|
$std = $this->equilizeParameters($std, $possible); |
813
|
|
|
$infCTe = $this->dom->createElement("infCTe"); |
814
|
|
|
$this->dom->addChild( |
815
|
|
|
$infCTe, |
816
|
|
|
"chCTe", |
817
|
|
|
$std->chCTe, |
818
|
|
|
true, |
819
|
|
|
"Chave de Acesso CTe" |
820
|
|
|
); |
821
|
|
|
$this->dom->addChild( |
822
|
|
|
$infCTe, |
823
|
|
|
"SegCodBarra", |
824
|
|
|
$std->SegCodBarra, |
825
|
|
|
false, |
826
|
|
|
"Segundo código de barras do CTe" |
827
|
|
|
); |
828
|
|
|
$this->dom->addChild( |
829
|
|
|
$infCTe, |
830
|
|
|
"indReentrega", |
831
|
|
|
$std->indReentrega, |
832
|
|
|
false, |
833
|
|
|
"Indicador de Reentrega" |
834
|
|
|
); |
835
|
|
View Code Duplication |
if ($std->infUnidTransp != null) { |
|
|
|
|
836
|
|
|
$infUnidTransp = $this->taginfUnidTransp($std->infUnidTransp); |
837
|
|
|
$this->dom->appChild($infCTe, $infUnidTransp, 'Falta tag "infCTe"'); |
838
|
|
|
} |
839
|
|
|
if ($std->peri != null) { |
840
|
|
|
$peri = $this->tagperi($std->peri); |
841
|
|
|
$this->dom->appChild($infCTe, $peri, 'Falta tag "infCTe"'); |
842
|
|
|
} |
843
|
|
View Code Duplication |
if ($std->infEntregaParcial != null) { |
|
|
|
|
844
|
|
|
$possible = [ |
845
|
|
|
'qtdTotal', |
846
|
|
|
'qtdParcial' |
847
|
|
|
]; |
848
|
|
|
$stdinfEntregaParcial = $this->equilizeParameters($std->infEntregaParcial, $possible); |
849
|
|
|
$infEntregaParcial = $this->dom->createElement("infEntregaParcial"); |
850
|
|
|
$this->dom->addChild( |
851
|
|
|
$infEntregaParcial, |
852
|
|
|
"qtdTotal", |
853
|
|
|
$stdinfEntregaParcial->qtdTotal, |
854
|
|
|
true, |
855
|
|
|
"Quantidade total de volumes" |
856
|
|
|
); |
857
|
|
|
$this->dom->addChild( |
858
|
|
|
$infEntregaParcial, |
859
|
|
|
"qtdParcial", |
860
|
|
|
$stdinfEntregaParcial->qtdParcial, |
861
|
|
|
true, |
862
|
|
|
"Quantidade de volumes enviados no MDF-e" |
863
|
|
|
); |
864
|
|
|
$this->dom->appChild($infCTe, $infEntregaParcial, 'Falta tag "infCTe"'); |
865
|
|
|
} |
866
|
|
|
$this->dom->appChild($this->aInfMunDescarga, $infCTe, 'Falta tag "infMunDescarga"'); |
867
|
|
|
return $infCTe; |
868
|
|
|
} |
869
|
|
|
|
870
|
|
|
/** |
871
|
|
|
* tagperi |
872
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/peri |
873
|
|
|
* |
874
|
|
|
* @param stdClass $std |
875
|
|
|
* @return DOMElement |
876
|
|
|
*/ |
877
|
|
View Code Duplication |
public function tagperi(stdClass $std) |
|
|
|
|
878
|
|
|
{ |
879
|
|
|
$possible = [ |
880
|
|
|
'nONU', |
881
|
|
|
'xNomeAE', |
882
|
|
|
'xClaRisco', |
883
|
|
|
'grEmb', |
884
|
|
|
'qTotProd', |
885
|
|
|
'qVolTipo' |
886
|
|
|
]; |
887
|
|
|
$std = $this->equilizeParameters($std, $possible); |
888
|
|
|
$peri = $this->dom->createElement("peri"); |
889
|
|
|
$this->dom->addChild( |
890
|
|
|
$peri, |
891
|
|
|
"nONU", |
892
|
|
|
$std->nONU, |
893
|
|
|
true, |
894
|
|
|
"Número ONU/UN" |
895
|
|
|
); |
896
|
|
|
$this->dom->addChild( |
897
|
|
|
$peri, |
898
|
|
|
"xNomeAE", |
899
|
|
|
$std->xNomeAE, |
900
|
|
|
true, |
901
|
|
|
"Nome apropriado para embarque do produto" |
902
|
|
|
); |
903
|
|
|
$this->dom->addChild( |
904
|
|
|
$peri, |
905
|
|
|
"xClaRisco", |
906
|
|
|
$std->xClaRisco, |
907
|
|
|
true, |
908
|
|
|
"Classe ou subclasse/divisão, e risco subsidiário/risco secundário" |
909
|
|
|
); |
910
|
|
|
$this->dom->addChild( |
911
|
|
|
$peri, |
912
|
|
|
"grEmb", |
913
|
|
|
$std->grEmb, |
914
|
|
|
true, |
915
|
|
|
"Grupo de Embalagem" |
916
|
|
|
); |
917
|
|
|
$this->dom->addChild( |
918
|
|
|
$peri, |
919
|
|
|
"qTotProd", |
920
|
|
|
$std->qTotProd, |
921
|
|
|
true, |
922
|
|
|
"Quantidade total por produto" |
923
|
|
|
); |
924
|
|
|
$this->dom->addChild( |
925
|
|
|
$peri, |
926
|
|
|
"qVolTipo", |
927
|
|
|
$std->qVolTipo, |
928
|
|
|
true, |
929
|
|
|
"Quantidade e Tipo de volumes" |
930
|
|
|
); |
931
|
|
|
return $peri; |
932
|
|
|
} |
933
|
|
|
|
934
|
|
|
/** |
935
|
|
|
* taginfNFe |
936
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/infNFe |
937
|
|
|
* |
938
|
|
|
* @param stdClass $std |
939
|
|
|
* @return DOMElement |
940
|
|
|
*/ |
941
|
|
|
public function taginfNFe(stdClass $std) |
942
|
|
|
{ |
943
|
|
|
$possible = [ |
944
|
|
|
'chNFe', |
945
|
|
|
'SegCodBarra', |
946
|
|
|
'indReentrega', |
947
|
|
|
'infUnidTransp', |
948
|
|
|
'peri' |
949
|
|
|
]; |
950
|
|
|
$std = $this->equilizeParameters($std, $possible); |
951
|
|
|
$infNFe = $this->dom->createElement("infNFe"); |
952
|
|
|
$this->dom->addChild( |
953
|
|
|
$infNFe, |
954
|
|
|
"chNFe", |
955
|
|
|
$std->chNFe, |
956
|
|
|
true, |
957
|
|
|
"Chave de Acesso NFe" |
958
|
|
|
); |
959
|
|
|
$this->dom->addChild( |
960
|
|
|
$infNFe, |
961
|
|
|
"SegCodBarra", |
962
|
|
|
$std->SegCodBarra, |
963
|
|
|
false, |
964
|
|
|
"Segundo código de barras do NFe" |
965
|
|
|
); |
966
|
|
|
$this->dom->addChild( |
967
|
|
|
$infNFe, |
968
|
|
|
"indReentrega", |
969
|
|
|
$std->indReentrega, |
970
|
|
|
false, |
971
|
|
|
"Indicador de Reentrega" |
972
|
|
|
); |
973
|
|
View Code Duplication |
if ($std->infUnidTransp != null) { |
|
|
|
|
974
|
|
|
$infUnidTransp = $this->taginfUnidTransp($std->infUnidTransp); |
975
|
|
|
$this->dom->appChild($infNFe, $infUnidTransp, 'Falta tag "infNFe"'); |
976
|
|
|
} |
977
|
|
|
if ($std->peri != null) { |
978
|
|
|
$peri = $this->tagperi($std->peri); |
979
|
|
|
$this->dom->appChild($infNFe, $peri, 'Falta tag "infNFe"'); |
980
|
|
|
} |
981
|
|
|
$this->dom->appChild($this->aInfMunDescarga, $infNFe, 'Falta tag "infMunDescarga"'); |
982
|
|
|
return $infNFe; |
983
|
|
|
} |
984
|
|
|
|
985
|
|
|
/** |
986
|
|
|
* taginfMDFeTransp |
987
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/infMDFeTransp |
988
|
|
|
* |
989
|
|
|
* @param stdClass $std |
990
|
|
|
* @return DOMElement |
991
|
|
|
*/ |
992
|
|
|
public function taginfMDFeTransp(stdClass $std) |
993
|
|
|
{ |
994
|
|
|
$possible = [ |
995
|
|
|
'chNFe', |
996
|
|
|
'indReentrega', |
997
|
|
|
'infUnidTransp', |
998
|
|
|
'peri' |
999
|
|
|
]; |
1000
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1001
|
|
|
$infMDFeTransp = $this->dom->createElement("infMDFeTransp"); |
1002
|
|
|
$this->dom->addChild( |
1003
|
|
|
$infMDFeTransp, |
1004
|
|
|
"chNFe", |
1005
|
|
|
$std->chNFe, |
1006
|
|
|
true, |
1007
|
|
|
"Chave de Acesso NFe" |
1008
|
|
|
); |
1009
|
|
|
$this->dom->addChild( |
1010
|
|
|
$infMDFeTransp, |
1011
|
|
|
"indReentrega", |
1012
|
|
|
$std->indReentrega, |
1013
|
|
|
false, |
1014
|
|
|
"Indicador de Reentrega" |
1015
|
|
|
); |
1016
|
|
View Code Duplication |
if ($std->infUnidTransp != null) { |
|
|
|
|
1017
|
|
|
$infUnidTransp = $this->taginfUnidTransp($std->infUnidTransp); |
1018
|
|
|
$this->dom->appChild($infMDFeTransp, $infUnidTransp, 'Falta tag "infMDFeTransp"'); |
1019
|
|
|
} |
1020
|
|
|
if ($std->peri != null) { |
1021
|
|
|
$peri = $this->tagperi($std->peri); |
1022
|
|
|
$this->dom->appChild($infMDFeTransp, $peri, 'Falta tag "infMDFeTransp"'); |
1023
|
|
|
} |
1024
|
|
|
$this->dom->appChild($this->aInfMunDescarga, $infMDFeTransp, 'Falta tag "infMunDescarga"'); |
1025
|
|
|
return $infMDFeTransp; |
1026
|
|
|
} |
1027
|
|
|
|
1028
|
|
|
/** |
1029
|
|
|
* taginfUnidTransp |
1030
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidTransp |
1031
|
|
|
* |
1032
|
|
|
* @param stdClass $std |
1033
|
|
|
* @return DOMElement |
1034
|
|
|
*/ |
1035
|
|
|
public function taginfUnidTransp(stdClass $std) |
1036
|
|
|
{ |
1037
|
|
|
$possible = [ |
1038
|
|
|
'tpUnidTrans', |
1039
|
|
|
'idUnidTrans', |
1040
|
|
|
'qtdRat', |
1041
|
|
|
'lacUnidTransp', |
1042
|
|
|
'infUnidCarga' |
1043
|
|
|
]; |
1044
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1045
|
|
|
$infUnidTransp = $this->dom->createElement("infUnidTransp"); |
1046
|
|
|
$this->dom->addChild( |
1047
|
|
|
$infUnidTransp, |
1048
|
|
|
"tpUnidTrans", |
1049
|
|
|
$std->tpUnidTrans, |
1050
|
|
|
true, |
1051
|
|
|
"Tipo da Unidade de Transporte" |
1052
|
|
|
); |
1053
|
|
|
$this->dom->addChild( |
1054
|
|
|
$infUnidTransp, |
1055
|
|
|
"idUnidTrans", |
1056
|
|
|
$std->idUnidTrans, |
1057
|
|
|
false, |
1058
|
|
|
"Identificação da Unidade de Transporte" |
1059
|
|
|
); |
1060
|
|
View Code Duplication |
if ($std->lacUnidTransp != null) { |
|
|
|
|
1061
|
|
|
$possible = [ |
1062
|
|
|
'nLacre' |
1063
|
|
|
]; |
1064
|
|
|
$stdlacUnidTransp = $this->equilizeParameters($std->lacUnidTransp, $possible); |
1065
|
|
|
foreach ($stdlacUnidTransp->nLacre as $nLacre) { |
1066
|
|
|
$lacUnidTransp = $this->dom->createElement("lacUnidTransp"); |
1067
|
|
|
$this->dom->addChild( |
1068
|
|
|
$lacUnidTransp, |
1069
|
|
|
"nLacre", |
1070
|
|
|
$nLacre, |
1071
|
|
|
true, |
1072
|
|
|
"Número do lacre" |
1073
|
|
|
); |
1074
|
|
|
$this->dom->appChild($infUnidTransp, $lacUnidTransp, 'Falta tag "infUnidTransp"'); |
1075
|
|
|
} |
1076
|
|
|
} |
1077
|
|
|
if ($std->infUnidCarga != null) { |
1078
|
|
|
$infUnidCarga = $this->taginfUnidCarga($std->infUnidCarga); |
1079
|
|
|
$this->dom->appChild($infUnidTransp, $infUnidCarga, 'Falta tag "infUnidTransp"'); |
1080
|
|
|
} |
1081
|
|
|
$this->dom->addChild( |
1082
|
|
|
$infUnidTransp, |
1083
|
|
|
"qtdRat", |
1084
|
|
|
$std->qtdRat, |
1085
|
|
|
false, |
1086
|
|
|
"Quantidade rateada (Peso,Volume) " |
1087
|
|
|
); |
1088
|
|
|
return $infUnidTransp; |
1089
|
|
|
} |
1090
|
|
|
|
1091
|
|
|
/** |
1092
|
|
|
* taginfUnidCarga |
1093
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidCarga |
1094
|
|
|
* |
1095
|
|
|
* @param stdClass $std |
1096
|
|
|
* @return DOMElement |
1097
|
|
|
*/ |
1098
|
|
|
public function taginfUnidCarga(stdClass $std) |
1099
|
|
|
{ |
1100
|
|
|
$possible = [ |
1101
|
|
|
'tpUnidCarga', |
1102
|
|
|
'idUnidCarga', |
1103
|
|
|
'lacUnidCarga', |
1104
|
|
|
'qtdRat' |
1105
|
|
|
]; |
1106
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1107
|
|
|
$infUnidCarga = $this->dom->createElement("infUnidCarga"); |
1108
|
|
|
$this->dom->addChild( |
1109
|
|
|
$infUnidCarga, |
1110
|
|
|
"tpUnidCarga", |
1111
|
|
|
$std->tpUnidCarga, |
1112
|
|
|
false, |
1113
|
|
|
"Tipo da Unidade de Carga" |
1114
|
|
|
); |
1115
|
|
|
$this->dom->addChild( |
1116
|
|
|
$infUnidCarga, |
1117
|
|
|
"idUnidCarga", |
1118
|
|
|
$std->idUnidCarga, |
1119
|
|
|
false, |
1120
|
|
|
"Identificação da Unidade de Carga " |
1121
|
|
|
); |
1122
|
|
View Code Duplication |
if ($std->lacUnidCarga != null) { |
|
|
|
|
1123
|
|
|
$possible = [ |
1124
|
|
|
'nLacre' |
1125
|
|
|
]; |
1126
|
|
|
$stdlacUnidCarga = $this->equilizeParameters($std->lacUnidCarga, $possible); |
1127
|
|
|
foreach ($stdlacUnidCarga->nLacre as $nLacre) { |
1128
|
|
|
$lacUnidCarga = $this->dom->createElement("lacUnidCarga"); |
1129
|
|
|
$this->dom->addChild( |
1130
|
|
|
$lacUnidCarga, |
1131
|
|
|
"nLacre", |
1132
|
|
|
$nLacre, |
1133
|
|
|
true, |
1134
|
|
|
"Número do lacre" |
1135
|
|
|
); |
1136
|
|
|
$this->dom->appChild($infUnidCarga, $lacUnidCarga, 'Falta tag "infUnidCarga"'); |
1137
|
|
|
} |
1138
|
|
|
} |
1139
|
|
|
$this->dom->addChild( |
1140
|
|
|
$infUnidCarga, |
1141
|
|
|
"qtdRat", |
1142
|
|
|
$std->qtdRat, |
1143
|
|
|
false, |
1144
|
|
|
"Quantidade rateada (Peso,Volume) " |
1145
|
|
|
); |
1146
|
|
|
|
1147
|
|
|
return $infUnidCarga ; |
1148
|
|
|
} |
1149
|
|
|
|
1150
|
|
|
/** |
1151
|
|
|
* tagseg |
1152
|
|
|
* tag MDFe/infMDFe/seg |
1153
|
|
|
* |
1154
|
|
|
* @param stdClass $std |
1155
|
|
|
* @return DOMElement |
1156
|
|
|
*/ |
1157
|
|
|
public function tagseg(stdClass $std) |
1158
|
|
|
{ |
1159
|
|
|
$possible = [ |
1160
|
|
|
'respSeg', |
1161
|
|
|
'CNPJ', |
1162
|
|
|
'CPF', |
1163
|
|
|
'infSeg', |
1164
|
|
|
'nApol', |
1165
|
|
|
'nAver' |
1166
|
|
|
]; |
1167
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1168
|
|
|
$seg = $this->dom->createElement("seg"); |
1169
|
|
|
$infResp = $this->dom->createElement("infResp"); |
1170
|
|
|
$this->dom->addChild( |
1171
|
|
|
$infResp, |
1172
|
|
|
"respSeg", |
1173
|
|
|
$std->respSeg, |
1174
|
|
|
true, |
1175
|
|
|
"Responsável pelo seguro" |
1176
|
|
|
); |
1177
|
|
|
$this->dom->addChild( |
1178
|
|
|
$infResp, |
1179
|
|
|
"CNPJ", |
1180
|
|
|
$std->CNPJ, |
1181
|
|
|
false, |
1182
|
|
|
"Número do CNPJ do responsável pelo seguro" |
1183
|
|
|
); |
1184
|
|
|
$this->dom->addChild( |
1185
|
|
|
$infResp, |
1186
|
|
|
"CPF", |
1187
|
|
|
$std->CPF, |
1188
|
|
|
false, |
1189
|
|
|
"Número do CPF do responsável pelo seguro" |
1190
|
|
|
); |
1191
|
|
|
$this->dom->appChild($seg, $infResp, 'Falta tag "seg"'); |
1192
|
|
View Code Duplication |
if ($std->infSeg != null) { |
|
|
|
|
1193
|
|
|
$possible = [ |
1194
|
|
|
'xSeg', |
1195
|
|
|
'CNPJ' |
1196
|
|
|
]; |
1197
|
|
|
$stdinfSeg = $this->equilizeParameters($std->infSeg, $possible); |
1198
|
|
|
$infSeg = $this->dom->createElement("infSeg"); |
1199
|
|
|
$this->dom->addChild( |
1200
|
|
|
$infSeg, |
1201
|
|
|
"xSeg", |
1202
|
|
|
$stdinfSeg->xSeg, |
1203
|
|
|
true, |
1204
|
|
|
"Nome da Seguradora" |
1205
|
|
|
); |
1206
|
|
|
$this->dom->addChild( |
1207
|
|
|
$infSeg, |
1208
|
|
|
"CNPJ", |
1209
|
|
|
$stdinfSeg->CNPJ, |
1210
|
|
|
false, |
1211
|
|
|
"Número do CNPJ da seguradora" |
1212
|
|
|
); |
1213
|
|
|
$this->dom->appChild($seg, $infSeg, 'Falta tag "seg"'); |
1214
|
|
|
} |
1215
|
|
|
$this->dom->addChild( |
1216
|
|
|
$seg, |
1217
|
|
|
"nApol", |
1218
|
|
|
$std->nApol, |
1219
|
|
|
false, |
1220
|
|
|
"Número da Apólice" |
1221
|
|
|
); |
1222
|
|
|
if ($std->nAver != null) { |
1223
|
|
|
foreach ($std->nAver as $nAver) { |
1224
|
|
|
$this->dom->addChild( |
1225
|
|
|
$seg, |
1226
|
|
|
"nAver", |
1227
|
|
|
$nAver, |
1228
|
|
|
true, |
1229
|
|
|
"Número da Averbação" |
1230
|
|
|
); |
1231
|
|
|
} |
1232
|
|
|
} |
1233
|
|
|
$this->seg = $seg; |
1234
|
|
|
return $seg; |
1235
|
|
|
} |
1236
|
|
|
|
1237
|
|
|
/** |
1238
|
|
|
* tagTot |
1239
|
|
|
* tag MDFe/infMDFe/tot |
1240
|
|
|
* |
1241
|
|
|
* @param stdClass $std |
1242
|
|
|
* @return DOMElement |
1243
|
|
|
*/ |
1244
|
|
View Code Duplication |
public function tagtot(stdClass $std) |
|
|
|
|
1245
|
|
|
{ |
1246
|
|
|
$possible = [ |
1247
|
|
|
'qCTe', |
1248
|
|
|
'qNFe', |
1249
|
|
|
'qMDFe', |
1250
|
|
|
'vCarga', |
1251
|
|
|
'cUnid', |
1252
|
|
|
'qCarga' |
1253
|
|
|
]; |
1254
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1255
|
|
|
$tot = $this->dom->createElement("tot"); |
1256
|
|
|
$this->dom->addChild( |
1257
|
|
|
$tot, |
1258
|
|
|
"qCTe", |
1259
|
|
|
$std->qCTe, |
1260
|
|
|
false, |
1261
|
|
|
"Quantidade total de CT-e relacionados no Manifesto" |
1262
|
|
|
); |
1263
|
|
|
$this->dom->addChild( |
1264
|
|
|
$tot, |
1265
|
|
|
"qNFe", |
1266
|
|
|
$std->qNFe, |
1267
|
|
|
false, |
1268
|
|
|
"Quantidade total de NF-e relacionados no Manifesto" |
1269
|
|
|
); |
1270
|
|
|
$this->dom->addChild( |
1271
|
|
|
$tot, |
1272
|
|
|
"qMDFe", |
1273
|
|
|
$std->qMDFe, |
1274
|
|
|
false, |
1275
|
|
|
"Quantidade total de MDF-e relacionados no Manifesto" |
1276
|
|
|
); |
1277
|
|
|
$this->dom->addChild( |
1278
|
|
|
$tot, |
1279
|
|
|
"vCarga", |
1280
|
|
|
$std->vCarga, |
1281
|
|
|
true, |
1282
|
|
|
"Valor total da mercadoria/carga transportada" |
1283
|
|
|
); |
1284
|
|
|
$this->dom->addChild( |
1285
|
|
|
$tot, |
1286
|
|
|
"cUnid", |
1287
|
|
|
$std->cUnid, |
1288
|
|
|
true, |
1289
|
|
|
"Código da unidade de medida do Peso Bruto da Carga / Mercadoria Transportada" |
1290
|
|
|
); |
1291
|
|
|
$this->dom->addChild( |
1292
|
|
|
$tot, |
1293
|
|
|
"qCarga", |
1294
|
|
|
$std->qCarga, |
1295
|
|
|
true, |
1296
|
|
|
"Peso Bruto Total da Carga / Mercadoria Transportada" |
1297
|
|
|
); |
1298
|
|
|
$this->tot = $tot; |
1299
|
|
|
return $tot; |
1300
|
|
|
} |
1301
|
|
|
|
1302
|
|
|
/** |
1303
|
|
|
* tagLacres |
1304
|
|
|
* tag MDFe/infMDFe/lacres |
1305
|
|
|
* |
1306
|
|
|
* @param stdClass $std |
1307
|
|
|
* @return DOMElement |
1308
|
|
|
*/ |
1309
|
|
View Code Duplication |
public function taglacres(stdClass $std) |
|
|
|
|
1310
|
|
|
{ |
1311
|
|
|
$possible = [ |
1312
|
|
|
'nLacre' |
1313
|
|
|
]; |
1314
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1315
|
|
|
foreach ($std->nLacre as $nLacre) { |
1316
|
|
|
$lacres = $this->dom->createElement("lacres"); |
1317
|
|
|
$this->dom->addChild( |
1318
|
|
|
$lacres, |
1319
|
|
|
"nLacre", |
1320
|
|
|
$nLacre, |
1321
|
|
|
false, |
1322
|
|
|
"Número do lacre" |
1323
|
|
|
); |
1324
|
|
|
$this->aLacres[] = $lacres; //array de DOMNode |
1325
|
|
|
} |
1326
|
|
|
return $this->aLacres; |
1327
|
|
|
} |
1328
|
|
|
|
1329
|
|
|
/** |
1330
|
|
|
* taginfAdic |
1331
|
|
|
* Grupo de Informações Adicionais Z01 pai A01 |
1332
|
|
|
* tag MDFe/infMDFe/infAdic (opcional) |
1333
|
|
|
* |
1334
|
|
|
* @param stdClass $std |
1335
|
|
|
* @return DOMElement |
1336
|
|
|
*/ |
1337
|
|
View Code Duplication |
public function taginfAdic(stdClass $std) |
|
|
|
|
1338
|
|
|
{ |
1339
|
|
|
$possible = [ |
1340
|
|
|
'infAdFisco', |
1341
|
|
|
'infCpl' |
1342
|
|
|
]; |
1343
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1344
|
|
|
$infAdic = $this->dom->createElement("infAdic"); |
1345
|
|
|
$this->dom->addChild( |
1346
|
|
|
$infAdic, |
1347
|
|
|
"infAdFisco", |
1348
|
|
|
$std->infAdFisco, |
1349
|
|
|
false, |
1350
|
|
|
"Informações Adicionais de Interesse do Fisco" |
1351
|
|
|
); |
1352
|
|
|
$this->dom->addChild( |
1353
|
|
|
$infAdic, |
1354
|
|
|
"infCpl", |
1355
|
|
|
$std->infCpl, |
1356
|
|
|
false, |
1357
|
|
|
"Informações Complementares de interesse do Contribuinte" |
1358
|
|
|
); |
1359
|
|
|
$this->infAdic = $infAdic; |
1360
|
|
|
return $infAdic; |
1361
|
|
|
} |
1362
|
|
|
|
1363
|
|
|
/** |
1364
|
|
|
* tagautXML |
1365
|
|
|
* tag MDFe/infMDFe/autXML |
1366
|
|
|
* |
1367
|
|
|
* Autorizados para download do XML do MDF-e |
1368
|
|
|
* |
1369
|
|
|
* @param stdClass $std |
1370
|
|
|
* @return DOMElement |
1371
|
|
|
*/ |
1372
|
|
View Code Duplication |
public function tagautXML(stdClass $std) |
|
|
|
|
1373
|
|
|
{ |
1374
|
|
|
$possible = [ |
1375
|
|
|
'CNPJ', |
1376
|
|
|
'CPF' |
1377
|
|
|
]; |
1378
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1379
|
|
|
$autXML = $this->dom->createElement("autXML"); |
1380
|
|
|
$this->dom->addChild( |
1381
|
|
|
$autXML, |
1382
|
|
|
"CNPJ", |
1383
|
|
|
$std->CNPJ, |
1384
|
|
|
false, |
1385
|
|
|
"CNPJ do autorizado" |
1386
|
|
|
); |
1387
|
|
|
$this->dom->addChild( |
1388
|
|
|
$autXML, |
1389
|
|
|
"CPF", |
1390
|
|
|
$std->CPF, |
1391
|
|
|
false, |
1392
|
|
|
"CPF do autorizado" |
1393
|
|
|
); |
1394
|
|
|
$this->autXML[] = $autXML; |
1395
|
|
|
return $this->autXML; |
1396
|
|
|
} |
1397
|
|
|
|
1398
|
|
|
/** |
1399
|
|
|
* buildInfModal |
1400
|
|
|
* tag MDFe/infMDFe/infModal |
1401
|
|
|
* |
1402
|
|
|
* @return DOMElement |
1403
|
|
|
*/ |
1404
|
|
|
public function buildInfModal() |
1405
|
|
|
{ |
1406
|
|
|
$infModal = $this->dom->createElement("infModal"); |
1407
|
|
|
$infModal->setAttribute("versaoModal", $this->versao); |
1408
|
|
|
$this->infModal = $infModal; |
1409
|
|
|
return $infModal; |
1410
|
|
|
} |
1411
|
|
|
|
1412
|
|
|
/** |
1413
|
|
|
* tagAereo |
1414
|
|
|
* tag MDFe/infMDFe/infModal/aereo |
1415
|
|
|
* |
1416
|
|
|
* @param string $nac |
1417
|
|
|
* @param string $matr |
1418
|
|
|
* @param string $nVoo |
1419
|
|
|
* @param string $cAerEmb |
1420
|
|
|
* @param string $cAerDes |
1421
|
|
|
* @param string $dVoo |
1422
|
|
|
* |
1423
|
|
|
* @return DOMElement |
1424
|
|
|
*/ |
1425
|
|
|
|
1426
|
|
|
public function tagAereo( |
1427
|
|
|
$nac = '', |
1428
|
|
|
$matr = '', |
1429
|
|
|
$nVoo = '', |
1430
|
|
|
$cAerEmb = '', |
1431
|
|
|
$cAerDes = '', |
1432
|
|
|
$dVoo = '' |
1433
|
|
|
) { |
1434
|
|
|
$aereo = $this->dom->createElement("aereo"); |
1435
|
|
|
$this->dom->addChild( |
1436
|
|
|
$aereo, |
1437
|
|
|
"nac", |
1438
|
|
|
$nac, |
1439
|
|
|
true, |
1440
|
|
|
"Marca da Nacionalidade da aeronave" |
1441
|
|
|
); |
1442
|
|
|
$this->dom->addChild( |
1443
|
|
|
$aereo, |
1444
|
|
|
"matr", |
1445
|
|
|
$matr, |
1446
|
|
|
true, |
1447
|
|
|
"Marca de Matrícula da aeronave" |
1448
|
|
|
); |
1449
|
|
|
$this->dom->addChild( |
1450
|
|
|
$aereo, |
1451
|
|
|
"nVoo", |
1452
|
|
|
$nVoo, |
1453
|
|
|
true, |
1454
|
|
|
"Número do Vôo" |
1455
|
|
|
); |
1456
|
|
|
$this->dom->addChild( |
1457
|
|
|
$aereo, |
1458
|
|
|
"cAerEmb", |
1459
|
|
|
$cAerEmb, |
1460
|
|
|
true, |
1461
|
|
|
"Aeródromo de Embarque - Código IATA" |
1462
|
|
|
); |
1463
|
|
|
$this->dom->addChild( |
1464
|
|
|
$aereo, |
1465
|
|
|
"cAerDes", |
1466
|
|
|
$cAerDes, |
1467
|
|
|
true, |
1468
|
|
|
"Aeródromo de Destino - Código IATA" |
1469
|
|
|
); |
1470
|
|
|
$this->dom->addChild( |
1471
|
|
|
$aereo, |
1472
|
|
|
"dVoo", |
1473
|
|
|
$dVoo, |
1474
|
|
|
true, |
1475
|
|
|
"Data do Vôo" |
1476
|
|
|
); |
1477
|
|
|
$this->aereo = $aereo; |
1478
|
|
|
return $aereo; |
1479
|
|
|
} |
1480
|
|
|
|
1481
|
|
|
/** |
1482
|
|
|
* tagTrem |
1483
|
|
|
* tag MDFe/infMDFe/infModal/ferrov/trem |
1484
|
|
|
* |
1485
|
|
|
* @param string $xPref |
1486
|
|
|
* @param string $dhTrem |
1487
|
|
|
* @param string $xOri |
1488
|
|
|
* @param string $xDest |
1489
|
|
|
* @param string $qVag |
1490
|
|
|
* |
1491
|
|
|
* @return DOMElement |
1492
|
|
|
*/ |
1493
|
|
|
|
1494
|
|
|
public function tagTrem( |
1495
|
|
|
$xPref = '', |
1496
|
|
|
$dhTrem = '', |
1497
|
|
|
$xOri = '', |
1498
|
|
|
$xDest = '', |
1499
|
|
|
$qVag = '' |
1500
|
|
|
) { |
1501
|
|
|
$trem = $this->dom->createElement("trem"); |
1502
|
|
|
$this->dom->addChild( |
1503
|
|
|
$trem, |
1504
|
|
|
"xPref", |
1505
|
|
|
$xPref, |
1506
|
|
|
true, |
1507
|
|
|
"Prefixo do Trem" |
1508
|
|
|
); |
1509
|
|
|
$this->dom->addChild( |
1510
|
|
|
$trem, |
1511
|
|
|
"dhTrem", |
1512
|
|
|
$dhTrem, |
1513
|
|
|
false, |
1514
|
|
|
"Data e hora de liberação do trem na origem" |
1515
|
|
|
); |
1516
|
|
|
$this->dom->addChild( |
1517
|
|
|
$trem, |
1518
|
|
|
"xOri", |
1519
|
|
|
$xOri, |
1520
|
|
|
true, |
1521
|
|
|
"Origem do Trem" |
1522
|
|
|
); |
1523
|
|
|
$this->dom->addChild( |
1524
|
|
|
$trem, |
1525
|
|
|
"xDest", |
1526
|
|
|
$xDest, |
1527
|
|
|
true, |
1528
|
|
|
"Destino do Trem" |
1529
|
|
|
); |
1530
|
|
|
$this->dom->addChild( |
1531
|
|
|
$trem, |
1532
|
|
|
"qVag", |
1533
|
|
|
$qVag, |
1534
|
|
|
true, |
1535
|
|
|
"Quantidade de vagões" |
1536
|
|
|
); |
1537
|
|
|
$this->trem = $trem; |
1538
|
|
|
return $trem; |
1539
|
|
|
} |
1540
|
|
|
|
1541
|
|
|
/** |
1542
|
|
|
* tagVag |
1543
|
|
|
* tag MDFe/infMDFe/infModal/ferrov/trem/vag |
1544
|
|
|
* |
1545
|
|
|
* @param string $serie |
1546
|
|
|
* @param string $nVag |
1547
|
|
|
* @param string $nSeq |
1548
|
|
|
* @param string $tonUtil |
1549
|
|
|
* |
1550
|
|
|
* @return DOMElement |
1551
|
|
|
*/ |
1552
|
|
|
|
1553
|
|
|
public function tagVag( |
1554
|
|
|
$serie = '', |
1555
|
|
|
$nVag = '', |
1556
|
|
|
$nSeq = '', |
1557
|
|
|
$tonUtil = '' |
1558
|
|
|
) { |
1559
|
|
|
$vag = $this->dom->createElement("vag"); |
1560
|
|
|
$this->dom->addChild( |
1561
|
|
|
$vag, |
1562
|
|
|
"serie", |
1563
|
|
|
$serie, |
1564
|
|
|
true, |
1565
|
|
|
"Série de Identificação do vagão" |
1566
|
|
|
); |
1567
|
|
|
$this->dom->addChild( |
1568
|
|
|
$vag, |
1569
|
|
|
"nVag", |
1570
|
|
|
$nVag, |
1571
|
|
|
true, |
1572
|
|
|
"Número de Identificação do vagão" |
1573
|
|
|
); |
1574
|
|
|
$this->dom->addChild( |
1575
|
|
|
$vag, |
1576
|
|
|
"nSeq", |
1577
|
|
|
$nSeq, |
1578
|
|
|
false, |
1579
|
|
|
"Sequência do vagão na composição" |
1580
|
|
|
); |
1581
|
|
|
$this->dom->addChild( |
1582
|
|
|
$vag, |
1583
|
|
|
"TU", |
1584
|
|
|
$tonUtil, |
1585
|
|
|
true, |
1586
|
|
|
"Tonelada Útil" |
1587
|
|
|
); |
1588
|
|
|
$this->aVag[] = $vag; |
|
|
|
|
1589
|
|
|
return $vag; |
1590
|
|
|
} |
1591
|
|
|
|
1592
|
|
|
/** |
1593
|
|
|
* tagAqua |
1594
|
|
|
* tag MDFe/infMDFe/infModal/Aqua |
1595
|
|
|
* |
1596
|
|
|
* @param string $cnpjAgeNav |
1597
|
|
|
* @param string $tpEmb |
1598
|
|
|
* @param string $cEmbar |
1599
|
|
|
* @param string $nViagem |
1600
|
|
|
* @param string $cPrtEmb |
1601
|
|
|
* @param string $cPrtDest |
1602
|
|
|
* |
1603
|
|
|
* @return DOMElement |
1604
|
|
|
*/ |
1605
|
|
|
|
1606
|
|
|
public function tagAqua( |
1607
|
|
|
$cnpjAgeNav = '', |
1608
|
|
|
$tpEmb = '', |
1609
|
|
|
$cEmbar = '', |
1610
|
|
|
$nViagem = '', |
1611
|
|
|
$cPrtEmb = '', |
1612
|
|
|
$cPrtDest = '' |
1613
|
|
|
) { |
1614
|
|
|
$aqua = $this->dom->createElement("Aqua"); |
1615
|
|
|
$this->dom->addChild( |
1616
|
|
|
$aqua, |
1617
|
|
|
"CNPJAgeNav", |
1618
|
|
|
$cnpjAgeNav, |
1619
|
|
|
true, |
1620
|
|
|
"CNPJ da Agência de Navegação" |
1621
|
|
|
); |
1622
|
|
|
$this->dom->addChild( |
1623
|
|
|
$aqua, |
1624
|
|
|
"tpEmb", |
1625
|
|
|
$tpEmb, |
1626
|
|
|
true, |
1627
|
|
|
"Código do tipo de embarcação" |
1628
|
|
|
); |
1629
|
|
|
$this->dom->addChild( |
1630
|
|
|
$aqua, |
1631
|
|
|
"cEmbar", |
1632
|
|
|
$cEmbar, |
1633
|
|
|
true, |
1634
|
|
|
"Código da Embarcação" |
1635
|
|
|
); |
1636
|
|
|
$this->dom->addChild( |
1637
|
|
|
$aqua, |
1638
|
|
|
"nViagem", |
1639
|
|
|
$nViagem, |
1640
|
|
|
true, |
1641
|
|
|
"Número da Viagem" |
1642
|
|
|
); |
1643
|
|
|
$this->dom->addChild( |
1644
|
|
|
$aqua, |
1645
|
|
|
"cPrtEmb", |
1646
|
|
|
$cPrtEmb, |
1647
|
|
|
true, |
1648
|
|
|
"Código do Porto de Embarque" |
1649
|
|
|
); |
1650
|
|
|
$this->dom->addChild( |
1651
|
|
|
$aqua, |
1652
|
|
|
"cPrtDest", |
1653
|
|
|
$cPrtDest, |
1654
|
|
|
true, |
1655
|
|
|
"Código do Porto de Destino" |
1656
|
|
|
); |
1657
|
|
|
$this->aqua = $aqua; |
1658
|
|
|
return $aqua; |
1659
|
|
|
} |
1660
|
|
|
|
1661
|
|
|
/** |
1662
|
|
|
* tagInfTermCarreg |
1663
|
|
|
* tag MDFe/infMDFe/infModal/Aqua/infTermCarreg |
1664
|
|
|
* |
1665
|
|
|
* @param string $cTermCarreg |
1666
|
|
|
* |
1667
|
|
|
* @return DOMElement |
1668
|
|
|
*/ |
1669
|
|
|
public function taginfTermCarreg( |
1670
|
|
|
$cTermCarreg = '' |
1671
|
|
|
) { |
1672
|
|
|
$infTermCarreg = $this->dom->createElement("infTermCarreg"); |
1673
|
|
|
$this->dom->addChild( |
1674
|
|
|
$infTermCarreg, |
1675
|
|
|
"cTermCarreg", |
1676
|
|
|
$cTermCarreg, |
1677
|
|
|
true, |
1678
|
|
|
"Código do Terminal de Carregamento" |
1679
|
|
|
); |
1680
|
|
|
$this->aInfTermCarreg[] = $infTermCarreg; |
|
|
|
|
1681
|
|
|
return $infTermCarreg; |
1682
|
|
|
} |
1683
|
|
|
/** |
1684
|
|
|
* tagInfTermDescarreg |
1685
|
|
|
* tag MDFe/infMDFe/infModal/Aqua/infTermDescarreg |
1686
|
|
|
* |
1687
|
|
|
* @param string cTermDescarreg |
1688
|
|
|
* |
1689
|
|
|
* @return DOMElement |
1690
|
|
|
*/ |
1691
|
|
|
public function taginfTermDescarreg( |
1692
|
|
|
$cTermDescarreg = '' |
1693
|
|
|
) { |
1694
|
|
|
$infTermDescarreg = $this->dom->createElement("infTermDescarreg"); |
1695
|
|
|
$this->dom->addChild( |
1696
|
|
|
$infTermDescarreg, |
1697
|
|
|
"cTermCarreg", |
1698
|
|
|
$cTermDescarreg, |
1699
|
|
|
true, |
1700
|
|
|
"Código do Terminal de Descarregamento" |
1701
|
|
|
); |
1702
|
|
|
$this->aInfTermDescarreg[] = $infTermDescarreg; |
|
|
|
|
1703
|
|
|
return $infTermDescarreg; |
1704
|
|
|
} |
1705
|
|
|
/** |
1706
|
|
|
* tagInfEmbComb |
1707
|
|
|
* tag MDFe/infMDFe/infModal/Aqua/infEmbComb |
1708
|
|
|
* |
1709
|
|
|
* @param string cEmbComb |
1710
|
|
|
* |
1711
|
|
|
* @return DOMElement |
1712
|
|
|
*/ |
1713
|
|
|
public function taginfEmbComb( |
1714
|
|
|
$cEmbComb = '' |
1715
|
|
|
) { |
1716
|
|
|
$infEmbComb = $this->dom->createElement("infEmbComb"); |
1717
|
|
|
$this->dom->addChild( |
1718
|
|
|
$infEmbComb, |
1719
|
|
|
"cEmbComb", |
1720
|
|
|
$cEmbComb, |
1721
|
|
|
true, |
1722
|
|
|
"Código da embarcação do comboio" |
1723
|
|
|
); |
1724
|
|
|
$this->aInfEmbComb[] = $infEmbComb; |
|
|
|
|
1725
|
|
|
return $infEmbComb; |
1726
|
|
|
} |
1727
|
|
|
|
1728
|
|
|
/** |
1729
|
|
|
* tagVeicTracao |
1730
|
|
|
* tag MDFe/infMDFe/infModal/rodo/veicTracao |
1731
|
|
|
* |
1732
|
|
|
* @param stdClass $std |
1733
|
|
|
* @return DOMElement |
1734
|
|
|
*/ |
1735
|
|
|
|
1736
|
|
|
public function tagveicTracao(stdClass $std) |
1737
|
|
|
{ |
1738
|
|
|
$possible = [ |
1739
|
|
|
'cInt', |
1740
|
|
|
'placa', |
1741
|
|
|
'RENAVAM', |
1742
|
|
|
'tara', |
1743
|
|
|
'capKG', |
1744
|
|
|
'capM3', |
1745
|
|
|
'prop', |
1746
|
|
|
'condutor', |
1747
|
|
|
'tpRod', |
1748
|
|
|
'tpCar', |
1749
|
|
|
'UF' |
1750
|
|
|
]; |
1751
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1752
|
|
|
$veicTracao = $this->dom->createElement("veicTracao"); |
1753
|
|
|
$this->dom->addChild( |
1754
|
|
|
$veicTracao, |
1755
|
|
|
"cInt", |
1756
|
|
|
$std->cInt, |
1757
|
|
|
false, |
1758
|
|
|
"Código interno do veículo" |
1759
|
|
|
); |
1760
|
|
|
$this->dom->addChild( |
1761
|
|
|
$veicTracao, |
1762
|
|
|
"placa", |
1763
|
|
|
$std->placa, |
1764
|
|
|
true, |
1765
|
|
|
"Placa do veículo" |
1766
|
|
|
); |
1767
|
|
|
$this->dom->addChild( |
1768
|
|
|
$veicTracao, |
1769
|
|
|
"RENAVAM", |
1770
|
|
|
$std->RENAVAM, |
1771
|
|
|
false, |
1772
|
|
|
"RENAVAM" |
1773
|
|
|
); |
1774
|
|
|
$this->dom->addChild( |
1775
|
|
|
$veicTracao, |
1776
|
|
|
"tara", |
1777
|
|
|
$std->tara, |
1778
|
|
|
true, |
1779
|
|
|
"Tara em KG" |
1780
|
|
|
); |
1781
|
|
|
$this->dom->addChild( |
1782
|
|
|
$veicTracao, |
1783
|
|
|
"capKG", |
1784
|
|
|
$std->capKG, |
1785
|
|
|
false, |
1786
|
|
|
"Capacidade em KG" |
1787
|
|
|
); |
1788
|
|
|
$this->dom->addChild( |
1789
|
|
|
$veicTracao, |
1790
|
|
|
"capM3", |
1791
|
|
|
$std->capM3, |
1792
|
|
|
false, |
1793
|
|
|
"Capacidade em M3" |
1794
|
|
|
); |
1795
|
|
View Code Duplication |
if ($std->prop != null) { |
|
|
|
|
1796
|
|
|
$possible = [ |
1797
|
|
|
'CPF', |
1798
|
|
|
'CNPJ', |
1799
|
|
|
'RNTRC', |
1800
|
|
|
'xNome', |
1801
|
|
|
'IE', |
1802
|
|
|
'UF', |
1803
|
|
|
'TpProp' |
1804
|
|
|
]; |
1805
|
|
|
$stdprop = $this->equilizeParameters($std->prop, $possible); |
1806
|
|
|
$prop = $this->dom->createElement("prop"); |
1807
|
|
|
$this->dom->addChild( |
1808
|
|
|
$prop, |
1809
|
|
|
"CPF", |
1810
|
|
|
$stdprop->CPF, |
1811
|
|
|
true, |
1812
|
|
|
"Número do CPF" |
1813
|
|
|
); |
1814
|
|
|
$this->dom->addChild( |
1815
|
|
|
$prop, |
1816
|
|
|
"CNPJ", |
1817
|
|
|
$stdprop->CNPJ, |
1818
|
|
|
true, |
1819
|
|
|
"Número do CNPJ" |
1820
|
|
|
); |
1821
|
|
|
$this->dom->addChild( |
1822
|
|
|
$prop, |
1823
|
|
|
"RNTRC", |
1824
|
|
|
$stdprop->RNTRC, |
1825
|
|
|
true, |
1826
|
|
|
"RNTRC" |
1827
|
|
|
); |
1828
|
|
|
$this->dom->addChild( |
1829
|
|
|
$prop, |
1830
|
|
|
"xNome", |
1831
|
|
|
$stdprop->xNome, |
1832
|
|
|
true, |
1833
|
|
|
"Razão Social" |
1834
|
|
|
); |
1835
|
|
|
$this->dom->addChild( |
1836
|
|
|
$prop, |
1837
|
|
|
"IE", |
1838
|
|
|
$stdprop->IE, |
1839
|
|
|
true, |
1840
|
|
|
"Inscrição Estadual" |
1841
|
|
|
); |
1842
|
|
|
$this->dom->addChild( |
1843
|
|
|
$prop, |
1844
|
|
|
"UF", |
1845
|
|
|
$stdprop->UF, |
1846
|
|
|
true, |
1847
|
|
|
"Unidade da Federação" |
1848
|
|
|
); |
1849
|
|
|
$this->dom->addChild( |
1850
|
|
|
$prop, |
1851
|
|
|
"TpProp", |
1852
|
|
|
$stdprop->TpProp, |
1853
|
|
|
true, |
1854
|
|
|
"Tipo Proprietário" |
1855
|
|
|
); |
1856
|
|
|
$this->dom->appChild($veicTracao, $prop, 'Falta tag "veicTracao"'); |
1857
|
|
|
} |
1858
|
|
|
|
1859
|
|
View Code Duplication |
if ($std->condutor != null) { |
|
|
|
|
1860
|
|
|
$possible = [ |
1861
|
|
|
'xNome', |
1862
|
|
|
'CPF' |
1863
|
|
|
]; |
1864
|
|
|
foreach ($std->condutor as $condutor) { |
1865
|
|
|
$stdcondutor = $this->equilizeParameters($condutor, $possible); |
1866
|
|
|
$tagcondutor = $this->dom->createElement("condutor"); |
1867
|
|
|
$this->dom->addChild( |
1868
|
|
|
$tagcondutor, |
1869
|
|
|
"xNome", |
1870
|
|
|
$stdcondutor->xNome, |
1871
|
|
|
true, |
1872
|
|
|
"Nome do Condutor " |
1873
|
|
|
); |
1874
|
|
|
$this->dom->addChild( |
1875
|
|
|
$tagcondutor, |
1876
|
|
|
"CPF", |
1877
|
|
|
$stdcondutor->CPF, |
1878
|
|
|
true, |
1879
|
|
|
"CPF do Condutor " |
1880
|
|
|
); |
1881
|
|
|
$this->dom->appChild($veicTracao, $tagcondutor, 'Falta tag "veicTracao"'); |
1882
|
|
|
} |
1883
|
|
|
} |
1884
|
|
|
$this->dom->addChild( |
1885
|
|
|
$veicTracao, |
1886
|
|
|
"tpRod", |
1887
|
|
|
$std->tpRod, |
1888
|
|
|
true, |
1889
|
|
|
"Tipo de rodado" |
1890
|
|
|
); |
1891
|
|
|
$this->dom->addChild( |
1892
|
|
|
$veicTracao, |
1893
|
|
|
"tpCar", |
1894
|
|
|
$std->tpCar, |
1895
|
|
|
true, |
1896
|
|
|
"Tipo de carroceria" |
1897
|
|
|
); |
1898
|
|
|
$this->dom->addChild( |
1899
|
|
|
$veicTracao, |
1900
|
|
|
"UF", |
1901
|
|
|
$std->UF, |
1902
|
|
|
true, |
1903
|
|
|
"UF de licenciamento do veículo" |
1904
|
|
|
); |
1905
|
|
|
|
1906
|
|
|
$this->dom->appChild($this->rodo, $veicTracao, 'Falta tag "rodo"'); |
1907
|
|
|
return $this->rodo; |
1908
|
|
|
} |
1909
|
|
|
|
1910
|
|
|
/** |
1911
|
|
|
* tagVeicReboque |
1912
|
|
|
* tag MDFe/infMDFe/infModal/rodo/VeicReboque |
1913
|
|
|
* |
1914
|
|
|
* @param stdClass $std |
1915
|
|
|
* @return DOMElement |
1916
|
|
|
*/ |
1917
|
|
|
public function tagveicReboque(stdClass $std) |
1918
|
|
|
{ |
1919
|
|
|
$possible = [ |
1920
|
|
|
'cInt', |
1921
|
|
|
'placa', |
1922
|
|
|
'RENAVAM', |
1923
|
|
|
'tara', |
1924
|
|
|
'capKG', |
1925
|
|
|
'capM3', |
1926
|
|
|
'prop', |
1927
|
|
|
'tpCar', |
1928
|
|
|
'UF' |
1929
|
|
|
]; |
1930
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1931
|
|
|
$veicReboque = $this->dom->createElement("veicReboque"); |
1932
|
|
|
$this->dom->addChild( |
1933
|
|
|
$veicReboque, |
1934
|
|
|
"cInt", |
1935
|
|
|
$std->cInt, |
1936
|
|
|
false, |
1937
|
|
|
"Código interno do veículo" |
1938
|
|
|
); |
1939
|
|
|
$this->dom->addChild( |
1940
|
|
|
$veicReboque, |
1941
|
|
|
"placa", |
1942
|
|
|
$std->placa, |
1943
|
|
|
true, |
1944
|
|
|
"Placa do veículo" |
1945
|
|
|
); |
1946
|
|
|
$this->dom->addChild( |
1947
|
|
|
$veicReboque, |
1948
|
|
|
"RENAVAM", |
1949
|
|
|
$std->RENAVAM, |
1950
|
|
|
false, |
1951
|
|
|
"RENAVAM" |
1952
|
|
|
); |
1953
|
|
|
$this->dom->addChild( |
1954
|
|
|
$veicReboque, |
1955
|
|
|
"tara", |
1956
|
|
|
$std->tara, |
1957
|
|
|
true, |
1958
|
|
|
"Tara em KG" |
1959
|
|
|
); |
1960
|
|
|
$this->dom->addChild( |
1961
|
|
|
$veicReboque, |
1962
|
|
|
"capKG", |
1963
|
|
|
$std->capKG, |
1964
|
|
|
false, |
1965
|
|
|
"Capacidade em KG" |
1966
|
|
|
); |
1967
|
|
|
$this->dom->addChild( |
1968
|
|
|
$veicReboque, |
1969
|
|
|
"capM3", |
1970
|
|
|
$std->capM3, |
1971
|
|
|
false, |
1972
|
|
|
"Capacidade em M3" |
1973
|
|
|
); |
1974
|
|
View Code Duplication |
if ($std->prop != null) { |
|
|
|
|
1975
|
|
|
$possible = [ |
1976
|
|
|
'CPF', |
1977
|
|
|
'CNPJ', |
1978
|
|
|
'RNTRC', |
1979
|
|
|
'xNome', |
1980
|
|
|
'IE', |
1981
|
|
|
'UF', |
1982
|
|
|
'TpProp' |
1983
|
|
|
]; |
1984
|
|
|
$stdprop = $this->equilizeParameters($std->prop, $possible); |
1985
|
|
|
$prop = $this->dom->createElement("prop"); |
1986
|
|
|
$this->dom->addChild( |
1987
|
|
|
$prop, |
1988
|
|
|
"CPF", |
1989
|
|
|
$stdprop->CPF, |
1990
|
|
|
true, |
1991
|
|
|
"Número do CPF" |
1992
|
|
|
); |
1993
|
|
|
$this->dom->addChild( |
1994
|
|
|
$prop, |
1995
|
|
|
"CNPJ", |
1996
|
|
|
$stdprop->CNPJ, |
1997
|
|
|
true, |
1998
|
|
|
"Número do CNPJ" |
1999
|
|
|
); |
2000
|
|
|
$this->dom->addChild( |
2001
|
|
|
$prop, |
2002
|
|
|
"RNTRC", |
2003
|
|
|
$stdprop->RNTRC, |
2004
|
|
|
true, |
2005
|
|
|
"RNTRC" |
2006
|
|
|
); |
2007
|
|
|
$this->dom->addChild( |
2008
|
|
|
$prop, |
2009
|
|
|
"xNome", |
2010
|
|
|
$stdprop->xNome, |
2011
|
|
|
true, |
2012
|
|
|
"Razão Social" |
2013
|
|
|
); |
2014
|
|
|
$this->dom->addChild( |
2015
|
|
|
$prop, |
2016
|
|
|
"IE", |
2017
|
|
|
$stdprop->IE, |
2018
|
|
|
true, |
2019
|
|
|
"Inscrição Estadual" |
2020
|
|
|
); |
2021
|
|
|
$this->dom->addChild( |
2022
|
|
|
$prop, |
2023
|
|
|
"UF", |
2024
|
|
|
$stdprop->UF, |
2025
|
|
|
true, |
2026
|
|
|
"Unidade da Federação" |
2027
|
|
|
); |
2028
|
|
|
$this->dom->addChild( |
2029
|
|
|
$prop, |
2030
|
|
|
"TpProp", |
2031
|
|
|
$stdprop->TpProp, |
2032
|
|
|
true, |
2033
|
|
|
"Tipo Proprietário" |
2034
|
|
|
); |
2035
|
|
|
$this->dom->appChild($veicReboque, $prop, 'Falta tag "veicReboque"'); |
2036
|
|
|
} |
2037
|
|
|
$this->dom->addChild( |
2038
|
|
|
$veicReboque, |
2039
|
|
|
"tpCar", |
2040
|
|
|
$std->tpCar, |
2041
|
|
|
true, |
2042
|
|
|
"Tipo de carroceria" |
2043
|
|
|
); |
2044
|
|
|
$this->dom->addChild( |
2045
|
|
|
$veicReboque, |
2046
|
|
|
"UF", |
2047
|
|
|
$std->UF, |
2048
|
|
|
true, |
2049
|
|
|
"UF de licenciamento do veículo" |
2050
|
|
|
); |
2051
|
|
|
|
2052
|
|
|
$this->dom->appChild($this->rodo, $veicReboque, 'Falta tag "rodo"'); |
2053
|
|
|
return $this->rodo; |
2054
|
|
|
} |
2055
|
|
|
|
2056
|
|
|
/** |
2057
|
|
|
* tagcodAgPorto |
2058
|
|
|
* tag MDFe/infMDFe/infModal/rodo/codAgPorto |
2059
|
|
|
* |
2060
|
|
|
* @param stdClass $std |
2061
|
|
|
* @return DOMElement |
2062
|
|
|
*/ |
2063
|
|
|
public function tagcodAgPorto(stdClass $std) |
2064
|
|
|
{ |
2065
|
|
|
$possible = [ |
2066
|
|
|
'codAgPorto' |
2067
|
|
|
]; |
2068
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2069
|
|
|
$this->dom->addChild( |
2070
|
|
|
$this->rodo, |
2071
|
|
|
"codAgPorto", |
2072
|
|
|
$std->codAgPorto, |
2073
|
|
|
false, |
2074
|
|
|
"Código de Agendamento no porto" |
2075
|
|
|
); |
2076
|
|
|
return $this->rodo; |
2077
|
|
|
} |
2078
|
|
|
|
2079
|
|
|
/** |
2080
|
|
|
* taglacRodo |
2081
|
|
|
* tag MDFe/infMDFe/infModal/rodo/lacRodo |
2082
|
|
|
* |
2083
|
|
|
* @param stdClass $std |
2084
|
|
|
* @return DOMElement |
2085
|
|
|
*/ |
2086
|
|
|
public function taglacRodo(stdClass $std) |
2087
|
|
|
{ |
2088
|
|
|
$possible = [ |
2089
|
|
|
'nLacre' |
2090
|
|
|
]; |
2091
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2092
|
|
|
$lacRodo = $this->dom->createElement("lacRodo"); |
2093
|
|
|
$this->dom->addChild( |
2094
|
|
|
$lacRodo, |
2095
|
|
|
"nLacre", |
2096
|
|
|
$std->nLacre, |
2097
|
|
|
false, |
2098
|
|
|
"Número do Lacre" |
2099
|
|
|
); |
2100
|
|
|
$this->dom->appChild($this->rodo, $lacRodo, 'Falta tag "rodo"'); |
2101
|
|
|
return $this->rodo; |
2102
|
|
|
} |
2103
|
|
|
|
2104
|
|
|
/** |
2105
|
|
|
* buildMDFe |
2106
|
|
|
* Tag raiz da MDFe |
2107
|
|
|
* tag MDFe DOMNode |
2108
|
|
|
* Função chamada pelo método [ monta ] |
2109
|
|
|
* |
2110
|
|
|
* @return DOMElement |
2111
|
|
|
*/ |
2112
|
|
|
protected function buildMDFe() |
2113
|
|
|
{ |
2114
|
|
|
if (empty($this->MDFe)) { |
2115
|
|
|
$this->MDFe = $this->dom->createElement("MDFe"); |
2116
|
|
|
$this->MDFe->setAttribute("xmlns", "http://www.portalfiscal.inf.br/mdfe"); |
2117
|
|
|
} |
2118
|
|
|
return $this->MDFe; |
2119
|
|
|
} |
2120
|
|
|
|
2121
|
|
|
/** |
2122
|
|
|
* buildTagIde |
2123
|
|
|
* Adiciona as tags |
2124
|
|
|
* infMunCarrega e infPercurso |
2125
|
|
|
* a tag ide |
2126
|
|
|
*/ |
2127
|
|
|
|
2128
|
|
|
protected function buildTagIde() |
2129
|
|
|
{ |
2130
|
|
|
if (! empty($this->aInfMunCarrega)) { |
2131
|
|
|
$this->dom->addArrayChild($this->ide, $this->aInfMunCarrega); |
2132
|
|
|
} |
2133
|
|
|
if (! empty($this->aInfPercurso)) { |
2134
|
|
|
$this->dom->addArrayChild($this->ide, $this->aInfPercurso); |
2135
|
|
|
} |
2136
|
|
|
} |
2137
|
|
|
|
2138
|
|
|
/** |
2139
|
|
|
* checkMDFKey |
2140
|
|
|
* Remonta a chave do MDFe de 44 digitos com base em seus dados |
2141
|
|
|
* Isso é útil no caso da chave informada estar errada |
2142
|
|
|
* se a chave estiver errada a mesma é substituida |
2143
|
|
|
* |
2144
|
|
|
* @param object $dom |
2145
|
|
|
*/ |
2146
|
|
|
private function checkMDFKey($dom) |
2147
|
|
|
{ |
2148
|
|
|
$infMDFe = $dom->getElementsByTagName("infMDFe")->item(0); |
2149
|
|
|
$ide = $dom->getElementsByTagName("ide")->item(0); |
2150
|
|
|
$emit = $dom->getElementsByTagName("emit")->item(0); |
2151
|
|
|
$cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue; |
2152
|
|
|
$dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue; |
2153
|
|
|
$cnpj = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
2154
|
|
|
$mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue; |
2155
|
|
|
$serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue; |
2156
|
|
|
$nNF = $ide->getElementsByTagName('nMDF')->item(0)->nodeValue; |
2157
|
|
|
$tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue; |
2158
|
|
|
$cNF = $ide->getElementsByTagName('cMDF')->item(0)->nodeValue; |
2159
|
|
|
$chave = str_replace('MDFe', '', $infMDFe->getAttribute("Id")); |
2160
|
|
|
$dt = new DateTime($dhEmi); |
2161
|
|
|
$chaveMontada = Keys::build( |
2162
|
|
|
$cUF, |
2163
|
|
|
$dt->format('y'), |
2164
|
|
|
$dt->format('m'), |
2165
|
|
|
$cnpj, |
2166
|
|
|
$mod, |
2167
|
|
|
$serie, |
2168
|
|
|
$nNF, |
2169
|
|
|
$tpEmis, |
2170
|
|
|
$cNF |
2171
|
|
|
); |
2172
|
|
|
//caso a chave contida na NFe esteja errada |
2173
|
|
|
//substituir a chave |
2174
|
|
|
if ($chaveMontada != $chave) { |
2175
|
|
|
$ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chaveMontada, -1); |
2176
|
|
|
$infMDFe = $dom->getElementsByTagName("infMDFe")->item(0); |
2177
|
|
|
$infMDFe->setAttribute("Id", "MDFe" . $chaveMontada); |
2178
|
|
|
$this->chMDFe = $chaveMontada; |
2179
|
|
|
} |
2180
|
|
|
} |
2181
|
|
|
|
2182
|
|
|
/** |
2183
|
|
|
* Includes missing or unsupported properties in stdClass |
2184
|
|
|
* Replace all unsuported chars |
2185
|
|
|
* @param stdClass $std |
2186
|
|
|
* @param array $possible |
2187
|
|
|
* @return stdClass |
2188
|
|
|
*/ |
2189
|
|
|
protected function equilizeParameters(stdClass $std, $possible) |
2190
|
|
|
{ |
2191
|
|
|
$arr = get_object_vars($std); |
2192
|
|
|
foreach ($possible as $key) { |
2193
|
|
|
if (!array_key_exists($key, $arr)) { |
2194
|
|
|
$std->$key = null; |
2195
|
|
|
} else { |
2196
|
|
|
if (is_string($std->$key)) { |
2197
|
|
|
$std->$key = trim(Strings::replaceUnacceptableCharacters($std->$key)); |
2198
|
|
|
if ($this->replaceAccentedChars) { |
2199
|
|
|
$std->$key = Strings::toASCII($std->$key); |
2200
|
|
|
} |
2201
|
|
|
} |
2202
|
|
|
} |
2203
|
|
|
} |
2204
|
|
|
return $std; |
2205
|
|
|
} |
2206
|
|
|
} |
2207
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: