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 Cleiton Perin <cperin20 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
|
|
|
use Exception; |
30
|
|
|
|
31
|
|
|
class Make |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
public $errors = []; |
37
|
|
|
/** |
38
|
|
|
* versao |
39
|
|
|
* numero da versão do xml da MDFe |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
public $versao = '3.00'; |
44
|
|
|
/** |
45
|
|
|
* mod |
46
|
|
|
* modelo da MDFe 58 |
47
|
|
|
* |
48
|
|
|
* @var integer |
49
|
|
|
*/ |
50
|
|
|
public $mod = '58'; |
51
|
|
|
/** |
52
|
|
|
* chave da MDFe |
53
|
|
|
* |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
public $chMDFe = ''; |
57
|
|
|
|
58
|
|
|
//propriedades privadas utilizadas internamente pela classe |
59
|
|
|
/** |
60
|
|
|
* @type string|\DOMNode |
61
|
|
|
*/ |
62
|
|
|
private $MDFe = ''; |
63
|
|
|
/** |
64
|
|
|
* @type string|\DOMNode |
65
|
|
|
*/ |
66
|
|
|
private $infMDFe = ''; |
67
|
|
|
/** |
68
|
|
|
* @type string|\DOMNode |
69
|
|
|
*/ |
70
|
|
|
private $ide = ''; |
71
|
|
|
/** |
72
|
|
|
* @type string|\DOMNode |
73
|
|
|
*/ |
74
|
|
|
private $emit = ''; |
75
|
|
|
/** |
76
|
|
|
* @type string|\DOMNode |
77
|
|
|
*/ |
78
|
|
|
private $infANTT = ''; |
79
|
|
|
/** |
80
|
|
|
* @type string|\DOMNode |
81
|
|
|
*/ |
82
|
|
|
private $enderEmit = ''; |
83
|
|
|
/** |
84
|
|
|
* @type string|\DOMNode |
85
|
|
|
*/ |
86
|
|
|
private $infModal = ''; |
87
|
|
|
/** |
88
|
|
|
* @type string|\DOMNode |
89
|
|
|
*/ |
90
|
|
|
private $tot = ''; |
91
|
|
|
/** |
92
|
|
|
* @type string|\DOMNode |
93
|
|
|
*/ |
94
|
|
|
private $seg = []; |
95
|
|
|
/** |
96
|
|
|
* @type string|\DOMNode |
97
|
|
|
*/ |
98
|
|
|
private $infMunDescarga = []; |
99
|
|
|
/** |
100
|
|
|
* @type string|\DOMNode |
101
|
|
|
*/ |
102
|
|
|
private $veicReboque = []; |
103
|
|
|
/** |
104
|
|
|
* @type string|\DOMNode |
105
|
|
|
*/ |
106
|
|
|
private $infNFe = []; |
107
|
|
|
/** |
108
|
|
|
* @type string|\DOMNode |
109
|
|
|
*/ |
110
|
|
|
private $infCTe = []; |
111
|
|
|
/** |
112
|
|
|
* @type string|\DOMNode |
113
|
|
|
*/ |
114
|
|
|
private $infMDFeTransp = []; |
115
|
|
|
/** |
116
|
|
|
* @type string|\DOMNode |
117
|
|
|
*/ |
118
|
|
|
private $infContratante = []; |
119
|
|
|
/** |
120
|
|
|
* @type string|\DOMNode |
121
|
|
|
*/ |
122
|
|
|
private $autXML = []; |
123
|
|
|
/** |
124
|
|
|
* @type string|\DOMNode |
125
|
|
|
*/ |
126
|
|
|
private $infCIOT = []; |
127
|
|
|
/** |
128
|
|
|
* @type string|\DOMNode |
129
|
|
|
*/ |
130
|
|
|
private $disp = []; |
131
|
|
|
/** |
132
|
|
|
* @type string|\DOMNode |
133
|
|
|
*/ |
134
|
|
|
private $infMunCarrega = []; |
135
|
|
|
/** |
136
|
|
|
* @type string|\DOMNode |
137
|
|
|
*/ |
138
|
|
|
private $infPercurso = []; |
139
|
|
|
/** |
140
|
|
|
* @type string|\DOMNode |
141
|
|
|
*/ |
142
|
|
|
private $lacRodo = []; |
143
|
|
|
/** |
144
|
|
|
* @type string|\DOMNode |
145
|
|
|
*/ |
146
|
|
|
private $vag = []; |
147
|
|
|
/** |
148
|
|
|
* @type string|\DOMNode |
149
|
|
|
*/ |
150
|
|
|
private $infAdic = ''; |
151
|
|
|
/** |
152
|
|
|
* @type string|\DOMNode |
153
|
|
|
*/ |
154
|
|
|
private $rodo = ''; |
155
|
|
|
/** |
156
|
|
|
* @type string|\DOMNode |
157
|
|
|
*/ |
158
|
|
|
private $ferrov = ''; |
159
|
|
|
/** |
160
|
|
|
* @type string|\DOMNode |
161
|
|
|
*/ |
162
|
|
|
private $infDoc = ''; |
163
|
|
|
/** |
164
|
|
|
* @type string|\DOMNode |
165
|
|
|
*/ |
166
|
|
|
private $valePed = ''; |
167
|
|
|
/** |
168
|
|
|
* @type string|\DOMNode |
169
|
|
|
*/ |
170
|
|
|
private $veicTracao = ''; |
171
|
|
|
/** |
172
|
|
|
* @type string|\DOMNode |
173
|
|
|
*/ |
174
|
|
|
private $infUnidTransp = ''; |
175
|
|
|
/** |
176
|
|
|
* @type string|\DOMNode |
177
|
|
|
*/ |
178
|
|
|
private $aereo = ''; |
179
|
|
|
/** |
180
|
|
|
* @type string|\DOMNode |
181
|
|
|
*/ |
182
|
|
|
private $trem = ''; |
183
|
|
|
/** |
184
|
|
|
* @type string|\DOMNode |
185
|
|
|
*/ |
186
|
|
|
private $aquav = ''; |
187
|
|
|
/** |
188
|
|
|
* @type array |
189
|
|
|
*/ |
190
|
|
|
private $infTermCarreg = []; |
191
|
|
|
/** |
192
|
|
|
* @type array |
193
|
|
|
*/ |
194
|
|
|
private $infTermDescarreg = []; |
195
|
|
|
/** |
196
|
|
|
* @type array |
197
|
|
|
*/ |
198
|
|
|
private $infEmbComb = []; |
199
|
|
|
/** |
200
|
|
|
* @type array |
201
|
|
|
*/ |
202
|
|
|
private $infUnidCargaVazia = []; |
203
|
|
|
/** |
204
|
|
|
* @type array |
205
|
|
|
*/ |
206
|
|
|
private $infUnidTranspVazia = []; |
207
|
|
|
/** |
208
|
|
|
* @var boolean |
209
|
|
|
*/ |
210
|
|
|
protected $replaceAccentedChars = false; |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Função construtora cria um objeto DOMDocument |
214
|
|
|
* que será carregado com o documento fiscal |
215
|
|
|
*/ |
216
|
|
|
public function __construct() |
217
|
|
|
{ |
218
|
|
|
$this->dom = new Dom('1.0', 'UTF-8'); |
|
|
|
|
219
|
|
|
$this->dom->preserveWhiteSpace = false; |
220
|
|
|
$this->dom->formatOutput = false; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Retorns the xml |
225
|
|
|
* |
226
|
|
|
* @return xml |
227
|
|
|
*/ |
228
|
|
|
public function getXML() |
229
|
|
|
{ |
230
|
|
|
if (empty($this->xml)) { |
|
|
|
|
231
|
|
|
$this->montaMDFe(); |
232
|
|
|
} |
233
|
|
|
return $this->xml; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Retorns the key number of NFe (44 digits) |
238
|
|
|
* |
239
|
|
|
* @return string |
240
|
|
|
*/ |
241
|
|
|
public function getChave() |
242
|
|
|
{ |
243
|
|
|
return $this->chMDFe; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Returns the model of MDFe |
248
|
|
|
* |
249
|
|
|
* @return int |
250
|
|
|
*/ |
251
|
|
|
public function getModelo() |
252
|
|
|
{ |
253
|
|
|
return $this->mod; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Set character convertion to ASCII only ou not |
258
|
|
|
* @param bool $option |
259
|
|
|
*/ |
260
|
|
|
public function setOnlyAscii($option = false) |
261
|
|
|
{ |
262
|
|
|
$this->replaceAccentedChars = $option; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Call method of xml assembly. For compatibility only. |
267
|
|
|
* |
268
|
|
|
* @return boolean |
269
|
|
|
*/ |
270
|
|
|
public function montaMDFe() |
271
|
|
|
{ |
272
|
|
|
return $this->monta(); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* MDFe xml mount method |
277
|
|
|
* this function returns TRUE on success or FALSE on error |
278
|
|
|
* The xml of the MDFe must be retrieved by the getXML() function or |
279
|
|
|
* directly by the public property $xml |
280
|
|
|
* |
281
|
|
|
* @return boolean |
282
|
|
|
*/ |
283
|
|
|
public function monta() |
284
|
|
|
{ |
285
|
|
|
$this->errors = $this->dom->errors; |
286
|
|
|
if (count($this->errors) > 0) { |
287
|
|
|
return false; |
288
|
|
|
} |
289
|
|
|
//cria a tag raiz da MDFe |
290
|
|
|
$this->buildMDFe(); |
291
|
|
|
$this->buildInfModal(); |
292
|
|
|
$this->infMDFe = $this->dom->createElement("infMDFe"); |
293
|
|
|
$this->buildIde(); |
294
|
|
|
$this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "enderEmit"'); |
295
|
|
|
$this->dom->appChild($this->infMDFe, $this->emit, 'Falta tag "emit"'); |
296
|
|
|
if ($this->rodo) { |
297
|
|
|
if ($this->infANTT) { |
298
|
|
|
if ($this->infCIOT) { |
299
|
|
|
$this->dom->addArrayChild($this->infANTT, $this->infCIOT, 'Falta tag "infCIOT"'); |
300
|
|
|
} |
301
|
|
|
if ($this->valePed) { |
302
|
|
|
$this->dom->appChild($this->infANTT, $this->valePed, 'Falta tag "valePed"'); |
303
|
|
|
if ($this->disp) { |
304
|
|
|
$this->dom->addArrayChild($this->valePed, $this->disp, 'Falta tag "disp"'); |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
if ($this->infContratante) { |
308
|
|
|
$this->dom->addArrayChild($this->infANTT, $this->infContratante, 'Falta tag "infContratante"'); |
309
|
|
|
} |
310
|
|
|
$this->dom->appChild($this->rodo, $this->infANTT, 'Falta tag "infANTT"'); |
311
|
|
|
} |
312
|
|
|
if ($this->veicTracao) { |
313
|
|
|
$this->dom->appChild($this->rodo, $this->veicTracao, 'Falta tag "rodo"'); |
314
|
|
|
} |
315
|
|
|
if ($this->veicReboque) { |
316
|
|
|
$this->dom->addArrayChild($this->rodo, $this->veicReboque, 'Falta tag "veicReboque"'); |
317
|
|
|
} |
318
|
|
|
if ($this->lacRodo) { |
319
|
|
|
$this->dom->addArrayChild($this->rodo, $this->lacRodo, 'Falta tag "lacRodo"'); |
320
|
|
|
} |
321
|
|
|
$this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "infModal"'); |
322
|
|
|
} |
323
|
|
|
if ($this->aereo) { |
324
|
|
|
$this->dom->appChild($this->infModal, $this->aereo, 'Falta tag "aereo"'); |
325
|
|
|
} |
326
|
|
|
if ($this->ferrov) { |
327
|
|
|
if ($this->trem) { |
328
|
|
|
$this->dom->appChild($this->ferrov, $this->trem, 'Falta tag "ferrov"'); |
329
|
|
|
} |
330
|
|
|
if ($this->vag) { |
331
|
|
|
$this->dom->addArrayChild($this->ferrov, $this->vag, 'Falta tag "vag"'); |
332
|
|
|
} |
333
|
|
|
$this->dom->appChild($this->infModal, $this->ferrov, 'Falta tag "ferrov"'); |
334
|
|
|
} |
335
|
|
|
if ($this->aquav) { |
336
|
|
|
foreach ($this->infTermCarreg as $termCarreg) { |
337
|
|
|
$this->dom->appChild($this->aquav, $termCarreg, 'Falta tag "aquav"'); |
338
|
|
|
} |
339
|
|
|
foreach ($this->infTermDescarreg as $termDescarreg) { |
340
|
|
|
$this->dom->appChild($this->aquav, $termDescarreg, 'Falta tag "aquav"'); |
341
|
|
|
} |
342
|
|
|
foreach ($this->infEmbComb as $embComb) { |
343
|
|
|
$this->dom->appChild($this->aquav, $embComb, 'Falta tag "aquav"'); |
344
|
|
|
} |
345
|
|
|
foreach ($this->infUnidCargaVazia as $unidCargaVazia) { |
346
|
|
|
$this->dom->appChild($this->aquav, $unidCargaVazia, 'Falta tag "aquav"'); |
347
|
|
|
} |
348
|
|
|
foreach ($this->infUnidTranspVazia as $unidTranspVazia) { |
349
|
|
|
$this->dom->appChild($this->aquav, $unidTranspVazia, 'Falta tag "aquav"'); |
350
|
|
|
} |
351
|
|
|
$this->dom->appChild($this->infModal, $this->aquav, 'Falta tag "aquav"'); |
352
|
|
|
} |
353
|
|
|
$this->dom->appChild($this->infMDFe, $this->infModal, 'Falta tag "infModal"'); |
354
|
|
|
if ($this->infDoc) { |
355
|
|
|
$this->dom->appChild($this->infMDFe, $this->infDoc, 'Falta tag "infDoc"'); |
356
|
|
|
if ($this->infMunDescarga) { |
357
|
|
|
foreach ($this->infMunDescarga as $key => $value) { |
|
|
|
|
358
|
|
|
$this->dom->appChild($this->infDoc, $value, 'Falta tag "infMunDescarga"'); |
359
|
|
|
if (isset($this->infCTe[$key])) { |
360
|
|
|
$this->dom->addArrayChild($value, $this->infCTe[$key], 'Falta tag "infCTe"'); |
361
|
|
|
} |
362
|
|
|
if (isset($this->infNFe[$key])) { |
363
|
|
|
$this->dom->addArrayChild($value, $this->infNFe[$key], 'Falta tag "infNFe"'); |
364
|
|
|
} |
365
|
|
|
if (isset($this->infMDFeTransp[$key])) { |
366
|
|
|
$this->dom->addArrayChild($value, $this->infMDFeTransp[$key], 'Falta tag "infMDFeTransp"'); |
367
|
|
|
} |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
} |
371
|
|
|
if (!empty($this->seg)) { |
372
|
|
|
$this->dom->addArrayChild($this->infMDFe, $this->seg, 'Falta tag "seg"'); |
373
|
|
|
} |
374
|
|
|
$this->dom->appChild($this->infMDFe, $this->tot, 'Falta tag "tot"'); |
375
|
|
|
foreach ($this->lacres as $lacres) { |
|
|
|
|
376
|
|
|
$this->dom->appChild($this->infMDFe, $lacres, 'Falta tag "lacres"'); |
377
|
|
|
} |
378
|
|
|
foreach ($this->autXML as $autXML) { |
|
|
|
|
379
|
|
|
$this->dom->appChild($this->infMDFe, $autXML, 'Falta tag "infMDFe"'); |
380
|
|
|
} |
381
|
|
|
if (!empty($this->infAdic)) { |
382
|
|
|
$this->dom->appChild($this->infMDFe, $this->infAdic, 'Falta tag "infAdic"'); |
383
|
|
|
} |
384
|
|
|
$this->dom->appChild($this->MDFe, $this->infMDFe, 'Falta tag "infMDFe"'); |
385
|
|
|
$this->dom->appendChild($this->MDFe); |
386
|
|
|
// testa da chave |
387
|
|
|
$this->checkMDFKey($this->dom); |
388
|
|
|
$this->xml = $this->dom->saveXML(); |
389
|
|
|
return true; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* Informações de identificação da MDFe |
394
|
|
|
* tag MDFe/infMDFe/ide |
395
|
|
|
* |
396
|
|
|
* @param stdClass $std |
397
|
|
|
* @return DOMElement |
398
|
|
|
*/ |
399
|
|
|
public function tagide(stdClass $std) |
400
|
|
|
{ |
401
|
|
|
|
402
|
|
|
$possible = [ |
403
|
|
|
'cUF', |
404
|
|
|
'tpAmb', |
405
|
|
|
'tpEmit', |
406
|
|
|
'tpTransp', |
407
|
|
|
'mod', |
408
|
|
|
'serie', |
409
|
|
|
'nMDF', |
410
|
|
|
'cMDF', |
411
|
|
|
'cDV', |
412
|
|
|
'modal', |
413
|
|
|
'dhEmi', |
414
|
|
|
'tpEmis', |
415
|
|
|
'procEmi', |
416
|
|
|
'verProc', |
417
|
|
|
'UFIni', |
418
|
|
|
'UFFim', |
419
|
|
|
'dhIniViagem', |
420
|
|
|
'indCanalVerde', |
421
|
|
|
'indCarregaPosterior' |
422
|
|
|
]; |
423
|
|
|
|
424
|
|
|
$std = $this->equilizeParameters($std, $possible); |
425
|
|
|
|
426
|
|
|
$this->tpAmb = $std->tpAmb; |
|
|
|
|
427
|
|
|
$identificador = '[4] <ide> - '; |
428
|
|
|
$ide = $this->dom->createElement("ide"); |
429
|
|
|
$this->dom->addChild( |
430
|
|
|
$ide, |
431
|
|
|
"cUF", |
432
|
|
|
$std->cUF, |
433
|
|
|
true, |
434
|
|
|
$identificador . "Código da UF do emitente do Documento Fiscal" |
435
|
|
|
); |
436
|
|
|
$this->dom->addChild( |
437
|
|
|
$ide, |
438
|
|
|
"tpAmb", |
439
|
|
|
$std->tpAmb, |
440
|
|
|
true, |
441
|
|
|
$identificador . "Identificação do Ambiente" |
442
|
|
|
); |
443
|
|
|
$this->dom->addChild( |
444
|
|
|
$ide, |
445
|
|
|
"tpEmit", |
446
|
|
|
$std->tpEmit, |
447
|
|
|
true, |
448
|
|
|
$identificador . "Indicador da tipo de emitente" |
449
|
|
|
); |
450
|
|
|
$this->dom->addChild( |
451
|
|
|
$ide, |
452
|
|
|
"tpTransp", |
453
|
|
|
$std->tpTransp, |
454
|
|
|
false, |
455
|
|
|
$identificador . "Tipo do Transportador" |
456
|
|
|
); |
457
|
|
|
$this->dom->addChild( |
458
|
|
|
$ide, |
459
|
|
|
"mod", |
460
|
|
|
$std->mod, |
461
|
|
|
true, |
462
|
|
|
$identificador . "Código do Modelo do Documento Fiscal" |
463
|
|
|
); |
464
|
|
|
$this->dom->addChild( |
465
|
|
|
$ide, |
466
|
|
|
"serie", |
467
|
|
|
$std->serie, |
468
|
|
|
true, |
469
|
|
|
$identificador . "Série do Documento Fiscal" |
470
|
|
|
); |
471
|
|
|
$this->dom->addChild( |
472
|
|
|
$ide, |
473
|
|
|
"nMDF", |
474
|
|
|
$std->nMDF, |
475
|
|
|
true, |
476
|
|
|
$identificador . "Número do Documento Fiscal" |
477
|
|
|
); |
478
|
|
|
$this->dom->addChild( |
479
|
|
|
$ide, |
480
|
|
|
"cMDF", |
481
|
|
|
str_pad($std->cMDF, 8, '0', STR_PAD_LEFT), |
482
|
|
|
true, |
483
|
|
|
$identificador . "Código do numérico do MDF" |
484
|
|
|
); |
485
|
|
|
$this->dom->addChild( |
486
|
|
|
$ide, |
487
|
|
|
"cDV", |
488
|
|
|
$std->cDV, |
489
|
|
|
true, |
490
|
|
|
$identificador . "Dígito Verificador da Chave de Acesso da NF-e" |
491
|
|
|
); |
492
|
|
|
$this->dom->addChild( |
493
|
|
|
$ide, |
494
|
|
|
"modal", |
495
|
|
|
$std->modal, |
496
|
|
|
true, |
497
|
|
|
$identificador . "Modalidade de transporte" |
498
|
|
|
); |
499
|
|
|
$this->dom->addChild( |
500
|
|
|
$ide, |
501
|
|
|
"dhEmi", |
502
|
|
|
$std->dhEmi, |
503
|
|
|
true, |
504
|
|
|
$identificador . "Data e hora de emissão do Documento Fiscal" |
505
|
|
|
); |
506
|
|
|
$this->dom->addChild( |
507
|
|
|
$ide, |
508
|
|
|
"tpEmis", |
509
|
|
|
$std->tpEmis, |
510
|
|
|
true, |
511
|
|
|
$identificador . "Tipo de Emissão do Documento Fiscal" |
512
|
|
|
); |
513
|
|
|
$this->dom->addChild( |
514
|
|
|
$ide, |
515
|
|
|
"procEmi", |
516
|
|
|
$std->procEmi, |
517
|
|
|
true, |
518
|
|
|
$identificador . "Processo de emissão" |
519
|
|
|
); |
520
|
|
|
$this->dom->addChild( |
521
|
|
|
$ide, |
522
|
|
|
"verProc", |
523
|
|
|
$std->verProc, |
524
|
|
|
true, |
525
|
|
|
$identificador . "Versão do Processo de emissão" |
526
|
|
|
); |
527
|
|
|
$this->dom->addChild( |
528
|
|
|
$ide, |
529
|
|
|
"UFIni", |
530
|
|
|
$std->UFIni, |
531
|
|
|
true, |
532
|
|
|
$identificador . "Sigla da UF do Carregamento" |
533
|
|
|
); |
534
|
|
|
$this->dom->addChild( |
535
|
|
|
$ide, |
536
|
|
|
"UFFim", |
537
|
|
|
$std->UFFim, |
538
|
|
|
true, |
539
|
|
|
$identificador . "Sigla da UF do Descarregamento" |
540
|
|
|
); |
541
|
|
|
$this->dom->addChild( |
542
|
|
|
$ide, |
543
|
|
|
"dhIniViagem", |
544
|
|
|
$std->dhIniViagem, |
545
|
|
|
false, |
546
|
|
|
$identificador . "Data e hora previstos de início da viagem" |
547
|
|
|
); |
548
|
|
|
$this->dom->addChild( |
549
|
|
|
$ide, |
550
|
|
|
"indCanalVerde", |
551
|
|
|
$std->indCanalVerde, |
552
|
|
|
false, |
553
|
|
|
$identificador . "Indicador de participação do Canal Verde" |
554
|
|
|
); |
555
|
|
|
$this->dom->addChild( |
556
|
|
|
$ide, |
557
|
|
|
"indCarregaPosterior", |
558
|
|
|
$std->indCarregaPosterior, |
559
|
|
|
false, |
560
|
|
|
$identificador . "Indicador de MDF-e com inclusão da Carga posterior a emissão por evento de inclusão de DF-e" |
561
|
|
|
); |
562
|
|
|
|
563
|
|
|
$this->mod = $std->mod; |
564
|
|
|
$this->ide = $ide; |
565
|
|
|
return $ide; |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* taginfMunCarrega |
570
|
|
|
* |
571
|
|
|
* tag MDFe/infMDFe/ide/infMunCarrega |
572
|
|
|
* |
573
|
|
|
* @param stdClass $std |
574
|
|
|
* @return DOMElement |
575
|
|
|
*/ |
576
|
|
|
public function taginfMunCarrega(stdClass $std) |
577
|
|
|
{ |
578
|
|
|
$possible = [ |
579
|
|
|
'cMunCarrega', |
580
|
|
|
'xMunCarrega' |
581
|
|
|
]; |
582
|
|
|
|
583
|
|
|
$std = $this->equilizeParameters($std, $possible); |
584
|
|
|
$infMunCarrega = $this->dom->createElement("infMunCarrega"); |
585
|
|
|
$this->dom->addChild( |
586
|
|
|
$infMunCarrega, |
587
|
|
|
"cMunCarrega", |
588
|
|
|
$std->cMunCarrega, |
589
|
|
|
true, |
590
|
|
|
"Código do Município de Carregamento" |
591
|
|
|
); |
592
|
|
|
$this->dom->addChild( |
593
|
|
|
$infMunCarrega, |
594
|
|
|
"xMunCarrega", |
595
|
|
|
$std->xMunCarrega, |
596
|
|
|
true, |
597
|
|
|
"Nome do Município de Carregamento" |
598
|
|
|
); |
599
|
|
|
$this->infMunCarrega[] = $infMunCarrega; |
600
|
|
|
return $infMunCarrega; |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
/** |
604
|
|
|
* tagInfPercurso |
605
|
|
|
* |
606
|
|
|
* tag MDFe/infMDFe/ide/infPercurso |
607
|
|
|
* |
608
|
|
|
* @param stdClass $std |
609
|
|
|
* @return DOMElement |
610
|
|
|
*/ |
611
|
|
|
public function taginfPercurso(stdClass $std) |
612
|
|
|
{ |
613
|
|
|
$possible = [ |
614
|
|
|
'UFPer' |
615
|
|
|
]; |
616
|
|
|
|
617
|
|
|
$std = $this->equilizeParameters($std, $possible); |
618
|
|
|
$infPercurso = $this->dom->createElement("infPercurso"); |
619
|
|
|
$this->dom->addChild( |
620
|
|
|
$infPercurso, |
621
|
|
|
"UFPer", |
622
|
|
|
$std->UFPer, |
623
|
|
|
true, |
624
|
|
|
"Sigla das Unidades da Federação do percurso" |
625
|
|
|
); |
626
|
|
|
$this->infPercurso[] = $infPercurso; |
627
|
|
|
return $infPercurso; |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
/** |
631
|
|
|
* tagemit |
632
|
|
|
* Identificação do emitente da MDFe |
633
|
|
|
* tag MDFe/infMDFe/emit |
634
|
|
|
* |
635
|
|
|
* @param stdClass $std |
636
|
|
|
* @return DOMElement |
637
|
|
|
*/ |
638
|
|
|
public function tagemit(stdClass $std) |
639
|
|
|
{ |
640
|
|
|
$possible = [ |
641
|
|
|
'CNPJ', |
642
|
|
|
'CPF', |
643
|
|
|
'IE', |
644
|
|
|
'xNome', |
645
|
|
|
'xFant' |
646
|
|
|
]; |
647
|
|
|
$std = $this->equilizeParameters($std, $possible); |
648
|
|
|
|
649
|
|
|
$identificador = '[25] <emit> - '; |
650
|
|
|
$this->emit = $this->dom->createElement("emit"); |
651
|
|
|
if ($std->CPF) { |
652
|
|
|
$this->dom->addChild( |
653
|
|
|
$this->emit, |
654
|
|
|
"CPF", |
655
|
|
|
$std->CPF, |
656
|
|
|
true, |
657
|
|
|
$identificador . "CPF do emitente" |
658
|
|
|
); |
659
|
|
|
} else { |
660
|
|
|
$this->dom->addChild( |
661
|
|
|
$this->emit, |
662
|
|
|
"CNPJ", |
663
|
|
|
$std->CNPJ, |
664
|
|
|
true, |
665
|
|
|
$identificador . "CNPJ do emitente" |
666
|
|
|
); |
667
|
|
|
} |
668
|
|
|
$this->dom->addChild( |
669
|
|
|
$this->emit, |
670
|
|
|
"IE", |
671
|
|
|
$std->IE, |
672
|
|
|
false, |
673
|
|
|
$identificador . "Inscrição Estadual do emitente" |
674
|
|
|
); |
675
|
|
|
$this->dom->addChild( |
676
|
|
|
$this->emit, |
677
|
|
|
"xNome", |
678
|
|
|
$std->xNome, |
679
|
|
|
true, |
680
|
|
|
$identificador . "Razão Social ou Nome do emitente" |
681
|
|
|
); |
682
|
|
|
$this->dom->addChild( |
683
|
|
|
$this->emit, |
684
|
|
|
"xFant", |
685
|
|
|
$std->xFant, |
686
|
|
|
false, |
687
|
|
|
$identificador . "Nome fantasia do emitente" |
688
|
|
|
); |
689
|
|
|
return $this->emit; |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
/** |
693
|
|
|
* tagenderEmit |
694
|
|
|
* Endereço do emitente [30] pai [25] |
695
|
|
|
* tag MDFe/infMDFe/emit/endEmit |
696
|
|
|
* |
697
|
|
|
* @param stdClass $std |
698
|
|
|
* @return DOMElement |
699
|
|
|
*/ |
700
|
|
|
public function tagenderEmit(stdClass $std) |
701
|
|
|
{ |
702
|
|
|
$possible = [ |
703
|
|
|
'xLgr', |
704
|
|
|
'nro', |
705
|
|
|
'xCpl', |
706
|
|
|
'xBairro', |
707
|
|
|
'cMun', |
708
|
|
|
'xMun', |
709
|
|
|
'CEP', |
710
|
|
|
'UF', |
711
|
|
|
'fone', |
712
|
|
|
'email' |
713
|
|
|
]; |
714
|
|
|
$std = $this->equilizeParameters($std, $possible); |
715
|
|
|
|
716
|
|
|
$identificador = '[30] <enderEmit> - '; |
717
|
|
|
$this->enderEmit = $this->dom->createElement("enderEmit"); |
718
|
|
|
|
719
|
|
|
$this->dom->addChild( |
720
|
|
|
$this->enderEmit, |
721
|
|
|
"xLgr", |
722
|
|
|
$std->xLgr, |
723
|
|
|
true, |
724
|
|
|
$identificador . "Logradouro do Endereço do emitente" |
725
|
|
|
); |
726
|
|
|
$this->dom->addChild( |
727
|
|
|
$this->enderEmit, |
728
|
|
|
"nro", |
729
|
|
|
$std->nro, |
730
|
|
|
true, |
731
|
|
|
$identificador . "Número do Endereço do emitente" |
732
|
|
|
); |
733
|
|
|
$this->dom->addChild( |
734
|
|
|
$this->enderEmit, |
735
|
|
|
"xCpl", |
736
|
|
|
$std->xCpl, |
737
|
|
|
false, |
738
|
|
|
$identificador . "Complemento do Endereço do emitente" |
739
|
|
|
); |
740
|
|
|
$this->dom->addChild( |
741
|
|
|
$this->enderEmit, |
742
|
|
|
"xBairro", |
743
|
|
|
$std->xBairro, |
744
|
|
|
true, |
745
|
|
|
$identificador . "Bairro do Endereço do emitente" |
746
|
|
|
); |
747
|
|
|
$this->dom->addChild( |
748
|
|
|
$this->enderEmit, |
749
|
|
|
"cMun", |
750
|
|
|
$std->cMun, |
751
|
|
|
true, |
752
|
|
|
$identificador . "Código do município do Endereço do emitente" |
753
|
|
|
); |
754
|
|
|
$this->dom->addChild( |
755
|
|
|
$this->enderEmit, |
756
|
|
|
"xMun", |
757
|
|
|
$std->xMun, |
758
|
|
|
true, |
759
|
|
|
$identificador . "Nome do município do Endereço do emitente" |
760
|
|
|
); |
761
|
|
|
$this->dom->addChild( |
762
|
|
|
$this->enderEmit, |
763
|
|
|
"CEP", |
764
|
|
|
$std->CEP, |
765
|
|
|
true, |
766
|
|
|
$identificador . "Código do CEP do Endereço do emitente" |
767
|
|
|
); |
768
|
|
|
$this->dom->addChild( |
769
|
|
|
$this->enderEmit, |
770
|
|
|
"UF", |
771
|
|
|
$std->UF, |
772
|
|
|
true, |
773
|
|
|
$identificador . "Sigla da UF do Endereço do emitente" |
774
|
|
|
); |
775
|
|
|
$this->dom->addChild( |
776
|
|
|
$this->enderEmit, |
777
|
|
|
"fone", |
778
|
|
|
$std->fone, |
779
|
|
|
false, |
780
|
|
|
$identificador . "Número de telefone do emitente" |
781
|
|
|
); |
782
|
|
|
$this->dom->addChild( |
783
|
|
|
$this->enderEmit, |
784
|
|
|
"email", |
785
|
|
|
$std->email, |
786
|
|
|
false, |
787
|
|
|
$identificador . "Endereço de email do emitente" |
788
|
|
|
); |
789
|
|
|
return $this->enderEmit; |
790
|
|
|
} |
791
|
|
|
|
792
|
|
|
/** |
793
|
|
|
* tagrodo |
794
|
|
|
* tag MDFe/infMDFe/infModal/rodo |
795
|
|
|
* |
796
|
|
|
* @return DOMElement |
797
|
|
|
*/ |
798
|
|
|
private function tagrodo() |
799
|
|
|
{ |
800
|
|
|
$this->rodo = $this->dom->createElement("rodo"); |
801
|
|
|
return $this->rodo; |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
/** |
805
|
|
|
* tagferrov |
806
|
|
|
* tag MDFe/infMDFe/infModal/ferrov |
807
|
|
|
* |
808
|
|
|
* @return DOMElement |
809
|
|
|
*/ |
810
|
|
|
private function tagferrov() |
811
|
|
|
{ |
812
|
|
|
if (empty($this->ferrov)) { |
813
|
|
|
$this->ferrov = $this->dom->createElement("ferrov"); |
814
|
|
|
} |
815
|
|
|
return $this->ferrov; |
816
|
|
|
} |
817
|
|
|
|
818
|
|
|
/** |
819
|
|
|
* tagrodo |
820
|
|
|
* tag MDFe/infMDFe/infModal/rodo |
821
|
|
|
* |
822
|
|
|
* @return DOMElement |
823
|
|
|
*/ |
824
|
|
|
private function taginfDoc() |
825
|
|
|
{ |
826
|
|
|
if (empty($this->infDoc)) { |
827
|
|
|
$this->infDoc = $this->dom->createElement("infDoc"); |
828
|
|
|
} |
829
|
|
|
return $this->infDoc; |
830
|
|
|
} |
831
|
|
|
|
832
|
|
|
/** |
833
|
|
|
* valePed |
834
|
|
|
* tag MDFe/infMDFe/infModal/rodo/infANTT/valePed |
835
|
|
|
* |
836
|
|
|
* @return DOMElement |
837
|
|
|
*/ |
838
|
|
|
private function tagvalePed() |
839
|
|
|
{ |
840
|
|
|
if (empty($this->valePed)) { |
841
|
|
|
$this->valePed = $this->dom->createElement("valePed"); |
842
|
|
|
} |
843
|
|
|
return $this->valePed; |
844
|
|
|
} |
845
|
|
|
|
846
|
|
|
/** |
847
|
|
|
* infANTT |
848
|
|
|
* tag MDFe/infMDFe/infModal/rodo/infANTT |
849
|
|
|
* |
850
|
|
|
* @return DOMElement |
851
|
|
|
*/ |
852
|
|
|
public function taginfANTT(stdClass $std) |
853
|
|
|
{ |
854
|
|
|
$possible = [ |
855
|
|
|
'RNTRC' |
856
|
|
|
]; |
857
|
|
|
$std = $this->equilizeParameters($std, $possible); |
858
|
|
|
$identificador = '[2] <infANTT> - '; |
859
|
|
|
$infANTT = $this->dom->createElement("infANTT"); |
860
|
|
|
$this->dom->addChild( |
861
|
|
|
$infANTT, |
862
|
|
|
"RNTRC", |
863
|
|
|
$std->RNTRC, |
864
|
|
|
false, |
865
|
|
|
$identificador . "Registro Nacional de Transportadores Rodoviários de Carga" |
866
|
|
|
); |
867
|
|
|
$this->infANTT = $infANTT; |
868
|
|
|
return $infANTT; |
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
/** |
872
|
|
|
* disp |
873
|
|
|
* tag MDFe/infMDFe/infModal/rodo/infANTT/disp |
874
|
|
|
* |
875
|
|
|
* @return DOMElement |
876
|
|
|
*/ |
877
|
|
|
public function tagdisp(stdClass $std) |
878
|
|
|
{ |
879
|
|
|
$possible = [ |
880
|
|
|
'CNPJForn', |
881
|
|
|
'CNPJPg', |
882
|
|
|
'CPFPg', |
883
|
|
|
'nCompra', |
884
|
|
|
'vValePed' |
885
|
|
|
]; |
886
|
|
|
$this->tagvalePed(); |
887
|
|
|
$std = $this->equilizeParameters($std, $possible); |
888
|
|
|
$identificador = '[4] <disp> - '; |
889
|
|
|
$disp = $this->dom->createElement("disp"); |
890
|
|
|
$this->dom->addChild( |
891
|
|
|
$disp, |
892
|
|
|
"CNPJForn", |
893
|
|
|
$std->CNPJForn, |
894
|
|
|
false, |
895
|
|
|
$identificador . "CNPJ da empresa fornecedora do ValePedágio" |
896
|
|
|
); |
897
|
|
|
$this->dom->addChild( |
898
|
|
|
$disp, |
899
|
|
|
"CNPJPg", |
900
|
|
|
$std->CNPJPg, |
901
|
|
|
false, |
902
|
|
|
$identificador . "CNPJ do responsável pelo pagamento do Vale-Pedágio" |
903
|
|
|
); |
904
|
|
|
$this->dom->addChild( |
905
|
|
|
$disp, |
906
|
|
|
"CPFPg", |
907
|
|
|
$std->CPFPg, |
908
|
|
|
false, |
909
|
|
|
$identificador . "CPF do responsável pelo pagamento do Vale-Pedágio" |
910
|
|
|
); |
911
|
|
|
$this->dom->addChild( |
912
|
|
|
$disp, |
913
|
|
|
"nCompra", |
914
|
|
|
$std->nCompra, |
915
|
|
|
false, |
916
|
|
|
$identificador . "Número do comprovante de compra" |
917
|
|
|
); |
918
|
|
|
$this->dom->addChild( |
919
|
|
|
$disp, |
920
|
|
|
"vValePed", |
921
|
|
|
$std->vValePed, |
922
|
|
|
false, |
923
|
|
|
$identificador . "Valor do Vale-Pedagio" |
924
|
|
|
); |
925
|
|
|
$this->disp[] = $disp; |
926
|
|
|
return $disp; |
927
|
|
|
} |
928
|
|
|
|
929
|
|
|
/** |
930
|
|
|
* infContratante |
931
|
|
|
* tag MDFe/infMDFe/infModal/rodo/infANTT/infContratante |
932
|
|
|
* |
933
|
|
|
* @return DOMElement |
934
|
|
|
*/ |
935
|
|
|
public function taginfContratante(stdClass $std) |
936
|
|
|
{ |
937
|
|
|
$possible = [ |
938
|
|
|
'CPF', |
939
|
|
|
'CNPJ' |
940
|
|
|
]; |
941
|
|
|
$std = $this->equilizeParameters($std, $possible); |
942
|
|
|
$identificador = '[4] <infContratante> - '; |
943
|
|
|
$infContratante = $this->dom->createElement("infContratante"); |
944
|
|
|
if ($std->CPF) { |
945
|
|
|
$this->dom->addChild( |
946
|
|
|
$infContratante, |
947
|
|
|
"CPF", |
948
|
|
|
$std->CPF, |
949
|
|
|
true, |
950
|
|
|
$identificador . "Número do CPF do contratente do serviço" |
951
|
|
|
); |
952
|
|
|
} else { |
953
|
|
|
$this->dom->addChild( |
954
|
|
|
$infContratante, |
955
|
|
|
"CNPJ", |
956
|
|
|
$std->CNPJ, |
957
|
|
|
true, |
958
|
|
|
$identificador . "Número do CNPJ do contratente do serviço" |
959
|
|
|
); |
960
|
|
|
} |
961
|
|
|
$this->infContratante[] = $infContratante; |
962
|
|
|
return $infContratante; |
963
|
|
|
} |
964
|
|
|
|
965
|
|
|
/** |
966
|
|
|
* infANTT |
967
|
|
|
* tag MDFe/infMDFe/infModal/rodo/infANTT/infCIOT |
968
|
|
|
* |
969
|
|
|
* @return DOMElement |
970
|
|
|
*/ |
971
|
|
|
public function taginfCIOT(stdClass $std) |
972
|
|
|
{ |
973
|
|
|
$possible = [ |
974
|
|
|
'CIOT', |
975
|
|
|
'CPF', |
976
|
|
|
'CNPJ' |
977
|
|
|
]; |
978
|
|
|
$std = $this->equilizeParameters($std, $possible); |
979
|
|
|
$identificador = '[4] <infCIOT> - '; |
980
|
|
|
$infCIOT = $this->dom->createElement("infCIOT"); |
981
|
|
|
$this->dom->addChild( |
982
|
|
|
$infCIOT, |
983
|
|
|
"CIOT", |
984
|
|
|
$std->CIOT, |
985
|
|
|
true, |
986
|
|
|
$identificador . "Código Identificador da Operação de Transporte" |
987
|
|
|
); |
988
|
|
|
if ($std->CPF) { |
989
|
|
|
$this->dom->addChild( |
990
|
|
|
$infCIOT, |
991
|
|
|
"CPF", |
992
|
|
|
$std->CPF, |
993
|
|
|
true, |
994
|
|
|
$identificador . "Número do CPF responsável pela geração do CIOT" |
995
|
|
|
); |
996
|
|
|
} else { |
997
|
|
|
$this->dom->addChild( |
998
|
|
|
$infCIOT, |
999
|
|
|
"CNPJ", |
1000
|
|
|
$std->CNPJ, |
1001
|
|
|
true, |
1002
|
|
|
$identificador . "Número do CNPJ responsável pela geração do CIOT" |
1003
|
|
|
); |
1004
|
|
|
} |
1005
|
|
|
$this->infCIOT[] = $infCIOT; |
1006
|
|
|
return $infCIOT; |
1007
|
|
|
} |
1008
|
|
|
|
1009
|
|
|
/** |
1010
|
|
|
* tagInfMunDescarga |
1011
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga |
1012
|
|
|
* |
1013
|
|
|
* @param stdClass $std |
1014
|
|
|
* @return DOMElement |
1015
|
|
|
*/ |
1016
|
|
|
public function taginfMunDescarga(stdClass $std) |
1017
|
|
|
{ |
1018
|
|
|
$possible = [ |
1019
|
|
|
'cMunDescarga', |
1020
|
|
|
'xMunDescarga', |
1021
|
|
|
'nItem' |
1022
|
|
|
]; |
1023
|
|
|
$this->taginfDoc(); |
1024
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1025
|
|
|
$identificador = '[4] <infMunDescarga> - '; |
1026
|
|
|
$infMunDescarga = $this->dom->createElement("infMunDescarga"); |
1027
|
|
|
$this->dom->addChild( |
1028
|
|
|
$infMunDescarga, |
1029
|
|
|
"cMunDescarga", |
1030
|
|
|
$std->cMunDescarga, |
1031
|
|
|
true, |
1032
|
|
|
$identificador . "Código do Município de Descarga" |
1033
|
|
|
); |
1034
|
|
|
$this->dom->addChild( |
1035
|
|
|
$infMunDescarga, |
1036
|
|
|
"xMunDescarga", |
1037
|
|
|
$std->xMunDescarga, |
1038
|
|
|
true, |
1039
|
|
|
$identificador . "Nome do Município de Descarga" |
1040
|
|
|
); |
1041
|
|
|
$this->infMunDescarga[$std->nItem] = $infMunDescarga; |
1042
|
|
|
return $infMunDescarga; |
1043
|
|
|
} |
1044
|
|
|
|
1045
|
|
|
/** |
1046
|
|
|
* taginfCTe |
1047
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/infCTe |
1048
|
|
|
* |
1049
|
|
|
* @param stdClass $std |
1050
|
|
|
* @return DOMElement |
1051
|
|
|
*/ |
1052
|
|
|
public function taginfCTe(stdClass $std) |
1053
|
|
|
{ |
1054
|
|
|
$possible = [ |
1055
|
|
|
'chCTe', |
1056
|
|
|
'SegCodBarra', |
1057
|
|
|
'indReentrega', |
1058
|
|
|
'infEntregaParcial', |
1059
|
|
|
'infUnidTransp', |
1060
|
|
|
'peri', |
1061
|
|
|
'nItem' |
1062
|
|
|
]; |
1063
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1064
|
|
|
$infCTe = $this->dom->createElement("infCTe"); |
1065
|
|
|
$identificador = '[4] <infCTe> - '; |
1066
|
|
|
$this->dom->addChild( |
1067
|
|
|
$infCTe, |
1068
|
|
|
"chCTe", |
1069
|
|
|
$std->chCTe, |
1070
|
|
|
true, |
1071
|
|
|
$identificador . "Chave de Acesso CTe" |
1072
|
|
|
); |
1073
|
|
|
$this->dom->addChild( |
1074
|
|
|
$infCTe, |
1075
|
|
|
"SegCodBarra", |
1076
|
|
|
$std->SegCodBarra, |
1077
|
|
|
false, |
1078
|
|
|
$identificador . "Segundo código de barras do CTe" |
1079
|
|
|
); |
1080
|
|
|
$this->dom->addChild( |
1081
|
|
|
$infCTe, |
1082
|
|
|
"indReentrega", |
1083
|
|
|
$std->indReentrega, |
1084
|
|
|
false, |
1085
|
|
|
$identificador . "Indicador de Reentrega" |
1086
|
|
|
); |
1087
|
|
|
if ($std->infUnidTransp) { |
1088
|
|
|
foreach ($std->infUnidTransp as $value) { |
1089
|
|
|
$this->dom->appChild($infCTe, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"'); |
1090
|
|
|
} |
1091
|
|
|
} |
1092
|
|
|
if ($std->peri) { |
1093
|
|
|
foreach ($std->peri as $value) { |
1094
|
|
|
$this->dom->appChild($infCTe, $this->tagperi($value), 'Falta tag "peri"'); |
1095
|
|
|
} |
1096
|
|
|
} |
1097
|
|
|
if ($std->infEntregaParcial != null) { |
1098
|
|
|
$possible = [ |
1099
|
|
|
'qtdTotal', |
1100
|
|
|
'qtdParcial' |
1101
|
|
|
]; |
1102
|
|
|
$stdinfEntregaParcial = $this->equilizeParameters($std->infEntregaParcial, $possible); |
1103
|
|
|
$identificadorparcial = '[4] <infEntregaParcial> - '; |
1104
|
|
|
$infEntregaParcial = $this->dom->createElement("infEntregaParcial"); |
1105
|
|
|
$this->dom->addChild( |
1106
|
|
|
$infEntregaParcial, |
1107
|
|
|
"qtdTotal", |
1108
|
|
|
$stdinfEntregaParcial->qtdTotal, |
1109
|
|
|
true, |
1110
|
|
|
$identificadorparcial . "Quantidade total de volumes" |
1111
|
|
|
); |
1112
|
|
|
$this->dom->addChild( |
1113
|
|
|
$infEntregaParcial, |
1114
|
|
|
"qtdParcial", |
1115
|
|
|
$stdinfEntregaParcial->qtdParcial, |
1116
|
|
|
true, |
1117
|
|
|
$identificadorparcial . "Quantidade de volumes enviados no MDF-e" |
1118
|
|
|
); |
1119
|
|
|
$this->dom->appChild($infCTe, $infEntregaParcial, 'Falta tag "infCTe"'); |
1120
|
|
|
} |
1121
|
|
|
$this->infCTe[$std->nItem][] = $infCTe; |
1122
|
|
|
return $infCTe; |
1123
|
|
|
} |
1124
|
|
|
|
1125
|
|
|
/** |
1126
|
|
|
* tagperi |
1127
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/peri |
1128
|
|
|
* |
1129
|
|
|
* @param stdClass $std |
1130
|
|
|
* @return DOMElement |
1131
|
|
|
*/ |
1132
|
|
|
private function tagperi(stdClass $std) |
1133
|
|
|
{ |
1134
|
|
|
$possible = [ |
1135
|
|
|
'nONU', |
1136
|
|
|
'xNomeAE', |
1137
|
|
|
'xClaRisco', |
1138
|
|
|
'grEmb', |
1139
|
|
|
'qTotProd', |
1140
|
|
|
'qVolTipo' |
1141
|
|
|
]; |
1142
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1143
|
|
|
$peri = $this->dom->createElement("peri"); |
1144
|
|
|
$this->dom->addChild( |
1145
|
|
|
$peri, |
1146
|
|
|
"nONU", |
1147
|
|
|
$std->nONU, |
1148
|
|
|
true, |
1149
|
|
|
"Número ONU/UN" |
1150
|
|
|
); |
1151
|
|
|
$this->dom->addChild( |
1152
|
|
|
$peri, |
1153
|
|
|
"xNomeAE", |
1154
|
|
|
$std->xNomeAE, |
1155
|
|
|
true, |
1156
|
|
|
"Nome apropriado para embarque do produto" |
1157
|
|
|
); |
1158
|
|
|
$this->dom->addChild( |
1159
|
|
|
$peri, |
1160
|
|
|
"xClaRisco", |
1161
|
|
|
$std->xClaRisco, |
1162
|
|
|
true, |
1163
|
|
|
"Classe ou subclasse/divisão, e risco subsidiário/risco secundário" |
1164
|
|
|
); |
1165
|
|
|
$this->dom->addChild( |
1166
|
|
|
$peri, |
1167
|
|
|
"grEmb", |
1168
|
|
|
$std->grEmb, |
1169
|
|
|
true, |
1170
|
|
|
"Grupo de Embalagem" |
1171
|
|
|
); |
1172
|
|
|
$this->dom->addChild( |
1173
|
|
|
$peri, |
1174
|
|
|
"qTotProd", |
1175
|
|
|
$std->qTotProd, |
1176
|
|
|
true, |
1177
|
|
|
"Quantidade total por produto" |
1178
|
|
|
); |
1179
|
|
|
$this->dom->addChild( |
1180
|
|
|
$peri, |
1181
|
|
|
"qVolTipo", |
1182
|
|
|
$std->qVolTipo, |
1183
|
|
|
true, |
1184
|
|
|
"Quantidade e Tipo de volumes" |
1185
|
|
|
); |
1186
|
|
|
return $peri; |
1187
|
|
|
} |
1188
|
|
|
|
1189
|
|
|
/** |
1190
|
|
|
* taginfNFe |
1191
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/infNFe |
1192
|
|
|
* |
1193
|
|
|
* @param stdClass $std |
1194
|
|
|
* @return DOMElement |
1195
|
|
|
*/ |
1196
|
|
|
public function taginfNFe(stdClass $std) |
1197
|
|
|
{ |
1198
|
|
|
$possible = [ |
1199
|
|
|
'chNFe', |
1200
|
|
|
'SegCodBarra', |
1201
|
|
|
'indReentrega', |
1202
|
|
|
'infUnidTransp', |
1203
|
|
|
'peri', |
1204
|
|
|
'nItem' |
1205
|
|
|
]; |
1206
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1207
|
|
|
$infNFe = $this->dom->createElement("infNFe"); |
1208
|
|
|
$this->dom->addChild( |
1209
|
|
|
$infNFe, |
1210
|
|
|
"chNFe", |
1211
|
|
|
$std->chNFe, |
1212
|
|
|
true, |
1213
|
|
|
"Chave de Acesso NFe" |
1214
|
|
|
); |
1215
|
|
|
$this->dom->addChild( |
1216
|
|
|
$infNFe, |
1217
|
|
|
"SegCodBarra", |
1218
|
|
|
$std->SegCodBarra, |
1219
|
|
|
false, |
1220
|
|
|
"Segundo código de barras do NFe" |
1221
|
|
|
); |
1222
|
|
|
$this->dom->addChild( |
1223
|
|
|
$infNFe, |
1224
|
|
|
"indReentrega", |
1225
|
|
|
$std->indReentrega, |
1226
|
|
|
false, |
1227
|
|
|
"Indicador de Reentrega" |
1228
|
|
|
); |
1229
|
|
|
if ($std->infUnidTransp) { |
1230
|
|
|
foreach ($std->infUnidTransp as $value) { |
1231
|
|
|
$this->dom->appChild($infNFe, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"'); |
1232
|
|
|
} |
1233
|
|
|
} |
1234
|
|
|
if ($std->peri) { |
1235
|
|
|
foreach ($std->peri as $value) { |
1236
|
|
|
$this->dom->appChild($infNFe, $this->tagperi($value), 'Falta tag "peri"'); |
1237
|
|
|
} |
1238
|
|
|
} |
1239
|
|
|
$this->infNFe[$std->nItem][] = $infNFe; |
1240
|
|
|
return $infNFe; |
1241
|
|
|
} |
1242
|
|
|
|
1243
|
|
|
/** |
1244
|
|
|
* taginfMDFeTransp |
1245
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/infMDFeTransp |
1246
|
|
|
* |
1247
|
|
|
* @param stdClass $std |
1248
|
|
|
* @return DOMElement |
1249
|
|
|
*/ |
1250
|
|
|
public function taginfMDFeTransp(stdClass $std) |
1251
|
|
|
{ |
1252
|
|
|
$possible = [ |
1253
|
|
|
'chMDFe', |
1254
|
|
|
'indReentrega', |
1255
|
|
|
'nItem' |
1256
|
|
|
]; |
1257
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1258
|
|
|
$infMDFeTransp = $this->dom->createElement("infMDFeTransp"); |
1259
|
|
|
$this->dom->addChild( |
1260
|
|
|
$infMDFeTransp, |
1261
|
|
|
"chMDFe", |
1262
|
|
|
$std->chMDFe, |
1263
|
|
|
true, |
1264
|
|
|
"Chave de Acesso NFe" |
1265
|
|
|
); |
1266
|
|
|
$this->dom->addChild( |
1267
|
|
|
$infMDFeTransp, |
1268
|
|
|
"indReentrega", |
1269
|
|
|
$std->indReentrega, |
1270
|
|
|
false, |
1271
|
|
|
"Indicador de Reentrega" |
1272
|
|
|
); |
1273
|
|
|
if ($std->infUnidTransp) { |
1274
|
|
|
foreach ($std->infUnidTransp as $value) { |
1275
|
|
|
$this->dom->appChild($infMDFeTransp, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"'); |
1276
|
|
|
} |
1277
|
|
|
} |
1278
|
|
|
if ($std->peri) { |
1279
|
|
|
foreach ($std->peri as $value) { |
1280
|
|
|
$this->dom->appChild($infMDFeTransp, $this->tagperi($value), 'Falta tag "peri"'); |
1281
|
|
|
} |
1282
|
|
|
} |
1283
|
|
|
$this->infMDFeTransp[$std->nItem][] = $infMDFeTransp; |
1284
|
|
|
return $infMDFeTransp; |
1285
|
|
|
} |
1286
|
|
|
|
1287
|
|
|
/** |
1288
|
|
|
* taginfUnidTransp |
1289
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidTransp |
1290
|
|
|
* |
1291
|
|
|
* @param stdClass $std |
1292
|
|
|
* @return DOMElement |
1293
|
|
|
*/ |
1294
|
|
|
private function taginfUnidTransp(stdClass $std) |
1295
|
|
|
{ |
1296
|
|
|
$possible = [ |
1297
|
|
|
'tpUnidTransp', |
1298
|
|
|
'idUnidTransp', |
1299
|
|
|
'qtdRat', |
1300
|
|
|
'lacUnidTransp', |
1301
|
|
|
'infUnidCarga' |
1302
|
|
|
]; |
1303
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1304
|
|
|
$infUnidTransp = $this->dom->createElement("infUnidTransp"); |
1305
|
|
|
$this->dom->addChild( |
1306
|
|
|
$infUnidTransp, |
1307
|
|
|
"tpUnidTransp", |
1308
|
|
|
$std->tpUnidTransp, |
1309
|
|
|
true, |
1310
|
|
|
"Tipo da Unidade de Transporte" |
1311
|
|
|
); |
1312
|
|
|
$this->dom->addChild( |
1313
|
|
|
$infUnidTransp, |
1314
|
|
|
"idUnidTransp", |
1315
|
|
|
$std->idUnidTransp, |
1316
|
|
|
false, |
1317
|
|
|
"Identificação da Unidade de Transporte" |
1318
|
|
|
); |
1319
|
|
|
if ($std->lacUnidTransp != null) { |
1320
|
|
|
$possible = [ |
1321
|
|
|
'nLacre' |
1322
|
|
|
]; |
1323
|
|
|
$stdlacUnidTransp = $this->equilizeParameters($std->lacUnidTransp, $possible); |
1324
|
|
|
foreach ($stdlacUnidTransp->nLacre as $nLacre) { |
1325
|
|
|
$lacUnidTransp = $this->dom->createElement("lacUnidTransp"); |
1326
|
|
|
$this->dom->addChild( |
1327
|
|
|
$lacUnidTransp, |
1328
|
|
|
"nLacre", |
1329
|
|
|
$nLacre, |
1330
|
|
|
true, |
1331
|
|
|
"Número do lacre" |
1332
|
|
|
); |
1333
|
|
|
$this->dom->appChild($infUnidTransp, $lacUnidTransp, 'Falta tag "infUnidTransp"'); |
1334
|
|
|
} |
1335
|
|
|
} |
1336
|
|
|
if ($std->infUnidCarga) { |
1337
|
|
|
foreach ($std->infUnidCarga as $value) { |
1338
|
|
|
$this->dom->appChild($infUnidTransp, $this->taginfUnidCarga($value), 'Falta tag "infUnidCarga"'); |
1339
|
|
|
} |
1340
|
|
|
} |
1341
|
|
|
$this->dom->addChild( |
1342
|
|
|
$infUnidTransp, |
1343
|
|
|
"qtdRat", |
1344
|
|
|
$std->qtdRat, |
1345
|
|
|
false, |
1346
|
|
|
"Quantidade rateada (Peso,Volume) " |
1347
|
|
|
); |
1348
|
|
|
return $infUnidTransp; |
1349
|
|
|
} |
1350
|
|
|
|
1351
|
|
|
/** |
1352
|
|
|
* taginfUnidCarga |
1353
|
|
|
* tag MDFe/infMDFe/infDoc/infMunDescarga/(infCTe/infNFe)/infUnidCarga |
1354
|
|
|
* |
1355
|
|
|
* @param stdClass $std |
1356
|
|
|
* @return DOMElement |
1357
|
|
|
*/ |
1358
|
|
|
private function taginfUnidCarga(stdClass $std) |
1359
|
|
|
{ |
1360
|
|
|
$possible = [ |
1361
|
|
|
'tpUnidCarga', |
1362
|
|
|
'idUnidCarga', |
1363
|
|
|
'lacUnidCarga', |
1364
|
|
|
'qtdRat' |
1365
|
|
|
]; |
1366
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1367
|
|
|
$infUnidCarga = $this->dom->createElement("infUnidCarga"); |
1368
|
|
|
$this->dom->addChild( |
1369
|
|
|
$infUnidCarga, |
1370
|
|
|
"tpUnidCarga", |
1371
|
|
|
$std->tpUnidCarga, |
1372
|
|
|
false, |
1373
|
|
|
"Tipo da Unidade de Carga" |
1374
|
|
|
); |
1375
|
|
|
$this->dom->addChild( |
1376
|
|
|
$infUnidCarga, |
1377
|
|
|
"idUnidCarga", |
1378
|
|
|
$std->idUnidCarga, |
1379
|
|
|
false, |
1380
|
|
|
"Identificação da Unidade de Carga " |
1381
|
|
|
); |
1382
|
|
|
if ($std->lacUnidCarga != null) { |
1383
|
|
|
$possible = [ |
1384
|
|
|
'nLacre' |
1385
|
|
|
]; |
1386
|
|
|
$stdlacUnidCarga = $this->equilizeParameters($std->lacUnidCarga, $possible); |
1387
|
|
|
foreach ($stdlacUnidCarga->nLacre as $nLacre) { |
1388
|
|
|
$lacUnidCarga = $this->dom->createElement("lacUnidCarga"); |
1389
|
|
|
$this->dom->addChild( |
1390
|
|
|
$lacUnidCarga, |
1391
|
|
|
"nLacre", |
1392
|
|
|
$nLacre, |
1393
|
|
|
true, |
1394
|
|
|
"Número do lacre" |
1395
|
|
|
); |
1396
|
|
|
$this->dom->appChild($infUnidCarga, $lacUnidCarga, 'Falta tag "infUnidCarga"'); |
1397
|
|
|
} |
1398
|
|
|
} |
1399
|
|
|
$this->dom->addChild( |
1400
|
|
|
$infUnidCarga, |
1401
|
|
|
"qtdRat", |
1402
|
|
|
$std->qtdRat, |
1403
|
|
|
false, |
1404
|
|
|
"Quantidade rateada (Peso,Volume) " |
1405
|
|
|
); |
1406
|
|
|
return $infUnidCarga; |
1407
|
|
|
} |
1408
|
|
|
|
1409
|
|
|
/** |
1410
|
|
|
* tagseg |
1411
|
|
|
* tag MDFe/infMDFe/seg |
1412
|
|
|
* |
1413
|
|
|
* @param stdClass $std |
1414
|
|
|
* @return DOMElement |
1415
|
|
|
*/ |
1416
|
|
|
public function tagseg(stdClass $std) |
1417
|
|
|
{ |
1418
|
|
|
$possible = [ |
1419
|
|
|
'respSeg', |
1420
|
|
|
'CNPJ', |
1421
|
|
|
'CPF', |
1422
|
|
|
'infSeg', |
1423
|
|
|
'nApol', |
1424
|
|
|
'nAver' |
1425
|
|
|
]; |
1426
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1427
|
|
|
$seg = $this->dom->createElement("seg"); |
1428
|
|
|
$infResp = $this->dom->createElement("infResp"); |
1429
|
|
|
$this->dom->addChild( |
1430
|
|
|
$infResp, |
1431
|
|
|
"respSeg", |
1432
|
|
|
$std->respSeg, |
1433
|
|
|
true, |
1434
|
|
|
"Responsável pelo seguro" |
1435
|
|
|
); |
1436
|
|
|
$this->dom->addChild( |
1437
|
|
|
$infResp, |
1438
|
|
|
"CNPJ", |
1439
|
|
|
$std->CNPJ, |
1440
|
|
|
false, |
1441
|
|
|
"Número do CNPJ do responsável pelo seguro" |
1442
|
|
|
); |
1443
|
|
|
$this->dom->addChild( |
1444
|
|
|
$infResp, |
1445
|
|
|
"CPF", |
1446
|
|
|
$std->CPF, |
1447
|
|
|
false, |
1448
|
|
|
"Número do CPF do responsável pelo seguro" |
1449
|
|
|
); |
1450
|
|
|
$this->dom->appChild($seg, $infResp, 'Falta tag "seg"'); |
1451
|
|
|
if ($std->infSeg != null) { |
1452
|
|
|
$possible = [ |
1453
|
|
|
'xSeg', |
1454
|
|
|
'CNPJ' |
1455
|
|
|
]; |
1456
|
|
|
$stdinfSeg = $this->equilizeParameters($std->infSeg, $possible); |
1457
|
|
|
$infSeg = $this->dom->createElement("infSeg"); |
1458
|
|
|
$this->dom->addChild( |
1459
|
|
|
$infSeg, |
1460
|
|
|
"xSeg", |
1461
|
|
|
$stdinfSeg->xSeg, |
1462
|
|
|
true, |
1463
|
|
|
"Nome da Seguradora" |
1464
|
|
|
); |
1465
|
|
|
$this->dom->addChild( |
1466
|
|
|
$infSeg, |
1467
|
|
|
"CNPJ", |
1468
|
|
|
$stdinfSeg->CNPJ, |
1469
|
|
|
false, |
1470
|
|
|
"Número do CNPJ da seguradora" |
1471
|
|
|
); |
1472
|
|
|
$this->dom->appChild($seg, $infSeg, 'Falta tag "seg"'); |
1473
|
|
|
} |
1474
|
|
|
$this->dom->addChild( |
1475
|
|
|
$seg, |
1476
|
|
|
"nApol", |
1477
|
|
|
$std->nApol, |
1478
|
|
|
false, |
1479
|
|
|
"Número da Apólice" |
1480
|
|
|
); |
1481
|
|
|
if ($std->nAver != null) { |
1482
|
|
|
foreach ($std->nAver as $nAver) { |
1483
|
|
|
$this->dom->addChild( |
1484
|
|
|
$seg, |
1485
|
|
|
"nAver", |
1486
|
|
|
$nAver, |
1487
|
|
|
true, |
1488
|
|
|
"Número da Averbação" |
1489
|
|
|
); |
1490
|
|
|
} |
1491
|
|
|
} |
1492
|
|
|
$this->seg[] = $seg; |
1493
|
|
|
return $seg; |
1494
|
|
|
} |
1495
|
|
|
|
1496
|
|
|
/** |
1497
|
|
|
* tagTot |
1498
|
|
|
* tag MDFe/infMDFe/tot |
1499
|
|
|
* |
1500
|
|
|
* @param stdClass $std |
1501
|
|
|
* @return DOMElement |
1502
|
|
|
*/ |
1503
|
|
|
public function tagtot(stdClass $std) |
1504
|
|
|
{ |
1505
|
|
|
$possible = [ |
1506
|
|
|
'vCarga', |
1507
|
|
|
'cUnid', |
1508
|
|
|
'qCarga' |
1509
|
|
|
]; |
1510
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1511
|
|
|
$std->qCTe = count($this->infCTe); |
1512
|
|
|
if ($std->qCTe == 0) { |
1513
|
|
|
$std->qCTe = ''; |
1514
|
|
|
} |
1515
|
|
|
$std->qNFe = count($this->infNFe); |
1516
|
|
|
if ($std->qNFe == 0) { |
1517
|
|
|
$std->qNFe = ''; |
1518
|
|
|
} |
1519
|
|
|
$std->qMDFe = count($this->infMDFeTransp); |
1520
|
|
|
if ($std->qMDFe == 0) { |
1521
|
|
|
$std->qMDFe = ''; |
1522
|
|
|
} |
1523
|
|
|
$tot = $this->dom->createElement("tot"); |
1524
|
|
|
$this->dom->addChild( |
1525
|
|
|
$tot, |
1526
|
|
|
"qCTe", |
1527
|
|
|
$std->qCTe, |
1528
|
|
|
false, |
1529
|
|
|
"Quantidade total de CT-e relacionados no Manifesto" |
1530
|
|
|
); |
1531
|
|
|
$this->dom->addChild( |
1532
|
|
|
$tot, |
1533
|
|
|
"qNFe", |
1534
|
|
|
$std->qNFe, |
1535
|
|
|
false, |
1536
|
|
|
"Quantidade total de NF-e relacionados no Manifesto" |
1537
|
|
|
); |
1538
|
|
|
$this->dom->addChild( |
1539
|
|
|
$tot, |
1540
|
|
|
"qMDFe", |
1541
|
|
|
$std->qMDFe, |
1542
|
|
|
false, |
1543
|
|
|
"Quantidade total de MDF-e relacionados no Manifesto" |
1544
|
|
|
); |
1545
|
|
|
$this->dom->addChild( |
1546
|
|
|
$tot, |
1547
|
|
|
"vCarga", |
1548
|
|
|
$std->vCarga, |
1549
|
|
|
true, |
1550
|
|
|
"Valor total da mercadoria/carga transportada" |
1551
|
|
|
); |
1552
|
|
|
$this->dom->addChild( |
1553
|
|
|
$tot, |
1554
|
|
|
"cUnid", |
1555
|
|
|
$std->cUnid, |
1556
|
|
|
true, |
1557
|
|
|
"Código da unidade de medida do Peso Bruto da Carga / Mercadoria Transportada" |
1558
|
|
|
); |
1559
|
|
|
$this->dom->addChild( |
1560
|
|
|
$tot, |
1561
|
|
|
"qCarga", |
1562
|
|
|
$std->qCarga, |
1563
|
|
|
true, |
1564
|
|
|
"Peso Bruto Total da Carga / Mercadoria Transportada" |
1565
|
|
|
); |
1566
|
|
|
$this->tot = $tot; |
1567
|
|
|
return $tot; |
1568
|
|
|
} |
1569
|
|
|
|
1570
|
|
|
/** |
1571
|
|
|
* tagLacres |
1572
|
|
|
* tag MDFe/infMDFe/lacres |
1573
|
|
|
* |
1574
|
|
|
* @param stdClass $std |
1575
|
|
|
* @return DOMElement |
1576
|
|
|
*/ |
1577
|
|
|
public function taglacres(stdClass $std) |
1578
|
|
|
{ |
1579
|
|
|
$possible = [ |
1580
|
|
|
'nLacre' |
1581
|
|
|
]; |
1582
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1583
|
|
|
$lacres = $this->dom->createElement("lacres"); |
1584
|
|
|
$this->dom->addChild( |
1585
|
|
|
$lacres, |
1586
|
|
|
"nLacre", |
1587
|
|
|
$std->nLacre, |
1588
|
|
|
false, |
1589
|
|
|
"Número do lacre" |
1590
|
|
|
); |
1591
|
|
|
$this->lacres[] = $lacres; //array de DOMNode |
1592
|
|
|
return $this->lacres; |
1593
|
|
|
} |
1594
|
|
|
|
1595
|
|
|
/** |
1596
|
|
|
* taginfAdic |
1597
|
|
|
* Grupo de Informações Adicionais Z01 pai A01 |
1598
|
|
|
* tag MDFe/infMDFe/infAdic (opcional) |
1599
|
|
|
* |
1600
|
|
|
* @param stdClass $std |
1601
|
|
|
* @return DOMElement |
1602
|
|
|
*/ |
1603
|
|
|
public function taginfAdic(stdClass $std) |
1604
|
|
|
{ |
1605
|
|
|
$possible = [ |
1606
|
|
|
'infAdFisco', |
1607
|
|
|
'infCpl' |
1608
|
|
|
]; |
1609
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1610
|
|
|
$infAdic = $this->dom->createElement("infAdic"); |
1611
|
|
|
$this->dom->addChild( |
1612
|
|
|
$infAdic, |
1613
|
|
|
"infAdFisco", |
1614
|
|
|
$std->infAdFisco, |
1615
|
|
|
false, |
1616
|
|
|
"Informações Adicionais de Interesse do Fisco" |
1617
|
|
|
); |
1618
|
|
|
$this->dom->addChild( |
1619
|
|
|
$infAdic, |
1620
|
|
|
"infCpl", |
1621
|
|
|
$std->infCpl, |
1622
|
|
|
false, |
1623
|
|
|
"Informações Complementares de interesse do Contribuinte" |
1624
|
|
|
); |
1625
|
|
|
$this->infAdic = $infAdic; |
1626
|
|
|
return $infAdic; |
1627
|
|
|
} |
1628
|
|
|
|
1629
|
|
|
/** |
1630
|
|
|
* tagautXML |
1631
|
|
|
* tag MDFe/infMDFe/autXML |
1632
|
|
|
* |
1633
|
|
|
* Autorizados para download do XML do MDF-e |
1634
|
|
|
* |
1635
|
|
|
* @param stdClass $std |
1636
|
|
|
* @return DOMElement |
1637
|
|
|
*/ |
1638
|
|
|
public function tagautXML(stdClass $std) |
1639
|
|
|
{ |
1640
|
|
|
$possible = [ |
1641
|
|
|
'CNPJ', |
1642
|
|
|
'CPF' |
1643
|
|
|
]; |
1644
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1645
|
|
|
$autXML = $this->dom->createElement("autXML"); |
1646
|
|
|
$this->dom->addChild( |
1647
|
|
|
$autXML, |
1648
|
|
|
"CNPJ", |
1649
|
|
|
$std->CNPJ, |
1650
|
|
|
false, |
1651
|
|
|
"CNPJ do autorizado" |
1652
|
|
|
); |
1653
|
|
|
$this->dom->addChild( |
1654
|
|
|
$autXML, |
1655
|
|
|
"CPF", |
1656
|
|
|
$std->CPF, |
1657
|
|
|
false, |
1658
|
|
|
"CPF do autorizado" |
1659
|
|
|
); |
1660
|
|
|
$this->autXML[] = $autXML; |
1661
|
|
|
return $this->autXML; |
|
|
|
|
1662
|
|
|
} |
1663
|
|
|
|
1664
|
|
|
/** |
1665
|
|
|
* buildInfModal |
1666
|
|
|
* tag MDFe/infMDFe/infModal |
1667
|
|
|
* |
1668
|
|
|
* @return DOMElement |
1669
|
|
|
*/ |
1670
|
|
|
private function buildInfModal() |
1671
|
|
|
{ |
1672
|
|
|
$infModal = $this->dom->createElement("infModal"); |
1673
|
|
|
$infModal->setAttribute("versaoModal", $this->versao); |
1674
|
|
|
$this->infModal = $infModal; |
1675
|
|
|
$modal = $this->ide->getElementsByTagName('modal')->item(0)->nodeValue; |
1676
|
|
|
/* |
1677
|
|
|
1 - Rodoviário; |
1678
|
|
|
2 - Aéreo; |
1679
|
|
|
3 - Aquaviário; |
1680
|
|
|
4 - Ferroviário; |
1681
|
|
|
*/ |
1682
|
|
|
if ($modal == '1') { |
1683
|
|
|
$this->tagrodo(); |
1684
|
|
|
} else if ($modal == '4') { |
1685
|
|
|
$this->tagferrov(); |
1686
|
|
|
} |
1687
|
|
|
return $infModal; |
1688
|
|
|
} |
1689
|
|
|
|
1690
|
|
|
private function buildIde() |
1691
|
|
|
{ |
1692
|
|
|
$this->dom->appChild($this->infMDFe, $this->ide, 'Falta tag "ide"'); |
1693
|
|
|
$UFFim = $this->ide->getElementsByTagName('UFFim')->item(0); |
1694
|
|
|
foreach ($this->infPercurso as $percurso) { |
|
|
|
|
1695
|
|
|
$this->dom->insertAfter($percurso, $UFFim); |
1696
|
|
|
} |
1697
|
|
|
foreach ($this->infMunCarrega as $munCarrega) { |
|
|
|
|
1698
|
|
|
$this->dom->insertAfter($munCarrega, $UFFim); |
1699
|
|
|
} |
1700
|
|
|
} |
1701
|
|
|
|
1702
|
|
|
/** |
1703
|
|
|
* tagAereo |
1704
|
|
|
* tag MDFe/infMDFe/infModal/aereo |
1705
|
|
|
* |
1706
|
|
|
* @return DOMElement |
1707
|
|
|
*/ |
1708
|
|
|
|
1709
|
|
|
public function tagaereo(stdClass $std) |
1710
|
|
|
{ |
1711
|
|
|
$possible = [ |
1712
|
|
|
'nac', |
1713
|
|
|
'matr', |
1714
|
|
|
'nVoo', |
1715
|
|
|
'cAerEmb', |
1716
|
|
|
'cAerDes', |
1717
|
|
|
'dVoo' |
1718
|
|
|
]; |
1719
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1720
|
|
|
$aereo = $this->dom->createElement("aereo"); |
1721
|
|
|
$identificador = '[1] <aereo> - '; |
1722
|
|
|
$this->dom->addChild( |
1723
|
|
|
$aereo, |
1724
|
|
|
"nac", |
1725
|
|
|
$std->nac, |
1726
|
|
|
true, |
1727
|
|
|
$identificador . "Marca da Nacionalidade da aeronave" |
1728
|
|
|
); |
1729
|
|
|
$this->dom->addChild( |
1730
|
|
|
$aereo, |
1731
|
|
|
"matr", |
1732
|
|
|
$std->matr, |
1733
|
|
|
true, |
1734
|
|
|
$identificador . "Marca de Matrícula da aeronave" |
1735
|
|
|
); |
1736
|
|
|
$this->dom->addChild( |
1737
|
|
|
$aereo, |
1738
|
|
|
"nVoo", |
1739
|
|
|
$std->nVoo, |
1740
|
|
|
true, |
1741
|
|
|
$identificador . "Número do Vôo" |
1742
|
|
|
); |
1743
|
|
|
$this->dom->addChild( |
1744
|
|
|
$aereo, |
1745
|
|
|
"cAerEmb", |
1746
|
|
|
$std->cAerEmb, |
1747
|
|
|
true, |
1748
|
|
|
$identificador . "Aeródromo de Embarque - Código IATA" |
1749
|
|
|
); |
1750
|
|
|
$this->dom->addChild( |
1751
|
|
|
$aereo, |
1752
|
|
|
"cAerDes", |
1753
|
|
|
$std->cAerDes, |
1754
|
|
|
true, |
1755
|
|
|
$identificador . "Aeródromo de Destino - Código IATA" |
1756
|
|
|
); |
1757
|
|
|
$this->dom->addChild( |
1758
|
|
|
$aereo, |
1759
|
|
|
"dVoo", |
1760
|
|
|
$std->dVoo, |
1761
|
|
|
true, |
1762
|
|
|
$identificador . "Data do Vôo" |
1763
|
|
|
); |
1764
|
|
|
$this->aereo = $aereo; |
1765
|
|
|
return $aereo; |
1766
|
|
|
} |
1767
|
|
|
|
1768
|
|
|
|
1769
|
|
|
/** |
1770
|
|
|
* tagtrem |
1771
|
|
|
* tag MDFe/infMDFe/infModal/ferrov/trem |
1772
|
|
|
* |
1773
|
|
|
* @return DOMElement |
1774
|
|
|
*/ |
1775
|
|
|
|
1776
|
|
|
public function tagtrem(stdClass $std) |
1777
|
|
|
{ |
1778
|
|
|
$possible = [ |
1779
|
|
|
'xPref', |
1780
|
|
|
'dhTrem', |
1781
|
|
|
'xOri', |
1782
|
|
|
'xDest', |
1783
|
|
|
'qVag' |
1784
|
|
|
]; |
1785
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1786
|
|
|
$trem = $this->dom->createElement("trem"); |
1787
|
|
|
$identificador = '[1] <trem> - '; |
1788
|
|
|
$this->dom->addChild( |
1789
|
|
|
$trem, |
1790
|
|
|
"xPref", |
1791
|
|
|
$std->xPref, |
1792
|
|
|
true, |
1793
|
|
|
$identificador . "Prefixo do Trem" |
1794
|
|
|
); |
1795
|
|
|
$this->dom->addChild( |
1796
|
|
|
$trem, |
1797
|
|
|
"dhTrem", |
1798
|
|
|
$std->dhTrem, |
1799
|
|
|
false, |
1800
|
|
|
$identificador . "Data e hora de liberação do trem na origem" |
1801
|
|
|
); |
1802
|
|
|
$this->dom->addChild( |
1803
|
|
|
$trem, |
1804
|
|
|
"xOri", |
1805
|
|
|
$std->xOri, |
1806
|
|
|
true, |
1807
|
|
|
$identificador . "Origem do Trem" |
1808
|
|
|
); |
1809
|
|
|
$this->dom->addChild( |
1810
|
|
|
$trem, |
1811
|
|
|
"xDest", |
1812
|
|
|
$std->xDest, |
1813
|
|
|
true, |
1814
|
|
|
$identificador . "Destino do Trem" |
1815
|
|
|
); |
1816
|
|
|
$this->dom->addChild( |
1817
|
|
|
$trem, |
1818
|
|
|
"qVag", |
1819
|
|
|
$std->qVag, |
1820
|
|
|
true, |
1821
|
|
|
$identificador . "Quantidade de vagões carregados" |
1822
|
|
|
); |
1823
|
|
|
$this->trem = $trem; |
1824
|
|
|
return $trem; |
1825
|
|
|
} |
1826
|
|
|
|
1827
|
|
|
/** |
1828
|
|
|
* tagVag |
1829
|
|
|
* tag MDFe/infMDFe/infModal/ferrov/trem/vag |
1830
|
|
|
* |
1831
|
|
|
* @param string $serie |
1832
|
|
|
* @param string $nVag |
|
|
|
|
1833
|
|
|
* @param string $nSeq |
|
|
|
|
1834
|
|
|
* @param string $tonUtil |
|
|
|
|
1835
|
|
|
* |
|
|
|
|
1836
|
|
|
* @return DOMElement |
1837
|
|
|
*/ |
1838
|
|
|
|
1839
|
|
|
public function tagVag(stdClass $std) |
1840
|
|
|
{ |
1841
|
|
|
$possible = [ |
1842
|
|
|
'pesoBC', |
1843
|
|
|
'pesoR', |
1844
|
|
|
'tpVag', |
1845
|
|
|
'serie', |
1846
|
|
|
'nVag', |
1847
|
|
|
'nSeq', |
1848
|
|
|
'TU' |
1849
|
|
|
]; |
1850
|
|
|
$identificador = '[1] <vag> - '; |
1851
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1852
|
|
|
$vag = $this->dom->createElement("vag"); |
1853
|
|
|
$this->dom->addChild( |
1854
|
|
|
$vag, |
1855
|
|
|
"pesoBC", |
1856
|
|
|
$std->pesoBC, |
1857
|
|
|
true, |
1858
|
|
|
$identificador . "Peso Base de Cálculo de Frete em Toneladas" |
1859
|
|
|
); |
1860
|
|
|
$this->dom->addChild( |
1861
|
|
|
$vag, |
1862
|
|
|
"pesoR", |
1863
|
|
|
$std->pesoR, |
1864
|
|
|
true, |
1865
|
|
|
$identificador . "Peso Real em Toneladas" |
1866
|
|
|
); |
1867
|
|
|
$this->dom->addChild( |
1868
|
|
|
$vag, |
1869
|
|
|
"tpVag", |
1870
|
|
|
$std->tpVag, |
1871
|
|
|
false, |
1872
|
|
|
$identificador . "Tipo de Vagão" |
1873
|
|
|
); |
1874
|
|
|
$this->dom->addChild( |
1875
|
|
|
$vag, |
1876
|
|
|
"serie", |
1877
|
|
|
$std->serie, |
1878
|
|
|
true, |
1879
|
|
|
$identificador . "Serie de Identificação do vagão" |
1880
|
|
|
); |
1881
|
|
|
$this->dom->addChild( |
1882
|
|
|
$vag, |
1883
|
|
|
"nVag", |
1884
|
|
|
$std->nVag, |
1885
|
|
|
true, |
1886
|
|
|
$identificador . "Número de Identificação do vagão" |
1887
|
|
|
); |
1888
|
|
|
$this->dom->addChild( |
1889
|
|
|
$vag, |
1890
|
|
|
"nSeq", |
1891
|
|
|
$std->nSeq, |
1892
|
|
|
false, |
1893
|
|
|
$identificador . "Sequência do vagão na composição" |
1894
|
|
|
); |
1895
|
|
|
$this->dom->addChild( |
1896
|
|
|
$vag, |
1897
|
|
|
"TU", |
1898
|
|
|
$std->TU, |
1899
|
|
|
true, |
1900
|
|
|
$identificador . "Tonelada Útil" |
1901
|
|
|
); |
1902
|
|
|
$this->vag[] = $vag; |
1903
|
|
|
return $vag; |
1904
|
|
|
} |
1905
|
|
|
|
1906
|
|
|
/** |
1907
|
|
|
* tagaquav |
1908
|
|
|
* tag MDFe/infMDFe/infModal/aquav |
1909
|
|
|
* |
1910
|
|
|
* @param stdClass $std |
1911
|
|
|
* @return DOMElement |
1912
|
|
|
*/ |
1913
|
|
|
|
1914
|
|
|
public function tagaquav(stdClass $std) |
1915
|
|
|
{ |
1916
|
|
|
$possible = [ |
1917
|
|
|
'irin', |
1918
|
|
|
'tpEmb', |
1919
|
|
|
'cEmbar', |
1920
|
|
|
'xEmbar', |
1921
|
|
|
'nViag', |
1922
|
|
|
'cPrtEmb', |
1923
|
|
|
'cPrtDest', |
1924
|
|
|
'prtTrans', |
1925
|
|
|
'tpNav', |
1926
|
|
|
'infTermCarreg', |
1927
|
|
|
'infTermDescarreg', |
1928
|
|
|
'infEmbComb', |
1929
|
|
|
'infUnidCargaVazia', |
1930
|
|
|
'infUnidTranspVazia' |
1931
|
|
|
]; |
1932
|
|
|
$identificador = '[1] <aquav> - '; |
1933
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1934
|
|
|
$aquav = $this->dom->createElement("aquav"); |
1935
|
|
|
$this->dom->addChild( |
1936
|
|
|
$aquav, |
1937
|
|
|
"irin", |
1938
|
|
|
$std->irin, |
1939
|
|
|
true, |
1940
|
|
|
$identificador . "Irin do navio sempre deverá ser informado" |
1941
|
|
|
); |
1942
|
|
|
$this->dom->addChild( |
1943
|
|
|
$aquav, |
1944
|
|
|
"tpEmb", |
1945
|
|
|
$std->tpEmb, |
1946
|
|
|
true, |
1947
|
|
|
$identificador . "Código do tipo de embarcação" |
1948
|
|
|
); |
1949
|
|
|
$this->dom->addChild( |
1950
|
|
|
$aquav, |
1951
|
|
|
"cEmbar", |
1952
|
|
|
$std->cEmbar, |
1953
|
|
|
true, |
1954
|
|
|
$identificador . "Código da embarcação" |
1955
|
|
|
); |
1956
|
|
|
$this->dom->addChild( |
1957
|
|
|
$aquav, |
1958
|
|
|
"xEmbar", |
1959
|
|
|
$std->xEmbar, |
1960
|
|
|
true, |
1961
|
|
|
$identificador . "Nome da embarcação" |
1962
|
|
|
); |
1963
|
|
|
$this->dom->addChild( |
1964
|
|
|
$aquav, |
1965
|
|
|
"nViag", |
1966
|
|
|
$std->nViag, |
1967
|
|
|
true, |
1968
|
|
|
$identificador . "Número da Viagem" |
1969
|
|
|
); |
1970
|
|
|
$this->dom->addChild( |
1971
|
|
|
$aquav, |
1972
|
|
|
"cPrtEmb", |
1973
|
|
|
$std->cPrtEmb, |
1974
|
|
|
true, |
1975
|
|
|
$identificador . "Código do Porto de Embarque" |
1976
|
|
|
); |
1977
|
|
|
$this->dom->addChild( |
1978
|
|
|
$aquav, |
1979
|
|
|
"cPrtDest", |
1980
|
|
|
$std->cPrtDest, |
1981
|
|
|
true, |
1982
|
|
|
$identificador . "Código do Porto de Destino" |
1983
|
|
|
); |
1984
|
|
|
$this->dom->addChild( |
1985
|
|
|
$aquav, |
1986
|
|
|
"prtTrans", |
1987
|
|
|
$std->prtTrans, |
1988
|
|
|
false, |
1989
|
|
|
$identificador . "Porto de Transbordo" |
1990
|
|
|
); |
1991
|
|
|
$this->dom->addChild( |
1992
|
|
|
$aquav, |
1993
|
|
|
"tpNav", |
1994
|
|
|
$std->tpNav, |
1995
|
|
|
false, |
1996
|
|
|
$identificador . "Tipo de Navegação" |
1997
|
|
|
); |
1998
|
|
|
if ($std->infTermCarreg) { |
1999
|
|
|
foreach ($std->infTermCarreg as $value) { |
2000
|
|
|
$this->dom->appChild($aquav, $this->taginfTermCarreg($value), 'Falta tag "infTermCarreg"'); |
2001
|
|
|
} |
2002
|
|
|
} |
2003
|
|
|
if ($std->infTermDescarreg) { |
2004
|
|
|
foreach ($std->infTermDescarreg as $value) { |
2005
|
|
|
$this->dom->appChild($aquav, $this->taginfTermDescarreg($value), 'Falta tag "infTermDescarreg"'); |
2006
|
|
|
} |
2007
|
|
|
} |
2008
|
|
|
if ($std->infEmbComb) { |
2009
|
|
|
foreach ($std->infEmbComb as $value) { |
2010
|
|
|
$this->dom->appChild($aquav, $this->taginfEmbComb($value), 'Falta tag "infEmbComb"'); |
2011
|
|
|
} |
2012
|
|
|
} |
2013
|
|
|
if ($std->infUnidCargaVazia) { |
2014
|
|
|
foreach ($std->infUnidCargaVazia as $value) { |
2015
|
|
|
$this->dom->appChild($aquav, $this->taginfUnidCargaVazia($value), 'Falta tag "infUnidCargaVazia"'); |
2016
|
|
|
} |
2017
|
|
|
} |
2018
|
|
|
if ($std->infUnidTranspVazia) { |
2019
|
|
|
foreach ($std->infUnidTranspVazia as $value) { |
2020
|
|
|
$this->dom->appChild($aquav, $this->taginfUnidTranspVazia($value), 'Falta tag "infUnidTranspVazia"'); |
2021
|
|
|
} |
2022
|
|
|
} |
2023
|
|
|
$this->aquav = $aquav; |
2024
|
|
|
return $aquav; |
2025
|
|
|
} |
2026
|
|
|
|
2027
|
|
|
/** |
2028
|
|
|
* infUnidTranspVazia |
2029
|
|
|
* tag MDFe/infMDFe/infModal/Aqua/infUnidTranspVazia |
2030
|
|
|
* |
2031
|
|
|
* @return DOMElement |
2032
|
|
|
*/ |
2033
|
|
|
public function taginfUnidTranspVazia(stdClass $std) |
2034
|
|
|
{ |
2035
|
|
|
$possible = [ |
2036
|
|
|
'idUnidTranspVazia', |
2037
|
|
|
'tpUnidTranspVazia' |
2038
|
|
|
]; |
2039
|
|
|
$identificador = '[1] <infUnidTranspVazia> - '; |
2040
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2041
|
|
|
$infUnidTranspVazia = $this->dom->createElement("infUnidTranspVazia"); |
2042
|
|
|
$this->dom->addChild( |
2043
|
|
|
$infUnidTranspVazia, |
2044
|
|
|
"idUnidTranspVazia", |
2045
|
|
|
$std->idUnidTranspVazia, |
2046
|
|
|
true, |
2047
|
|
|
$identificador . "dentificação da unidades de transporte vazia" |
2048
|
|
|
); |
2049
|
|
|
$this->dom->addChild( |
2050
|
|
|
$infUnidTranspVazia, |
2051
|
|
|
"tpUnidTranspVazia", |
2052
|
|
|
$std->tpUnidTranspVazia, |
2053
|
|
|
true, |
2054
|
|
|
$identificador . "Tipo da unidade de transporte vazia" |
2055
|
|
|
); |
2056
|
|
|
return $infUnidTranspVazia; |
2057
|
|
|
} |
2058
|
|
|
|
2059
|
|
|
/** |
2060
|
|
|
* infUnidCargaVazia |
2061
|
|
|
* tag MDFe/infMDFe/infModal/Aqua/infUnidCargaVazia |
2062
|
|
|
* |
2063
|
|
|
* @return DOMElement |
2064
|
|
|
*/ |
2065
|
|
|
public function taginfUnidCargaVazia(stdClass $std) |
2066
|
|
|
{ |
2067
|
|
|
$possible = [ |
2068
|
|
|
'idUnidCargaVazia', |
2069
|
|
|
'tpUnidCargaVazia' |
2070
|
|
|
]; |
2071
|
|
|
$identificador = '[1] <infUnidCargaVazia> - '; |
2072
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2073
|
|
|
$infUnidCargaVazia = $this->dom->createElement("infUnidCargaVazia"); |
2074
|
|
|
$this->dom->addChild( |
2075
|
|
|
$infUnidCargaVazia, |
2076
|
|
|
"idUnidCargaVazia", |
2077
|
|
|
$std->idUnidCargaVazia, |
2078
|
|
|
true, |
2079
|
|
|
$identificador . "Identificação da unidades de carga vazia" |
2080
|
|
|
); |
2081
|
|
|
$this->dom->addChild( |
2082
|
|
|
$infUnidCargaVazia, |
2083
|
|
|
"tpUnidCargaVazia", |
2084
|
|
|
$std->tpUnidCargaVazia, |
2085
|
|
|
true, |
2086
|
|
|
$identificador . "Tipo da unidade de carga vazia" |
2087
|
|
|
); |
2088
|
|
|
return $infUnidCargaVazia; |
2089
|
|
|
} |
2090
|
|
|
|
2091
|
|
|
/** |
2092
|
|
|
* taginfTermDescarreg |
2093
|
|
|
* tag MDFe/infMDFe/infModal/Aqua/infTermDescarreg |
2094
|
|
|
* |
2095
|
|
|
* @return DOMElement |
2096
|
|
|
*/ |
2097
|
|
|
public function taginfTermDescarreg(stdClass $std) |
2098
|
|
|
{ |
2099
|
|
|
$possible = [ |
2100
|
|
|
'cTermDescarreg', |
2101
|
|
|
'xTermDescarreg' |
2102
|
|
|
]; |
2103
|
|
|
$identificador = '[1] <infTermDescarreg> - '; |
2104
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2105
|
|
|
$infTermDescarreg = $this->dom->createElement("infTermDescarreg"); |
2106
|
|
|
$this->dom->addChild( |
2107
|
|
|
$infTermDescarreg, |
2108
|
|
|
"cTermDescarreg", |
2109
|
|
|
$std->cTermDescarreg, |
2110
|
|
|
true, |
2111
|
|
|
$identificador . "Código do Terminal de Descarregamento" |
2112
|
|
|
); |
2113
|
|
|
$this->dom->addChild( |
2114
|
|
|
$infTermDescarreg, |
2115
|
|
|
"xTermDescarreg", |
2116
|
|
|
$std->xTermDescarreg, |
2117
|
|
|
true, |
2118
|
|
|
$identificador . "Nome do Terminal de Descarregamento" |
2119
|
|
|
); |
2120
|
|
|
return $infTermDescarreg; |
2121
|
|
|
} |
2122
|
|
|
|
2123
|
|
|
/** |
2124
|
|
|
* tagInfTermCarreg |
2125
|
|
|
* tag MDFe/infMDFe/infModal/aquav/infTermCarreg |
2126
|
|
|
* |
2127
|
|
|
* @return DOMElement |
2128
|
|
|
*/ |
2129
|
|
|
public function taginfTermCarreg(stdClass $std) |
2130
|
|
|
{ |
2131
|
|
|
$possible = [ |
2132
|
|
|
'cTermCarreg', |
2133
|
|
|
'xTermCarreg' |
2134
|
|
|
]; |
2135
|
|
|
$identificador = '[1] <infTermCarreg> - '; |
2136
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2137
|
|
|
$infTermCarreg = $this->dom->createElement("infTermCarreg"); |
2138
|
|
|
|
2139
|
|
|
$this->dom->addChild( |
2140
|
|
|
$infTermCarreg, |
2141
|
|
|
"cTermCarreg", |
2142
|
|
|
$std->cTermCarreg, |
2143
|
|
|
true, |
2144
|
|
|
$identificador . "Código do Terminal de Carregamento" |
2145
|
|
|
); |
2146
|
|
|
$this->dom->addChild( |
2147
|
|
|
$infTermCarreg, |
2148
|
|
|
"xTermCarreg", |
2149
|
|
|
$std->xTermCarreg, |
2150
|
|
|
true, |
2151
|
|
|
$identificador . "Nome do Terminal de Carregamento" |
2152
|
|
|
); |
2153
|
|
|
return $infTermCarreg; |
2154
|
|
|
} |
2155
|
|
|
|
2156
|
|
|
/** |
2157
|
|
|
* tagInfTermCarreg |
2158
|
|
|
* tag MDFe/infMDFe/infModal/aquav/infEmbComb |
2159
|
|
|
* |
2160
|
|
|
* @param stdClass $std |
2161
|
|
|
* @return DOMElement |
2162
|
|
|
*/ |
2163
|
|
|
public function taginfEmbComb(stdClass $std) |
2164
|
|
|
{ |
2165
|
|
|
$possible = [ |
2166
|
|
|
'cEmbComb', |
2167
|
|
|
'xBalsa' |
2168
|
|
|
]; |
2169
|
|
|
$identificador = '[1] <infEmbComb> - '; |
2170
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2171
|
|
|
$infEmbComb = $this->dom->createElement("infEmbComb"); |
2172
|
|
|
|
2173
|
|
|
$this->dom->addChild( |
2174
|
|
|
$infEmbComb, |
2175
|
|
|
"cEmbComb", |
2176
|
|
|
$std->cEmbComb, |
2177
|
|
|
true, |
2178
|
|
|
$identificador . "Código da embarcação do comboio" |
2179
|
|
|
); |
2180
|
|
|
$this->dom->addChild( |
2181
|
|
|
$infEmbComb, |
2182
|
|
|
"xBalsa", |
2183
|
|
|
$std->xBalsa, |
2184
|
|
|
true, |
2185
|
|
|
$identificador . "Identificador da Balsa" |
2186
|
|
|
); |
2187
|
|
|
return $infEmbComb; |
2188
|
|
|
} |
2189
|
|
|
|
2190
|
|
|
/** |
2191
|
|
|
* condutor |
2192
|
|
|
* tag MDFe/infMDFe/infModal/rodo/veicTracao/condutor |
2193
|
|
|
* |
2194
|
|
|
* @param string $cEmbComb |
|
|
|
|
2195
|
|
|
* |
2196
|
|
|
* @return DOMElement |
2197
|
|
|
*/ |
2198
|
|
|
private function tagcondutor(stdClass $std) |
2199
|
|
|
{ |
2200
|
|
|
$possible = [ |
2201
|
|
|
'xNome', |
2202
|
|
|
'CPF' |
2203
|
|
|
]; |
2204
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2205
|
|
|
$condutor = $this->dom->createElement("condutor"); |
2206
|
|
|
$identificador = '[4] <condutor> - '; |
2207
|
|
|
$this->dom->addChild( |
2208
|
|
|
$condutor, |
2209
|
|
|
"xNome", |
2210
|
|
|
$std->xNome, |
2211
|
|
|
true, |
2212
|
|
|
$identificador . "Nome do Condutor " |
2213
|
|
|
); |
2214
|
|
|
$this->dom->addChild( |
2215
|
|
|
$condutor, |
2216
|
|
|
"CPF", |
2217
|
|
|
$std->CPF, |
2218
|
|
|
true, |
2219
|
|
|
$identificador . "CPF do Condutor " |
2220
|
|
|
); |
2221
|
|
|
return $condutor; |
2222
|
|
|
} |
2223
|
|
|
|
2224
|
|
|
/** |
2225
|
|
|
* tagVeicTracao |
2226
|
|
|
* tag MDFe/infMDFe/infModal/rodo/veicTracao |
2227
|
|
|
* |
2228
|
|
|
* @param stdClass $std |
2229
|
|
|
* @return DOMElement |
2230
|
|
|
*/ |
2231
|
|
|
public function tagveicTracao(stdClass $std) |
2232
|
|
|
{ |
2233
|
|
|
$possible = [ |
2234
|
|
|
'cInt', |
2235
|
|
|
'placa', |
2236
|
|
|
'RENAVAM', |
2237
|
|
|
'tara', |
2238
|
|
|
'capKG', |
2239
|
|
|
'capM3', |
2240
|
|
|
'prop', |
2241
|
|
|
'tpRod', |
2242
|
|
|
'tpCar', |
2243
|
|
|
'UF', |
2244
|
|
|
'condutor' |
2245
|
|
|
]; |
2246
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2247
|
|
|
$veicTracao = $this->dom->createElement("veicTracao"); |
2248
|
|
|
$identificador = '[4] <disp> - '; |
2249
|
|
|
$this->dom->addChild( |
2250
|
|
|
$veicTracao, |
2251
|
|
|
"cInt", |
2252
|
|
|
$std->cInt, |
2253
|
|
|
false, |
2254
|
|
|
$identificador . "Código interno do veículo" |
2255
|
|
|
); |
2256
|
|
|
$this->dom->addChild( |
2257
|
|
|
$veicTracao, |
2258
|
|
|
"placa", |
2259
|
|
|
$std->placa, |
2260
|
|
|
true, |
2261
|
|
|
$identificador . "Placa do veículo" |
2262
|
|
|
); |
2263
|
|
|
$this->dom->addChild( |
2264
|
|
|
$veicTracao, |
2265
|
|
|
"RENAVAM", |
2266
|
|
|
$std->RENAVAM, |
2267
|
|
|
false, |
2268
|
|
|
$identificador . "RENAVAM" |
2269
|
|
|
); |
2270
|
|
|
$this->dom->addChild( |
2271
|
|
|
$veicTracao, |
2272
|
|
|
"tara", |
2273
|
|
|
$std->tara, |
2274
|
|
|
true, |
2275
|
|
|
$identificador . "Tara em KG" |
2276
|
|
|
); |
2277
|
|
|
$this->dom->addChild( |
2278
|
|
|
$veicTracao, |
2279
|
|
|
"capKG", |
2280
|
|
|
$std->capKG, |
2281
|
|
|
false, |
2282
|
|
|
$identificador . "Capacidade em KG" |
2283
|
|
|
); |
2284
|
|
|
$this->dom->addChild( |
2285
|
|
|
$veicTracao, |
2286
|
|
|
"capM3", |
2287
|
|
|
$std->capM3, |
2288
|
|
|
false, |
2289
|
|
|
$identificador . "Capacidade em M3" |
2290
|
|
|
); |
2291
|
|
|
if ($std->prop != null) { |
2292
|
|
|
$possible = [ |
2293
|
|
|
'CPF', |
2294
|
|
|
'CNPJ', |
2295
|
|
|
'RNTRC', |
2296
|
|
|
'xNome', |
2297
|
|
|
'IE', |
2298
|
|
|
'UF', |
2299
|
|
|
'tpProp' |
2300
|
|
|
]; |
2301
|
|
|
$identificadorProp = '[4] <prop> - '; |
2302
|
|
|
$stdprop = $this->equilizeParameters($std->prop, $possible); |
2303
|
|
|
$prop = $this->dom->createElement("prop"); |
2304
|
|
|
if ($stdprop->CPF) { |
2305
|
|
|
$this->dom->addChild( |
2306
|
|
|
$prop, |
2307
|
|
|
"CPF", |
2308
|
|
|
$stdprop->CPF, |
2309
|
|
|
true, |
2310
|
|
|
$identificadorProp . "Número do CPF" |
2311
|
|
|
); |
2312
|
|
|
} else { |
2313
|
|
|
$this->dom->addChild( |
2314
|
|
|
$prop, |
2315
|
|
|
"CNPJ", |
2316
|
|
|
$stdprop->CNPJ, |
2317
|
|
|
true, |
2318
|
|
|
$identificadorProp . "Número do CNPJ" |
2319
|
|
|
); |
2320
|
|
|
} |
2321
|
|
|
$this->dom->addChild( |
2322
|
|
|
$prop, |
2323
|
|
|
"RNTRC", |
2324
|
|
|
$stdprop->RNTRC, |
2325
|
|
|
true, |
2326
|
|
|
$identificadorProp . "RNTRC" |
2327
|
|
|
); |
2328
|
|
|
$this->dom->addChild( |
2329
|
|
|
$prop, |
2330
|
|
|
"xNome", |
2331
|
|
|
$stdprop->xNome, |
2332
|
|
|
true, |
2333
|
|
|
$identificadorProp . "Razão Social" |
2334
|
|
|
); |
2335
|
|
|
$this->dom->addChild( |
2336
|
|
|
$prop, |
2337
|
|
|
"IE", |
2338
|
|
|
$stdprop->IE, |
2339
|
|
|
true, |
2340
|
|
|
$identificadorProp . "Inscrição Estadual" |
2341
|
|
|
); |
2342
|
|
|
$this->dom->addChild( |
2343
|
|
|
$prop, |
2344
|
|
|
"UF", |
2345
|
|
|
$stdprop->UF, |
2346
|
|
|
true, |
2347
|
|
|
$identificadorProp . "Unidade da Federação" |
2348
|
|
|
); |
2349
|
|
|
$this->dom->addChild( |
2350
|
|
|
$prop, |
2351
|
|
|
"tpProp", |
2352
|
|
|
$stdprop->tpProp, |
2353
|
|
|
true, |
2354
|
|
|
$identificadorProp . "Tipo Proprietário" |
2355
|
|
|
); |
2356
|
|
|
$this->dom->appChild($veicTracao, $prop, 'Falta tag "veicTracao"'); |
2357
|
|
|
} |
2358
|
|
|
if ($std->condutor) { |
2359
|
|
|
foreach ($std->condutor as $value) { |
2360
|
|
|
$this->dom->appChild($veicTracao, $this->tagcondutor($value), 'Falta tag "condutor"'); |
2361
|
|
|
} |
2362
|
|
|
} |
2363
|
|
|
$this->dom->addChild( |
2364
|
|
|
$veicTracao, |
2365
|
|
|
"tpRod", |
2366
|
|
|
$std->tpRod, |
2367
|
|
|
true, |
2368
|
|
|
$identificador . "Tipo de rodado" |
2369
|
|
|
); |
2370
|
|
|
$this->dom->addChild( |
2371
|
|
|
$veicTracao, |
2372
|
|
|
"tpCar", |
2373
|
|
|
$std->tpCar, |
2374
|
|
|
true, |
2375
|
|
|
$identificador . "Tipo de carroceria" |
2376
|
|
|
); |
2377
|
|
|
$this->dom->addChild( |
2378
|
|
|
$veicTracao, |
2379
|
|
|
"UF", |
2380
|
|
|
$std->UF, |
2381
|
|
|
true, |
2382
|
|
|
$identificador . "UF de licenciamento do veículo" |
2383
|
|
|
); |
2384
|
|
|
$this->veicTracao = $veicTracao; |
2385
|
|
|
return $veicTracao; |
2386
|
|
|
} |
2387
|
|
|
|
2388
|
|
|
/** |
2389
|
|
|
* tagVeicReboque |
2390
|
|
|
* tag MDFe/infMDFe/infModal/rodo/VeicReboque |
2391
|
|
|
* |
2392
|
|
|
* @param stdClass $std |
2393
|
|
|
* @return DOMElement |
2394
|
|
|
*/ |
2395
|
|
|
public function tagveicReboque(stdClass $std) |
2396
|
|
|
{ |
2397
|
|
|
$possible = [ |
2398
|
|
|
'cInt', |
2399
|
|
|
'placa', |
2400
|
|
|
'RENAVAM', |
2401
|
|
|
'tara', |
2402
|
|
|
'capKG', |
2403
|
|
|
'capM3', |
2404
|
|
|
'prop', |
2405
|
|
|
'tpCar', |
2406
|
|
|
'UF' |
2407
|
|
|
]; |
2408
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2409
|
|
|
$veicReboque = $this->dom->createElement("veicReboque"); |
2410
|
|
|
$identificador = '[4] <veicReboque> - '; |
2411
|
|
|
$this->dom->addChild( |
2412
|
|
|
$veicReboque, |
2413
|
|
|
"cInt", |
2414
|
|
|
$std->cInt, |
2415
|
|
|
false, |
2416
|
|
|
$identificador . "Código interno do veículo" |
2417
|
|
|
); |
2418
|
|
|
$this->dom->addChild( |
2419
|
|
|
$veicReboque, |
2420
|
|
|
"placa", |
2421
|
|
|
$std->placa, |
2422
|
|
|
true, |
2423
|
|
|
$identificador . "Placa do veículo" |
2424
|
|
|
); |
2425
|
|
|
$this->dom->addChild( |
2426
|
|
|
$veicReboque, |
2427
|
|
|
"RENAVAM", |
2428
|
|
|
$std->RENAVAM, |
2429
|
|
|
false, |
2430
|
|
|
$identificador . "RENAVAM" |
2431
|
|
|
); |
2432
|
|
|
$this->dom->addChild( |
2433
|
|
|
$veicReboque, |
2434
|
|
|
"tara", |
2435
|
|
|
$std->tara, |
2436
|
|
|
true, |
2437
|
|
|
$identificador . "Tara em KG" |
2438
|
|
|
); |
2439
|
|
|
$this->dom->addChild( |
2440
|
|
|
$veicReboque, |
2441
|
|
|
"capKG", |
2442
|
|
|
$std->capKG, |
2443
|
|
|
false, |
2444
|
|
|
$identificador . "Capacidade em KG" |
2445
|
|
|
); |
2446
|
|
|
$this->dom->addChild( |
2447
|
|
|
$veicReboque, |
2448
|
|
|
"capM3", |
2449
|
|
|
$std->capM3, |
2450
|
|
|
false, |
2451
|
|
|
$identificador . "Capacidade em M3" |
2452
|
|
|
); |
2453
|
|
|
if ($std->prop != null) { |
2454
|
|
|
$identificadorprop = '[4] <prop> - '; |
2455
|
|
|
$possible = [ |
2456
|
|
|
'CPF', |
2457
|
|
|
'CNPJ', |
2458
|
|
|
'RNTRC', |
2459
|
|
|
'xNome', |
2460
|
|
|
'IE', |
2461
|
|
|
'UF', |
2462
|
|
|
'tpProp' |
2463
|
|
|
]; |
2464
|
|
|
$stdprop = $this->equilizeParameters($std->prop, $possible); |
2465
|
|
|
$prop = $this->dom->createElement("prop"); |
2466
|
|
|
if ($stdprop->CPF) { |
2467
|
|
|
$this->dom->addChild( |
2468
|
|
|
$prop, |
2469
|
|
|
"CPF", |
2470
|
|
|
$stdprop->CPF, |
2471
|
|
|
true, |
2472
|
|
|
$identificadorprop . "Número do CPF" |
2473
|
|
|
); |
2474
|
|
|
} else { |
2475
|
|
|
$this->dom->addChild( |
2476
|
|
|
$prop, |
2477
|
|
|
"CNPJ", |
2478
|
|
|
$stdprop->CNPJ, |
2479
|
|
|
true, |
2480
|
|
|
$identificadorprop . "Número do CNPJ" |
2481
|
|
|
); |
2482
|
|
|
} |
2483
|
|
|
$this->dom->addChild( |
2484
|
|
|
$prop, |
2485
|
|
|
"RNTRC", |
2486
|
|
|
$stdprop->RNTRC, |
2487
|
|
|
true, |
2488
|
|
|
$identificadorprop . "RNTRC" |
2489
|
|
|
); |
2490
|
|
|
$this->dom->addChild( |
2491
|
|
|
$prop, |
2492
|
|
|
"xNome", |
2493
|
|
|
$stdprop->xNome, |
2494
|
|
|
true, |
2495
|
|
|
$identificadorprop . "Razão Social" |
2496
|
|
|
); |
2497
|
|
|
$this->dom->addChild( |
2498
|
|
|
$prop, |
2499
|
|
|
"IE", |
2500
|
|
|
$stdprop->IE, |
2501
|
|
|
true, |
2502
|
|
|
$identificadorprop . "Inscrição Estadual" |
2503
|
|
|
); |
2504
|
|
|
$this->dom->addChild( |
2505
|
|
|
$prop, |
2506
|
|
|
"UF", |
2507
|
|
|
$stdprop->UF, |
2508
|
|
|
true, |
2509
|
|
|
$identificadorprop . "Unidade da Federação" |
2510
|
|
|
); |
2511
|
|
|
$this->dom->addChild( |
2512
|
|
|
$prop, |
2513
|
|
|
"tpProp", |
2514
|
|
|
$stdprop->tpProp, |
2515
|
|
|
true, |
2516
|
|
|
$identificadorprop . "Tipo Proprietário" |
2517
|
|
|
); |
2518
|
|
|
$this->dom->appChild($veicReboque, $prop, 'Falta tag "veicReboque"'); |
2519
|
|
|
} |
2520
|
|
|
$this->dom->addChild( |
2521
|
|
|
$veicReboque, |
2522
|
|
|
"tpCar", |
2523
|
|
|
$std->tpCar, |
2524
|
|
|
true, |
2525
|
|
|
$identificador . "Tipo de carroceria" |
2526
|
|
|
); |
2527
|
|
|
$this->dom->addChild( |
2528
|
|
|
$veicReboque, |
2529
|
|
|
"UF", |
2530
|
|
|
$std->UF, |
2531
|
|
|
true, |
2532
|
|
|
$identificador . "UF de licenciamento do veículo" |
2533
|
|
|
); |
2534
|
|
|
$this->veicReboque[] = $veicReboque; |
2535
|
|
|
return $veicReboque; |
2536
|
|
|
} |
2537
|
|
|
|
2538
|
|
|
/** |
2539
|
|
|
* tagcodAgPorto |
2540
|
|
|
* tag MDFe/infMDFe/infModal/rodo/codAgPorto |
2541
|
|
|
* |
2542
|
|
|
* @param stdClass $std |
2543
|
|
|
* @return DOMElement |
2544
|
|
|
*/ |
2545
|
|
|
public function tagcodAgPorto(stdClass $std) |
2546
|
|
|
{ |
2547
|
|
|
$possible = [ |
2548
|
|
|
'codAgPorto' |
2549
|
|
|
]; |
2550
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2551
|
|
|
$this->dom->addChild( |
2552
|
|
|
$this->rodo, |
2553
|
|
|
"codAgPorto", |
2554
|
|
|
$std->codAgPorto, |
2555
|
|
|
false, |
2556
|
|
|
"Código de Agendamento no porto" |
2557
|
|
|
); |
2558
|
|
|
return $this->rodo; |
|
|
|
|
2559
|
|
|
} |
2560
|
|
|
|
2561
|
|
|
/** |
2562
|
|
|
* taglacRodo |
2563
|
|
|
* tag MDFe/infMDFe/infModal/rodo/lacRodo |
2564
|
|
|
* |
2565
|
|
|
* @param stdClass $std |
2566
|
|
|
* @return DOMElement |
2567
|
|
|
*/ |
2568
|
|
|
public function taglacRodo(stdClass $std) |
2569
|
|
|
{ |
2570
|
|
|
$possible = [ |
2571
|
|
|
'nLacre' |
2572
|
|
|
]; |
2573
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2574
|
|
|
$lacRodo = $this->dom->createElement("lacRodo"); |
2575
|
|
|
$this->dom->addChild( |
2576
|
|
|
$lacRodo, |
2577
|
|
|
"nLacre", |
2578
|
|
|
$std->nLacre, |
2579
|
|
|
true, |
2580
|
|
|
"Número do Lacre" |
2581
|
|
|
); |
2582
|
|
|
$this->lacRodo[] = $lacRodo; |
2583
|
|
|
return $lacRodo; |
2584
|
|
|
} |
2585
|
|
|
|
2586
|
|
|
/** |
2587
|
|
|
* Informações do Responsável técnico ZD01 pai A01 |
2588
|
|
|
* tag NFe/infNFe/infRespTec (opcional) |
2589
|
|
|
* @param stdClass $std |
2590
|
|
|
* @return DOMElement |
2591
|
|
|
* @throws RuntimeException |
2592
|
|
|
*/ |
2593
|
|
|
public function taginfRespTec(stdClass $std) |
2594
|
|
|
{ |
2595
|
|
|
$possible = [ |
2596
|
|
|
'CNPJ', |
2597
|
|
|
'xContato', |
2598
|
|
|
'email', |
2599
|
|
|
'fone', |
2600
|
|
|
'CSRT', |
2601
|
|
|
'idCSRT' |
2602
|
|
|
]; |
2603
|
|
|
|
2604
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2605
|
|
|
$infRespTec = $this->dom->createElement("infRespTec"); |
2606
|
|
|
$this->dom->addChild( |
2607
|
|
|
$infRespTec, |
2608
|
|
|
"CNPJ", |
2609
|
|
|
$std->CNPJ, |
2610
|
|
|
true, |
2611
|
|
|
"Informar o CNPJ da pessoa jurídica responsável pelo sistema " |
2612
|
|
|
. "utilizado na emissão do documento fiscal eletrônico" |
2613
|
|
|
); |
2614
|
|
|
$this->dom->addChild( |
2615
|
|
|
$infRespTec, |
2616
|
|
|
"xContato", |
2617
|
|
|
$std->xContato, |
2618
|
|
|
true, |
2619
|
|
|
"Informar o nome da pessoa a ser contatada na empresa desenvolvedora " |
2620
|
|
|
. "do sistema utilizado na emissão do documento fiscal eletrônico" |
2621
|
|
|
); |
2622
|
|
|
$this->dom->addChild( |
2623
|
|
|
$infRespTec, |
2624
|
|
|
"email", |
2625
|
|
|
$std->email, |
2626
|
|
|
true, |
2627
|
|
|
"Informar o e-mail da pessoa a ser contatada na empresa " |
2628
|
|
|
. "desenvolvedora do sistema." |
2629
|
|
|
); |
2630
|
|
|
$this->dom->addChild( |
2631
|
|
|
$infRespTec, |
2632
|
|
|
"fone", |
2633
|
|
|
$std->fone, |
2634
|
|
|
true, |
2635
|
|
|
"Informar o telefone da pessoa a ser contatada na empresa " |
2636
|
|
|
. "desenvolvedora do sistema." |
2637
|
|
|
); |
2638
|
|
|
if (!empty($std->CSRT) && !empty($std->idCSRT)) { |
2639
|
|
|
$this->csrt = $std->CSRT; |
|
|
|
|
2640
|
|
|
$this->dom->addChild( |
2641
|
|
|
$infRespTec, |
2642
|
|
|
"idCSRT", |
2643
|
|
|
$std->idCSRT, |
2644
|
|
|
true, |
2645
|
|
|
"Identificador do CSRT utilizado para montar o hash do CSRT" |
2646
|
|
|
); |
2647
|
|
|
$this->dom->addChild( |
2648
|
|
|
$infRespTec, |
2649
|
|
|
"hashCSRT", |
2650
|
|
|
$std->CSRT, |
2651
|
|
|
true, |
2652
|
|
|
"hash do CSRT" |
2653
|
|
|
); |
2654
|
|
|
} |
2655
|
|
|
$this->infRespTec = $infRespTec; |
|
|
|
|
2656
|
|
|
return $infRespTec; |
2657
|
|
|
} |
2658
|
|
|
|
2659
|
|
|
/** |
2660
|
|
|
* buildMDFe |
2661
|
|
|
* Tag raiz da MDFe |
2662
|
|
|
* tag MDFe DOMNode |
2663
|
|
|
* Função chamada pelo método [ monta ] |
2664
|
|
|
* |
2665
|
|
|
* @return DOMElement |
2666
|
|
|
*/ |
2667
|
|
|
protected function buildMDFe() |
2668
|
|
|
{ |
2669
|
|
|
if (empty($this->MDFe)) { |
2670
|
|
|
$this->MDFe = $this->dom->createElement("MDFe"); |
2671
|
|
|
$this->MDFe->setAttribute("xmlns", "http://www.portalfiscal.inf.br/mdfe"); |
2672
|
|
|
} |
2673
|
|
|
return $this->MDFe; |
2674
|
|
|
} |
2675
|
|
|
|
2676
|
|
|
/** |
2677
|
|
|
* checkMDFKey |
2678
|
|
|
* Remonta a chave do MDFe de 44 digitos com base em seus dados |
2679
|
|
|
* Isso é útil no caso da chave informada estar errada |
2680
|
|
|
* se a chave estiver errada a mesma é substituida |
2681
|
|
|
* |
2682
|
|
|
* @param object $dom |
2683
|
|
|
*/ |
2684
|
|
|
private function checkMDFKey($dom) |
2685
|
|
|
{ |
2686
|
|
|
$infMDFe = $dom->getElementsByTagName("infMDFe")->item(0); |
2687
|
|
|
$ide = $dom->getElementsByTagName("ide")->item(0); |
2688
|
|
|
$emit = $dom->getElementsByTagName("emit")->item(0); |
2689
|
|
|
$cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue; |
2690
|
|
|
$dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue; |
2691
|
|
|
if (!empty($emit->getElementsByTagName('CNPJ')->item(0)->nodeValue)) { |
2692
|
|
|
$doc = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
2693
|
|
|
} else { |
2694
|
|
|
$doc = $emit->getElementsByTagName('CPF')->item(0)->nodeValue; |
2695
|
|
|
} |
2696
|
|
|
$mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue; |
2697
|
|
|
$serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue; |
2698
|
|
|
$nMDF = $ide->getElementsByTagName('nMDF')->item(0)->nodeValue; |
2699
|
|
|
$tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue; |
2700
|
|
|
$cNF = $ide->getElementsByTagName('cMDF')->item(0)->nodeValue; |
2701
|
|
|
$chave = str_replace('MDFe', '', $infMDFe->getAttribute("Id")); |
2702
|
|
|
$dt = new \DateTime($dhEmi); |
2703
|
|
|
$chaveMontada = Keys::build( |
2704
|
|
|
$cUF, |
2705
|
|
|
$dt->format('y'), |
2706
|
|
|
$dt->format('m'), |
2707
|
|
|
$doc, |
2708
|
|
|
$mod, |
2709
|
|
|
$serie, |
2710
|
|
|
$nMDF, |
2711
|
|
|
$tpEmis, |
2712
|
|
|
$cNF |
2713
|
|
|
); |
2714
|
|
|
|
2715
|
|
|
//caso a chave contida na NFe esteja errada |
2716
|
|
|
//substituir a chave |
2717
|
|
|
if ($chaveMontada != $chave) { |
2718
|
|
|
$ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chaveMontada, -1); |
2719
|
|
|
$infMDFe = $dom->getElementsByTagName("infMDFe")->item(0); |
2720
|
|
|
$infMDFe->setAttribute("Id", "MDFe" . $chaveMontada); |
2721
|
|
|
$infMDFe->setAttribute("versao", $this->versao); |
2722
|
|
|
$this->chMDFe = $chaveMontada; |
2723
|
|
|
} |
2724
|
|
|
} |
2725
|
|
|
|
2726
|
|
|
/** |
2727
|
|
|
* Includes missing or unsupported properties in stdClass |
2728
|
|
|
* Replace all unsuported chars |
2729
|
|
|
* |
2730
|
|
|
* @param stdClass $std |
2731
|
|
|
* @param array $possible |
2732
|
|
|
* @return stdClass |
2733
|
|
|
*/ |
2734
|
|
|
private function equilizeParameters(stdClass $std, $possible) |
2735
|
|
|
{ |
2736
|
|
|
return Strings::equilizeParameters($std, $possible, $this->replaceAccentedChars); |
|
|
|
|
2737
|
|
|
} |
2738
|
|
|
} |
2739
|
|
|
|
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: