1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\CTe; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* |
7
|
|
|
* @category Library |
8
|
|
|
* @package nfephp-org/sped-cte |
9
|
|
|
* @copyright 2009-2016 NFePHP |
10
|
|
|
* @name Make.php |
11
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL v.3 |
12
|
|
|
* @link http://github.com/nfephp-org/sped-cte for the canonical source repository |
13
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
use DOMElement; |
17
|
|
|
use NFePHP\Common\DOMImproved as Dom; |
18
|
|
|
use NFePHP\Common\Keys; |
19
|
|
|
use NFePHP\Common\Strings; |
20
|
|
|
use RuntimeException; |
21
|
|
|
use stdClass; |
22
|
|
|
|
23
|
|
|
class Make |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
public $errors = []; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* versao |
32
|
|
|
* numero da versão do xml da CTe |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
public $versao = '3.00'; |
36
|
|
|
/** |
37
|
|
|
* mod |
38
|
|
|
* modelo da CTe 57 |
39
|
|
|
* @var integer |
40
|
|
|
*/ |
41
|
|
|
public $mod = 57; |
42
|
|
|
/** |
43
|
|
|
* chave da MDFe |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
public $chCTe = ''; |
47
|
|
|
/** |
48
|
|
|
* xml |
49
|
|
|
* String com o xml do documento fiscal montado |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
public $xml = ''; |
53
|
|
|
/** |
54
|
|
|
* dom |
55
|
|
|
* Variável onde será montado o xml do documento fiscal |
56
|
|
|
* @var \NFePHP\Common\Dom\Dom |
57
|
|
|
*/ |
58
|
|
|
public $dom; |
59
|
|
|
/** |
60
|
|
|
* tpAmb |
61
|
|
|
* tipo de ambiente |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
public $tpAmb = '2'; |
65
|
|
|
/** |
66
|
|
|
* Modal do Cte |
67
|
|
|
* @var integer |
68
|
|
|
*/ |
69
|
|
|
private $modal = 0; |
70
|
|
|
/** |
71
|
|
|
* Tag CTe |
72
|
|
|
* @var \DOMNode |
73
|
|
|
*/ |
74
|
|
|
private $CTe = ''; |
75
|
|
|
/** |
76
|
|
|
* Informações do CT-e |
77
|
|
|
* @var \DOMNode |
78
|
|
|
*/ |
79
|
|
|
private $infCte = ''; |
80
|
|
|
/** |
81
|
|
|
* Identificação do CT-e |
82
|
|
|
* @var \DOMNode |
83
|
|
|
*/ |
84
|
|
|
private $ide = ''; |
85
|
|
|
/** |
86
|
|
|
* Percurso do CT-e OS |
87
|
|
|
* @var \DOMNode |
88
|
|
|
*/ |
89
|
|
|
private $infPercurso = []; |
90
|
|
|
/** |
91
|
|
|
* Tipo do Serviço |
92
|
|
|
* @var integer |
93
|
|
|
*/ |
94
|
|
|
private $tpServ = 0; |
95
|
|
|
/** |
96
|
|
|
* Indicador do "papel" do tomador do serviço no CT-e |
97
|
|
|
* @var \DOMNode |
98
|
|
|
*/ |
99
|
|
|
private $toma3 = ''; |
100
|
|
|
/** |
101
|
|
|
* Indicador do "papel" do tomador do serviço no CT-e |
102
|
|
|
* @var \DOMNode |
103
|
|
|
*/ |
104
|
|
|
private $toma4 = ''; |
105
|
|
|
/** |
106
|
|
|
* Indicador do "papel" do tomador do serviço no CT-e OS |
107
|
|
|
* @var \DOMNode |
108
|
|
|
*/ |
109
|
|
|
private $toma = ''; |
110
|
|
|
/** |
111
|
|
|
* Dados do endereço |
112
|
|
|
* @var \DOMNode |
113
|
|
|
*/ |
114
|
|
|
private $enderToma = ''; |
115
|
|
|
/** |
116
|
|
|
* Dados complementares do CT-e para fins operacionais ou comerciais |
117
|
|
|
* @var \DOMNode |
118
|
|
|
*/ |
119
|
|
|
private $compl = ''; |
120
|
|
|
/** |
121
|
|
|
* Previsão do fluxo da carga |
122
|
|
|
* @var \DOMNode |
123
|
|
|
*/ |
124
|
|
|
private $fluxo = ''; |
125
|
|
|
/** |
126
|
|
|
* Passagem |
127
|
|
|
* @var array |
128
|
|
|
*/ |
129
|
|
|
private $pass = array(); |
130
|
|
|
/** |
131
|
|
|
* Informações ref. a previsão de entrega |
132
|
|
|
* @var \DOMNode |
133
|
|
|
*/ |
134
|
|
|
private $entrega = ''; |
135
|
|
|
/** |
136
|
|
|
* Entrega sem data definida |
137
|
|
|
* @var \DOMNode |
138
|
|
|
*/ |
139
|
|
|
private $semData = ''; |
140
|
|
|
/** |
141
|
|
|
* Entrega com data definida |
142
|
|
|
* @var \DOMNode |
143
|
|
|
*/ |
144
|
|
|
private $comData = ''; |
145
|
|
|
/** |
146
|
|
|
* Entrega no período definido |
147
|
|
|
* @var \DOMNode |
148
|
|
|
*/ |
149
|
|
|
private $noPeriodo = ''; |
150
|
|
|
/** |
151
|
|
|
* Entrega sem hora definida |
152
|
|
|
* @var \DOMNode |
153
|
|
|
*/ |
154
|
|
|
private $semHora = ''; |
155
|
|
|
/** |
156
|
|
|
* Entrega com hora definida |
157
|
|
|
* @var \DOMNode |
158
|
|
|
*/ |
159
|
|
|
private $comHora = ''; |
160
|
|
|
/** |
161
|
|
|
* Entrega no intervalo de horário definido |
162
|
|
|
* @var \DOMNode |
163
|
|
|
*/ |
164
|
|
|
private $noInter = ''; |
165
|
|
|
/** |
166
|
|
|
* Campo de uso livre do contribuinte |
167
|
|
|
* @var array |
168
|
|
|
*/ |
169
|
|
|
private $obsCont = array(); |
170
|
|
|
/** |
171
|
|
|
* Campo de uso livre do contribuinte |
172
|
|
|
* @var array |
173
|
|
|
*/ |
174
|
|
|
private $obsFisco = array(); |
175
|
|
|
/** |
176
|
|
|
* Identificação do Emitente do CT-e |
177
|
|
|
* @var \DOMNode |
178
|
|
|
*/ |
179
|
|
|
private $emit = ''; |
180
|
|
|
/** |
181
|
|
|
* Endereço do emitente |
182
|
|
|
* @var \DOMNode |
183
|
|
|
*/ |
184
|
|
|
private $enderEmit = ''; |
185
|
|
|
/** |
186
|
|
|
* Informações do Remetente das mercadorias transportadas pelo CT-e |
187
|
|
|
* @var \DOMNode |
188
|
|
|
*/ |
189
|
|
|
private $rem = ''; |
190
|
|
|
/** |
191
|
|
|
* Dados do endereço |
192
|
|
|
* @var \DOMNode |
193
|
|
|
*/ |
194
|
|
|
private $enderReme = ''; |
195
|
|
|
/** |
196
|
|
|
* Informações do Expedidor da Carga |
197
|
|
|
* @var \DOMNode |
198
|
|
|
*/ |
199
|
|
|
private $exped = ''; |
200
|
|
|
/** |
201
|
|
|
* Dados do endereço |
202
|
|
|
* @var \DOMNode |
203
|
|
|
*/ |
204
|
|
|
private $enderExped = ''; |
205
|
|
|
/** |
206
|
|
|
* Informações do Recebedor da Carga |
207
|
|
|
* @var \DOMNode |
208
|
|
|
*/ |
209
|
|
|
private $receb = ''; |
210
|
|
|
/** |
211
|
|
|
* Dados do endereço |
212
|
|
|
* @var \DOMNode |
213
|
|
|
*/ |
214
|
|
|
private $enderReceb = ''; |
215
|
|
|
/** |
216
|
|
|
* Informações do Destinatário do CT-e |
217
|
|
|
* @var \DOMNode |
218
|
|
|
*/ |
219
|
|
|
private $dest = ''; |
220
|
|
|
/** |
221
|
|
|
* Dados do endereço |
222
|
|
|
* @var \DOMNode |
223
|
|
|
*/ |
224
|
|
|
private $enderDest = ''; |
225
|
|
|
/** |
226
|
|
|
* Valores da Prestação de Serviço |
227
|
|
|
* @var \DOMNode |
228
|
|
|
*/ |
229
|
|
|
private $vPrest = ''; |
230
|
|
|
/** |
231
|
|
|
* Componentes do Valor da Prestação |
232
|
|
|
* @var array |
233
|
|
|
*/ |
234
|
|
|
private $comp = array(); |
235
|
|
|
/** |
236
|
|
|
* Informações relativas aos Impostos |
237
|
|
|
* @var \DOMNode |
238
|
|
|
*/ |
239
|
|
|
private $imp = ''; |
240
|
|
|
/** |
241
|
|
|
* Observações adicionais da CT-e |
242
|
|
|
* @var string |
243
|
|
|
*/ |
244
|
|
|
private $xObs = ''; |
245
|
|
|
/** |
246
|
|
|
* Grupo de informações do CT-e Normal e Substituto |
247
|
|
|
* @var \DOMNode |
248
|
|
|
*/ |
249
|
|
|
private $infCTeNorm = ''; |
250
|
|
|
/** |
251
|
|
|
* Informações da Carga do CT-e |
252
|
|
|
* @var \DOMNode |
253
|
|
|
*/ |
254
|
|
|
private $infCarga = ''; |
255
|
|
|
/** |
256
|
|
|
* Informações da Prestação do Serviço |
257
|
|
|
* @var \DOMNode |
258
|
|
|
*/ |
259
|
|
|
private $infServico = ''; |
260
|
|
|
/** |
261
|
|
|
* Informações de quantidades da Carga do CT-e |
262
|
|
|
* @var \DOMNode |
263
|
|
|
*/ |
264
|
|
|
private $infQ = array(); |
265
|
|
|
/** |
266
|
|
|
* Informações dos documentos transportados pelo CT-e Opcional para Redespacho Intermediario |
267
|
|
|
* e Serviço vinculado a multimodal. |
268
|
|
|
* @var \DOMNode |
269
|
|
|
*/ |
270
|
|
|
private $infDoc = array(); |
271
|
|
|
/** |
272
|
|
|
* Informações das NF |
273
|
|
|
* @var array |
274
|
|
|
*/ |
275
|
|
|
private $infNF = array(); |
276
|
|
|
/** |
277
|
|
|
* Informações das NF-e |
278
|
|
|
* @var array |
279
|
|
|
*/ |
280
|
|
|
private $infNFe = array(); |
281
|
|
|
/** |
282
|
|
|
* Informações dos demais documentos |
283
|
|
|
* @var array |
284
|
|
|
*/ |
285
|
|
|
private $infOutros = array(); |
286
|
|
|
/** |
287
|
|
|
* Informações dos demais documentos |
288
|
|
|
* @var array |
289
|
|
|
*/ |
290
|
|
|
private $infDocRef = array(); |
291
|
|
|
/** |
292
|
|
|
* Informações das Unidades de Transporte (Carreta/Reboque/Vagão) |
293
|
|
|
* @var array |
294
|
|
|
*/ |
295
|
|
|
private $infUnidTransp = array(); |
296
|
|
|
/** |
297
|
|
|
* Lacres das Unidades de Transporte |
298
|
|
|
* @var array |
299
|
|
|
*/ |
300
|
|
|
private $lacUnidTransp = array(); |
301
|
|
|
/** |
302
|
|
|
* Informações das Unidades de Carga (Containeres/ULD/Outros) |
303
|
|
|
* @var array |
304
|
|
|
*/ |
305
|
|
|
private $infUnidCarga = array(); |
306
|
|
|
/** |
307
|
|
|
* Lacres das Unidades de Carga |
308
|
|
|
* @var array |
309
|
|
|
*/ |
310
|
|
|
private $lacUnidCarga = array(); |
311
|
|
|
/** |
312
|
|
|
* Documentos de Transporte Anterior |
313
|
|
|
* @var \DOMNode |
314
|
|
|
*/ |
315
|
|
|
private $docAnt = array(); |
316
|
|
|
/** |
317
|
|
|
* Emissor do documento anterior |
318
|
|
|
* @var array |
319
|
|
|
*/ |
320
|
|
|
private $emiDocAnt = array(); |
321
|
|
|
/** |
322
|
|
|
* Informações de identificação dos documentos de Transporte Anterior |
323
|
|
|
* @var array |
324
|
|
|
*/ |
325
|
|
|
private $idDocAnt = array(); |
326
|
|
|
/** |
327
|
|
|
* Documentos de transporte anterior em papel |
328
|
|
|
* @var array |
329
|
|
|
*/ |
330
|
|
|
private $idDocAntPap = array(); |
331
|
|
|
/** |
332
|
|
|
* Documentos de transporte anterior eletrônicos |
333
|
|
|
* @var array |
334
|
|
|
*/ |
335
|
|
|
private $idDocAntEle = array(); |
336
|
|
|
/** |
337
|
|
|
* Informações de Seguro da Carga |
338
|
|
|
* @var array |
339
|
|
|
*/ |
340
|
|
|
private $seg = array(); |
341
|
|
|
/** |
342
|
|
|
* Informações do modal |
343
|
|
|
* @var \DOMNode |
344
|
|
|
*/ |
345
|
|
|
private $infModal = ''; |
346
|
|
|
/** |
347
|
|
|
* Preenchido quando for transporte de produtos classificados pela ONU como perigosos. |
348
|
|
|
* @var array |
349
|
|
|
*/ |
350
|
|
|
private $peri = array(); |
351
|
|
|
/** |
352
|
|
|
* informações dos veículos transportados |
353
|
|
|
* @var array |
354
|
|
|
*/ |
355
|
|
|
private $veicNovos = array(); |
356
|
|
|
/** |
357
|
|
|
* Dados da cobrança do CT-e |
358
|
|
|
* @var \DOMNode |
359
|
|
|
*/ |
360
|
|
|
private $cobr = ''; |
361
|
|
|
/** |
362
|
|
|
* Dados da fatura |
363
|
|
|
* @var \DOMNode |
364
|
|
|
*/ |
365
|
|
|
private $fat = ''; |
366
|
|
|
/** |
367
|
|
|
* Dados das duplicatas |
368
|
|
|
* @var array |
369
|
|
|
*/ |
370
|
|
|
private $dup = array(); |
371
|
|
|
/** |
372
|
|
|
* Informações do CT-e de substituição |
373
|
|
|
* @var \DOMNode |
374
|
|
|
*/ |
375
|
|
|
private $infCteSub = ''; |
376
|
|
|
/** |
377
|
|
|
* Informações do Serviço Vinculado a Multimodal |
378
|
|
|
* @var \DOMNode |
379
|
|
|
*/ |
380
|
|
|
private $infServVinc = ''; |
381
|
|
|
/** |
382
|
|
|
* Informações do CT-e multimodal vinculado |
383
|
|
|
* @var \DOMNode |
384
|
|
|
*/ |
385
|
|
|
private $infCTeMultimodal = array(); |
386
|
|
|
/** |
387
|
|
|
* Tomador é contribuinte do ICMS |
388
|
|
|
* @var \DOMNode |
389
|
|
|
*/ |
390
|
|
|
private $tomaICMS = ''; |
391
|
|
|
/** |
392
|
|
|
* Informação da NFe emitida pelo Tomador |
393
|
|
|
* @var \DOMNode |
394
|
|
|
*/ |
395
|
|
|
private $refNFe = ''; |
396
|
|
|
/** |
397
|
|
|
* Informação da NF ou CT emitido pelo Tomador |
398
|
|
|
* @var \DOMNode |
399
|
|
|
*/ |
400
|
|
|
private $refNF = ''; |
401
|
|
|
/** |
402
|
|
|
* Informação da NF ou CT emitido pelo Tomador |
403
|
|
|
* @var \DOMNode |
404
|
|
|
*/ |
405
|
|
|
private $infCteComp = ''; |
406
|
|
|
/** |
407
|
|
|
* Detalhamento do CT-e do tipo Anulação |
408
|
|
|
* @var \DOMNode |
409
|
|
|
*/ |
410
|
|
|
private $infCteAnu = ''; |
411
|
|
|
/** |
412
|
|
|
* Informações do modal Rodoviário |
413
|
|
|
* @var \DOMNode |
414
|
|
|
*/ |
415
|
|
|
private $rodo = ''; |
416
|
|
|
/** |
417
|
|
|
* Informações do modal Aéreo |
418
|
|
|
* @var \DOMNode |
419
|
|
|
*/ |
420
|
|
|
private $aereo = ''; |
421
|
|
|
/** |
422
|
|
|
* Informações do modal Ferroviario |
423
|
|
|
* @var \DOMNode |
424
|
|
|
*/ |
425
|
|
|
private $ferrov = ''; |
426
|
|
|
|
427
|
|
|
private $ferroEnv = ''; |
428
|
|
|
/** |
429
|
|
|
* Informações do modal Aquaviario |
430
|
|
|
* @var \DOMNode |
431
|
|
|
*/ |
432
|
|
|
private $aquav = ''; |
433
|
|
|
/** |
434
|
|
|
* Informações de Lacre para modal Aquaviario |
435
|
|
|
* @var array |
436
|
|
|
*/ |
437
|
|
|
private $lacre = array(); |
438
|
|
|
/** |
439
|
|
|
* Informações de Balsa para modal Aquaviario |
440
|
|
|
* @var array |
441
|
|
|
*/ |
442
|
|
|
private $balsa = array(); |
443
|
|
|
/** |
444
|
|
|
* Informações de Container para modal Aquaviario |
445
|
|
|
* @var array |
446
|
|
|
*/ |
447
|
|
|
private $detCont = array(); |
448
|
|
|
/** |
449
|
|
|
* Informações dos documentos de conteiner para modal Aquaviario |
450
|
|
|
* @var array |
451
|
|
|
*/ |
452
|
|
|
private $infDocCont = array(); |
453
|
|
|
/** |
454
|
|
|
* Informações de NF de conteiner para modal Aquaviario |
455
|
|
|
* @var array |
456
|
|
|
*/ |
457
|
|
|
private $infNFCont = array(); |
458
|
|
|
/** |
459
|
|
|
* Informações de NFe de conteiner para modal Aquaviario |
460
|
|
|
* @var array |
461
|
|
|
*/ |
462
|
|
|
private $infNFeCont = array(); |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Informações do modal Dutoviário |
466
|
|
|
* @var \DOMNode |
467
|
|
|
*/ |
468
|
|
|
private $duto = ''; |
469
|
|
|
/** |
470
|
|
|
* Ordens de Coleta associados |
471
|
|
|
* @var array |
472
|
|
|
*/ |
473
|
|
|
private $occ = array(); |
474
|
|
|
/** |
475
|
|
|
* @var \DOMNode |
476
|
|
|
*/ |
477
|
|
|
private $emiOcc = array(); |
478
|
|
|
/** |
479
|
|
|
* Informações de Vale Pedágio |
480
|
|
|
* @var array |
481
|
|
|
*/ |
482
|
|
|
private $valePed = array(); |
483
|
|
|
/** |
484
|
|
|
* Dados dos Veículos |
485
|
|
|
* @var array |
486
|
|
|
*/ |
487
|
|
|
private $veic = array(); |
488
|
|
|
/** |
489
|
|
|
* Proprietários do Veículo. Só preenchido quando o veículo não pertencer à empresa emitente do CT-e |
490
|
|
|
* @var array |
491
|
|
|
*/ |
492
|
|
|
private $prop = array(); |
493
|
|
|
/** |
494
|
|
|
* Informações do CTe Multimodal |
495
|
|
|
* @var array |
496
|
|
|
*/ |
497
|
|
|
private $multimodal = ''; |
498
|
|
|
/** |
499
|
|
|
* Informações do seguro no CTe Multimodal |
500
|
|
|
* @var array |
501
|
|
|
*/ |
502
|
|
|
private $segMultim = ''; |
503
|
|
|
/** |
504
|
|
|
* Autorizados para download do XML do DF-e |
505
|
|
|
* @var array |
506
|
|
|
*/ |
507
|
|
|
private $autXML = array(); |
508
|
|
|
/** |
509
|
|
|
* Dados do Fretamento - CTe-OS |
510
|
|
|
* @var |
511
|
|
|
*/ |
512
|
|
|
private $infFretamento; |
513
|
|
|
/** |
514
|
|
|
* @var DOMElement |
515
|
|
|
*/ |
516
|
|
|
protected $infRespTec; |
517
|
|
|
/** |
518
|
|
|
* @var boolean |
519
|
|
|
*/ |
520
|
|
|
protected $replaceAccentedChars = false; |
521
|
|
|
|
522
|
|
|
public function __construct() |
523
|
|
|
{ |
524
|
|
|
$this->dom = new Dom('1.0', 'UTF-8'); |
|
|
|
|
525
|
|
|
$this->dom->preserveWhiteSpace = false; |
526
|
|
|
$this->dom->formatOutput = false; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* Returns xml string and assembly it is necessary |
531
|
|
|
* @return string |
532
|
|
|
*/ |
533
|
|
|
public function getXML() |
534
|
|
|
{ |
535
|
|
|
if (empty($this->xml)) { |
536
|
|
|
$this->montaCTe(); |
537
|
|
|
} |
538
|
|
|
return $this->xml; |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
/** |
542
|
|
|
* Retorns the key number of NFe (44 digits) |
543
|
|
|
* @return string |
544
|
|
|
*/ |
545
|
|
|
public function getChave() |
546
|
|
|
{ |
547
|
|
|
return $this->chCTe; |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
/** |
551
|
|
|
* Returns the model of CTe 57 or 67 |
552
|
|
|
* @return int |
553
|
|
|
*/ |
554
|
|
|
public function getModelo() |
555
|
|
|
{ |
556
|
|
|
return $this->mod; |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* Set character convertion to ASCII only ou not |
561
|
|
|
* @param bool $option |
562
|
|
|
*/ |
563
|
|
|
public function setOnlyAscii($option = false) |
564
|
|
|
{ |
565
|
|
|
$this->replaceAccentedChars = $option; |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* Call method of xml assembly. For compatibility only. |
570
|
|
|
* @return boolean |
571
|
|
|
*/ |
572
|
|
|
public function montaCTe() |
573
|
|
|
{ |
574
|
|
|
return $this->monta(); |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* Monta o arquivo XML usando as tag's já preenchidas |
579
|
|
|
* |
580
|
|
|
* @return bool |
581
|
|
|
*/ |
582
|
|
|
public function monta() |
583
|
|
|
{ |
584
|
|
|
$this->errors = $this->dom->errors; |
585
|
|
|
if ($this->mod == 57) { |
586
|
|
|
$this->buildCTe(); |
587
|
|
|
} else { |
588
|
|
|
return $this->montaCTeOS(); |
589
|
|
|
} |
590
|
|
|
if ($this->toma3 != '') { |
591
|
|
|
$this->dom->appChild($this->ide, $this->toma3, 'Falta tag "ide"'); |
592
|
|
|
} else { |
593
|
|
|
$this->dom->appChild($this->ide, $this->toma4, 'Falta tag "ide"'); |
594
|
|
|
} |
595
|
|
|
$this->dom->appChild($this->infCte, $this->ide, 'Falta tag "infCte"'); |
596
|
|
|
if ($this->compl != '') { |
597
|
|
|
foreach ($this->obsCont as $obsCont) { |
598
|
|
|
$this->dom->appChild($this->compl, $obsCont, 'Falta tag "compl"'); |
599
|
|
|
} |
600
|
|
|
foreach ($this->obsFisco as $obsFisco) { |
601
|
|
|
$this->dom->appChild($this->compl, $obsFisco, 'Falta tag "compl"'); |
602
|
|
|
} |
603
|
|
|
$this->dom->appChild($this->infCte, $this->compl, 'Falta tag "infCte"'); |
604
|
|
|
} |
605
|
|
|
$this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "emit"'); |
606
|
|
|
$this->dom->appChild($this->infCte, $this->emit, 'Falta tag "infCte"'); |
607
|
|
|
if ($this->rem != '') { |
608
|
|
|
$this->dom->appChild($this->infCte, $this->rem, 'Falta tag "infCte"'); |
609
|
|
|
} |
610
|
|
|
if ($this->exped != '') { |
611
|
|
|
$this->dom->appChild($this->infCte, $this->exped, 'Falta tag "infCte"'); |
612
|
|
|
} |
613
|
|
|
if ($this->receb != '') { |
614
|
|
|
$this->dom->appChild($this->infCte, $this->receb, 'Falta tag "infCte"'); |
615
|
|
|
} |
616
|
|
|
if ($this->dest != '') { |
617
|
|
|
$this->dom->appChild($this->infCte, $this->dest, 'Falta tag "infCte"'); |
618
|
|
|
} |
619
|
|
|
foreach ($this->comp as $comp) { |
620
|
|
|
$this->dom->appChild($this->vPrest, $comp, 'Falta tag "vPrest"'); |
621
|
|
|
} |
622
|
|
|
$this->dom->appChild($this->infCte, $this->vPrest, 'Falta tag "infCte"'); |
623
|
|
|
$this->dom->appChild($this->infCte, $this->imp, 'Falta tag "imp"'); |
624
|
|
|
if ($this->infCteComp != '') { // Caso seja um CTe tipo complemento de valores |
625
|
|
|
$this->dom->appChild($this->infCte, $this->infCteComp, 'Falta tag "infCteComp"'); |
626
|
|
|
} |
627
|
|
|
if ($this->infCteAnu != '') { // Caso seja um CTe tipo anulação |
628
|
|
|
$this->dom->appChild($this->infCte, $this->infCteAnu, 'Falta tag "infCteAnu"'); |
629
|
|
|
} |
630
|
|
|
if ($this->infCTeNorm != '') { // Caso seja um CTe tipo normal |
631
|
|
|
$this->dom->appChild($this->infCte, $this->infCTeNorm, 'Falta tag "infCTeNorm"'); |
632
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->infCarga, 'Falta tag "infCarga"'); |
633
|
|
|
foreach ($this->infQ as $infQ) { |
|
|
|
|
634
|
|
|
$this->dom->appChild($this->infCarga, $infQ, 'Falta tag "infQ"'); |
635
|
|
|
} |
636
|
|
|
foreach ($this->infNF as $infNF) { |
637
|
|
|
$this->dom->appChild($this->infDoc, $infNF, 'Falta tag "infNF"'); |
638
|
|
|
} |
639
|
|
|
foreach ($this->infNFe as $infNFe) { |
640
|
|
|
$this->dom->appChild($this->infDoc, $infNFe, 'Falta tag "infNFe"'); |
641
|
|
|
} |
642
|
|
|
foreach ($this->infOutros as $infOutros) { |
643
|
|
|
$this->dom->appChild($this->infDoc, $infOutros, 'Falta tag "infOutros"'); |
644
|
|
|
} |
645
|
|
|
if (!empty($this->infDoc)) { |
646
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->infDoc, 'Falta tag "infCTeNorm"'); |
647
|
|
|
} |
648
|
|
|
if ($this->idDocAntEle != [] || $this->idDocAntPap != []) { //Caso tenha CT-es Anteriores viculados |
649
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->docAnt, 'Falta tag "docAnt"'); |
650
|
|
|
foreach ($this->emiDocAnt as $indice => $emiDocAnt) { |
651
|
|
|
$this->dom->appChild($this->docAnt, $emiDocAnt, 'Falta tag "emiDocAnt"'); |
652
|
|
|
$indiceIdDocant = 0; |
653
|
|
|
if (array_key_exists($indice, $this->idDocAntEle)) { |
654
|
|
|
$this->dom->appChild($emiDocAnt, $this->idDocAnt[$indice][$indiceIdDocant], 'Falta tag "idDocAnt"'); |
655
|
|
|
foreach ($this->idDocAntEle[$indice] as $idDocAntEle) { |
656
|
|
|
$this->dom->appChild($this->idDocAnt[$indice][$indiceIdDocant], $idDocAntEle, 'Falta tag "emiDocAnt"'); |
657
|
|
|
} |
658
|
|
|
} |
659
|
|
|
if (count($this->idDocAnt[$indice]) > 1) $indiceIdDocant = $indiceIdDocant + 1; |
660
|
|
|
if (array_key_exists($indice, $this->idDocAntPap)) { |
661
|
|
|
$this->dom->appChild($emiDocAnt, $this->idDocAnt[$indice][$indiceIdDocant], 'Falta tag "idDocAnt"'); |
662
|
|
|
foreach ($this->idDocAntPap[$indice] as $idDocAntPap) { |
663
|
|
|
$this->dom->appChild($this->idDocAnt[$indice][$indiceIdDocant], $idDocAntPap, 'Falta tag "idDocAntEle"'); |
664
|
|
|
} |
665
|
|
|
} |
666
|
|
|
} |
667
|
|
|
} |
668
|
|
|
foreach ($this->seg as $seg) { |
669
|
|
|
$this->dom->appChild($this->infCTeNorm, $seg, 'Falta tag "seg"'); |
670
|
|
|
} |
671
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->infModal, 'Falta tag "infModal"'); |
672
|
|
|
if ($this->modal == '01') { |
673
|
|
|
if ($this->rodo) { |
674
|
|
|
foreach ($this->occ as $occ) { |
675
|
|
|
$this->dom->appChild($this->rodo, $occ, 'Falta tag "occ"'); |
676
|
|
|
} |
677
|
|
|
$this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "rodo"'); |
678
|
|
|
} |
679
|
|
|
} elseif ($this->modal == '02') { |
680
|
|
|
foreach ($this->peri as $peri) { |
681
|
|
|
$this->dom->appChild($this->aereo, $peri, 'Falta tag "aereo"'); |
682
|
|
|
} |
683
|
|
|
$this->dom->appChild($this->infModal, $this->aereo, 'Falta tag "aereo"'); |
684
|
|
|
} elseif ($this->modal == '04') { |
685
|
|
|
foreach ($this->ferroEnv as $ferroEnv) { |
|
|
|
|
686
|
|
|
$this->ferrov->insertBefore($ferroEnv, $this->ferrov->getElementsByTagName('fluxo')->item(0)); |
687
|
|
|
} |
688
|
|
|
$this->dom->appChild($this->infModal, $this->ferrov, 'Falta tag "ferrov"'); |
689
|
|
|
} elseif ($this->modal == '03') { |
690
|
|
|
$this->dom->appChild($this->infModal, $this->aquav, 'Falta tag "aquav"'); |
691
|
|
|
if ($this->detCont != []) { //Caso tenha informações de conteiner |
692
|
|
|
foreach ($this->detCont as $indice => $conteiner) { |
693
|
|
|
$this->dom->appChild($this->aquav, $conteiner, 'Falta tag "detCont"'); |
694
|
|
|
if (array_key_exists($indice, $this->lacre)) { |
695
|
|
|
foreach ($this->lacre[$indice] as $lacre) { |
696
|
|
|
$this->dom->appChild($this->detCont[$indice], $lacre, 'Falta tag "lacre"'); |
697
|
|
|
} |
698
|
|
|
} |
699
|
|
|
if (array_key_exists($indice, $this->infNFCont)) { |
700
|
|
|
foreach ($this->infNFCont[$indice] as $infNFCont) { |
701
|
|
|
$this->dom->appChild($this->infDocCont[$indice], $infNFCont, 'Falta tag "infNF"'); |
702
|
|
|
} |
703
|
|
|
} |
704
|
|
|
if (array_key_exists($indice, $this->infNFeCont)) { |
705
|
|
|
foreach ($this->infNFeCont[$indice] as $infNFeCont) { |
706
|
|
|
$this->dom->appChild($this->infDocCont[$indice], $infNFeCont, 'Falta tag "infNFe"'); |
707
|
|
|
} |
708
|
|
|
} |
709
|
|
|
if (array_key_exists($indice, $this->infDocCont)) { |
710
|
|
|
$this->dom->appChild( |
711
|
|
|
$this->detCont[$indice], |
712
|
|
|
$this->infDocCont[$indice], |
713
|
|
|
'Falta tag "infDoc"' |
714
|
|
|
); |
715
|
|
|
} |
716
|
|
|
} |
717
|
|
|
} |
718
|
|
|
foreach ($this->balsa as $balsa) { |
719
|
|
|
$this->aquav->insertBefore($balsa, $this->aquav->getElementsByTagName('nViag')->item(0)); |
720
|
|
|
} |
721
|
|
|
} elseif ($this->modal == '05') { |
722
|
|
|
$this->dom->appChild($this->infModal, $this->duto, 'Falta tag "duto"'); |
723
|
|
|
} elseif ($this->modal == '06') { |
724
|
|
|
if ($this->segMultim != '') { |
725
|
|
|
$this->dom->appChild($this->multimodal, $this->segMultim, 'Falta tag "seg"'); |
726
|
|
|
} |
727
|
|
|
$this->dom->appChild($this->infModal, $this->multimodal, 'Falta tag "multimodal"'); |
728
|
|
|
} else { |
729
|
|
|
throw new Exception('Modal não informado ou não suportado.'); |
730
|
|
|
} |
731
|
|
|
foreach ($this->veicNovos as $veicNovos) { |
732
|
|
|
$this->dom->appChild($this->infCTeNorm, $veicNovos, 'Falta tag "infCte"'); |
733
|
|
|
} |
734
|
|
|
if ($this->infCteSub != '') { |
735
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->infCteSub, 'Falta tag "infCteSub"'); |
736
|
|
|
|
737
|
|
|
if ($this->tomaICMS != '') { |
738
|
|
|
$this->dom->appChild($this->infCteSub, $this->tomaICMS, 'Falta tag "infCteSub"'); |
739
|
|
|
} |
740
|
|
|
} |
741
|
|
|
if ($this->infServVinc != '') { |
742
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->infServVinc, 'Falta tag "infServVinc"'); |
743
|
|
|
|
744
|
|
|
foreach ($this->infCTeMultimodal as $infCTeMultimodal) { |
|
|
|
|
745
|
|
|
$this->dom->appChild($this->infServVinc, $infCTeMultimodal, 'Falta tag "infCTeMultimodal"'); |
746
|
|
|
} |
747
|
|
|
} |
748
|
|
|
} |
749
|
|
|
if ($this->cobr != '') { |
750
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->cobr, 'Falta tag "infCte"'); |
751
|
|
|
} |
752
|
|
|
foreach ($this->autXML as $autXML) { |
753
|
|
|
$this->dom->appChild($this->infCte, $autXML, 'Falta tag "infCte"'); |
754
|
|
|
} |
755
|
|
|
$this->dom->appChild($this->infCte, $this->infRespTec, 'Falta tag "infCte"'); |
756
|
|
|
//[1] tag infCTe |
757
|
|
|
$this->dom->appChild($this->CTe, $this->infCte, 'Falta tag "CTe"'); |
758
|
|
|
//[0] tag CTe |
759
|
|
|
$this->dom->appendChild($this->CTe); |
760
|
|
|
// testa da chave |
761
|
|
|
$this->checkCTeKey($this->dom); |
762
|
|
|
$this->xml = $this->dom->saveXML(); |
763
|
|
|
if (count($this->errors) > 0) { |
764
|
|
|
throw new RuntimeException('Existem erros nas tags. Obtenha os erros com getErrors().'); |
765
|
|
|
} |
766
|
|
|
return true; |
767
|
|
|
} |
768
|
|
|
|
769
|
|
|
/** |
770
|
|
|
* Gera as tags para o elemento: "occ" (ordem de coletas) |
771
|
|
|
* #3 |
772
|
|
|
* Nível:1 |
773
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "occ" do |
774
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 1 |
775
|
|
|
* |
776
|
|
|
* @return \DOMElement |
777
|
|
|
*/ |
778
|
|
|
|
779
|
|
|
public function tagocc($std) |
780
|
|
|
{ |
781
|
|
|
|
782
|
|
|
$possible = [ |
783
|
|
|
'serie', |
784
|
|
|
'nOcc', |
785
|
|
|
'dEmi', |
786
|
|
|
'CNPJ', |
787
|
|
|
'cInt', |
788
|
|
|
'IE', |
789
|
|
|
'UF', |
790
|
|
|
'fone' |
791
|
|
|
]; |
792
|
|
|
|
793
|
|
|
$std = $this->equilizeParameters($std, $possible); |
794
|
|
|
|
795
|
|
|
$identificador = '#3 <occ> - '; |
796
|
|
|
$occ = $this->dom->createElement('occ'); |
797
|
|
|
$this->dom->addChild( |
798
|
|
|
$occ, |
799
|
|
|
'serie', |
800
|
|
|
$std->serie, |
801
|
|
|
false, |
802
|
|
|
$identificador . 'Série da OCC' |
803
|
|
|
); |
804
|
|
|
$this->dom->addChild( |
805
|
|
|
$occ, |
806
|
|
|
'nOcc', |
807
|
|
|
$std->nOcc, |
808
|
|
|
true, |
809
|
|
|
$identificador . 'Número da Ordem de coleta' |
810
|
|
|
); |
811
|
|
|
$this->dom->addChild( |
812
|
|
|
$occ, |
813
|
|
|
'dEmi', |
814
|
|
|
$std->dEmi, |
815
|
|
|
true, |
816
|
|
|
$identificador . 'Data de emissão da ordem de coleta' |
817
|
|
|
); |
818
|
|
|
//emitente |
819
|
|
|
$identificador = '#7 <emiOcc> - '; |
820
|
|
|
$emiOcc = $this->dom->createElement('emiOcc'); |
821
|
|
|
$this->dom->addChild( |
822
|
|
|
$emiOcc, |
823
|
|
|
'CNPJ', |
824
|
|
|
$std->CNPJ, |
825
|
|
|
true, |
826
|
|
|
$identificador . 'Número do CNPJ' |
827
|
|
|
); |
828
|
|
|
$this->dom->addChild( |
829
|
|
|
$emiOcc, |
830
|
|
|
'cInt', |
831
|
|
|
$std->cInt, |
832
|
|
|
false, |
833
|
|
|
$identificador . 'Código interno de uso da transportadora' |
834
|
|
|
); |
835
|
|
|
$this->dom->addChild( |
836
|
|
|
$emiOcc, |
837
|
|
|
'IE', |
838
|
|
|
$std->IE, |
839
|
|
|
true, |
840
|
|
|
$identificador . 'Inscrição Estadual' |
841
|
|
|
); |
842
|
|
|
$this->dom->addChild( |
843
|
|
|
$emiOcc, |
844
|
|
|
'UF', |
845
|
|
|
$std->UF, |
846
|
|
|
true, |
847
|
|
|
$identificador . 'Sigla da UF' |
848
|
|
|
); |
849
|
|
|
$this->dom->addChild( |
850
|
|
|
$emiOcc, |
851
|
|
|
'fone', |
852
|
|
|
$std->fone, |
853
|
|
|
false, |
854
|
|
|
$identificador . 'Telefone' |
855
|
|
|
); |
856
|
|
|
$this->dom->appChild($occ, $emiOcc, 'Falta tag "emiOcc"'); |
857
|
|
|
$this->occ[] = $occ; |
858
|
|
|
return $occ; |
859
|
|
|
} |
860
|
|
|
|
861
|
|
|
|
862
|
|
|
/** |
863
|
|
|
* Monta o arquivo XML usando as tag's já preenchidas |
864
|
|
|
* |
865
|
|
|
* @return bool |
866
|
|
|
*/ |
867
|
|
|
public function montaCTeOS() |
868
|
|
|
{ |
869
|
|
|
$this->errors = $this->dom->errors; |
870
|
|
|
if (count($this->errors) > 0) { |
871
|
|
|
return false; |
872
|
|
|
} |
873
|
|
|
$this->buildCTeOS(); |
874
|
|
|
if ($this->infPercurso != '') { |
875
|
|
|
foreach ($this->infPercurso as $perc) { |
|
|
|
|
876
|
|
|
$this->dom->appChild($this->ide, $perc, 'Falta tag "infPercurso"'); |
877
|
|
|
} |
878
|
|
|
} |
879
|
|
|
$this->dom->appChild($this->infCte, $this->ide, 'Falta tag "infCte"'); |
880
|
|
|
if ($this->compl != '') { |
881
|
|
|
$this->dom->appChild($this->infCte, $this->compl, 'Falta tag "infCte"'); |
882
|
|
|
} |
883
|
|
|
$this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "emit"'); |
884
|
|
|
$this->dom->appChild($this->infCte, $this->emit, 'Falta tag "infCte"'); |
885
|
|
|
if ($this->toma != '') { |
886
|
|
|
$this->dom->appChild($this->infCte, $this->toma, 'Falta tag "infCte"'); |
887
|
|
|
} |
888
|
|
|
foreach ($this->comp as $comp) { |
889
|
|
|
$this->dom->appChild($this->vPrest, $comp, 'Falta tag "vPrest"'); |
890
|
|
|
} |
891
|
|
|
$this->dom->appChild($this->infCte, $this->vPrest, 'Falta tag "infCte"'); |
892
|
|
|
$this->dom->appChild($this->infCte, $this->imp, 'Falta tag "imp"'); |
893
|
|
|
if ($this->infCteComp != '') { // Caso seja um CTe tipo complemento de valores |
894
|
|
|
$this->dom->appChild($this->infCte, $this->infCteComp, 'Falta tag "infCteComp"'); |
895
|
|
|
} elseif ($this->infCteAnu != '') { // Caso seja um CTe tipo anulação |
896
|
|
|
$this->dom->appChild($this->infCte, $this->infCteAnu, 'Falta tag "infCteAnu"'); |
897
|
|
|
} elseif ($this->infCTeNorm != '') { // Caso seja um CTe tipo normal |
898
|
|
|
$this->dom->appChild($this->infCte, $this->infCTeNorm, 'Falta tag "infCTeNorm"'); |
899
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->infServico, 'Falta tag "infServico"'); |
900
|
|
|
foreach ($this->infDocRef as $infDocRef) { |
901
|
|
|
$this->dom->appChild($this->infCTeNorm, $infDocRef, 'Falta tag "infDocRef"'); |
902
|
|
|
} |
903
|
|
|
foreach ($this->seg as $seg) { |
904
|
|
|
$this->dom->appChild($this->infCTeNorm, $seg, 'Falta tag "seg"'); |
905
|
|
|
} |
906
|
|
|
if ($this->infModal != '') { |
907
|
|
|
$this->dom->appChild($this->infCTeNorm, $this->infModal, 'Falta tag "infModal"'); |
908
|
|
|
if (!empty($this->veic)) { |
909
|
|
|
$this->dom->appChild($this->rodo, $this->veic, 'Falta tag "veic"'); |
910
|
|
|
} |
911
|
|
|
$this->dom->appChild($this->rodo, $this->infFretamento, 'Falta tag "infFretamento"'); |
912
|
|
|
$this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "rodo"'); |
913
|
|
|
} |
914
|
|
|
} |
915
|
|
|
if ($this->cobr != '') { |
916
|
|
|
$this->dom->appChild($this->infCte, $this->cobr, 'Falta tag "infCte"'); |
917
|
|
|
} |
918
|
|
|
foreach ($this->autXML as $autXML) { |
919
|
|
|
$this->dom->appChild($this->infCte, $autXML, 'Falta tag "infCte"'); |
920
|
|
|
} |
921
|
|
|
$this->dom->appChild($this->infCte, $this->infRespTec, 'Falta tag "infCte"'); |
922
|
|
|
$this->dom->appChild($this->CTe, $this->infCte, 'Falta tag "CTe"'); |
923
|
|
|
$this->dom->appendChild($this->CTe); |
924
|
|
|
// testa da chave |
925
|
|
|
$this->checkCTeKey($this->dom); |
926
|
|
|
$this->xml = $this->dom->saveXML(); |
927
|
|
|
return true; |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
/** |
931
|
|
|
* Gera o grupo básico: Informações do CT-e |
932
|
|
|
* #1 |
933
|
|
|
* Nível: 0 |
934
|
|
|
* @param stdClass $std |
935
|
|
|
* @return \DOMElement |
936
|
|
|
*/ |
937
|
|
|
public function taginfCTe($std) |
938
|
|
|
{ |
939
|
|
|
$chave = preg_replace('/[^0-9]/', '', $std->Id); |
940
|
|
|
$this->infCte = $this->dom->createElement('infCte'); |
941
|
|
|
$this->infCte->setAttribute('Id', 'CTe' . $chave); |
942
|
|
|
$this->infCte->setAttribute('versao', $std->versao); |
943
|
|
|
return $this->infCte; |
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
/** |
947
|
|
|
* Gera as tags para o elemento: Identificação do CT-e |
948
|
|
|
* #4 |
949
|
|
|
* Nível: 1 |
950
|
|
|
* @param stdClass $std |
951
|
|
|
* @return DOMElement|\DOMNode |
952
|
|
|
*/ |
953
|
|
|
public function tagide($std) |
954
|
|
|
{ |
955
|
|
|
|
956
|
|
|
$possible = [ |
957
|
|
|
'cUF', |
958
|
|
|
'cCT', |
959
|
|
|
'CFOP', |
960
|
|
|
'natOp', |
961
|
|
|
'mod', |
962
|
|
|
'serie', |
963
|
|
|
'nCT', |
964
|
|
|
'dhEmi', |
965
|
|
|
'tpImp', |
966
|
|
|
'tpEmis', |
967
|
|
|
'cDV', |
968
|
|
|
'tpEmis', |
969
|
|
|
'tpAmb', |
970
|
|
|
'tpCTe', |
971
|
|
|
'procEmi', |
972
|
|
|
'verProc', |
973
|
|
|
'indGlobalizado', |
974
|
|
|
'cMunEnv', |
975
|
|
|
'xMunEnv', |
976
|
|
|
'UFEnv', |
977
|
|
|
'modal', |
978
|
|
|
'tpServ', |
979
|
|
|
'indIEToma', |
980
|
|
|
'cMunIni', |
981
|
|
|
'xMunIni', |
982
|
|
|
'UFIni', |
983
|
|
|
'cMunFim', |
984
|
|
|
'xMunFim', |
985
|
|
|
'UFFim', |
986
|
|
|
'retira', |
987
|
|
|
'xDetRetira', |
988
|
|
|
'indIEToma', |
989
|
|
|
'dhCont', |
990
|
|
|
'xJust' |
991
|
|
|
]; |
992
|
|
|
|
993
|
|
|
$std = $this->equilizeParameters($std, $possible); |
994
|
|
|
|
995
|
|
|
$this->tpAmb = $std->tpAmb; |
996
|
|
|
$this->mod = $std->mod; |
997
|
|
|
$identificador = '#4 <ide> - '; |
998
|
|
|
$this->ide = $this->dom->createElement('ide'); |
999
|
|
|
$this->dom->addChild( |
1000
|
|
|
$this->ide, |
1001
|
|
|
'cUF', |
1002
|
|
|
$std->cUF, |
1003
|
|
|
true, |
1004
|
|
|
$identificador . 'Código da UF do emitente do CT-e' |
1005
|
|
|
); |
1006
|
|
|
$this->dom->addChild( |
1007
|
|
|
$this->ide, |
1008
|
|
|
'cCT', |
1009
|
|
|
str_pad($std->cCT, 8, '0', STR_PAD_LEFT), |
1010
|
|
|
true, |
1011
|
|
|
$identificador . 'Código numérico que compõe a Chave de Acesso' |
1012
|
|
|
); |
1013
|
|
|
$this->dom->addChild( |
1014
|
|
|
$this->ide, |
1015
|
|
|
'CFOP', |
1016
|
|
|
$std->CFOP, |
1017
|
|
|
true, |
1018
|
|
|
$identificador . 'Código Fiscal de Operações e Prestações' |
1019
|
|
|
); |
1020
|
|
|
$this->dom->addChild( |
1021
|
|
|
$this->ide, |
1022
|
|
|
'natOp', |
1023
|
|
|
Strings::replaceSpecialsChars(substr(trim($std->natOp), 0, 60)), |
1024
|
|
|
true, |
1025
|
|
|
$identificador . 'Natureza da Operação' |
1026
|
|
|
); |
1027
|
|
|
$this->dom->addChild( |
1028
|
|
|
$this->ide, |
1029
|
|
|
'mod', |
1030
|
|
|
$std->mod, |
1031
|
|
|
true, |
1032
|
|
|
$identificador . 'Modelo do documento fiscal' |
1033
|
|
|
); |
1034
|
|
|
$this->dom->addChild( |
1035
|
|
|
$this->ide, |
1036
|
|
|
'serie', |
1037
|
|
|
$std->serie, |
1038
|
|
|
true, |
1039
|
|
|
$identificador . 'Série do CT-e' |
1040
|
|
|
); |
1041
|
|
|
$this->dom->addChild( |
1042
|
|
|
$this->ide, |
1043
|
|
|
'nCT', |
1044
|
|
|
$std->nCT, |
1045
|
|
|
true, |
1046
|
|
|
$identificador . 'Número do CT-e' |
1047
|
|
|
); |
1048
|
|
|
$this->dom->addChild( |
1049
|
|
|
$this->ide, |
1050
|
|
|
'dhEmi', |
1051
|
|
|
$std->dhEmi, |
1052
|
|
|
true, |
1053
|
|
|
$identificador . 'Data e hora de emissão do CT-e' |
1054
|
|
|
); |
1055
|
|
|
$this->dom->addChild( |
1056
|
|
|
$this->ide, |
1057
|
|
|
'tpImp', |
1058
|
|
|
$std->tpImp, |
1059
|
|
|
true, |
1060
|
|
|
$identificador . 'Formato de impressão do DACTE' |
1061
|
|
|
); |
1062
|
|
|
$this->dom->addChild( |
1063
|
|
|
$this->ide, |
1064
|
|
|
'tpEmis', |
1065
|
|
|
$std->tpEmis, |
1066
|
|
|
true, |
1067
|
|
|
$identificador . 'Forma de emissão do CT-e' |
1068
|
|
|
); |
1069
|
|
|
$this->dom->addChild( |
1070
|
|
|
$this->ide, |
1071
|
|
|
'cDV', |
1072
|
|
|
$std->cDV, |
1073
|
|
|
false, |
1074
|
|
|
$identificador . 'Digito Verificador da chave de acesso do CT-e' |
1075
|
|
|
); |
1076
|
|
|
$this->dom->addChild( |
1077
|
|
|
$this->ide, |
1078
|
|
|
'tpAmb', |
1079
|
|
|
$std->tpAmb, |
1080
|
|
|
true, |
1081
|
|
|
$identificador . 'Tipo do Ambiente' |
1082
|
|
|
); |
1083
|
|
|
$this->dom->addChild( |
1084
|
|
|
$this->ide, |
1085
|
|
|
'tpCTe', |
1086
|
|
|
$std->tpCTe, |
1087
|
|
|
true, |
1088
|
|
|
$identificador . 'Tipo do CT-e' |
1089
|
|
|
); |
1090
|
|
|
$this->dom->addChild( |
1091
|
|
|
$this->ide, |
1092
|
|
|
'procEmi', |
1093
|
|
|
$std->procEmi, |
1094
|
|
|
true, |
1095
|
|
|
$identificador . 'Identificador do processo de emissão do CT-e' |
1096
|
|
|
); |
1097
|
|
|
$this->dom->addChild( |
1098
|
|
|
$this->ide, |
1099
|
|
|
'verProc', |
1100
|
|
|
$std->verProc, |
1101
|
|
|
true, |
1102
|
|
|
$identificador . 'Versão do processo de emissão' |
1103
|
|
|
); |
1104
|
|
|
if ($this->mod == 57) { |
1105
|
|
|
$this->dom->addChild( |
1106
|
|
|
$this->ide, |
1107
|
|
|
'indGlobalizado', |
1108
|
|
|
$std->indGlobalizado, |
1109
|
|
|
false, |
1110
|
|
|
$identificador . 'Indicador de CT-e Globalizado' |
1111
|
|
|
); |
1112
|
|
|
} |
1113
|
|
|
$this->dom->addChild( |
1114
|
|
|
$this->ide, |
1115
|
|
|
'cMunEnv', |
1116
|
|
|
$std->cMunEnv, |
1117
|
|
|
true, |
1118
|
|
|
$identificador . 'Código do Município de envio do CT-e (de onde o documento foi transmitido)' |
1119
|
|
|
); |
1120
|
|
|
$this->dom->addChild( |
1121
|
|
|
$this->ide, |
1122
|
|
|
'xMunEnv', |
1123
|
|
|
$std->xMunEnv, |
1124
|
|
|
true, |
1125
|
|
|
$identificador . 'Nome do Município de envio do CT-e (de onde o documento foi transmitido)' |
1126
|
|
|
); |
1127
|
|
|
$this->dom->addChild( |
1128
|
|
|
$this->ide, |
1129
|
|
|
'UFEnv', |
1130
|
|
|
$std->UFEnv, |
1131
|
|
|
true, |
1132
|
|
|
$identificador . 'Sigla da UF de envio do CT-e (de onde o documento foi transmitido)' |
1133
|
|
|
); |
1134
|
|
|
$this->dom->addChild( |
1135
|
|
|
$this->ide, |
1136
|
|
|
'modal', |
1137
|
|
|
$std->modal, |
1138
|
|
|
true, |
1139
|
|
|
$identificador . 'Modal' |
1140
|
|
|
); |
1141
|
|
|
$this->modal = $std->modal; |
1142
|
|
|
$this->dom->addChild( |
1143
|
|
|
$this->ide, |
1144
|
|
|
'tpServ', |
1145
|
|
|
$std->tpServ, |
1146
|
|
|
true, |
1147
|
|
|
$identificador . 'Tipo do Serviço' |
1148
|
|
|
); |
1149
|
|
|
if ($this->mod == 67) { |
1150
|
|
|
$this->dom->addChild( |
1151
|
|
|
$this->ide, |
1152
|
|
|
'indIEToma', |
1153
|
|
|
$std->indIEToma, |
1154
|
|
|
true, |
1155
|
|
|
$identificador . 'Indicador do papel do tomador na prestação do serviço' |
1156
|
|
|
); |
1157
|
|
|
} |
1158
|
|
|
$this->dom->addChild( |
1159
|
|
|
$this->ide, |
1160
|
|
|
'cMunIni', |
1161
|
|
|
$std->cMunIni, |
1162
|
|
|
true, |
1163
|
|
|
$identificador . 'Nome do Município do início da prestação' |
1164
|
|
|
); |
1165
|
|
|
$this->dom->addChild( |
1166
|
|
|
$this->ide, |
1167
|
|
|
'xMunIni', |
1168
|
|
|
$std->xMunIni, |
1169
|
|
|
true, |
1170
|
|
|
$identificador . 'Nome do Município do início da prestação' |
1171
|
|
|
); |
1172
|
|
|
$this->dom->addChild( |
1173
|
|
|
$this->ide, |
1174
|
|
|
'UFIni', |
1175
|
|
|
$std->UFIni, |
1176
|
|
|
true, |
1177
|
|
|
$identificador . 'UF do início da prestação' |
1178
|
|
|
); |
1179
|
|
|
$this->dom->addChild( |
1180
|
|
|
$this->ide, |
1181
|
|
|
'cMunFim', |
1182
|
|
|
$std->cMunFim, |
1183
|
|
|
true, |
1184
|
|
|
$identificador . 'Código do Município de término da prestação' |
1185
|
|
|
); |
1186
|
|
|
$this->dom->addChild( |
1187
|
|
|
$this->ide, |
1188
|
|
|
'xMunFim', |
1189
|
|
|
$std->xMunFim, |
1190
|
|
|
true, |
1191
|
|
|
$identificador . 'Nome do Município do término da prestação' |
1192
|
|
|
); |
1193
|
|
|
$this->dom->addChild( |
1194
|
|
|
$this->ide, |
1195
|
|
|
'UFFim', |
1196
|
|
|
$std->UFFim, |
1197
|
|
|
true, |
1198
|
|
|
$identificador . 'UF do término da prestação' |
1199
|
|
|
); |
1200
|
|
|
if ($this->mod == 57) { |
1201
|
|
|
$this->dom->addChild( |
1202
|
|
|
$this->ide, |
1203
|
|
|
'retira', |
1204
|
|
|
$std->retira, |
1205
|
|
|
true, |
1206
|
|
|
$identificador . 'Indicador se o Recebedor retira no Aeroporto, Filial, Porto ou Estação de Destino' |
1207
|
|
|
); |
1208
|
|
|
$this->dom->addChild( |
1209
|
|
|
$this->ide, |
1210
|
|
|
'xDetRetira', |
1211
|
|
|
$std->xDetRetira, |
1212
|
|
|
false, |
1213
|
|
|
$identificador . 'Detalhes do retira' |
1214
|
|
|
); |
1215
|
|
|
$this->dom->addChild( |
1216
|
|
|
$this->ide, |
1217
|
|
|
'indIEToma', |
1218
|
|
|
$std->indIEToma, |
1219
|
|
|
true, |
1220
|
|
|
$identificador . 'Indicador do papel do tomador na prestação do serviço' |
1221
|
|
|
); |
1222
|
|
|
} |
1223
|
|
|
$this->dom->addChild( |
1224
|
|
|
$this->ide, |
1225
|
|
|
'dhCont', |
1226
|
|
|
$std->dhCont, |
1227
|
|
|
false, |
1228
|
|
|
$identificador . 'Data e Hora da entrada em contingência' |
1229
|
|
|
); |
1230
|
|
|
$this->dom->addChild( |
1231
|
|
|
$this->ide, |
1232
|
|
|
'xJust', |
1233
|
|
|
Strings::replaceSpecialsChars(substr(trim($std->xJust), 0, 256)), |
1234
|
|
|
false, |
1235
|
|
|
$identificador . 'Justificativa da entrada em contingência' |
1236
|
|
|
); |
1237
|
|
|
$this->tpServ = $std->tpServ; |
1238
|
|
|
return $this->ide; |
1239
|
|
|
} |
1240
|
|
|
|
1241
|
|
|
public function taginfPercurso($std) |
1242
|
|
|
{ |
1243
|
|
|
|
1244
|
|
|
$possible = [ |
1245
|
|
|
'UFPer' |
1246
|
|
|
]; |
1247
|
|
|
|
1248
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1249
|
|
|
|
1250
|
|
|
$identificador = '#4 <infPercurso> - '; |
1251
|
|
|
$this->infPercurso[] = $this->dom->createElement('infPercurso'); |
1252
|
|
|
$posicao = (int)count($this->infPercurso) - 1; |
1253
|
|
|
$this->dom->addChild( |
1254
|
|
|
$this->infPercurso[$posicao], |
1255
|
|
|
'UFPer', |
1256
|
|
|
$std->UFPer, |
1257
|
|
|
true, |
1258
|
|
|
$identificador . 'Código da UF do percurso' |
1259
|
|
|
); |
1260
|
|
|
|
1261
|
|
|
return $this->infPercurso[$posicao]; |
1262
|
|
|
} |
1263
|
|
|
|
1264
|
|
|
/** |
1265
|
|
|
* Gera as tags para o elemento: toma3 (Indicador do "papel" do tomador do serviço no CT-e) |
1266
|
|
|
* e adiciona ao grupo ide |
1267
|
|
|
* #35 |
1268
|
|
|
* Nível: 2 |
1269
|
|
|
* @param string $toma Tomador do Serviço |
|
|
|
|
1270
|
|
|
* @param stdClass $std |
1271
|
|
|
* @return \DOMElement |
1272
|
|
|
*/ |
1273
|
|
|
public function tagtoma3($std) |
1274
|
|
|
{ |
1275
|
|
|
|
1276
|
|
|
$possible = [ |
1277
|
|
|
'toma' |
1278
|
|
|
]; |
1279
|
|
|
|
1280
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1281
|
|
|
|
1282
|
|
|
$identificador = '#35 <toma3> - '; |
1283
|
|
|
$this->toma3 = $this->dom->createElement('toma3'); |
1284
|
|
|
$this->dom->addChild( |
1285
|
|
|
$this->toma3, |
1286
|
|
|
'toma', |
1287
|
|
|
$std->toma, |
1288
|
|
|
true, |
1289
|
|
|
$identificador . 'Tomador do Serviço' |
1290
|
|
|
); |
1291
|
|
|
return $this->toma3; |
1292
|
|
|
} |
1293
|
|
|
|
1294
|
|
|
/** |
1295
|
|
|
* Gera as tags para o elemento: toma4 (Indicador do "papel" do tomador |
1296
|
|
|
* do serviço no CT-e) e adiciona ao grupo ide |
1297
|
|
|
* #37 |
1298
|
|
|
* Nível: 2 |
1299
|
|
|
* @param stdClass $std |
1300
|
|
|
* @return \DOMElement |
1301
|
|
|
*/ |
1302
|
|
|
public function tagtoma4($std) |
1303
|
|
|
{ |
1304
|
|
|
|
1305
|
|
|
$possible = [ |
1306
|
|
|
'toma', |
1307
|
|
|
'CNPJ', |
1308
|
|
|
'CPF', |
1309
|
|
|
'IE', |
1310
|
|
|
'xNome', |
1311
|
|
|
'xFant', |
1312
|
|
|
'fone', |
1313
|
|
|
'email' |
1314
|
|
|
]; |
1315
|
|
|
|
1316
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1317
|
|
|
|
1318
|
|
|
$identificador = '#37 <toma4> - '; |
1319
|
|
|
$this->toma4 = $this->dom->createElement('toma4'); |
1320
|
|
|
$this->dom->addChild( |
1321
|
|
|
$this->toma4, |
1322
|
|
|
'toma', |
1323
|
|
|
$std->toma, |
1324
|
|
|
true, |
1325
|
|
|
$identificador . 'Tomador do Serviço' |
1326
|
|
|
); |
1327
|
|
|
if ($std->CNPJ != '') { |
1328
|
|
|
$this->dom->addChild( |
1329
|
|
|
$this->toma4, |
1330
|
|
|
'CNPJ', |
1331
|
|
|
$std->CNPJ, |
1332
|
|
|
true, |
1333
|
|
|
$identificador . 'Número do CNPJ' |
1334
|
|
|
); |
1335
|
|
|
} elseif ($std->CPF != '') { |
1336
|
|
|
$this->dom->addChild( |
1337
|
|
|
$this->toma4, |
1338
|
|
|
'CPF', |
1339
|
|
|
$std->CPF, |
1340
|
|
|
true, |
1341
|
|
|
$identificador . 'Número do CPF' |
1342
|
|
|
); |
1343
|
|
|
} else { |
1344
|
|
|
$this->dom->addChild( |
1345
|
|
|
$this->toma4, |
1346
|
|
|
'CNPJ', |
1347
|
|
|
$std->CNPJ, |
1348
|
|
|
true, |
1349
|
|
|
$identificador . 'Número do CNPJ' |
1350
|
|
|
); |
1351
|
|
|
$this->dom->addChild( |
1352
|
|
|
$this->toma4, |
1353
|
|
|
'CPF', |
1354
|
|
|
$std->CPF, |
1355
|
|
|
true, |
1356
|
|
|
$identificador . 'Número do CPF' |
1357
|
|
|
); |
1358
|
|
|
} |
1359
|
|
|
$this->dom->addChild( |
1360
|
|
|
$this->toma4, |
1361
|
|
|
'IE', |
1362
|
|
|
$std->IE, |
1363
|
|
|
false, |
1364
|
|
|
$identificador . 'Inscrição Estadual' |
1365
|
|
|
); |
1366
|
|
|
$this->dom->addChild( |
1367
|
|
|
$this->toma4, |
1368
|
|
|
'xNome', |
1369
|
|
|
$std->xNome, |
1370
|
|
|
true, |
1371
|
|
|
$identificador . 'Razão Social ou Nome' |
1372
|
|
|
); |
1373
|
|
|
$this->dom->addChild( |
1374
|
|
|
$this->toma4, |
1375
|
|
|
'xFant', |
1376
|
|
|
$std->xFant, |
1377
|
|
|
false, |
1378
|
|
|
$identificador . 'Nome Fantasia' |
1379
|
|
|
); |
1380
|
|
|
$this->dom->addChild( |
1381
|
|
|
$this->toma4, |
1382
|
|
|
'fone', |
1383
|
|
|
$std->fone, |
1384
|
|
|
false, |
1385
|
|
|
$identificador . 'Telefone' |
1386
|
|
|
); |
1387
|
|
|
$this->dom->addChild( |
1388
|
|
|
$this->toma4, |
1389
|
|
|
'email', |
1390
|
|
|
$std->email, |
1391
|
|
|
false, |
1392
|
|
|
$identificador . 'Endereço de email' |
1393
|
|
|
); |
1394
|
|
|
return $this->toma4; |
1395
|
|
|
} |
1396
|
|
|
|
1397
|
|
|
/** |
1398
|
|
|
* Gera as tags para o elemento: toma4 (Indicador do "papel" do tomador |
1399
|
|
|
* do serviço no CT-e OS) e adiciona ao grupo ide |
1400
|
|
|
* #37 |
1401
|
|
|
* Nível: 2 |
1402
|
|
|
* |
1403
|
|
|
* @return \DOMElement |
1404
|
|
|
*/ |
1405
|
|
|
public function tagtomador($std) |
1406
|
|
|
{ |
1407
|
|
|
|
1408
|
|
|
$possible = [ |
1409
|
|
|
'CNPJ', |
1410
|
|
|
'CPF', |
1411
|
|
|
'IE', |
1412
|
|
|
'xNome', |
1413
|
|
|
'xFant', |
1414
|
|
|
'fone', |
1415
|
|
|
'xLgr', |
1416
|
|
|
'nro', |
1417
|
|
|
'xCpl', |
1418
|
|
|
'xBairro', |
1419
|
|
|
'cMun', |
1420
|
|
|
'xMun', |
1421
|
|
|
'CEP', |
1422
|
|
|
'UF', |
1423
|
|
|
'cPais', |
1424
|
|
|
'xPais', |
1425
|
|
|
'email' |
1426
|
|
|
]; |
1427
|
|
|
|
1428
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1429
|
|
|
|
1430
|
|
|
$identificador = '#37 <toma> - '; |
1431
|
|
|
$this->toma = $this->dom->createElement('toma'); |
1432
|
|
|
if ($std->CNPJ != '') { |
1433
|
|
|
$this->dom->addChild( |
1434
|
|
|
$this->toma, |
1435
|
|
|
'CNPJ', |
1436
|
|
|
$std->CNPJ, |
1437
|
|
|
true, |
1438
|
|
|
$identificador . 'Número do CNPJ' |
1439
|
|
|
); |
1440
|
|
|
} elseif ($std->CPF != '') { |
1441
|
|
|
$this->dom->addChild( |
1442
|
|
|
$this->toma, |
1443
|
|
|
'CPF', |
1444
|
|
|
$std->CPF, |
1445
|
|
|
true, |
1446
|
|
|
$identificador . 'Número do CPF' |
1447
|
|
|
); |
1448
|
|
|
} else { |
1449
|
|
|
$this->dom->addChild( |
1450
|
|
|
$this->toma, |
1451
|
|
|
'CNPJ', |
1452
|
|
|
$std->CNPJ, |
1453
|
|
|
true, |
1454
|
|
|
$identificador . 'Número do CNPJ' |
1455
|
|
|
); |
1456
|
|
|
$this->dom->addChild( |
1457
|
|
|
$this->toma, |
1458
|
|
|
'CPF', |
1459
|
|
|
$std->CPF, |
1460
|
|
|
true, |
1461
|
|
|
$identificador . 'Número do CPF' |
1462
|
|
|
); |
1463
|
|
|
} |
1464
|
|
|
$this->dom->addChild( |
1465
|
|
|
$this->toma, |
1466
|
|
|
'IE', |
1467
|
|
|
$std->IE, |
1468
|
|
|
false, |
1469
|
|
|
$identificador . 'Inscrição Estadual' |
1470
|
|
|
); |
1471
|
|
|
$this->dom->addChild( |
1472
|
|
|
$this->toma, |
1473
|
|
|
'xNome', |
1474
|
|
|
$std->xNome, |
1475
|
|
|
true, |
1476
|
|
|
$identificador . 'Razão Social ou Nome' |
1477
|
|
|
); |
1478
|
|
|
$this->dom->addChild( |
1479
|
|
|
$this->toma, |
1480
|
|
|
'xFant', |
1481
|
|
|
$std->xFant, |
1482
|
|
|
false, |
1483
|
|
|
$identificador . 'Nome Fantasia' |
1484
|
|
|
); |
1485
|
|
|
$this->dom->addChild( |
1486
|
|
|
$this->toma, |
1487
|
|
|
'fone', |
1488
|
|
|
$std->fone, |
1489
|
|
|
false, |
1490
|
|
|
$identificador . 'Telefone' |
1491
|
|
|
); |
1492
|
|
|
//Endereço Tomador |
1493
|
|
|
$this->enderToma = $this->dom->createElement('enderToma'); |
1494
|
|
|
$this->dom->addChild( |
1495
|
|
|
$this->enderToma, |
1496
|
|
|
'xLgr', |
1497
|
|
|
$std->xLgr, |
1498
|
|
|
true, |
1499
|
|
|
$identificador . 'Logradouro' |
1500
|
|
|
); |
1501
|
|
|
$this->dom->addChild( |
1502
|
|
|
$this->enderToma, |
1503
|
|
|
'nro', |
1504
|
|
|
$std->nro, |
1505
|
|
|
true, |
1506
|
|
|
$identificador . 'Número' |
1507
|
|
|
); |
1508
|
|
|
$this->dom->addChild( |
1509
|
|
|
$this->enderToma, |
1510
|
|
|
'xCpl', |
1511
|
|
|
$std->xCpl, |
1512
|
|
|
false, |
1513
|
|
|
$identificador . 'Complemento' |
1514
|
|
|
); |
1515
|
|
|
$this->dom->addChild( |
1516
|
|
|
$this->enderToma, |
1517
|
|
|
'xBairro', |
1518
|
|
|
$std->xBairro, |
1519
|
|
|
true, |
1520
|
|
|
$identificador . 'Bairro' |
1521
|
|
|
); |
1522
|
|
|
$this->dom->addChild( |
1523
|
|
|
$this->enderToma, |
1524
|
|
|
'cMun', |
1525
|
|
|
$std->cMun, |
1526
|
|
|
true, |
1527
|
|
|
$identificador . 'Código do município (utilizar a tabela do IBGE)' |
1528
|
|
|
); |
1529
|
|
|
$this->dom->addChild( |
1530
|
|
|
$this->enderToma, |
1531
|
|
|
'xMun', |
1532
|
|
|
$std->xMun, |
1533
|
|
|
true, |
1534
|
|
|
$identificador . 'Nome do município' |
1535
|
|
|
); |
1536
|
|
|
$this->dom->addChild( |
1537
|
|
|
$this->enderToma, |
1538
|
|
|
'CEP', |
1539
|
|
|
$std->CEP, |
1540
|
|
|
false, |
1541
|
|
|
$identificador . 'CEP' |
1542
|
|
|
); |
1543
|
|
|
$this->dom->addChild( |
1544
|
|
|
$this->enderToma, |
1545
|
|
|
'UF', |
1546
|
|
|
$std->UF, |
1547
|
|
|
true, |
1548
|
|
|
$identificador . 'Sigla da UF' |
1549
|
|
|
); |
1550
|
|
|
$this->dom->addChild( |
1551
|
|
|
$this->enderToma, |
1552
|
|
|
'cPais', |
1553
|
|
|
$std->cPais, |
1554
|
|
|
false, |
1555
|
|
|
$identificador . 'Código do país' |
1556
|
|
|
); |
1557
|
|
|
$this->dom->addChild( |
1558
|
|
|
$this->enderToma, |
1559
|
|
|
'xPais', |
1560
|
|
|
$std->xPais, |
1561
|
|
|
false, |
1562
|
|
|
$identificador . 'Nome do país' |
1563
|
|
|
); |
1564
|
|
|
$this->dom->appChild($this->toma, $this->enderToma, 'Falta tag "enderToma"'); |
1565
|
|
|
$this->dom->addChild( |
1566
|
|
|
$this->toma, |
1567
|
|
|
'email', |
1568
|
|
|
$std->email, |
1569
|
|
|
false, |
1570
|
|
|
$identificador . 'Endereço de email' |
1571
|
|
|
); |
1572
|
|
|
return $this->toma; |
1573
|
|
|
} |
1574
|
|
|
|
1575
|
|
|
/** |
1576
|
|
|
* Gera as tags para o elemento: "enderToma" (Dados do endereço) e adiciona ao grupo "toma4" |
1577
|
|
|
* #45 |
1578
|
|
|
* Nível: 3 |
1579
|
|
|
* |
1580
|
|
|
* @return \DOMElement |
1581
|
|
|
*/ |
1582
|
|
|
public function tagenderToma($std) |
1583
|
|
|
{ |
1584
|
|
|
|
1585
|
|
|
$possible = [ |
1586
|
|
|
'xLgr', |
1587
|
|
|
'nro', |
1588
|
|
|
'xCpl', |
1589
|
|
|
'xBairro', |
1590
|
|
|
'cMun', |
1591
|
|
|
'xMun', |
1592
|
|
|
'CEP', |
1593
|
|
|
'UF', |
1594
|
|
|
'cPais', |
1595
|
|
|
'xPais' |
1596
|
|
|
]; |
1597
|
|
|
|
1598
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1599
|
|
|
|
1600
|
|
|
$identificador = '#45 <enderToma> - '; |
1601
|
|
|
$this->enderToma = $this->dom->createElement('enderToma'); |
1602
|
|
|
$this->dom->addChild( |
1603
|
|
|
$this->enderToma, |
1604
|
|
|
'xLgr', |
1605
|
|
|
$std->xLgr, |
1606
|
|
|
true, |
1607
|
|
|
$identificador . 'Logradouro' |
1608
|
|
|
); |
1609
|
|
|
$this->dom->addChild( |
1610
|
|
|
$this->enderToma, |
1611
|
|
|
'nro', |
1612
|
|
|
$std->nro, |
1613
|
|
|
true, |
1614
|
|
|
$identificador . 'Número' |
1615
|
|
|
); |
1616
|
|
|
$this->dom->addChild( |
1617
|
|
|
$this->enderToma, |
1618
|
|
|
'xCpl', |
1619
|
|
|
$std->xCpl, |
1620
|
|
|
false, |
1621
|
|
|
$identificador . 'Complemento' |
1622
|
|
|
); |
1623
|
|
|
$this->dom->addChild( |
1624
|
|
|
$this->enderToma, |
1625
|
|
|
'xBairro', |
1626
|
|
|
$std->xBairro, |
1627
|
|
|
true, |
1628
|
|
|
$identificador . 'Bairro' |
1629
|
|
|
); |
1630
|
|
|
$this->dom->addChild( |
1631
|
|
|
$this->enderToma, |
1632
|
|
|
'cMun', |
1633
|
|
|
$std->cMun, |
1634
|
|
|
true, |
1635
|
|
|
$identificador . 'Código do município (utilizar a tabela do IBGE)' |
1636
|
|
|
); |
1637
|
|
|
$this->dom->addChild( |
1638
|
|
|
$this->enderToma, |
1639
|
|
|
'xMun', |
1640
|
|
|
$std->xMun, |
1641
|
|
|
true, |
1642
|
|
|
$identificador . 'Nome do município' |
1643
|
|
|
); |
1644
|
|
|
$this->dom->addChild( |
1645
|
|
|
$this->enderToma, |
1646
|
|
|
'CEP', |
1647
|
|
|
$std->CEP, |
1648
|
|
|
false, |
1649
|
|
|
$identificador . 'CEP' |
1650
|
|
|
); |
1651
|
|
|
$this->dom->addChild( |
1652
|
|
|
$this->enderToma, |
1653
|
|
|
'UF', |
1654
|
|
|
$std->UF, |
1655
|
|
|
true, |
1656
|
|
|
$identificador . 'Sigla da UF' |
1657
|
|
|
); |
1658
|
|
|
$this->dom->addChild( |
1659
|
|
|
$this->enderToma, |
1660
|
|
|
'cPais', |
1661
|
|
|
$std->cPais, |
1662
|
|
|
false, |
1663
|
|
|
$identificador . 'Código do país' |
1664
|
|
|
); |
1665
|
|
|
$this->dom->addChild( |
1666
|
|
|
$this->enderToma, |
1667
|
|
|
'xPais', |
1668
|
|
|
$std->xPais, |
1669
|
|
|
false, |
1670
|
|
|
$identificador . 'Nome do país' |
1671
|
|
|
); |
1672
|
|
|
|
1673
|
|
|
if (!empty($this->toma4)) { |
1674
|
|
|
$this->toma4->insertBefore($this->enderToma, $this->toma4->getElementsByTagName("email")->item(0)); |
1675
|
|
|
} |
1676
|
|
|
return $this->enderToma; |
1677
|
|
|
} |
1678
|
|
|
|
1679
|
|
|
/** |
1680
|
|
|
* Gera as tags para o elemento: "compl" (Dados complementares do CT-e para fins operacionais ou comerciais) |
1681
|
|
|
* #59 |
1682
|
|
|
* Nível: 1 |
1683
|
|
|
* |
1684
|
|
|
* @return \DOMElement |
1685
|
|
|
*/ |
1686
|
|
|
public function tagcompl($std) |
1687
|
|
|
{ |
1688
|
|
|
|
1689
|
|
|
$possible = [ |
1690
|
|
|
'xCaracAd', |
1691
|
|
|
'xCaracSer', |
1692
|
|
|
'xEmi', |
1693
|
|
|
'origCalc', |
1694
|
|
|
'destCalc', |
1695
|
|
|
'xObs' |
1696
|
|
|
]; |
1697
|
|
|
|
1698
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1699
|
|
|
|
1700
|
|
|
$identificador = '#59 <compl> - '; |
1701
|
|
|
if ($this->compl == '') { |
1702
|
|
|
$this->compl = $this->dom->createElement('compl'); |
1703
|
|
|
} |
1704
|
|
|
$this->dom->addChild( |
1705
|
|
|
$this->compl, |
1706
|
|
|
'xCaracAd', |
1707
|
|
|
$std->xCaracAd, |
1708
|
|
|
false, |
1709
|
|
|
$identificador . 'Característica adicional do transporte' |
1710
|
|
|
); |
1711
|
|
|
$this->dom->addChild( |
1712
|
|
|
$this->compl, |
1713
|
|
|
'xCaracSer', |
1714
|
|
|
$std->xCaracSer, |
1715
|
|
|
false, |
1716
|
|
|
$identificador . 'Característica adicional do serviço' |
1717
|
|
|
); |
1718
|
|
|
$this->dom->addChild( |
1719
|
|
|
$this->compl, |
1720
|
|
|
'xEmi', |
1721
|
|
|
$std->xEmi, |
1722
|
|
|
false, |
1723
|
|
|
$identificador . 'Funcionário emissor do CTe' |
1724
|
|
|
); |
1725
|
|
|
if ($this->fluxo != '') { |
1726
|
|
|
foreach ($this->pass as $pass) { |
1727
|
|
|
$this->dom->appChild($this->fluxo, $pass, 'Falta tag "fluxo"'); |
1728
|
|
|
} |
1729
|
|
|
$this->dom->appChild($this->compl, $this->fluxo, 'Falta tag "infCte"'); |
1730
|
|
|
} |
1731
|
|
|
if ($this->semData != '') { |
1732
|
|
|
$this->tagEntrega(); |
1733
|
|
|
$this->dom->appChild($this->entrega, $this->semData, 'Falta tag "Entrega"'); |
1734
|
|
|
} |
1735
|
|
|
if ($this->comData != '') { |
1736
|
|
|
$this->tagEntrega(); |
1737
|
|
|
$this->dom->appChild($this->entrega, $this->comData, 'Falta tag "Entrega"'); |
1738
|
|
|
} |
1739
|
|
|
if ($this->noPeriodo != '') { |
1740
|
|
|
$this->tagEntrega(); |
1741
|
|
|
$this->dom->appChild($this->entrega, $this->noPeriodo, 'Falta tag "Entrega"'); |
1742
|
|
|
} |
1743
|
|
|
if ($this->semHora != '') { |
1744
|
|
|
$this->tagEntrega(); |
1745
|
|
|
$this->dom->appChild($this->entrega, $this->semHora, 'Falta tag "Entrega"'); |
1746
|
|
|
} |
1747
|
|
|
if ($this->comHora != '') { |
1748
|
|
|
$this->tagEntrega(); |
1749
|
|
|
$this->dom->appChild($this->entrega, $this->comHora, 'Falta tag "Entrega"'); |
1750
|
|
|
} |
1751
|
|
|
if ($this->noInter != '') { |
1752
|
|
|
$this->tagEntrega(); |
1753
|
|
|
$this->dom->appChild($this->entrega, $this->noInter, 'Falta tag "Entrega"'); |
1754
|
|
|
} |
1755
|
|
|
if ($this->mod == 57) { |
1756
|
|
|
$this->dom->addChild( |
1757
|
|
|
$this->compl, |
1758
|
|
|
'origCalc', |
1759
|
|
|
$std->origCalc, |
1760
|
|
|
false, |
1761
|
|
|
$identificador . 'Município de origem para efeito de cálculo do frete' |
1762
|
|
|
); |
1763
|
|
|
$this->dom->addChild( |
1764
|
|
|
$this->compl, |
1765
|
|
|
'destCalc', |
1766
|
|
|
$std->destCalc, |
1767
|
|
|
false, |
1768
|
|
|
$identificador . 'Município de destino para efeito de cálculo do frete' |
1769
|
|
|
); |
1770
|
|
|
} |
1771
|
|
|
$this->dom->addChild( |
1772
|
|
|
$this->compl, |
1773
|
|
|
'xObs', |
1774
|
|
|
$std->xObs, |
1775
|
|
|
false, |
1776
|
|
|
$identificador . 'Observações Gerais' |
1777
|
|
|
); |
1778
|
|
|
return $this->compl; |
1779
|
|
|
} |
1780
|
|
|
|
1781
|
|
|
/** |
1782
|
|
|
* Gera as tags para o elemento: "compl" (Dados complementares do CT-e OS para fins operacionais ou comerciais) |
1783
|
|
|
* #59 |
1784
|
|
|
* Nível: 1 |
1785
|
|
|
* |
1786
|
|
|
* @return \DOMElement |
1787
|
|
|
*/ |
1788
|
|
|
public function tagcomplCTeOs($std) |
1789
|
|
|
{ |
1790
|
|
|
|
1791
|
|
|
$possible = [ |
1792
|
|
|
'xCaracAd', |
1793
|
|
|
'xCaracSer', |
1794
|
|
|
'xEmi', |
1795
|
|
|
'xObs' |
1796
|
|
|
]; |
1797
|
|
|
|
1798
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1799
|
|
|
|
1800
|
|
|
$identificador = '#59 <compl> - '; |
1801
|
|
|
$this->compl = $this->dom->createElement('compl'); |
1802
|
|
|
$this->dom->addChild( |
1803
|
|
|
$this->compl, |
1804
|
|
|
'xCaracAd', |
1805
|
|
|
$std->xCaracAd, |
1806
|
|
|
false, |
1807
|
|
|
$identificador . 'Característica adicional do transporte' |
1808
|
|
|
); |
1809
|
|
|
$this->dom->addChild( |
1810
|
|
|
$this->compl, |
1811
|
|
|
'xCaracSer', |
1812
|
|
|
$std->xCaracSer, |
1813
|
|
|
false, |
1814
|
|
|
$identificador . 'Característica adicional do serviço' |
1815
|
|
|
); |
1816
|
|
|
$this->dom->addChild( |
1817
|
|
|
$this->compl, |
1818
|
|
|
'xEmi', |
1819
|
|
|
$std->xEmi, |
1820
|
|
|
false, |
1821
|
|
|
$identificador . 'Funcionário emissor do CTe' |
1822
|
|
|
); |
1823
|
|
|
$this->dom->addChild( |
1824
|
|
|
$this->compl, |
1825
|
|
|
'xObs', |
1826
|
|
|
$std->xObs, |
1827
|
|
|
false, |
1828
|
|
|
$identificador . 'Observações Gerais' |
1829
|
|
|
); |
1830
|
|
|
return $this->compl; |
1831
|
|
|
} |
1832
|
|
|
|
1833
|
|
|
/** |
1834
|
|
|
* Gera as tags para o elemento: "fluxo" (Previsão do fluxo da carga) |
1835
|
|
|
* #63 |
1836
|
|
|
* Nível: 2 |
1837
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "fluxo" do |
1838
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
1839
|
|
|
* |
1840
|
|
|
* @return \DOMElement |
1841
|
|
|
*/ |
1842
|
|
|
public function tagfluxo($std) |
1843
|
|
|
{ |
1844
|
|
|
|
1845
|
|
|
$possible = [ |
1846
|
|
|
'xOrig', |
1847
|
|
|
'xDest', |
1848
|
|
|
'xRota' |
1849
|
|
|
]; |
1850
|
|
|
|
1851
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1852
|
|
|
|
1853
|
|
|
$identificador = '#63 <fluxo> - '; |
1854
|
|
|
$this->fluxo = $this->dom->createElement('fluxo'); |
1855
|
|
|
$this->dom->addChild( |
1856
|
|
|
$this->fluxo, |
1857
|
|
|
'xOrig', |
1858
|
|
|
$std->xOrig, |
1859
|
|
|
false, |
1860
|
|
|
$identificador . 'Sigla ou código interno da Filial/Porto/Estação/ Aeroporto de Origem' |
1861
|
|
|
); |
1862
|
|
|
$this->dom->addChild( |
1863
|
|
|
$this->fluxo, |
1864
|
|
|
'xDest', |
1865
|
|
|
$std->xDest, |
1866
|
|
|
false, |
1867
|
|
|
$identificador . 'Sigla ou código interno da Filial/Porto/Estação/Aeroporto de Destino' |
1868
|
|
|
); |
1869
|
|
|
$this->dom->addChild( |
1870
|
|
|
$this->fluxo, |
1871
|
|
|
'xRota', |
1872
|
|
|
$std->xRota, |
1873
|
|
|
false, |
1874
|
|
|
$identificador . 'Código da Rota de Entrega' |
1875
|
|
|
); |
1876
|
|
|
return $this->fluxo; |
1877
|
|
|
} |
1878
|
|
|
|
1879
|
|
|
/** |
1880
|
|
|
* Gera as tags para o elemento: "pass" |
1881
|
|
|
* #65 |
1882
|
|
|
* Nível: 3 |
1883
|
|
|
* |
1884
|
|
|
* @return \DOMElement |
1885
|
|
|
*/ |
1886
|
|
|
public function tagpass($std) |
1887
|
|
|
{ |
1888
|
|
|
|
1889
|
|
|
$possible = [ |
1890
|
|
|
'xPass' |
1891
|
|
|
]; |
1892
|
|
|
|
1893
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1894
|
|
|
|
1895
|
|
|
$identificador = '#65 <pass> - '; |
1896
|
|
|
$this->pass[] = $this->dom->createElement('pass'); |
1897
|
|
|
$posicao = (int)count($this->pass) - 1; |
1898
|
|
|
$this->dom->addChild( |
1899
|
|
|
$this->pass[$posicao], |
1900
|
|
|
'xPass', |
1901
|
|
|
$std->xPass, |
1902
|
|
|
false, |
1903
|
|
|
$identificador . 'Sigla ou código interno da Filial/Porto/Estação/Aeroporto de Passagem' |
1904
|
|
|
); |
1905
|
|
|
return $this->pass[$posicao]; |
1906
|
|
|
} |
1907
|
|
|
|
1908
|
|
|
/** |
1909
|
|
|
* Gera as tags para o elemento: "semData" (Entrega sem data definida) |
1910
|
|
|
* #70 |
1911
|
|
|
* Nível: 3 |
1912
|
|
|
* |
1913
|
|
|
* @return \DOMElement |
1914
|
|
|
*/ |
1915
|
|
|
public function tagsemData($std) |
1916
|
|
|
{ |
1917
|
|
|
|
1918
|
|
|
$possible = [ |
1919
|
|
|
'tpPer' |
1920
|
|
|
]; |
1921
|
|
|
|
1922
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1923
|
|
|
|
1924
|
|
|
$identificador = '#70 <semData> - '; |
1925
|
|
|
$this->semData = $this->dom->createElement('semData'); |
1926
|
|
|
$this->dom->addChild( |
1927
|
|
|
$this->semData, |
1928
|
|
|
'tpPer', |
1929
|
|
|
$std->tpPer, |
1930
|
|
|
true, |
1931
|
|
|
$identificador . 'Tipo de data/período programado para entrega' |
1932
|
|
|
); |
1933
|
|
|
return $this->semData; |
1934
|
|
|
} |
1935
|
|
|
|
1936
|
|
|
/** |
1937
|
|
|
* Gera as tags para o elemento: "comData" (Entrega com data definida) |
1938
|
|
|
* #72 |
1939
|
|
|
* Nível: 3 |
1940
|
|
|
* |
1941
|
|
|
* @return \DOMElement |
1942
|
|
|
*/ |
1943
|
|
|
public function tagcomData($std) |
1944
|
|
|
{ |
1945
|
|
|
|
1946
|
|
|
$possible = [ |
1947
|
|
|
'tpPer', |
1948
|
|
|
'dProg' |
1949
|
|
|
]; |
1950
|
|
|
|
1951
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1952
|
|
|
|
1953
|
|
|
$identificador = '#72 <comData> - '; |
1954
|
|
|
$this->comData = $this->dom->createElement('comData'); |
1955
|
|
|
$this->dom->addChild( |
1956
|
|
|
$this->comData, |
1957
|
|
|
'tpPer', |
1958
|
|
|
$std->tpPer, |
1959
|
|
|
true, |
1960
|
|
|
$identificador . 'Tipo de data/período programado para entrega' |
1961
|
|
|
); |
1962
|
|
|
$this->dom->addChild( |
1963
|
|
|
$this->comData, |
1964
|
|
|
'dProg', |
1965
|
|
|
$std->dProg, |
1966
|
|
|
true, |
1967
|
|
|
$identificador . 'Data programada' |
1968
|
|
|
); |
1969
|
|
|
return $this->comData; |
1970
|
|
|
} |
1971
|
|
|
|
1972
|
|
|
/** |
1973
|
|
|
* Gera as tags para o elemento: "noPeriodo" (Entrega no período definido) |
1974
|
|
|
* #75 |
1975
|
|
|
* Nível: 3 |
1976
|
|
|
* |
1977
|
|
|
* @return \DOMElement |
1978
|
|
|
*/ |
1979
|
|
|
public function tagnoPeriodo($std) |
1980
|
|
|
{ |
1981
|
|
|
|
1982
|
|
|
$possible = [ |
1983
|
|
|
'tpPer', |
1984
|
|
|
'dIni', |
1985
|
|
|
'dFim' |
1986
|
|
|
]; |
1987
|
|
|
|
1988
|
|
|
$std = $this->equilizeParameters($std, $possible); |
1989
|
|
|
|
1990
|
|
|
$identificador = '#75 <noPeriodo> - '; |
1991
|
|
|
$this->noPeriodo = $this->dom->createElement('noPeriodo'); |
1992
|
|
|
$this->dom->addChild( |
1993
|
|
|
$this->noPeriodo, |
1994
|
|
|
'tpPer', |
1995
|
|
|
$std->tpPer, |
1996
|
|
|
true, |
1997
|
|
|
$identificador . 'Tipo de data/período programado para entrega' |
1998
|
|
|
); |
1999
|
|
|
$this->dom->addChild( |
2000
|
|
|
$this->noPeriodo, |
2001
|
|
|
'dIni', |
2002
|
|
|
$std->dIni, |
2003
|
|
|
true, |
2004
|
|
|
$identificador . 'Data inicial' |
2005
|
|
|
); |
2006
|
|
|
$this->dom->addChild( |
2007
|
|
|
$this->noPeriodo, |
2008
|
|
|
'dFim', |
2009
|
|
|
$std->dFim, |
2010
|
|
|
true, |
2011
|
|
|
$identificador . 'Data final' |
2012
|
|
|
); |
2013
|
|
|
return $this->noPeriodo; |
2014
|
|
|
} |
2015
|
|
|
|
2016
|
|
|
/** |
2017
|
|
|
* Gera as tags para o elemento: "semHora" (Entrega sem hora definida) |
2018
|
|
|
* #79 |
2019
|
|
|
* Nível: 3 |
2020
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "semHora" do |
2021
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 4 |
2022
|
|
|
* |
2023
|
|
|
* @return \DOMElement |
2024
|
|
|
*/ |
2025
|
|
|
public function tagsemHora($std) |
2026
|
|
|
{ |
2027
|
|
|
|
2028
|
|
|
$possible = [ |
2029
|
|
|
'tpHor' |
2030
|
|
|
]; |
2031
|
|
|
|
2032
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2033
|
|
|
|
2034
|
|
|
$identificador = '#79 <semHora> - '; |
2035
|
|
|
$this->semHora = $this->dom->createElement('semHora'); |
2036
|
|
|
$this->dom->addChild( |
2037
|
|
|
$this->semHora, |
2038
|
|
|
'tpHor', |
2039
|
|
|
$std->tpHor, |
2040
|
|
|
true, |
2041
|
|
|
$identificador . 'Tipo de hora' |
2042
|
|
|
); |
2043
|
|
|
return $this->semHora; |
2044
|
|
|
} |
2045
|
|
|
|
2046
|
|
|
/** |
2047
|
|
|
* Gera as tags para o elemento: "comHora" (Entrega sem hora definida) |
2048
|
|
|
* # = 81 |
2049
|
|
|
* Nível = 3 |
2050
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "comHora" do |
2051
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 4 |
2052
|
|
|
* |
2053
|
|
|
* @return \DOMElement |
2054
|
|
|
*/ |
2055
|
|
|
public function tagcomHora($std) |
2056
|
|
|
{ |
2057
|
|
|
|
2058
|
|
|
$possible = [ |
2059
|
|
|
'tpHor', |
2060
|
|
|
'hProg' |
2061
|
|
|
]; |
2062
|
|
|
|
2063
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2064
|
|
|
|
2065
|
|
|
$identificador = '#81 <comHora> - '; |
2066
|
|
|
$this->comHora = $this->dom->createElement('comHora'); |
2067
|
|
|
$this->dom->addChild( |
2068
|
|
|
$this->comHora, |
2069
|
|
|
'tpHor', |
2070
|
|
|
$std->tpHor, |
2071
|
|
|
true, |
2072
|
|
|
$identificador . 'Tipo de hora' |
2073
|
|
|
); |
2074
|
|
|
$this->dom->addChild( |
2075
|
|
|
$this->comHora, |
2076
|
|
|
'hProg', |
2077
|
|
|
$std->hProg, |
2078
|
|
|
true, |
2079
|
|
|
$identificador . 'Hora programada' |
2080
|
|
|
); |
2081
|
|
|
return $this->comHora; |
2082
|
|
|
} |
2083
|
|
|
|
2084
|
|
|
/** |
2085
|
|
|
* Gera as tags para o elemento: "noInter" (Entrega no intervalo de horário definido) |
2086
|
|
|
* #84 |
2087
|
|
|
* Nível: 3 |
2088
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "noInter" do |
2089
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 4 |
2090
|
|
|
* |
2091
|
|
|
* @return \DOMElement |
2092
|
|
|
*/ |
2093
|
|
|
public function tagnoInter($std) |
2094
|
|
|
{ |
2095
|
|
|
|
2096
|
|
|
$possible = [ |
2097
|
|
|
'tpHor', |
2098
|
|
|
'hIni', |
2099
|
|
|
'hFim' |
2100
|
|
|
]; |
2101
|
|
|
|
2102
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2103
|
|
|
|
2104
|
|
|
$identificador = '#84 <noInter> - '; |
2105
|
|
|
$this->noInter = $this->dom->createElement('noInter'); |
2106
|
|
|
$this->dom->addChild( |
2107
|
|
|
$this->noInter, |
2108
|
|
|
'tpHor', |
2109
|
|
|
$std->tpHor, |
2110
|
|
|
true, |
2111
|
|
|
$identificador . 'Tipo de hora' |
2112
|
|
|
); |
2113
|
|
|
$this->dom->addChild( |
2114
|
|
|
$this->noInter, |
2115
|
|
|
'hIni', |
2116
|
|
|
$std->hIni, |
2117
|
|
|
true, |
2118
|
|
|
$identificador . 'Hora inicial' |
2119
|
|
|
); |
2120
|
|
|
$this->dom->addChild( |
2121
|
|
|
$this->noInter, |
2122
|
|
|
'hFim', |
2123
|
|
|
$std->hFim, |
2124
|
|
|
true, |
2125
|
|
|
$identificador . 'Hora final' |
2126
|
|
|
); |
2127
|
|
|
return $this->noInter; |
2128
|
|
|
} |
2129
|
|
|
|
2130
|
|
|
/** |
2131
|
|
|
* Gera as tags para o elemento: "ObsCont" (Campo de uso livre do contribuinte) |
2132
|
|
|
* #91 |
2133
|
|
|
* Nível: 2 |
2134
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "ObsCont" do |
2135
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
2136
|
|
|
* |
2137
|
|
|
* @return boolean |
2138
|
|
|
*/ |
2139
|
|
|
public function tagobsCont($std) |
2140
|
|
|
{ |
2141
|
|
|
|
2142
|
|
|
$possible = [ |
2143
|
|
|
'xCampo', |
2144
|
|
|
'xTexto' |
2145
|
|
|
]; |
2146
|
|
|
|
2147
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2148
|
|
|
|
2149
|
|
|
$identificador = '#91 <ObsCont> - '; |
2150
|
|
|
if (count($this->obsCont) <= 10) { |
2151
|
|
|
$this->obsCont[] = $this->dom->createElement('ObsCont'); |
2152
|
|
|
$posicao = (int)count($this->obsCont) - 1; |
2153
|
|
|
$this->obsCont[$posicao]->setAttribute('xCampo', $std->xCampo); |
2154
|
|
|
$this->dom->addChild( |
2155
|
|
|
$this->obsCont[$posicao], |
2156
|
|
|
'xTexto', |
2157
|
|
|
$std->xTexto, |
2158
|
|
|
true, |
2159
|
|
|
$identificador . 'Conteúdo do campo' |
2160
|
|
|
); |
2161
|
|
|
return true; |
2162
|
|
|
} |
2163
|
|
|
$this->errors[] = array( |
2164
|
|
|
'tag' => (string)'<ObsCont>', |
2165
|
|
|
'desc' => (string)'Campo de uso livre do contribuinte', |
2166
|
|
|
'erro' => (string)'Tag deve aparecer de 0 a 10 vezes' |
2167
|
|
|
); |
2168
|
|
|
return false; |
2169
|
|
|
} |
2170
|
|
|
|
2171
|
|
|
/** |
2172
|
|
|
* Gera as tags para o elemento: "ObsFisco" (Campo de uso livre do contribuinte) |
2173
|
|
|
* #94 |
2174
|
|
|
* Nível: 2 |
2175
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "ObsFisco" do tipo |
2176
|
|
|
* elemento (Ele = E|CE|A) e nível 3 |
2177
|
|
|
* |
2178
|
|
|
* @return boolean |
2179
|
|
|
*/ |
2180
|
|
|
public function tagobsFisco($std) |
2181
|
|
|
{ |
2182
|
|
|
|
2183
|
|
|
$possible = [ |
2184
|
|
|
'xCampo', |
2185
|
|
|
'xTexto' |
2186
|
|
|
]; |
2187
|
|
|
|
2188
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2189
|
|
|
|
2190
|
|
|
$identificador = '#94 <ObsFisco> - '; |
2191
|
|
|
if (count($this->obsFisco) <= 10) { |
2192
|
|
|
$this->obsFisco[] = $this->dom->createElement('ObsFisco'); |
2193
|
|
|
$posicao = (int)count($this->obsFisco) - 1; |
2194
|
|
|
$this->obsFisco[$posicao]->setAttribute('xCampo', $std->xCampo); |
2195
|
|
|
$this->dom->addChild( |
2196
|
|
|
$this->obsFisco[$posicao], |
2197
|
|
|
'xTexto', |
2198
|
|
|
$std->xTexto, |
2199
|
|
|
true, |
2200
|
|
|
$identificador . 'Conteúdo do campo' |
2201
|
|
|
); |
2202
|
|
|
return true; |
2203
|
|
|
} |
2204
|
|
|
$this->errors[] = array( |
2205
|
|
|
'tag' => (string)'<ObsFisco>', |
2206
|
|
|
'desc' => (string)'Campo de uso livre do contribuinte', |
2207
|
|
|
'erro' => (string)'Tag deve aparecer de 0 a 10 vezes' |
2208
|
|
|
); |
2209
|
|
|
return false; |
2210
|
|
|
} |
2211
|
|
|
|
2212
|
|
|
/** |
2213
|
|
|
* Gera as tags para o elemento: "emit" (Identificação do Emitente do CT-e) |
2214
|
|
|
* #97 |
2215
|
|
|
* Nível: 1 |
2216
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "emit" do |
2217
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 2 |
2218
|
|
|
* |
2219
|
|
|
* @return \DOMElement |
2220
|
|
|
*/ |
2221
|
|
|
public function tagemit($std) |
2222
|
|
|
{ |
2223
|
|
|
|
2224
|
|
|
$possible = [ |
2225
|
|
|
'CNPJ', |
2226
|
|
|
'IE', |
2227
|
|
|
'IEST', |
2228
|
|
|
'xNome', |
2229
|
|
|
'xFant' |
2230
|
|
|
]; |
2231
|
|
|
|
2232
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2233
|
|
|
|
2234
|
|
|
$identificador = '#97 <emit> - '; |
2235
|
|
|
$this->emit = $this->dom->createElement('emit'); |
2236
|
|
|
$this->dom->addChild( |
2237
|
|
|
$this->emit, |
2238
|
|
|
'CNPJ', |
2239
|
|
|
$std->CNPJ, |
2240
|
|
|
true, |
2241
|
|
|
$identificador . 'CNPJ do emitente' |
2242
|
|
|
); |
2243
|
|
|
$this->dom->addChild( |
2244
|
|
|
$this->emit, |
2245
|
|
|
'IE', |
2246
|
|
|
Strings::onlyNumbers($std->IE), |
2247
|
|
|
false, |
2248
|
|
|
$identificador . 'Inscrição Estadual do Emitente' |
2249
|
|
|
); |
2250
|
|
|
$this->dom->addChild( |
2251
|
|
|
$this->emit, |
2252
|
|
|
'IEST', |
2253
|
|
|
Strings::onlyNumbers($std->IEST), |
2254
|
|
|
false, |
2255
|
|
|
$identificador . 'Inscrição Estadual do Substituto Tributário' |
2256
|
|
|
); |
2257
|
|
|
$this->dom->addChild( |
2258
|
|
|
$this->emit, |
2259
|
|
|
'xNome', |
2260
|
|
|
$std->xNome, |
2261
|
|
|
true, |
2262
|
|
|
$identificador . 'Razão social ou Nome do emitente' |
2263
|
|
|
); |
2264
|
|
|
$this->dom->addChild( |
2265
|
|
|
$this->emit, |
2266
|
|
|
'xFant', |
2267
|
|
|
$std->xFant, |
2268
|
|
|
false, |
2269
|
|
|
$identificador . 'Nome fantasia' |
2270
|
|
|
); |
2271
|
|
|
return $this->emit; |
2272
|
|
|
} |
2273
|
|
|
|
2274
|
|
|
/** |
2275
|
|
|
* Gera as tags para o elemento: "enderEmit" (Endereço do emitente) |
2276
|
|
|
* #102 |
2277
|
|
|
* Nível: 2 |
2278
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "enderEmit" do |
2279
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
2280
|
|
|
* |
2281
|
|
|
* @return \DOMElement |
2282
|
|
|
*/ |
2283
|
|
|
public function tagenderEmit($std) |
2284
|
|
|
{ |
2285
|
|
|
|
2286
|
|
|
$possible = [ |
2287
|
|
|
'xLgr', |
2288
|
|
|
'nro', |
2289
|
|
|
'xCpl', |
2290
|
|
|
'xBairro', |
2291
|
|
|
'cMun', |
2292
|
|
|
'xMun', |
2293
|
|
|
'CEP', |
2294
|
|
|
'UF', |
2295
|
|
|
'fone' |
2296
|
|
|
]; |
2297
|
|
|
|
2298
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2299
|
|
|
|
2300
|
|
|
$identificador = '#102 <enderEmit> - '; |
2301
|
|
|
$this->enderEmit = $this->dom->createElement('enderEmit'); |
2302
|
|
|
$this->dom->addChild( |
2303
|
|
|
$this->enderEmit, |
2304
|
|
|
'xLgr', |
2305
|
|
|
$std->xLgr, |
2306
|
|
|
true, |
2307
|
|
|
$identificador . 'Logradouro' |
2308
|
|
|
); |
2309
|
|
|
$this->dom->addChild( |
2310
|
|
|
$this->enderEmit, |
2311
|
|
|
'nro', |
2312
|
|
|
$std->nro, |
2313
|
|
|
true, |
2314
|
|
|
$identificador . 'Número' |
2315
|
|
|
); |
2316
|
|
|
$this->dom->addChild( |
2317
|
|
|
$this->enderEmit, |
2318
|
|
|
'xCpl', |
2319
|
|
|
$std->xCpl, |
2320
|
|
|
false, |
2321
|
|
|
$identificador . 'Complemento' |
2322
|
|
|
); |
2323
|
|
|
$this->dom->addChild( |
2324
|
|
|
$this->enderEmit, |
2325
|
|
|
'xBairro', |
2326
|
|
|
$std->xBairro, |
2327
|
|
|
true, |
2328
|
|
|
$identificador . 'Bairro' |
2329
|
|
|
); |
2330
|
|
|
$this->dom->addChild( |
2331
|
|
|
$this->enderEmit, |
2332
|
|
|
'cMun', |
2333
|
|
|
$std->cMun, |
2334
|
|
|
true, |
2335
|
|
|
$identificador . 'Código do município' |
2336
|
|
|
); |
2337
|
|
|
$this->dom->addChild( |
2338
|
|
|
$this->enderEmit, |
2339
|
|
|
'xMun', |
2340
|
|
|
$std->xMun, |
2341
|
|
|
true, |
2342
|
|
|
$identificador . 'Nome do município' |
2343
|
|
|
); |
2344
|
|
|
$this->dom->addChild( |
2345
|
|
|
$this->enderEmit, |
2346
|
|
|
'CEP', |
2347
|
|
|
$std->CEP, |
2348
|
|
|
false, |
2349
|
|
|
$identificador . 'CEP' |
2350
|
|
|
); |
2351
|
|
|
$this->dom->addChild( |
2352
|
|
|
$this->enderEmit, |
2353
|
|
|
'UF', |
2354
|
|
|
$std->UF, |
2355
|
|
|
true, |
2356
|
|
|
$identificador . 'Sigla da UF' |
2357
|
|
|
); |
2358
|
|
|
$this->dom->addChild( |
2359
|
|
|
$this->enderEmit, |
2360
|
|
|
'fone', |
2361
|
|
|
$std->fone, |
2362
|
|
|
false, |
2363
|
|
|
$identificador . 'Telefone' |
2364
|
|
|
); |
2365
|
|
|
return $this->enderEmit; |
2366
|
|
|
} |
2367
|
|
|
|
2368
|
|
|
/** |
2369
|
|
|
* Gera as tags para o elemento: "rem" (Informações do Remetente das mercadorias |
2370
|
|
|
* transportadas pelo CT-e) |
2371
|
|
|
* #112 |
2372
|
|
|
* Nível = 1 |
2373
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "rem" do |
2374
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 2 |
2375
|
|
|
* |
2376
|
|
|
* @return \DOMElement |
2377
|
|
|
*/ |
2378
|
|
|
public function tagrem($std) |
2379
|
|
|
{ |
2380
|
|
|
|
2381
|
|
|
$possible = [ |
2382
|
|
|
'CNPJ', |
2383
|
|
|
'CPF', |
2384
|
|
|
'IE', |
2385
|
|
|
'xNome', |
2386
|
|
|
'xFant', |
2387
|
|
|
'fone', |
2388
|
|
|
'email' |
2389
|
|
|
]; |
2390
|
|
|
|
2391
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2392
|
|
|
|
2393
|
|
|
$identificador = '#97 <rem> - '; |
2394
|
|
|
$this->rem = $this->dom->createElement('rem'); |
2395
|
|
|
if ($std->CNPJ != '') { |
2396
|
|
|
$this->dom->addChild( |
2397
|
|
|
$this->rem, |
2398
|
|
|
'CNPJ', |
2399
|
|
|
$std->CNPJ, |
2400
|
|
|
true, |
2401
|
|
|
$identificador . 'CNPJ do Remente' |
2402
|
|
|
); |
2403
|
|
|
} elseif ($std->CPF != '') { |
2404
|
|
|
$this->dom->addChild( |
2405
|
|
|
$this->rem, |
2406
|
|
|
'CPF', |
2407
|
|
|
$std->CPF, |
2408
|
|
|
true, |
2409
|
|
|
$identificador . 'CPF do Remente' |
2410
|
|
|
); |
2411
|
|
|
} else { |
2412
|
|
|
$this->dom->addChild( |
2413
|
|
|
$this->rem, |
2414
|
|
|
'CNPJ', |
2415
|
|
|
$std->CNPJ, |
2416
|
|
|
true, |
2417
|
|
|
$identificador . 'CNPJ do Remente' |
2418
|
|
|
); |
2419
|
|
|
$this->dom->addChild( |
2420
|
|
|
$this->rem, |
2421
|
|
|
'CPF', |
2422
|
|
|
$std->CPF, |
2423
|
|
|
true, |
2424
|
|
|
$identificador . 'CPF do remente' |
2425
|
|
|
); |
2426
|
|
|
} |
2427
|
|
|
$this->dom->addChild( |
2428
|
|
|
$this->rem, |
2429
|
|
|
'IE', |
2430
|
|
|
$std->IE, |
2431
|
|
|
false, |
2432
|
|
|
$identificador . 'Inscrição Estadual do remente' |
2433
|
|
|
); |
2434
|
|
|
$xNome = $std->xNome; |
2435
|
|
|
if ($this->tpAmb == '2') { |
2436
|
|
|
$xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
2437
|
|
|
} |
2438
|
|
|
$this->dom->addChild( |
2439
|
|
|
$this->rem, |
2440
|
|
|
'xNome', |
2441
|
|
|
Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
2442
|
|
|
true, |
2443
|
|
|
$identificador . 'Razão social ou Nome do remente' |
2444
|
|
|
); |
2445
|
|
|
$this->dom->addChild( |
2446
|
|
|
$this->rem, |
2447
|
|
|
'xFant', |
2448
|
|
|
$std->xFant, |
2449
|
|
|
false, |
2450
|
|
|
$identificador . 'Nome fantasia' |
2451
|
|
|
); |
2452
|
|
|
$this->dom->addChild( |
2453
|
|
|
$this->rem, |
2454
|
|
|
'fone', |
2455
|
|
|
$std->fone, |
2456
|
|
|
false, |
2457
|
|
|
$identificador . 'Telefone' |
2458
|
|
|
); |
2459
|
|
|
$this->dom->addChild( |
2460
|
|
|
$this->rem, |
2461
|
|
|
'email', |
2462
|
|
|
$std->email, |
2463
|
|
|
false, |
2464
|
|
|
$identificador . 'Endereço de email' |
2465
|
|
|
); |
2466
|
|
|
return $this->rem; |
2467
|
|
|
} |
2468
|
|
|
|
2469
|
|
|
/** |
2470
|
|
|
* Gera as tags para o elemento: "enderReme" (Dados do endereço) |
2471
|
|
|
* #120 |
2472
|
|
|
* Nível: 2 |
2473
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "enderReme" do |
2474
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
2475
|
|
|
* |
2476
|
|
|
* @return \DOMElement |
2477
|
|
|
*/ |
2478
|
|
|
public function tagenderReme($std) |
2479
|
|
|
{ |
2480
|
|
|
|
2481
|
|
|
$possible = [ |
2482
|
|
|
'xLgr', |
2483
|
|
|
'nro', |
2484
|
|
|
'xCpl', |
2485
|
|
|
'xBairro', |
2486
|
|
|
'cMun', |
2487
|
|
|
'xMun', |
2488
|
|
|
'CEP', |
2489
|
|
|
'UF', |
2490
|
|
|
'cPais', |
2491
|
|
|
'xPais' |
2492
|
|
|
]; |
2493
|
|
|
|
2494
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2495
|
|
|
|
2496
|
|
|
$identificador = '#119 <enderReme> - '; |
2497
|
|
|
$this->enderReme = $this->dom->createElement('enderReme'); |
2498
|
|
|
$this->dom->addChild( |
2499
|
|
|
$this->enderReme, |
2500
|
|
|
'xLgr', |
2501
|
|
|
$std->xLgr, |
2502
|
|
|
true, |
2503
|
|
|
$identificador . 'Logradouro' |
2504
|
|
|
); |
2505
|
|
|
$this->dom->addChild( |
2506
|
|
|
$this->enderReme, |
2507
|
|
|
'nro', |
2508
|
|
|
$std->nro, |
2509
|
|
|
true, |
2510
|
|
|
$identificador . 'Número' |
2511
|
|
|
); |
2512
|
|
|
$this->dom->addChild( |
2513
|
|
|
$this->enderReme, |
2514
|
|
|
'xCpl', |
2515
|
|
|
$std->xCpl, |
2516
|
|
|
false, |
2517
|
|
|
$identificador . 'Complemento' |
2518
|
|
|
); |
2519
|
|
|
$this->dom->addChild( |
2520
|
|
|
$this->enderReme, |
2521
|
|
|
'xBairro', |
2522
|
|
|
$std->xBairro, |
2523
|
|
|
true, |
2524
|
|
|
$identificador . 'Bairro' |
2525
|
|
|
); |
2526
|
|
|
$this->dom->addChild( |
2527
|
|
|
$this->enderReme, |
2528
|
|
|
'cMun', |
2529
|
|
|
$std->cMun, |
2530
|
|
|
true, |
2531
|
|
|
$identificador . 'Código do município (utilizar a tabela do IBGE)' |
2532
|
|
|
); |
2533
|
|
|
$this->dom->addChild( |
2534
|
|
|
$this->enderReme, |
2535
|
|
|
'xMun', |
2536
|
|
|
$std->xMun, |
2537
|
|
|
true, |
2538
|
|
|
$identificador . 'Nome do município' |
2539
|
|
|
); |
2540
|
|
|
$this->dom->addChild( |
2541
|
|
|
$this->enderReme, |
2542
|
|
|
'CEP', |
2543
|
|
|
$std->CEP, |
2544
|
|
|
false, |
2545
|
|
|
$identificador . 'CEP' |
2546
|
|
|
); |
2547
|
|
|
$this->dom->addChild( |
2548
|
|
|
$this->enderReme, |
2549
|
|
|
'UF', |
2550
|
|
|
$std->UF, |
2551
|
|
|
true, |
2552
|
|
|
$identificador . 'Sigla da UF' |
2553
|
|
|
); |
2554
|
|
|
$this->dom->addChild( |
2555
|
|
|
$this->enderReme, |
2556
|
|
|
'cPais', |
2557
|
|
|
$std->cPais, |
2558
|
|
|
false, |
2559
|
|
|
$identificador . 'Código do país' |
2560
|
|
|
); |
2561
|
|
|
$this->dom->addChild( |
2562
|
|
|
$this->enderReme, |
2563
|
|
|
'xPais', |
2564
|
|
|
$std->xPais, |
2565
|
|
|
false, |
2566
|
|
|
$identificador . 'Nome do país' |
2567
|
|
|
); |
2568
|
|
|
|
2569
|
|
|
$node = $this->rem->getElementsByTagName("email")->item(0); |
2570
|
|
|
$this->rem->insertBefore($this->enderReme, $node); |
2571
|
|
|
return $this->enderReme; |
2572
|
|
|
} |
2573
|
|
|
|
2574
|
|
|
/** |
2575
|
|
|
* Gera as tags para o elemento: "exped" (Informações do Expedidor da Carga) |
2576
|
|
|
* #132 |
2577
|
|
|
* Nível: 1 |
2578
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "exped" do |
2579
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 2 |
2580
|
|
|
* |
2581
|
|
|
* @return \DOMElement |
2582
|
|
|
*/ |
2583
|
|
|
public function tagexped($std) |
2584
|
|
|
{ |
2585
|
|
|
|
2586
|
|
|
$possible = [ |
2587
|
|
|
'CNPJ', |
2588
|
|
|
'CPF', |
2589
|
|
|
'IE', |
2590
|
|
|
'xNome', |
2591
|
|
|
'fone', |
2592
|
|
|
'email' |
2593
|
|
|
]; |
2594
|
|
|
|
2595
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2596
|
|
|
|
2597
|
|
|
$identificador = '#142 <exped> - '; |
2598
|
|
|
$this->exped = $this->dom->createElement('exped'); |
2599
|
|
|
if ($std->CNPJ != '') { |
2600
|
|
|
$this->dom->addChild( |
2601
|
|
|
$this->exped, |
2602
|
|
|
'CNPJ', |
2603
|
|
|
$std->CNPJ, |
2604
|
|
|
true, |
2605
|
|
|
$identificador . 'Número do CNPJ' |
2606
|
|
|
); |
2607
|
|
|
} elseif ($std->CPF != '') { |
2608
|
|
|
$this->dom->addChild( |
2609
|
|
|
$this->exped, |
2610
|
|
|
'CPF', |
2611
|
|
|
$std->CPF, |
2612
|
|
|
true, |
2613
|
|
|
$identificador . 'Número do CPF' |
2614
|
|
|
); |
2615
|
|
|
} else { |
2616
|
|
|
$this->dom->addChild( |
2617
|
|
|
$this->exped, |
2618
|
|
|
'CNPJ', |
2619
|
|
|
$std->CNPJ, |
2620
|
|
|
true, |
2621
|
|
|
$identificador . 'Número do CNPJ' |
2622
|
|
|
); |
2623
|
|
|
$this->dom->addChild( |
2624
|
|
|
$this->exped, |
2625
|
|
|
'CPF', |
2626
|
|
|
$std->CPF, |
2627
|
|
|
true, |
2628
|
|
|
$identificador . 'Número do CPF' |
2629
|
|
|
); |
2630
|
|
|
} |
2631
|
|
|
if (!empty($std->IE)) { |
2632
|
|
|
$this->dom->addChild( |
2633
|
|
|
$this->exped, |
2634
|
|
|
'IE', |
2635
|
|
|
$std->IE, |
2636
|
|
|
true, |
2637
|
|
|
$identificador . 'Inscrição Estadual' |
2638
|
|
|
); |
2639
|
|
|
} |
2640
|
|
|
$xNome = $std->xNome; |
2641
|
|
|
if ($this->tpAmb == '2') { |
2642
|
|
|
$xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
2643
|
|
|
} |
2644
|
|
|
$this->dom->addChild( |
2645
|
|
|
$this->exped, |
2646
|
|
|
'xNome', |
2647
|
|
|
Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
2648
|
|
|
true, |
2649
|
|
|
$identificador . 'Razão social ou Nome' |
2650
|
|
|
); |
2651
|
|
|
$this->dom->addChild( |
2652
|
|
|
$this->exped, |
2653
|
|
|
'fone', |
2654
|
|
|
$std->fone, |
2655
|
|
|
false, |
2656
|
|
|
$identificador . 'Telefone' |
2657
|
|
|
); |
2658
|
|
|
$this->dom->addChild( |
2659
|
|
|
$this->exped, |
2660
|
|
|
'email', |
2661
|
|
|
$std->email, |
2662
|
|
|
false, |
2663
|
|
|
$identificador . 'Endereço de email' |
2664
|
|
|
); |
2665
|
|
|
return $this->exped; |
2666
|
|
|
} |
2667
|
|
|
|
2668
|
|
|
/** |
2669
|
|
|
* Gera as tags para o elemento: "enderExped" (Dados do endereço) |
2670
|
|
|
* #138 |
2671
|
|
|
* Nível: 2 |
2672
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "enderExped" do |
2673
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
2674
|
|
|
* |
2675
|
|
|
* @return \DOMElement |
2676
|
|
|
*/ |
2677
|
|
|
public function tagenderExped($std) |
2678
|
|
|
{ |
2679
|
|
|
|
2680
|
|
|
$possible = [ |
2681
|
|
|
'xLgr', |
2682
|
|
|
'nro', |
2683
|
|
|
'xCpl', |
2684
|
|
|
'xBairro', |
2685
|
|
|
'cMun', |
2686
|
|
|
'xMun', |
2687
|
|
|
'CEP', |
2688
|
|
|
'UF', |
2689
|
|
|
'cPais', |
2690
|
|
|
'xPais' |
2691
|
|
|
]; |
2692
|
|
|
|
2693
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2694
|
|
|
|
2695
|
|
|
$identificador = '#148 <enderExped> - '; |
2696
|
|
|
$this->enderExped = $this->dom->createElement('enderExped'); |
2697
|
|
|
$this->dom->addChild( |
2698
|
|
|
$this->enderExped, |
2699
|
|
|
'xLgr', |
2700
|
|
|
$std->xLgr, |
2701
|
|
|
true, |
2702
|
|
|
$identificador . 'Logradouro' |
2703
|
|
|
); |
2704
|
|
|
$this->dom->addChild( |
2705
|
|
|
$this->enderExped, |
2706
|
|
|
'nro', |
2707
|
|
|
$std->nro, |
2708
|
|
|
true, |
2709
|
|
|
$identificador . 'Número' |
2710
|
|
|
); |
2711
|
|
|
$this->dom->addChild( |
2712
|
|
|
$this->enderExped, |
2713
|
|
|
'xCpl', |
2714
|
|
|
$std->xCpl, |
2715
|
|
|
false, |
2716
|
|
|
$identificador . 'Complemento' |
2717
|
|
|
); |
2718
|
|
|
$this->dom->addChild( |
2719
|
|
|
$this->enderExped, |
2720
|
|
|
'xBairro', |
2721
|
|
|
$std->xBairro, |
2722
|
|
|
true, |
2723
|
|
|
$identificador . 'Bairro' |
2724
|
|
|
); |
2725
|
|
|
$this->dom->addChild( |
2726
|
|
|
$this->enderExped, |
2727
|
|
|
'cMun', |
2728
|
|
|
$std->cMun, |
2729
|
|
|
true, |
2730
|
|
|
$identificador . 'Código do município (utilizar a tabela do IBGE)' |
2731
|
|
|
); |
2732
|
|
|
$this->dom->addChild( |
2733
|
|
|
$this->enderExped, |
2734
|
|
|
'xMun', |
2735
|
|
|
$std->xMun, |
2736
|
|
|
true, |
2737
|
|
|
$identificador . 'Nome do município' |
2738
|
|
|
); |
2739
|
|
|
$this->dom->addChild( |
2740
|
|
|
$this->enderExped, |
2741
|
|
|
'CEP', |
2742
|
|
|
$std->CEP, |
2743
|
|
|
false, |
2744
|
|
|
$identificador . 'CEP' |
2745
|
|
|
); |
2746
|
|
|
$this->dom->addChild( |
2747
|
|
|
$this->enderExped, |
2748
|
|
|
'UF', |
2749
|
|
|
$std->UF, |
2750
|
|
|
true, |
2751
|
|
|
$identificador . 'Sigla da UF' |
2752
|
|
|
); |
2753
|
|
|
$this->dom->addChild( |
2754
|
|
|
$this->enderExped, |
2755
|
|
|
'cPais', |
2756
|
|
|
$std->cPais, |
2757
|
|
|
false, |
2758
|
|
|
$identificador . 'Código do país' |
2759
|
|
|
); |
2760
|
|
|
$this->dom->addChild( |
2761
|
|
|
$this->enderExped, |
2762
|
|
|
'xPais', |
2763
|
|
|
$std->xPais, |
2764
|
|
|
false, |
2765
|
|
|
$identificador . 'Nome do país' |
2766
|
|
|
); |
2767
|
|
|
$node = $this->exped->getElementsByTagName("email")->item(0); |
2768
|
|
|
$this->exped->insertBefore($this->enderExped, $node); |
2769
|
|
|
return $this->enderExped; |
2770
|
|
|
} |
2771
|
|
|
|
2772
|
|
|
/** |
2773
|
|
|
* Gera as tags para o elemento: "receb" (Informações do Recebedor da Carga) |
2774
|
|
|
* #150 |
2775
|
|
|
* Nível: 1 |
2776
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "receb" do |
2777
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 2 |
2778
|
|
|
* |
2779
|
|
|
* @return \DOMElement |
2780
|
|
|
*/ |
2781
|
|
|
public function tagreceb($std) |
2782
|
|
|
{ |
2783
|
|
|
|
2784
|
|
|
$possible = [ |
2785
|
|
|
'CNPJ', |
2786
|
|
|
'CPF', |
2787
|
|
|
'IE', |
2788
|
|
|
'xNome', |
2789
|
|
|
'fone', |
2790
|
|
|
'email' |
2791
|
|
|
]; |
2792
|
|
|
|
2793
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2794
|
|
|
|
2795
|
|
|
$identificador = '#160 <receb> - '; |
2796
|
|
|
$this->receb = $this->dom->createElement('receb'); |
2797
|
|
|
if ($std->CNPJ != '') { |
2798
|
|
|
$this->dom->addChild( |
2799
|
|
|
$this->receb, |
2800
|
|
|
'CNPJ', |
2801
|
|
|
$std->CNPJ, |
2802
|
|
|
true, |
2803
|
|
|
$identificador . 'Número do CNPJ' |
2804
|
|
|
); |
2805
|
|
|
} elseif ($std->CPF != '') { |
2806
|
|
|
$this->dom->addChild( |
2807
|
|
|
$this->receb, |
2808
|
|
|
'CPF', |
2809
|
|
|
$std->CPF, |
2810
|
|
|
true, |
2811
|
|
|
$identificador . 'Número do CPF' |
2812
|
|
|
); |
2813
|
|
|
} else { |
2814
|
|
|
$this->dom->addChild( |
2815
|
|
|
$this->receb, |
2816
|
|
|
'CNPJ', |
2817
|
|
|
$std->CNPJ, |
2818
|
|
|
true, |
2819
|
|
|
$identificador . 'Número do CNPJ' |
2820
|
|
|
); |
2821
|
|
|
$this->dom->addChild( |
2822
|
|
|
$this->receb, |
2823
|
|
|
'CPF', |
2824
|
|
|
$std->CPF, |
2825
|
|
|
true, |
2826
|
|
|
$identificador . 'Número do CPF' |
2827
|
|
|
); |
2828
|
|
|
} |
2829
|
|
|
if (!empty($std->IE)) { |
2830
|
|
|
$this->dom->addChild( |
2831
|
|
|
$this->receb, |
2832
|
|
|
'IE', |
2833
|
|
|
$std->IE, |
2834
|
|
|
true, |
2835
|
|
|
$identificador . 'Inscrição Estadual' |
2836
|
|
|
); |
2837
|
|
|
} |
2838
|
|
|
$xNome = $std->xNome; |
2839
|
|
|
if ($this->tpAmb == '2') { |
2840
|
|
|
$xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
2841
|
|
|
} |
2842
|
|
|
$this->dom->addChild( |
2843
|
|
|
$this->receb, |
2844
|
|
|
'xNome', |
2845
|
|
|
Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
2846
|
|
|
true, |
2847
|
|
|
$identificador . 'Razão social ou Nome' |
2848
|
|
|
); |
2849
|
|
|
$this->dom->addChild( |
2850
|
|
|
$this->receb, |
2851
|
|
|
'fone', |
2852
|
|
|
$std->fone, |
2853
|
|
|
false, |
2854
|
|
|
$identificador . 'Telefone' |
2855
|
|
|
); |
2856
|
|
|
$this->dom->addChild( |
2857
|
|
|
$this->receb, |
2858
|
|
|
'email', |
2859
|
|
|
$std->email, |
2860
|
|
|
false, |
2861
|
|
|
$identificador . 'Endereço de email' |
2862
|
|
|
); |
2863
|
|
|
return $this->receb; |
2864
|
|
|
} |
2865
|
|
|
|
2866
|
|
|
/** |
2867
|
|
|
* Gera as tags para o elemento: "enderReceb" (Informações do Recebedor da Carga) |
2868
|
|
|
* #156 |
2869
|
|
|
* Nível: 2 |
2870
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "enderReceb" do |
2871
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
2872
|
|
|
* |
2873
|
|
|
* @return \DOMElement |
2874
|
|
|
*/ |
2875
|
|
|
public function tagenderReceb($std) |
2876
|
|
|
{ |
2877
|
|
|
|
2878
|
|
|
$possible = [ |
2879
|
|
|
'xLgr', |
2880
|
|
|
'nro', |
2881
|
|
|
'xCpl', |
2882
|
|
|
'xBairro', |
2883
|
|
|
'cMun', |
2884
|
|
|
'xMun', |
2885
|
|
|
'CEP', |
2886
|
|
|
'UF', |
2887
|
|
|
'cPais', |
2888
|
|
|
'xPais' |
2889
|
|
|
]; |
2890
|
|
|
|
2891
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2892
|
|
|
|
2893
|
|
|
$identificador = '#160 <enderReceb> - '; |
2894
|
|
|
$this->enderReceb = $this->dom->createElement('enderReceb'); |
2895
|
|
|
$this->dom->addChild( |
2896
|
|
|
$this->enderReceb, |
2897
|
|
|
'xLgr', |
2898
|
|
|
$std->xLgr, |
2899
|
|
|
true, |
2900
|
|
|
$identificador . 'Logradouro' |
2901
|
|
|
); |
2902
|
|
|
$this->dom->addChild( |
2903
|
|
|
$this->enderReceb, |
2904
|
|
|
'nro', |
2905
|
|
|
$std->nro, |
2906
|
|
|
true, |
2907
|
|
|
$identificador . 'Número' |
2908
|
|
|
); |
2909
|
|
|
$this->dom->addChild( |
2910
|
|
|
$this->enderReceb, |
2911
|
|
|
'xCpl', |
2912
|
|
|
$std->xCpl, |
2913
|
|
|
false, |
2914
|
|
|
$identificador . 'Complemento' |
2915
|
|
|
); |
2916
|
|
|
$this->dom->addChild( |
2917
|
|
|
$this->enderReceb, |
2918
|
|
|
'xBairro', |
2919
|
|
|
$std->xBairro, |
2920
|
|
|
true, |
2921
|
|
|
$identificador . 'Bairro' |
2922
|
|
|
); |
2923
|
|
|
$this->dom->addChild( |
2924
|
|
|
$this->enderReceb, |
2925
|
|
|
'cMun', |
2926
|
|
|
$std->cMun, |
2927
|
|
|
true, |
2928
|
|
|
$identificador . 'Código do município (utilizar a tabela do IBGE)' |
2929
|
|
|
); |
2930
|
|
|
$this->dom->addChild( |
2931
|
|
|
$this->enderReceb, |
2932
|
|
|
'xMun', |
2933
|
|
|
$std->xMun, |
2934
|
|
|
true, |
2935
|
|
|
$identificador . 'Nome do município' |
2936
|
|
|
); |
2937
|
|
|
$this->dom->addChild( |
2938
|
|
|
$this->enderReceb, |
2939
|
|
|
'CEP', |
2940
|
|
|
$std->CEP, |
2941
|
|
|
false, |
2942
|
|
|
$identificador . 'CEP' |
2943
|
|
|
); |
2944
|
|
|
$this->dom->addChild( |
2945
|
|
|
$this->enderReceb, |
2946
|
|
|
'UF', |
2947
|
|
|
$std->UF, |
2948
|
|
|
true, |
2949
|
|
|
$identificador . 'Sigla da UF' |
2950
|
|
|
); |
2951
|
|
|
$this->dom->addChild( |
2952
|
|
|
$this->enderReceb, |
2953
|
|
|
'cPais', |
2954
|
|
|
$std->cPais, |
2955
|
|
|
false, |
2956
|
|
|
$identificador . 'Código do país' |
2957
|
|
|
); |
2958
|
|
|
$this->dom->addChild( |
2959
|
|
|
$this->enderReceb, |
2960
|
|
|
'xPais', |
2961
|
|
|
$std->xPais, |
2962
|
|
|
false, |
2963
|
|
|
$identificador . 'Nome do país' |
2964
|
|
|
); |
2965
|
|
|
$node = $this->receb->getElementsByTagName("email")->item(0); |
2966
|
|
|
$this->receb->insertBefore($this->enderReceb, $node); |
2967
|
|
|
return $this->enderReceb; |
2968
|
|
|
} |
2969
|
|
|
|
2970
|
|
|
/** |
2971
|
|
|
* Gera as tags para o elemento: "dest" (Informações do Destinatário do CT-e) |
2972
|
|
|
* #168 |
2973
|
|
|
* Nível: 1 |
2974
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "dest" do |
2975
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 2 |
2976
|
|
|
* |
2977
|
|
|
* @return \DOMElement |
2978
|
|
|
*/ |
2979
|
|
|
public function tagdest($std) |
2980
|
|
|
{ |
2981
|
|
|
|
2982
|
|
|
$possible = [ |
2983
|
|
|
'CNPJ', |
2984
|
|
|
'CPF', |
2985
|
|
|
'IE', |
2986
|
|
|
'xNome', |
2987
|
|
|
'fone', |
2988
|
|
|
'ISUF', |
2989
|
|
|
'email' |
2990
|
|
|
]; |
2991
|
|
|
|
2992
|
|
|
$std = $this->equilizeParameters($std, $possible); |
2993
|
|
|
|
2994
|
|
|
$identificador = '#178 <dest> - '; |
2995
|
|
|
$this->dest = $this->dom->createElement('dest'); |
2996
|
|
|
if ($std->CNPJ != '') { |
2997
|
|
|
$this->dom->addChild( |
2998
|
|
|
$this->dest, |
2999
|
|
|
'CNPJ', |
3000
|
|
|
$std->CNPJ, |
3001
|
|
|
true, |
3002
|
|
|
$identificador . 'Número do CNPJ' |
3003
|
|
|
); |
3004
|
|
|
} elseif ($std->CPF != '') { |
3005
|
|
|
$this->dom->addChild( |
3006
|
|
|
$this->dest, |
3007
|
|
|
'CPF', |
3008
|
|
|
$std->CPF, |
3009
|
|
|
true, |
3010
|
|
|
$identificador . 'Número do CPF' |
3011
|
|
|
); |
3012
|
|
|
} else { |
3013
|
|
|
$this->dom->addChild( |
3014
|
|
|
$this->dest, |
3015
|
|
|
'CNPJ', |
3016
|
|
|
$std->CNPJ, |
3017
|
|
|
true, |
3018
|
|
|
$identificador . 'Número do CNPJ' |
3019
|
|
|
); |
3020
|
|
|
$this->dom->addChild( |
3021
|
|
|
$this->dest, |
3022
|
|
|
'CPF', |
3023
|
|
|
$std->CPF, |
3024
|
|
|
true, |
3025
|
|
|
$identificador . 'Número do CPF' |
3026
|
|
|
); |
3027
|
|
|
} |
3028
|
|
|
if (!empty($std->IE)) { |
3029
|
|
|
$this->dom->addChild( |
3030
|
|
|
$this->dest, |
3031
|
|
|
'IE', |
3032
|
|
|
$std->IE, |
3033
|
|
|
true, |
3034
|
|
|
$identificador . 'Inscrição Estadual' |
3035
|
|
|
); |
3036
|
|
|
} |
3037
|
|
|
$xNome = $std->xNome; |
3038
|
|
|
if ($this->tpAmb == '2') { |
3039
|
|
|
$xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
3040
|
|
|
} |
3041
|
|
|
$this->dom->addChild( |
3042
|
|
|
$this->dest, |
3043
|
|
|
'xNome', |
3044
|
|
|
Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
3045
|
|
|
true, |
3046
|
|
|
$identificador . 'Razão social ou Nome' |
3047
|
|
|
); |
3048
|
|
|
$this->dom->addChild( |
3049
|
|
|
$this->dest, |
3050
|
|
|
'fone', |
3051
|
|
|
$std->fone, |
3052
|
|
|
false, |
3053
|
|
|
$identificador . 'Telefone' |
3054
|
|
|
); |
3055
|
|
|
$this->dom->addChild( |
3056
|
|
|
$this->dest, |
3057
|
|
|
'ISUF', |
3058
|
|
|
$std->ISUF, |
3059
|
|
|
false, |
3060
|
|
|
$identificador . 'Inscrição na SUFRAMA' |
3061
|
|
|
); |
3062
|
|
|
$this->dom->addChild( |
3063
|
|
|
$this->dest, |
3064
|
|
|
'email', |
3065
|
|
|
$std->email, |
3066
|
|
|
false, |
3067
|
|
|
$identificador . 'Endereço de email' |
3068
|
|
|
); |
3069
|
|
|
return $this->dest; |
3070
|
|
|
} |
3071
|
|
|
|
3072
|
|
|
/** |
3073
|
|
|
* Gera as tags para o elemento: "enderDest" (Informações do Recebedor da Carga) |
3074
|
|
|
* # = 175 |
3075
|
|
|
* Nível = 2 |
3076
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "enderDest" do |
3077
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
3078
|
|
|
* |
3079
|
|
|
* @return \DOMElement |
3080
|
|
|
*/ |
3081
|
|
|
public function tagenderDest($std) |
3082
|
|
|
{ |
3083
|
|
|
|
3084
|
|
|
$possible = [ |
3085
|
|
|
'xLgr', |
3086
|
|
|
'nro', |
3087
|
|
|
'xCpl', |
3088
|
|
|
'xBairro', |
3089
|
|
|
'cMun', |
3090
|
|
|
'xMun', |
3091
|
|
|
'CEP', |
3092
|
|
|
'UF', |
3093
|
|
|
'cPais', |
3094
|
|
|
'xPais' |
3095
|
|
|
]; |
3096
|
|
|
|
3097
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3098
|
|
|
|
3099
|
|
|
$identificador = '#185 <enderDest> - '; |
3100
|
|
|
$this->enderDest = $this->dom->createElement('enderDest'); |
3101
|
|
|
$this->dom->addChild( |
3102
|
|
|
$this->enderDest, |
3103
|
|
|
'xLgr', |
3104
|
|
|
$std->xLgr, |
3105
|
|
|
true, |
3106
|
|
|
$identificador . 'Logradouro' |
3107
|
|
|
); |
3108
|
|
|
$this->dom->addChild( |
3109
|
|
|
$this->enderDest, |
3110
|
|
|
'nro', |
3111
|
|
|
$std->nro, |
3112
|
|
|
true, |
3113
|
|
|
$identificador . 'Número' |
3114
|
|
|
); |
3115
|
|
|
$this->dom->addChild( |
3116
|
|
|
$this->enderDest, |
3117
|
|
|
'xCpl', |
3118
|
|
|
$std->xCpl, |
3119
|
|
|
false, |
3120
|
|
|
$identificador . 'Complemento' |
3121
|
|
|
); |
3122
|
|
|
$this->dom->addChild( |
3123
|
|
|
$this->enderDest, |
3124
|
|
|
'xBairro', |
3125
|
|
|
$std->xBairro, |
3126
|
|
|
true, |
3127
|
|
|
$identificador . 'Bairro' |
3128
|
|
|
); |
3129
|
|
|
$this->dom->addChild( |
3130
|
|
|
$this->enderDest, |
3131
|
|
|
'cMun', |
3132
|
|
|
$std->cMun, |
3133
|
|
|
true, |
3134
|
|
|
$identificador . 'Código do município (utilizar a tabela do IBGE)' |
3135
|
|
|
); |
3136
|
|
|
$this->dom->addChild( |
3137
|
|
|
$this->enderDest, |
3138
|
|
|
'xMun', |
3139
|
|
|
$std->xMun, |
3140
|
|
|
true, |
3141
|
|
|
$identificador . 'Nome do município' |
3142
|
|
|
); |
3143
|
|
|
$this->dom->addChild( |
3144
|
|
|
$this->enderDest, |
3145
|
|
|
'CEP', |
3146
|
|
|
$std->CEP, |
3147
|
|
|
false, |
3148
|
|
|
$identificador . 'CEP' |
3149
|
|
|
); |
3150
|
|
|
$this->dom->addChild( |
3151
|
|
|
$this->enderDest, |
3152
|
|
|
'UF', |
3153
|
|
|
$std->UF, |
3154
|
|
|
true, |
3155
|
|
|
$identificador . 'Sigla da UF' |
3156
|
|
|
); |
3157
|
|
|
$this->dom->addChild( |
3158
|
|
|
$this->enderDest, |
3159
|
|
|
'cPais', |
3160
|
|
|
$std->cPais, |
3161
|
|
|
false, |
3162
|
|
|
$identificador . 'Código do país' |
3163
|
|
|
); |
3164
|
|
|
$this->dom->addChild( |
3165
|
|
|
$this->enderDest, |
3166
|
|
|
'xPais', |
3167
|
|
|
$std->xPais, |
3168
|
|
|
false, |
3169
|
|
|
$identificador . 'Nome do país' |
3170
|
|
|
); |
3171
|
|
|
$node = $this->dest->getElementsByTagName("email")->item(0); |
3172
|
|
|
$this->dest->insertBefore($this->enderDest, $node); |
3173
|
|
|
return $this->enderDest; |
3174
|
|
|
} |
3175
|
|
|
|
3176
|
|
|
/** |
3177
|
|
|
* Gera as tags para o elemento: "vPrest" (Valores da Prestação de Serviço) |
3178
|
|
|
* #187 |
3179
|
|
|
* Nível: 1 |
3180
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "vPrest" do |
3181
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 2 |
3182
|
|
|
* |
3183
|
|
|
* @return \DOMElement |
3184
|
|
|
*/ |
3185
|
|
|
public function tagvPrest($std) |
3186
|
|
|
{ |
3187
|
|
|
|
3188
|
|
|
$possible = [ |
3189
|
|
|
'vTPrest', |
3190
|
|
|
'vRec' |
3191
|
|
|
]; |
3192
|
|
|
|
3193
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3194
|
|
|
|
3195
|
|
|
$identificador = '#208 <vPrest> - '; |
3196
|
|
|
$this->vPrest = $this->dom->createElement('vPrest'); |
3197
|
|
|
$this->dom->addChild( |
3198
|
|
|
$this->vPrest, |
3199
|
|
|
'vTPrest', |
3200
|
|
|
$std->vTPrest, |
3201
|
|
|
true, |
3202
|
|
|
$identificador . 'Valor Total da Prestação do Serviço' |
3203
|
|
|
); |
3204
|
|
|
$this->dom->addChild( |
3205
|
|
|
$this->vPrest, |
3206
|
|
|
'vRec', |
3207
|
|
|
$std->vRec, |
3208
|
|
|
true, |
3209
|
|
|
$identificador . 'Valor a Receber' |
3210
|
|
|
); |
3211
|
|
|
return $this->vPrest; |
3212
|
|
|
} |
3213
|
|
|
|
3214
|
|
|
/** |
3215
|
|
|
* Gera as tags para o elemento: "Comp" (Componentes do Valor da Prestação) |
3216
|
|
|
* #211 |
3217
|
|
|
* Nível: 2 |
3218
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "Comp" do |
3219
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
3220
|
|
|
* |
3221
|
|
|
* @return \DOMElement |
3222
|
|
|
*/ |
3223
|
|
|
public function tagComp($std) |
3224
|
|
|
{ |
3225
|
|
|
|
3226
|
|
|
$possible = [ |
3227
|
|
|
'xNome', |
3228
|
|
|
'vComp' |
3229
|
|
|
]; |
3230
|
|
|
|
3231
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3232
|
|
|
|
3233
|
|
|
$identificador = '#65 <pass> - '; |
3234
|
|
|
$this->comp[] = $this->dom->createElement('Comp'); |
3235
|
|
|
$posicao = (int)count($this->comp) - 1; |
3236
|
|
|
$this->dom->addChild( |
3237
|
|
|
$this->comp[$posicao], |
3238
|
|
|
'xNome', |
3239
|
|
|
$std->xNome, |
3240
|
|
|
false, |
3241
|
|
|
$identificador . 'Nome do componente' |
3242
|
|
|
); |
3243
|
|
|
$this->dom->addChild( |
3244
|
|
|
$this->comp[$posicao], |
3245
|
|
|
'vComp', |
3246
|
|
|
$std->vComp, |
3247
|
|
|
false, |
3248
|
|
|
$identificador . 'Valor do componente' |
3249
|
|
|
); |
3250
|
|
|
return $this->comp[$posicao]; |
3251
|
|
|
} |
3252
|
|
|
|
3253
|
|
|
/** |
3254
|
|
|
* tagICMS |
3255
|
|
|
* Informações relativas ao ICMS |
3256
|
|
|
* #194 |
3257
|
|
|
* |
3258
|
|
|
* @return DOMElement |
3259
|
|
|
*/ |
3260
|
|
|
public function tagicms($std) |
3261
|
|
|
{ |
3262
|
|
|
|
3263
|
|
|
$possible = [ |
3264
|
|
|
'cst', |
3265
|
|
|
'vBC', |
3266
|
|
|
'pICMS', |
3267
|
|
|
'vICMS', |
3268
|
|
|
'pRedBC', |
3269
|
|
|
'vBCSTRet', |
3270
|
|
|
'vICMSSTRet', |
3271
|
|
|
'pICMSSTRet', |
3272
|
|
|
'vCred', |
3273
|
|
|
'pRedBCOutraUF', |
3274
|
|
|
'vBCOutraUF', |
3275
|
|
|
'pICMSOutraUF', |
3276
|
|
|
'vICMSOutraUF', |
3277
|
|
|
'pRedBC', |
3278
|
|
|
'vTotTrib', |
3279
|
|
|
'infAdFisco', |
3280
|
|
|
'vBCUFFim', |
3281
|
|
|
'pFCPUFFim', |
3282
|
|
|
'pICMSUFFim', |
3283
|
|
|
'pICMSInter', |
3284
|
|
|
'vFCPUFFim', |
3285
|
|
|
'vICMSUFFim', |
3286
|
|
|
'vICMSUFIni' |
3287
|
|
|
]; |
3288
|
|
|
|
3289
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3290
|
|
|
|
3291
|
|
|
$identificador = 'N01 <ICMSxx> - '; |
3292
|
|
|
switch ($std->cst) { |
3293
|
|
|
case '00': |
3294
|
|
|
$icms = $this->dom->createElement("ICMS00"); |
3295
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 00"); |
3296
|
|
|
$this->dom->addChild($icms, 'vBC', $std->vBC, true, "$identificador Valor da BC do ICMS"); |
3297
|
|
|
$this->dom->addChild($icms, 'pICMS', $std->pICMS, true, "$identificador Alíquota do imposto"); |
3298
|
|
|
$this->dom->addChild($icms, 'vICMS', $std->vICMS, true, "$identificador Valor do ICMS"); |
3299
|
|
|
break; |
3300
|
|
|
case '20': |
3301
|
|
|
$icms = $this->dom->createElement("ICMS20"); |
3302
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 20"); |
3303
|
|
|
$this->dom->addChild( |
3304
|
|
|
$icms, |
3305
|
|
|
'pRedBC', |
3306
|
|
|
$std->pRedBC, |
3307
|
|
|
true, |
3308
|
|
|
"$identificador Percentual da Redução de BC" |
3309
|
|
|
); |
3310
|
|
|
$this->dom->addChild($icms, 'vBC', $std->vBC, true, "$identificador Valor da BC do ICMS"); |
3311
|
|
|
$this->dom->addChild($icms, 'pICMS', $std->pICMS, true, "$identificador Alíquota do imposto"); |
3312
|
|
|
$this->dom->addChild($icms, 'vICMS', $std->vICMS, true, "$identificador Valor do ICMS"); |
3313
|
|
|
break; |
3314
|
|
|
case '40': |
3315
|
|
|
$icms = $this->dom->createElement("ICMS45"); |
3316
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 40"); |
3317
|
|
|
break; |
3318
|
|
|
case '41': |
3319
|
|
|
$icms = $this->dom->createElement("ICMS45"); |
3320
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 41"); |
3321
|
|
|
break; |
3322
|
|
|
case '51': |
3323
|
|
|
$icms = $this->dom->createElement("ICMS45"); |
3324
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 51"); |
3325
|
|
|
break; |
3326
|
|
|
case '60': |
3327
|
|
|
$icms = $this->dom->createElement("ICMS60"); |
3328
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 60"); |
3329
|
|
|
$this->dom->addChild( |
3330
|
|
|
$icms, |
3331
|
|
|
'vBCSTRet', |
3332
|
|
|
$std->vBCSTRet, |
3333
|
|
|
true, |
3334
|
|
|
"$identificador Valor BC do ICMS ST retido" |
3335
|
|
|
); |
3336
|
|
|
$this->dom->addChild( |
3337
|
|
|
$icms, |
3338
|
|
|
'vICMSSTRet', |
3339
|
|
|
$std->vICMSSTRet, |
3340
|
|
|
true, |
3341
|
|
|
"$identificador Valor do ICMS ST retido" |
3342
|
|
|
); |
3343
|
|
|
$this->dom->addChild( |
3344
|
|
|
$icms, |
3345
|
|
|
'pICMSSTRet', |
3346
|
|
|
$std->pICMSSTRet, |
3347
|
|
|
true, |
3348
|
|
|
"$identificador Valor do ICMS ST retido" |
3349
|
|
|
); |
3350
|
|
|
if ($std->vCred > 0) { |
3351
|
|
|
$this->dom->addChild($icms, 'vCred', $std->vCred, false, "$identificador Valor do Crédito"); |
3352
|
|
|
} |
3353
|
|
|
break; |
3354
|
|
|
case '90': |
3355
|
|
|
if ($std->outraUF == true) { |
3356
|
|
|
$icms = $this->dom->createElement("ICMSOutraUF"); |
3357
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 90"); |
3358
|
|
|
if ($std->vICMSOutraUF > 0) { |
3359
|
|
|
$this->dom->addChild( |
3360
|
|
|
$icms, |
3361
|
|
|
'pRedBCOutraUF', |
3362
|
|
|
$std->pRedBCOutraUF, |
3363
|
|
|
false, |
3364
|
|
|
"$identificador Percentual Red " |
3365
|
|
|
. "BC Outra UF" |
3366
|
|
|
); |
3367
|
|
|
} |
3368
|
|
|
$this->dom->addChild( |
3369
|
|
|
$icms, |
3370
|
|
|
'vBCOutraUF', |
3371
|
|
|
$std->vBCOutraUF, |
3372
|
|
|
true, |
3373
|
|
|
"$identificador Valor BC ICMS Outra UF" |
3374
|
|
|
); |
3375
|
|
|
$this->dom->addChild( |
3376
|
|
|
$icms, |
3377
|
|
|
'pICMSOutraUF', |
3378
|
|
|
$std->pICMSOutraUF, |
3379
|
|
|
true, |
3380
|
|
|
"$identificador Alíquota do imposto Outra UF" |
3381
|
|
|
); |
3382
|
|
|
$this->dom->addChild( |
3383
|
|
|
$icms, |
3384
|
|
|
'vICMSOutraUF', |
3385
|
|
|
$std->vICMSOutraUF, |
3386
|
|
|
true, |
3387
|
|
|
"$identificador Valor ICMS Outra UF" |
3388
|
|
|
); |
3389
|
|
|
} else { |
3390
|
|
|
$icms = $this->dom->createElement("ICMS90"); |
3391
|
|
|
$this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 90"); |
3392
|
|
|
if ($std->pRedBC > 0) { |
3393
|
|
|
$this->dom->addChild( |
3394
|
|
|
$icms, |
3395
|
|
|
'pRedBC', |
3396
|
|
|
$std->pRedBC, |
3397
|
|
|
false, |
3398
|
|
|
"$identificador Percentual Redução BC" |
3399
|
|
|
); |
3400
|
|
|
} |
3401
|
|
|
$this->dom->addChild($icms, 'vBC', $std->vBC, true, "$identificador Valor da BC do ICMS"); |
3402
|
|
|
$this->dom->addChild($icms, 'pICMS', $std->pICMS, true, "$identificador Alíquota do imposto"); |
3403
|
|
|
$this->dom->addChild($icms, 'vICMS', $std->vICMS, true, "$identificador Valor do ICMS"); |
3404
|
|
|
if ($std->vCred > 0) { |
3405
|
|
|
$this->dom->addChild($icms, 'vCred', $std->vCred, false, "$identificador Valor do Crédido"); |
3406
|
|
|
} |
3407
|
|
|
} |
3408
|
|
|
break; |
3409
|
|
|
case 'SN': |
3410
|
|
|
$icms = $this->dom->createElement("ICMSSN"); |
3411
|
|
|
$this->dom->addChild($icms, 'CST', 90, true, "$identificador Tributação do ICMS = 90"); |
3412
|
|
|
$this->dom->addChild($icms, 'indSN', '1', true, "$identificador Indica se contribuinte é SN"); |
3413
|
|
|
break; |
3414
|
|
|
} |
3415
|
|
|
$this->imp = $this->dom->createElement('imp'); |
3416
|
|
|
$tagIcms = $this->dom->createElement('ICMS'); |
3417
|
|
|
if (isset($icms)) { |
3418
|
|
|
$this->imp->appendChild($tagIcms); |
3419
|
|
|
} |
3420
|
|
|
if (isset($icms)) { |
3421
|
|
|
$tagIcms->appendChild($icms); |
3422
|
|
|
} |
3423
|
|
|
if ($std->vTotTrib > 0) { |
3424
|
|
|
$this->dom->addChild( |
3425
|
|
|
$this->imp, |
3426
|
|
|
'vTotTrib', |
3427
|
|
|
$std->vTotTrib, |
3428
|
|
|
false, |
3429
|
|
|
"$identificador Valor Total dos Tributos" |
3430
|
|
|
); |
3431
|
|
|
} |
3432
|
|
|
if (isset($std->infAdFisco)) { |
3433
|
|
|
$this->dom->addChild( |
3434
|
|
|
$this->imp, |
3435
|
|
|
'infAdFisco', |
3436
|
|
|
$std->infAdFisco, |
3437
|
|
|
false, |
3438
|
|
|
"$identificador Informações adicionais de interesse do Fisco" |
3439
|
|
|
); |
3440
|
|
|
} |
3441
|
|
|
|
3442
|
|
|
if ($std->vICMSUFFim != '' || $std->vICMSUFIni != '') { |
3443
|
|
|
$icmsDifal = $this->dom->createElement("ICMSUFFim"); |
3444
|
|
|
$this->dom->addChild( |
3445
|
|
|
$icmsDifal, |
3446
|
|
|
'vBCUFFim', |
3447
|
|
|
$std->vBCUFFim, |
3448
|
|
|
true, |
3449
|
|
|
"$identificador Valor da BC do ICMS na UF |
3450
|
|
|
de término da prestação do serviço de transporte" |
3451
|
|
|
); |
3452
|
|
|
$this->dom->addChild( |
3453
|
|
|
$icmsDifal, |
3454
|
|
|
'pFCPUFFim', |
3455
|
|
|
$std->pFCPUFFim, |
3456
|
|
|
true, |
3457
|
|
|
"$identificador Percentual do ICMS |
3458
|
|
|
relativo ao Fundo de Combate à pobreza (FCP) na UF de término da prestação do serviço de |
3459
|
|
|
transporte" |
3460
|
|
|
); |
3461
|
|
|
$this->dom->addChild( |
3462
|
|
|
$icmsDifal, |
3463
|
|
|
'pICMSUFFim', |
3464
|
|
|
$std->pICMSUFFim, |
3465
|
|
|
true, |
3466
|
|
|
"$identificador Alíquota interna da UF |
3467
|
|
|
de término da prestação do serviço de transporte" |
3468
|
|
|
); |
3469
|
|
|
$this->dom->addChild( |
3470
|
|
|
$icmsDifal, |
3471
|
|
|
'pICMSInter', |
3472
|
|
|
$std->pICMSInter, |
3473
|
|
|
true, |
3474
|
|
|
"$identificador Alíquota interestadual |
3475
|
|
|
das UF envolvidas" |
3476
|
|
|
); |
3477
|
|
|
$this->dom->addChild( |
3478
|
|
|
$icmsDifal, |
3479
|
|
|
'vFCPUFFim', |
3480
|
|
|
$std->vFCPUFFim, |
3481
|
|
|
true, |
3482
|
|
|
"$identificador Valor do ICMS relativo |
3483
|
|
|
ao Fundo de Combate á Pobreza (FCP) da UF de término da prestação" |
3484
|
|
|
); |
3485
|
|
|
$this->dom->addChild( |
3486
|
|
|
$icmsDifal, |
3487
|
|
|
'vICMSUFFim', |
3488
|
|
|
$std->vICMSUFFim, |
3489
|
|
|
true, |
3490
|
|
|
"$identificador Valor do ICMS de |
3491
|
|
|
partilha para a UF de término da prestação do serviço de transporte" |
3492
|
|
|
); |
3493
|
|
|
$this->dom->addChild( |
3494
|
|
|
$icmsDifal, |
3495
|
|
|
'vICMSUFIni', |
3496
|
|
|
$std->vICMSUFIni, |
3497
|
|
|
true, |
3498
|
|
|
"$identificador Valor do ICMS de |
3499
|
|
|
partilha para a UF de início da prestação do serviço de transporte" |
3500
|
|
|
); |
3501
|
|
|
|
3502
|
|
|
$this->imp->appendChild($icmsDifal); |
3503
|
|
|
} |
3504
|
|
|
|
3505
|
|
|
return $tagIcms; |
3506
|
|
|
} |
3507
|
|
|
|
3508
|
|
|
/** |
3509
|
|
|
* tagInfTribFed |
3510
|
|
|
* Informações do Impostos Federais |
3511
|
|
|
* CTe OS |
3512
|
|
|
* @return DOMElement |
3513
|
|
|
*/ |
3514
|
|
|
public function taginfTribFed($std) |
3515
|
|
|
{ |
3516
|
|
|
|
3517
|
|
|
$possible = [ |
3518
|
|
|
'vPIS', |
3519
|
|
|
'vCOFINS', |
3520
|
|
|
'vIR', |
3521
|
|
|
'vINSS', |
3522
|
|
|
'vCSLL' |
3523
|
|
|
]; |
3524
|
|
|
|
3525
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3526
|
|
|
|
3527
|
|
|
$identificador = 'N02 <imp> - '; |
3528
|
|
|
$tagInfTribFed = $this->dom->createElement('infTribFed'); |
3529
|
|
|
$this->dom->addChild($tagInfTribFed, 'vPIS', $std->vPIS, false, "$identificador Valor de PIS"); |
3530
|
|
|
$this->dom->addChild($tagInfTribFed, 'vCOFINS', $std->vCOFINS, false, "$identificador Valor de COFINS"); |
3531
|
|
|
$this->dom->addChild($tagInfTribFed, 'vIR', $std->vIR, false, "$identificador Valor de IR"); |
3532
|
|
|
$this->dom->addChild($tagInfTribFed, 'vINSS', $std->vINSS, false, "$identificador Valor de INSS"); |
3533
|
|
|
$this->dom->addChild($tagInfTribFed, 'vCSLL', $std->vCSLL, false, "$identificador Valor de CSLL"); |
3534
|
|
|
$this->imp->appendChild($tagInfTribFed); |
3535
|
|
|
} |
3536
|
|
|
|
3537
|
|
|
|
3538
|
|
|
/** |
3539
|
|
|
* Tag raiz do documento xml |
3540
|
|
|
* Função chamada pelo método [ monta ] |
3541
|
|
|
* @return \DOMElement |
3542
|
|
|
*/ |
3543
|
|
|
private function buildCTe() |
3544
|
|
|
{ |
3545
|
|
|
if (empty($this->CTe)) { |
3546
|
|
|
$this->CTe = $this->dom->createElement('CTe'); |
3547
|
|
|
$this->CTe->setAttribute('xmlns', 'http://www.portalfiscal.inf.br/cte'); |
3548
|
|
|
} |
3549
|
|
|
return $this->CTe; |
3550
|
|
|
} |
3551
|
|
|
|
3552
|
|
|
/** |
3553
|
|
|
* Tag raiz do documento xml |
3554
|
|
|
* Função chamada pelo método [ monta ] |
3555
|
|
|
* @return \DOMElement |
3556
|
|
|
*/ |
3557
|
|
|
private function buildCTeOS() |
3558
|
|
|
{ |
3559
|
|
|
if (empty($this->CTe)) { |
3560
|
|
|
$this->CTe = $this->dom->createElement('CTeOS'); |
3561
|
|
|
$this->CTe->setAttribute('versao', '3.00'); |
3562
|
|
|
$this->CTe->setAttribute('xmlns', 'http://www.portalfiscal.inf.br/cte'); |
3563
|
|
|
} |
3564
|
|
|
return $this->CTe; |
3565
|
|
|
} |
3566
|
|
|
|
3567
|
|
|
/** |
3568
|
|
|
* Gera as tags para o elemento: "Entrega" (Informações ref. a previsão de entrega) |
3569
|
|
|
* #69 |
3570
|
|
|
* Nível: 2 |
3571
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "Entrega" do |
3572
|
|
|
* tipo elemento (Ele = E|CE|A) e nível 3 |
3573
|
|
|
* |
3574
|
|
|
* @return \DOMElement |
3575
|
|
|
*/ |
3576
|
|
|
private function tagEntrega() |
3577
|
|
|
{ |
3578
|
|
|
if ($this->compl == '') { |
3579
|
|
|
$this->compl = $this->dom->createElement('compl'); |
3580
|
|
|
} |
3581
|
|
|
if ($this->entrega == '') { |
3582
|
|
|
$this->entrega = $this->dom->createElement('Entrega'); |
3583
|
|
|
$this->dom->appChild($this->compl, $this->entrega, 'Falta tag "compl"'); |
3584
|
|
|
} |
3585
|
|
|
return $this->entrega; |
3586
|
|
|
} |
3587
|
|
|
|
3588
|
|
|
/** |
3589
|
|
|
* #241 |
3590
|
|
|
* @return type |
3591
|
|
|
*/ |
3592
|
|
|
public function taginfCTeNorm() |
3593
|
|
|
{ |
3594
|
|
|
$this->infCTeNorm = $this->dom->createElement('infCTeNorm'); |
3595
|
|
|
return $this->infCTeNorm; |
3596
|
|
|
} |
3597
|
|
|
|
3598
|
|
|
/** |
3599
|
|
|
* Gera as tags para o elemento: "infCarga" (Informações da Carga do CT-e) |
3600
|
|
|
* #242 |
3601
|
|
|
* Nível: 2 |
3602
|
|
|
* |
3603
|
|
|
* @return \DOMElement |
3604
|
|
|
*/ |
3605
|
|
|
public function taginfCarga($std) |
3606
|
|
|
{ |
3607
|
|
|
|
3608
|
|
|
$possible = [ |
3609
|
|
|
'vCarga', |
3610
|
|
|
'proPred', |
3611
|
|
|
'xOutCat' |
3612
|
|
|
]; |
3613
|
|
|
|
3614
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3615
|
|
|
|
3616
|
|
|
$identificador = '#242 <infCarga> - '; |
3617
|
|
|
$this->infCarga = $this->dom->createElement('infCarga'); |
3618
|
|
|
$this->dom->addChild( |
3619
|
|
|
$this->infCarga, |
3620
|
|
|
'vCarga', |
3621
|
|
|
$std->vCarga, |
3622
|
|
|
false, |
3623
|
|
|
$identificador . 'Valor Total da Carga' |
3624
|
|
|
); |
3625
|
|
|
$this->dom->addChild( |
3626
|
|
|
$this->infCarga, |
3627
|
|
|
'proPred', |
3628
|
|
|
$std->proPred, |
3629
|
|
|
true, |
3630
|
|
|
$identificador . 'Produto Predominante' |
3631
|
|
|
); |
3632
|
|
|
$this->dom->addChild( |
3633
|
|
|
$this->infCarga, |
3634
|
|
|
'xOutCat', |
3635
|
|
|
$std->xOutCat, |
3636
|
|
|
false, |
3637
|
|
|
$identificador . 'Outras Caract. da Carga' |
3638
|
|
|
); |
3639
|
|
|
return $this->infCarga; |
3640
|
|
|
} |
3641
|
|
|
|
3642
|
|
|
/** |
3643
|
|
|
* Gera as tags para o elemento: "infCTeNorm" (Informações da Carga do CT-e OS) |
3644
|
|
|
* #253 |
3645
|
|
|
* Nível: 2 |
3646
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "infServico" |
3647
|
|
|
* |
3648
|
|
|
* @return \DOMElement |
3649
|
|
|
*/ |
3650
|
|
|
public function taginfServico($std) |
3651
|
|
|
{ |
3652
|
|
|
|
3653
|
|
|
$possible = [ |
3654
|
|
|
'xDescServ' |
3655
|
|
|
]; |
3656
|
|
|
|
3657
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3658
|
|
|
|
3659
|
|
|
$identificador = '#253 <infServico> - '; |
3660
|
|
|
$this->infServico = $this->dom->createElement('infServico'); |
3661
|
|
|
$this->dom->addChild( |
3662
|
|
|
$this->infServico, |
3663
|
|
|
'xDescServ', |
3664
|
|
|
$std->xDescServ, |
3665
|
|
|
true, |
3666
|
|
|
$identificador . 'Descrição do Serviço Prestado' |
3667
|
|
|
); |
3668
|
|
|
$infQ = $this->dom->createElement('infQ'); |
3669
|
|
|
$this->dom->addChild($infQ, 'qCarga', $std->qCarga, false, $identificador . 'Quantidade'); |
3670
|
|
|
$this->infServico->appendChild($infQ); |
3671
|
|
|
return $this->infServico; |
3672
|
|
|
} |
3673
|
|
|
|
3674
|
|
|
/** |
3675
|
|
|
* Gera as tags para o elemento: "infQ" (Informações de quantidades da Carga do CT-e) |
3676
|
|
|
* #246 |
3677
|
|
|
* Nível: 3 |
3678
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "infQ" |
3679
|
|
|
* |
3680
|
|
|
* @return mixed |
3681
|
|
|
*/ |
3682
|
|
|
public function taginfQ($std) |
3683
|
|
|
{ |
3684
|
|
|
|
3685
|
|
|
$possible = [ |
3686
|
|
|
'cUnid', |
3687
|
|
|
'tpMed', |
3688
|
|
|
'qCarga', |
3689
|
|
|
'vCargaAverb' |
3690
|
|
|
]; |
3691
|
|
|
|
3692
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3693
|
|
|
|
3694
|
|
|
$identificador = '#257 <infQ> - '; |
3695
|
|
|
$this->infQ[] = $this->dom->createElement('infQ'); |
3696
|
|
|
$posicao = (int)count($this->infQ) - 1; |
3697
|
|
|
$this->dom->addChild( |
3698
|
|
|
$this->infQ[$posicao], |
3699
|
|
|
'cUnid', |
3700
|
|
|
$std->cUnid, |
3701
|
|
|
true, |
3702
|
|
|
$identificador . 'Código da Unidade de Medida' |
3703
|
|
|
); |
3704
|
|
|
$this->dom->addChild( |
3705
|
|
|
$this->infQ[$posicao], |
3706
|
|
|
'tpMed', |
3707
|
|
|
$std->tpMed, |
3708
|
|
|
true, |
3709
|
|
|
$identificador . 'Tipo da Medida' |
3710
|
|
|
); |
3711
|
|
|
$this->dom->addChild( |
3712
|
|
|
$this->infQ[$posicao], |
3713
|
|
|
'qCarga', |
3714
|
|
|
$std->qCarga, |
3715
|
|
|
true, |
3716
|
|
|
$identificador . 'Quantidade' |
3717
|
|
|
); |
3718
|
|
|
$this->dom->addChild( |
3719
|
|
|
$this->infQ[$posicao], |
3720
|
|
|
'vCargaAverb', |
3721
|
|
|
$std->vCargaAverb, |
3722
|
|
|
false, |
3723
|
|
|
$identificador . 'Valor da Carga para efeito de averbação' |
3724
|
|
|
); |
3725
|
|
|
return $this->infQ[$posicao]; |
3726
|
|
|
} |
3727
|
|
|
|
3728
|
|
|
private function taginfDoc() |
3729
|
|
|
{ |
3730
|
|
|
if (empty($this->infDoc)) { |
3731
|
|
|
$this->infDoc = $this->dom->createElement('infDoc'); |
3732
|
|
|
} |
3733
|
|
|
return $this->infDoc; |
3734
|
|
|
} |
3735
|
|
|
|
3736
|
|
|
/** |
3737
|
|
|
* Documentos de Transporte Anterior |
3738
|
|
|
* @return DOMElement|\DOMNode |
3739
|
|
|
*/ |
3740
|
|
|
public function tagdocAnt() |
3741
|
|
|
{ |
3742
|
|
|
$this->docAnt = $this->dom->createElement('docAnt'); |
3743
|
|
|
return $this->docAnt; |
3744
|
|
|
} |
3745
|
|
|
|
3746
|
|
|
/** |
3747
|
|
|
* Informações de identificação dos documentos de Transporte Anterior |
3748
|
|
|
* @return array|DOMElement |
3749
|
|
|
*/ |
3750
|
|
|
public function tagidDocAnt() |
3751
|
|
|
{ |
3752
|
|
|
$this->idDocAnt[count($this->emiDocAnt) - 1][] = $this->dom->createElement('idDocAnt'); |
3753
|
|
|
return $this->idDocAnt; |
3754
|
|
|
} |
3755
|
|
|
|
3756
|
|
|
/** |
3757
|
|
|
* Gera as tags para o elemento: "infNF" (Informações das NF) |
3758
|
|
|
* #262 |
3759
|
|
|
* Nível: 3 |
3760
|
|
|
* @return mixed |
3761
|
|
|
*/ |
3762
|
|
|
public function taginfNF($std) |
3763
|
|
|
{ |
3764
|
|
|
|
3765
|
|
|
$possible = [ |
3766
|
|
|
'nRoma', |
3767
|
|
|
'nPed', |
3768
|
|
|
'mod', |
3769
|
|
|
'serie', |
3770
|
|
|
'nDoc', |
3771
|
|
|
'dEmi', |
3772
|
|
|
'vBC', |
3773
|
|
|
'vICMS', |
3774
|
|
|
'vBCST', |
3775
|
|
|
'vST', |
3776
|
|
|
'vProd', |
3777
|
|
|
'vNF', |
3778
|
|
|
'nCFOP', |
3779
|
|
|
'nPeso', |
3780
|
|
|
'PIN', |
3781
|
|
|
'dPrev', |
3782
|
|
|
'infUnidCarga', |
3783
|
|
|
'infUnidTransp' |
3784
|
|
|
]; |
3785
|
|
|
$this->taginfDoc(); |
3786
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3787
|
|
|
|
3788
|
|
|
$identificador = '#262 <infNF> - '; |
3789
|
|
|
$infNF = $this->dom->createElement('infNF'); |
3790
|
|
|
$this->dom->addChild( |
3791
|
|
|
$infNF, |
3792
|
|
|
'nRoma', |
3793
|
|
|
$std->nRoma, |
3794
|
|
|
false, |
3795
|
|
|
$identificador . 'Número do Romaneio da NF' |
3796
|
|
|
); |
3797
|
|
|
$this->dom->addChild( |
3798
|
|
|
$infNF, |
3799
|
|
|
'nPed', |
3800
|
|
|
$std->nPed, |
3801
|
|
|
false, |
3802
|
|
|
$identificador . 'Número do Pedido da NF' |
3803
|
|
|
); |
3804
|
|
|
$this->dom->addChild( |
3805
|
|
|
$infNF, |
3806
|
|
|
'mod', |
3807
|
|
|
$std->mod, |
3808
|
|
|
true, |
3809
|
|
|
$identificador . 'Modelo da Nota Fiscal' |
3810
|
|
|
); |
3811
|
|
|
$this->dom->addChild( |
3812
|
|
|
$infNF, |
3813
|
|
|
'serie', |
3814
|
|
|
$std->serie, |
3815
|
|
|
true, |
3816
|
|
|
$identificador . 'Série' |
3817
|
|
|
); |
3818
|
|
|
$this->dom->addChild( |
3819
|
|
|
$infNF, |
3820
|
|
|
'nDoc', |
3821
|
|
|
$std->nDoc, |
3822
|
|
|
true, |
3823
|
|
|
$identificador . 'Número' |
3824
|
|
|
); |
3825
|
|
|
$this->dom->addChild( |
3826
|
|
|
$infNF, |
3827
|
|
|
'dEmi', |
3828
|
|
|
$std->dEmi, |
3829
|
|
|
true, |
3830
|
|
|
$identificador . 'Data de Emissão' |
3831
|
|
|
); |
3832
|
|
|
$this->dom->addChild( |
3833
|
|
|
$infNF, |
3834
|
|
|
'vBC', |
3835
|
|
|
$std->vBC, |
3836
|
|
|
true, |
3837
|
|
|
$identificador . 'Valor da Base de Cálculo do ICMS' |
3838
|
|
|
); |
3839
|
|
|
$this->dom->addChild( |
3840
|
|
|
$infNF, |
3841
|
|
|
'vICMS', |
3842
|
|
|
$std->vICMS, |
3843
|
|
|
true, |
3844
|
|
|
$identificador . 'Valor Totaldo ICMS' |
3845
|
|
|
); |
3846
|
|
|
$this->dom->addChild( |
3847
|
|
|
$infNF, |
3848
|
|
|
'vBCST', |
3849
|
|
|
$std->vBCST, |
3850
|
|
|
true, |
3851
|
|
|
$identificador . 'Valor da Base de Cálculo do ICMS ST' |
3852
|
|
|
); |
3853
|
|
|
$this->dom->addChild( |
3854
|
|
|
$infNF, |
3855
|
|
|
'vST', |
3856
|
|
|
$std->vST, |
3857
|
|
|
true, |
3858
|
|
|
$identificador . 'Valor Total do ICMS ST' |
3859
|
|
|
); |
3860
|
|
|
$this->dom->addChild( |
3861
|
|
|
$infNF, |
3862
|
|
|
'vProd', |
3863
|
|
|
$std->vProd, |
3864
|
|
|
true, |
3865
|
|
|
$identificador . 'Valor Total dos Produtos' |
3866
|
|
|
); |
3867
|
|
|
$this->dom->addChild( |
3868
|
|
|
$infNF, |
3869
|
|
|
'vNF', |
3870
|
|
|
$std->vNF, |
3871
|
|
|
true, |
3872
|
|
|
$identificador . 'Valor Total da NF' |
3873
|
|
|
); |
3874
|
|
|
$this->dom->addChild( |
3875
|
|
|
$infNF, |
3876
|
|
|
'nCFOP', |
3877
|
|
|
$std->nCFOP, |
3878
|
|
|
true, |
3879
|
|
|
$identificador . 'CFOP Predominante' |
3880
|
|
|
); |
3881
|
|
|
$this->dom->addChild( |
3882
|
|
|
$infNF, |
3883
|
|
|
'nPeso', |
3884
|
|
|
$std->nPeso, |
3885
|
|
|
false, |
3886
|
|
|
$identificador . 'Peso total em Kg' |
3887
|
|
|
); |
3888
|
|
|
$this->dom->addChild( |
3889
|
|
|
$infNF, |
3890
|
|
|
'PIN', |
3891
|
|
|
$std->PIN, |
3892
|
|
|
false, |
3893
|
|
|
$identificador . 'PIN SUFRAMA' |
3894
|
|
|
); |
3895
|
|
|
$this->dom->addChild( |
3896
|
|
|
$infNF, |
3897
|
|
|
'dPrev', |
3898
|
|
|
$std->dPrev, |
3899
|
|
|
false, |
3900
|
|
|
$identificador . 'Data prevista de entrega' |
3901
|
|
|
); |
3902
|
|
|
if ($std->infUnidCarga) { |
3903
|
|
|
foreach ($std->infUnidCarga as $value) { |
3904
|
|
|
$this->dom->appChild($infNF, $this->taginfUnidCarga($value), 'Falta tag "infUnidCarga"'); |
3905
|
|
|
} |
3906
|
|
|
} |
3907
|
|
|
if ($std->infUnidTransp) { |
3908
|
|
|
foreach ($std->infUnidTransp as $value) { |
3909
|
|
|
$this->dom->appChild($infNF, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"'); |
3910
|
|
|
} |
3911
|
|
|
} |
3912
|
|
|
$this->infNF[] = $infNF; |
3913
|
|
|
return $infNF; |
3914
|
|
|
} |
3915
|
|
|
|
3916
|
|
|
/** |
3917
|
|
|
* Gera as tags para o elemento: "infNFe" (Informações das NF-e) |
3918
|
|
|
* #297 |
3919
|
|
|
* Nível: 3 |
3920
|
|
|
* @return mixed |
3921
|
|
|
*/ |
3922
|
|
|
public function taginfNFe($std) |
3923
|
|
|
{ |
3924
|
|
|
|
3925
|
|
|
$possible = [ |
3926
|
|
|
'chave', |
3927
|
|
|
'PIN', |
3928
|
|
|
'dPrev', |
3929
|
|
|
'infUnidCarga', |
3930
|
|
|
'infUnidTransp' |
3931
|
|
|
]; |
3932
|
|
|
$this->taginfDoc(); |
3933
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3934
|
|
|
|
3935
|
|
|
$identificador = '#297 <infNFe> - '; |
3936
|
|
|
$infNFe = $this->dom->createElement('infNFe'); |
3937
|
|
|
$this->dom->addChild( |
3938
|
|
|
$infNFe, |
3939
|
|
|
'chave', |
3940
|
|
|
$std->chave, |
3941
|
|
|
true, |
3942
|
|
|
$identificador . 'Chave de acesso da NF-e' |
3943
|
|
|
); |
3944
|
|
|
$this->dom->addChild( |
3945
|
|
|
$infNFe, |
3946
|
|
|
'PIN', |
3947
|
|
|
$std->PIN, |
3948
|
|
|
false, |
3949
|
|
|
$identificador . 'PIN SUFRAMA' |
3950
|
|
|
); |
3951
|
|
|
$this->dom->addChild( |
3952
|
|
|
$infNFe, |
3953
|
|
|
'dPrev', |
3954
|
|
|
$std->dPrev, |
3955
|
|
|
false, |
3956
|
|
|
$identificador . 'Data prevista de entrega' |
3957
|
|
|
); |
3958
|
|
|
if ($std->infUnidCarga) { |
3959
|
|
|
foreach ($std->infUnidCarga as $value) { |
3960
|
|
|
$this->dom->appChild($infNFe, $this->taginfUnidCarga($value), 'Falta tag "infUnidCarga"'); |
3961
|
|
|
} |
3962
|
|
|
} |
3963
|
|
|
if ($std->infUnidTransp) { |
3964
|
|
|
foreach ($std->infUnidTransp as $value) { |
3965
|
|
|
$this->dom->appChild($infNFe, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"'); |
3966
|
|
|
} |
3967
|
|
|
} |
3968
|
|
|
$this->infNFe[] = $infNFe; |
3969
|
|
|
return $infNFe; |
3970
|
|
|
} |
3971
|
|
|
|
3972
|
|
|
/** |
3973
|
|
|
* Gera as tags para o elemento: "infOutros" (Informações dos demais documentos) |
3974
|
|
|
* #319 |
3975
|
|
|
* Nível: 3 |
3976
|
|
|
* @return mixed |
3977
|
|
|
*/ |
3978
|
|
|
public function taginfOutros($std) |
3979
|
|
|
{ |
3980
|
|
|
|
3981
|
|
|
$possible = [ |
3982
|
|
|
'tpDoc', |
3983
|
|
|
'descOutros', |
3984
|
|
|
'nDoc', |
3985
|
|
|
'dEmi', |
3986
|
|
|
'vDocFisc', |
3987
|
|
|
'dPrev', |
3988
|
|
|
'infUnidCarga', |
3989
|
|
|
'infUnidTransp' |
3990
|
|
|
]; |
3991
|
|
|
$this->taginfDoc(); |
3992
|
|
|
$std = $this->equilizeParameters($std, $possible); |
3993
|
|
|
|
3994
|
|
|
$ident = '#319 <infOutros> - '; |
3995
|
|
|
$infOutros = $this->dom->createElement('infOutros'); |
3996
|
|
|
$this->dom->addChild( |
3997
|
|
|
$infOutros, |
3998
|
|
|
'tpDoc', |
3999
|
|
|
$std->tpDoc, |
4000
|
|
|
true, |
4001
|
|
|
$ident . 'Tipo de documento originário' |
4002
|
|
|
); |
4003
|
|
|
$this->dom->addChild( |
4004
|
|
|
$infOutros, |
4005
|
|
|
'descOutros', |
4006
|
|
|
$std->descOutros, |
4007
|
|
|
false, |
4008
|
|
|
$ident . 'Descrição do documento' |
4009
|
|
|
); |
4010
|
|
|
$this->dom->addChild( |
4011
|
|
|
$infOutros, |
4012
|
|
|
'nDoc', |
4013
|
|
|
$std->nDoc, |
4014
|
|
|
false, |
4015
|
|
|
$ident . 'Número do documento' |
4016
|
|
|
); |
4017
|
|
|
$this->dom->addChild( |
4018
|
|
|
$infOutros, |
4019
|
|
|
'dEmi', |
4020
|
|
|
$std->dEmi, |
4021
|
|
|
false, |
4022
|
|
|
$ident . 'Data de Emissão' |
4023
|
|
|
); |
4024
|
|
|
$this->dom->addChild( |
4025
|
|
|
$infOutros, |
4026
|
|
|
'vDocFisc', |
4027
|
|
|
$std->vDocFisc, |
4028
|
|
|
false, |
4029
|
|
|
$ident . 'Valor do documento' |
4030
|
|
|
); |
4031
|
|
|
$this->dom->addChild( |
4032
|
|
|
$infOutros, |
4033
|
|
|
'dPrev', |
4034
|
|
|
$std->dPrev, |
4035
|
|
|
false, |
4036
|
|
|
$ident . 'Data ista de entrega' |
4037
|
|
|
); |
4038
|
|
|
if ($std->infUnidCarga) { |
4039
|
|
|
foreach ($std->infUnidCarga as $value) { |
4040
|
|
|
$this->dom->appChild($infOutros, $this->taginfUnidCarga($value), 'Falta tag "infUnidCarga"'); |
4041
|
|
|
} |
4042
|
|
|
} |
4043
|
|
|
if ($std->infUnidTransp) { |
4044
|
|
|
foreach ($std->infUnidTransp as $value) { |
4045
|
|
|
$this->dom->appChild($infOutros, $this->taginfUnidTransp($value), 'Falta tag "infUnidTransp"'); |
4046
|
|
|
} |
4047
|
|
|
} |
4048
|
|
|
$this->infOutros[] = $infOutros; |
4049
|
|
|
return $infOutros; |
4050
|
|
|
} |
4051
|
|
|
|
4052
|
|
|
/** |
4053
|
|
|
* taginfUnidCarga |
4054
|
|
|
* tag CTe/infCte/infDoc/(infNF/infNFe/infOutros)/infUnidCarga |
4055
|
|
|
* |
4056
|
|
|
* @param stdClass $std |
4057
|
|
|
* @return DOMElement |
4058
|
|
|
*/ |
4059
|
|
|
private function taginfUnidCarga(stdClass $std) |
4060
|
|
|
{ |
4061
|
|
|
$possible = [ |
4062
|
|
|
'tpUnidCarga', |
4063
|
|
|
'idUnidCarga', |
4064
|
|
|
'lacUnidCarga', |
4065
|
|
|
'qtdRat' |
4066
|
|
|
]; |
4067
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4068
|
|
|
$infUnidCarga = $this->dom->createElement("infUnidCarga"); |
4069
|
|
|
$this->dom->addChild( |
4070
|
|
|
$infUnidCarga, |
4071
|
|
|
"tpUnidCarga", |
4072
|
|
|
$std->tpUnidCarga, |
4073
|
|
|
false, |
4074
|
|
|
"Tipo da Unidade de Carga" |
4075
|
|
|
); |
4076
|
|
|
$this->dom->addChild( |
4077
|
|
|
$infUnidCarga, |
4078
|
|
|
"idUnidCarga", |
4079
|
|
|
$std->idUnidCarga, |
4080
|
|
|
false, |
4081
|
|
|
"Identificação da Unidade de Carga " |
4082
|
|
|
); |
4083
|
|
|
if ($std->lacUnidCarga != null) { |
4084
|
|
|
$possible = [ |
4085
|
|
|
'nLacre' |
4086
|
|
|
]; |
4087
|
|
|
$stdlacUnidCarga = $this->equilizeParameters($std->lacUnidCarga, $possible); |
4088
|
|
|
foreach ($stdlacUnidCarga->nLacre as $nLacre) { |
4089
|
|
|
$lacUnidCarga = $this->dom->createElement("lacUnidCarga"); |
4090
|
|
|
$this->dom->addChild( |
4091
|
|
|
$lacUnidCarga, |
4092
|
|
|
"nLacre", |
4093
|
|
|
$nLacre, |
4094
|
|
|
true, |
4095
|
|
|
"Número do lacre" |
4096
|
|
|
); |
4097
|
|
|
$this->dom->appChild($infUnidCarga, $lacUnidCarga, 'Falta tag "infUnidCarga"'); |
4098
|
|
|
} |
4099
|
|
|
} |
4100
|
|
|
$this->dom->addChild( |
4101
|
|
|
$infUnidCarga, |
4102
|
|
|
"qtdRat", |
4103
|
|
|
$std->qtdRat, |
4104
|
|
|
false, |
4105
|
|
|
"Quantidade rateada (Peso,Volume)" |
4106
|
|
|
); |
4107
|
|
|
return $infUnidCarga; |
4108
|
|
|
} |
4109
|
|
|
|
4110
|
|
|
/** |
4111
|
|
|
* taginfUnidTransp |
4112
|
|
|
* tag CTe/infCte/infDoc/(infNF/infNFe/infOutros)/infUnidTransp |
4113
|
|
|
* |
4114
|
|
|
* @param stdClass $std |
4115
|
|
|
* @return DOMElement |
4116
|
|
|
*/ |
4117
|
|
|
private function taginfUnidTransp(stdClass $std) |
4118
|
|
|
{ |
4119
|
|
|
$possible = [ |
4120
|
|
|
'tpUnidTransp', |
4121
|
|
|
'idUnidTransp', |
4122
|
|
|
'qtdRat', |
4123
|
|
|
'lacUnidTransp', |
4124
|
|
|
'infUnidCarga' |
4125
|
|
|
]; |
4126
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4127
|
|
|
$infUnidTransp = $this->dom->createElement("infUnidTransp"); |
4128
|
|
|
$this->dom->addChild( |
4129
|
|
|
$infUnidTransp, |
4130
|
|
|
"tpUnidTransp", |
4131
|
|
|
$std->tpUnidTransp, |
4132
|
|
|
true, |
4133
|
|
|
"Tipo da Unidade de Transporte" |
4134
|
|
|
); |
4135
|
|
|
$this->dom->addChild( |
4136
|
|
|
$infUnidTransp, |
4137
|
|
|
"idUnidTransp", |
4138
|
|
|
$std->idUnidTransp, |
4139
|
|
|
false, |
4140
|
|
|
"Identificação da Unidade de Transporte" |
4141
|
|
|
); |
4142
|
|
|
if ($std->lacUnidTransp != null) { |
4143
|
|
|
$possible = [ |
4144
|
|
|
'nLacre' |
4145
|
|
|
]; |
4146
|
|
|
$stdlacUnidTransp = $this->equilizeParameters($std->lacUnidTransp, $possible); |
4147
|
|
|
foreach ($stdlacUnidTransp->nLacre as $nLacre) { |
4148
|
|
|
$lacUnidTransp = $this->dom->createElement("lacUnidTransp"); |
4149
|
|
|
$this->dom->addChild( |
4150
|
|
|
$lacUnidTransp, |
4151
|
|
|
"nLacre", |
4152
|
|
|
$nLacre, |
4153
|
|
|
true, |
4154
|
|
|
"Número do lacre" |
4155
|
|
|
); |
4156
|
|
|
$this->dom->appChild($infUnidTransp, $lacUnidTransp, 'Falta tag "infUnidTransp"'); |
4157
|
|
|
} |
4158
|
|
|
} |
4159
|
|
|
if ($std->infUnidCarga) { |
4160
|
|
|
foreach ($std->infUnidCarga as $value) { |
4161
|
|
|
$this->dom->appChild($infUnidTransp, $this->taginfUnidCarga($value), 'Falta tag "infUnidCarga"'); |
4162
|
|
|
} |
4163
|
|
|
} |
4164
|
|
|
$this->dom->addChild( |
4165
|
|
|
$infUnidTransp, |
4166
|
|
|
"qtdRat", |
4167
|
|
|
$std->qtdRat, |
4168
|
|
|
false, |
4169
|
|
|
"Quantidade rateada (Peso,Volume) " |
4170
|
|
|
); |
4171
|
|
|
return $infUnidTransp; |
4172
|
|
|
} |
4173
|
|
|
|
4174
|
|
|
/** |
4175
|
|
|
* Gera as tags para o elemento: "infDocRef" (Informações dos demais documentos) |
4176
|
|
|
* #319 |
4177
|
|
|
* Nível: 3 |
4178
|
|
|
* @return mixed |
4179
|
|
|
*/ |
4180
|
|
|
public function taginfDocRef($std) |
4181
|
|
|
{ |
4182
|
|
|
|
4183
|
|
|
$possible = [ |
4184
|
|
|
'nDoc', |
4185
|
|
|
'serie', |
4186
|
|
|
'subserie', |
4187
|
|
|
'dEmi', |
4188
|
|
|
'vDoc' |
4189
|
|
|
]; |
4190
|
|
|
|
4191
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4192
|
|
|
|
4193
|
|
|
$ident = '#319 <infDocRef> - '; |
4194
|
|
|
$this->infDocRef[] = $this->dom->createElement('infDocRef'); |
4195
|
|
|
$posicao = (int)count($this->infDocRef) - 1; |
4196
|
|
|
$this->dom->addChild( |
4197
|
|
|
$this->infDocRef[$posicao], |
4198
|
|
|
'nDoc', |
4199
|
|
|
$std->nDoc, |
4200
|
|
|
false, |
4201
|
|
|
$ident . 'Número do documento' |
4202
|
|
|
); |
4203
|
|
|
$this->dom->addChild( |
4204
|
|
|
$this->infDocRef[$posicao], |
4205
|
|
|
'serie', |
4206
|
|
|
$std->serie, |
4207
|
|
|
false, |
4208
|
|
|
$ident . 'Série do documento' |
4209
|
|
|
); |
4210
|
|
|
$this->dom->addChild( |
4211
|
|
|
$this->infDocRef[$posicao], |
4212
|
|
|
'subserie', |
4213
|
|
|
$std->subserie, |
4214
|
|
|
false, |
4215
|
|
|
$ident . 'Subserie do documento' |
4216
|
|
|
); |
4217
|
|
|
$this->dom->addChild( |
4218
|
|
|
$this->infDocRef[$posicao], |
4219
|
|
|
'dEmi', |
4220
|
|
|
$std->dEmi, |
4221
|
|
|
false, |
4222
|
|
|
$ident . 'Data de Emissão' |
4223
|
|
|
); |
4224
|
|
|
$this->dom->addChild( |
4225
|
|
|
$this->infDocRef[$posicao], |
4226
|
|
|
'vDoc', |
4227
|
|
|
$std->vDoc, |
4228
|
|
|
false, |
4229
|
|
|
$ident . 'Valor do documento' |
4230
|
|
|
); |
4231
|
|
|
return $this->infDocRef[$posicao]; |
4232
|
|
|
} |
4233
|
|
|
|
4234
|
|
|
/** |
4235
|
|
|
* Gera as tags para o elemento: "emiDocAnt" (Informações dos CT-es Anteriores) |
4236
|
|
|
* #345 |
4237
|
|
|
* Nível: 3 |
4238
|
|
|
* @return mixed |
4239
|
|
|
*/ |
4240
|
|
|
public function tagemiDocAnt($std) |
4241
|
|
|
{ |
4242
|
|
|
|
4243
|
|
|
$possible = [ |
4244
|
|
|
'CNPJ', |
4245
|
|
|
'IE', |
4246
|
|
|
'UF', |
4247
|
|
|
'CPF', |
4248
|
|
|
'xNome' |
4249
|
|
|
]; |
4250
|
|
|
|
4251
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4252
|
|
|
|
4253
|
|
|
$identificador = '#345 <emiDocAnt> - '; |
4254
|
|
|
$this->emiDocAnt[] = $this->dom->createElement('emiDocAnt'); |
4255
|
|
|
$posicao = (int)count($this->emiDocAnt) - 1; |
4256
|
|
|
if ($std->CNPJ != '') { |
4257
|
|
|
$this->dom->addChild( |
4258
|
|
|
$this->emiDocAnt[$posicao], |
4259
|
|
|
'CNPJ', |
4260
|
|
|
$std->CNPJ, |
4261
|
|
|
true, |
4262
|
|
|
$identificador . 'Número do CNPJ' |
4263
|
|
|
); |
4264
|
|
|
$this->dom->addChild( |
4265
|
|
|
$this->emiDocAnt[$posicao], |
4266
|
|
|
'IE', |
4267
|
|
|
Strings::onlyNumbers($std->IE), |
4268
|
|
|
true, |
4269
|
|
|
$identificador . 'Inscrição Estadual' |
4270
|
|
|
); |
4271
|
|
|
$this->dom->addChild( |
4272
|
|
|
$this->emiDocAnt[$posicao], |
4273
|
|
|
'UF', |
4274
|
|
|
$std->UF, |
4275
|
|
|
true, |
4276
|
|
|
$identificador . 'Sigla da UF' |
4277
|
|
|
); |
4278
|
|
|
} else { |
4279
|
|
|
$this->dom->addChild( |
4280
|
|
|
$this->emiDocAnt[$posicao], |
4281
|
|
|
'CPF', |
4282
|
|
|
$std->CPF, |
4283
|
|
|
true, |
4284
|
|
|
$identificador . 'Número do CPF' |
4285
|
|
|
); |
4286
|
|
|
} |
4287
|
|
|
$this->dom->addChild( |
4288
|
|
|
$this->emiDocAnt[$posicao], |
4289
|
|
|
'xNome', |
4290
|
|
|
$std->xNome, |
4291
|
|
|
true, |
4292
|
|
|
$identificador . 'Razão Social ou Nome do Expedidor' |
4293
|
|
|
); |
4294
|
|
|
return $this->emiDocAnt[$posicao]; |
4295
|
|
|
} |
4296
|
|
|
|
4297
|
|
|
/** |
4298
|
|
|
* Gera as tags para o elemento: "idDocAntEle" (Informações dos CT-es Anteriores) |
4299
|
|
|
* #348 |
4300
|
|
|
* Nível: 4 |
4301
|
|
|
* @return mixed |
4302
|
|
|
*/ |
4303
|
|
|
public function tagidDocAntEle($std) |
4304
|
|
|
{ |
4305
|
|
|
|
4306
|
|
|
$possible = [ |
4307
|
|
|
'chCTe' |
4308
|
|
|
]; |
4309
|
|
|
|
4310
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4311
|
|
|
|
4312
|
|
|
$identificador = '#358 <idDocAntEle> - '; |
4313
|
|
|
$this->idDocAntEle[count($this->emiDocAnt) - 1][] = $this->dom->createElement('idDocAntEle'); |
4314
|
|
|
$posicao = (int)count($this->idDocAntEle[count($this->emiDocAnt) - 1]) - 1; |
4315
|
|
|
$this->dom->addChild( |
4316
|
|
|
$this->idDocAntEle[count($this->emiDocAnt) - 1][$posicao], |
4317
|
|
|
'chCTe', |
4318
|
|
|
$std->chCTe, |
4319
|
|
|
true, |
4320
|
|
|
$identificador . 'Chave de Acesso do CT-e' |
4321
|
|
|
); |
4322
|
|
|
return $this->idDocAntEle[count($this->emiDocAnt) - 1][$posicao]; |
4323
|
|
|
} |
4324
|
|
|
|
4325
|
|
|
|
4326
|
|
|
/** |
4327
|
|
|
* Gera as tags para o elemento: "seg" (Informações de Seguro da Carga) |
4328
|
|
|
* #360 |
4329
|
|
|
* Nível: 2 |
4330
|
|
|
* @return mixed |
4331
|
|
|
*/ |
4332
|
|
|
public function tagseg($std) |
4333
|
|
|
{ |
4334
|
|
|
|
4335
|
|
|
$possible = [ |
4336
|
|
|
'respSeg', |
4337
|
|
|
'xSeg', |
4338
|
|
|
'nApol' |
4339
|
|
|
]; |
4340
|
|
|
|
4341
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4342
|
|
|
|
4343
|
|
|
$identificador = '#360 <seg> - '; |
4344
|
|
|
$this->seg[] = $this->dom->createElement('seg'); |
4345
|
|
|
$posicao = (int)count($this->seg) - 1; |
4346
|
|
|
$this->dom->addChild( |
4347
|
|
|
$this->seg[$posicao], |
4348
|
|
|
'respSeg', |
4349
|
|
|
$std->respSeg, |
4350
|
|
|
true, |
4351
|
|
|
$identificador . 'Responsável pelo Seguro' |
4352
|
|
|
); |
4353
|
|
|
$this->dom->addChild( |
4354
|
|
|
$this->seg[$posicao], |
4355
|
|
|
'xSeg', |
4356
|
|
|
$std->xSeg, |
4357
|
|
|
false, |
4358
|
|
|
$identificador . 'Nome da Seguradora' |
4359
|
|
|
); |
4360
|
|
|
$this->dom->addChild( |
4361
|
|
|
$this->seg[$posicao], |
4362
|
|
|
'nApol', |
4363
|
|
|
$std->nApol, |
4364
|
|
|
false, |
4365
|
|
|
$identificador . 'Número da Apólice' |
4366
|
|
|
); |
4367
|
|
|
return $this->seg[$posicao]; |
4368
|
|
|
} |
4369
|
|
|
|
4370
|
|
|
/** |
4371
|
|
|
* Gera as tags para o elemento: "idDocAntEle" (Informações dos CT-es Anteriores) |
4372
|
|
|
* #348 |
4373
|
|
|
* Nível: 4 |
4374
|
|
|
* @return mixed |
4375
|
|
|
*/ |
4376
|
|
|
public function tagidDocAntPap($std) |
4377
|
|
|
{ |
4378
|
|
|
|
4379
|
|
|
$possible = [ |
4380
|
|
|
'tpDoc', |
4381
|
|
|
'serie', |
4382
|
|
|
'subser', |
4383
|
|
|
'nDoc', |
4384
|
|
|
'dEmi' |
4385
|
|
|
]; |
4386
|
|
|
|
4387
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4388
|
|
|
|
4389
|
|
|
$identificador = '#358 <idDocAntPap> - '; |
4390
|
|
|
$this->idDocAntPap[count($this->emiDocAnt) - 1][] = $this->dom->createElement('idDocAntPap'); |
4391
|
|
|
$posicao = (int)count($this->idDocAntPap[count($this->emiDocAnt) - 1]) - 1; |
4392
|
|
|
$this->dom->addChild( |
4393
|
|
|
$this->idDocAntPap[count($this->emiDocAnt) - 1][$posicao], |
4394
|
|
|
'tpDoc', |
4395
|
|
|
$std->tpDoc, |
4396
|
|
|
true, |
4397
|
|
|
$identificador . 'Tipo do Documento de Transporte Anterior' |
4398
|
|
|
); |
4399
|
|
|
$this->dom->addChild( |
4400
|
|
|
$this->idDocAntPap[count($this->emiDocAnt) - 1][$posicao], |
4401
|
|
|
'serie', |
4402
|
|
|
$std->serie, |
4403
|
|
|
true, |
4404
|
|
|
$identificador . 'Série do Documento Fiscal' |
4405
|
|
|
); |
4406
|
|
|
$this->dom->addChild( |
4407
|
|
|
$this->idDocAntPap[count($this->emiDocAnt) - 1][$posicao], |
4408
|
|
|
'subser', |
4409
|
|
|
$std->subser, |
4410
|
|
|
false, |
4411
|
|
|
$identificador . 'Série do Documento Fiscal' |
4412
|
|
|
); |
4413
|
|
|
$this->dom->addChild( |
4414
|
|
|
$this->idDocAntPap[count($this->emiDocAnt) - 1][$posicao], |
4415
|
|
|
'nDoc', |
4416
|
|
|
$std->nDoc, |
4417
|
|
|
true, |
4418
|
|
|
$identificador . 'Número do Documento Fiscal' |
4419
|
|
|
); |
4420
|
|
|
$this->dom->addChild( |
4421
|
|
|
$this->idDocAntPap[count($this->emiDocAnt) - 1][$posicao], |
4422
|
|
|
'dEmi', |
4423
|
|
|
$std->dEmi, |
4424
|
|
|
true, |
4425
|
|
|
$identificador . 'Data de emissão (AAAA-MM-DD)' |
4426
|
|
|
); |
4427
|
|
|
return $this->idDocAntPap[count($this->emiDocAnt) - 1][$posicao]; |
4428
|
|
|
} |
4429
|
|
|
|
4430
|
|
|
|
4431
|
|
|
/** |
4432
|
|
|
* Gera as tags para o elemento: "infModal" (Informações do modal) |
4433
|
|
|
* #366 |
4434
|
|
|
* Nível: 2 |
4435
|
|
|
* @param string $versaoModal |
|
|
|
|
4436
|
|
|
* @return DOMElement|\DOMNode |
4437
|
|
|
*/ |
4438
|
|
|
public function taginfModal($std) |
4439
|
|
|
{ |
4440
|
|
|
$this->infModal = $this->dom->createElement('infModal'); |
4441
|
|
|
$this->infModal->setAttribute('versaoModal', $std->versaoModal); |
4442
|
|
|
return $this->infModal; |
4443
|
|
|
} |
4444
|
|
|
|
4445
|
|
|
/** |
4446
|
|
|
* Leiaute - Rodoviário |
4447
|
|
|
* Gera as tags para o elemento: "rodo" (Informações do modal Rodoviário) |
4448
|
|
|
* #1 |
4449
|
|
|
* Nível: 0 |
4450
|
|
|
* @return DOMElement|\DOMNode |
4451
|
|
|
*/ |
4452
|
|
|
public function tagrodo($std) |
4453
|
|
|
{ |
4454
|
|
|
|
4455
|
|
|
$possible = [ |
4456
|
|
|
'RNTRC' |
4457
|
|
|
]; |
4458
|
|
|
|
4459
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4460
|
|
|
|
4461
|
|
|
$identificador = '#1 <rodo> - '; |
4462
|
|
|
$this->rodo = $this->dom->createElement('rodo'); |
4463
|
|
|
$this->dom->addChild( |
4464
|
|
|
$this->rodo, |
4465
|
|
|
'RNTRC', |
4466
|
|
|
$std->RNTRC, |
4467
|
|
|
true, |
4468
|
|
|
$identificador . 'Registro nacional de transportadores |
4469
|
|
|
rodoviários de carga' |
4470
|
|
|
); |
4471
|
|
|
return $this->rodo; |
4472
|
|
|
} |
4473
|
|
|
|
4474
|
|
|
/** |
4475
|
|
|
* Leiaute - Dutoviário |
4476
|
|
|
* Gera as tags para o elemento: "duto" (informações do modal Dutoviário) |
4477
|
|
|
* @return DOMElement|\DOMNode |
4478
|
|
|
* @author Uilasmar Guedes |
4479
|
|
|
* #1 |
4480
|
|
|
* Nivel: 0 |
4481
|
|
|
*/ |
4482
|
|
|
public function tagduto($std) |
4483
|
|
|
{ |
4484
|
|
|
|
4485
|
|
|
$possible = [ |
4486
|
|
|
'vTar', |
4487
|
|
|
'dIni', |
4488
|
|
|
'dFim' |
4489
|
|
|
]; |
4490
|
|
|
|
4491
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4492
|
|
|
|
4493
|
|
|
$identificador = '#1 <duto> - '; |
4494
|
|
|
$this->duto = $this->dom->createElement('duto'); |
4495
|
|
|
$this->dom->addChild( |
4496
|
|
|
$this->duto, |
4497
|
|
|
'vTar', |
4498
|
|
|
$std->vTar, |
4499
|
|
|
false, |
4500
|
|
|
$identificador . 'Valor da tarifa ' |
4501
|
|
|
); |
4502
|
|
|
$this->dom->addChild( |
4503
|
|
|
$this->duto, |
4504
|
|
|
'dIni', |
4505
|
|
|
$std->dIni, |
4506
|
|
|
true, |
4507
|
|
|
$identificador . 'Data de Início da prestação do serviço' |
4508
|
|
|
); |
4509
|
|
|
$this->dom->addChild( |
4510
|
|
|
$this->duto, |
4511
|
|
|
'dFim', |
4512
|
|
|
$std->dFim, |
4513
|
|
|
true, |
4514
|
|
|
$identificador . 'Data de Fim da prestação do serviço' |
4515
|
|
|
); |
4516
|
|
|
return $this->duto; |
4517
|
|
|
} |
4518
|
|
|
|
4519
|
|
|
/** |
4520
|
|
|
* Leiaute - Aquaviario |
4521
|
|
|
* Gera as tags para o elemento: "aquav" (informações do modal Aquaviario) |
4522
|
|
|
* @return DOMElement|\DOMNode |
4523
|
|
|
* @author Anderson Minuto Consoni Vaz |
4524
|
|
|
* #1 |
4525
|
|
|
* Nivel: 0 |
4526
|
|
|
*/ |
4527
|
|
|
public function tagaquav($std) |
4528
|
|
|
{ |
4529
|
|
|
|
4530
|
|
|
$possible = [ |
4531
|
|
|
'vPrest', |
4532
|
|
|
'vAFRMM', |
4533
|
|
|
'xNavio', |
4534
|
|
|
'nViag', |
4535
|
|
|
'direc', |
4536
|
|
|
'irin', |
4537
|
|
|
'tpNav' |
4538
|
|
|
]; |
4539
|
|
|
|
4540
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4541
|
|
|
|
4542
|
|
|
$identificador = '#1 <aquav> - '; |
4543
|
|
|
$this->aquav = $this->dom->createElement('aquav'); |
4544
|
|
|
$this->dom->addChild( |
4545
|
|
|
$this->aquav, |
4546
|
|
|
'vPrest', |
4547
|
|
|
$std->vPrest, |
4548
|
|
|
true, |
4549
|
|
|
$identificador . 'vPrest' |
4550
|
|
|
); |
4551
|
|
|
$this->dom->addChild( |
4552
|
|
|
$this->aquav, |
4553
|
|
|
'vAFRMM', |
4554
|
|
|
$std->vAFRMM, |
4555
|
|
|
true, |
4556
|
|
|
$identificador . 'vAFRMM' |
4557
|
|
|
); |
4558
|
|
|
$this->dom->addChild( |
4559
|
|
|
$this->aquav, |
4560
|
|
|
'xNavio', |
4561
|
|
|
$std->xNavio, |
4562
|
|
|
true, |
4563
|
|
|
$identificador . 'xNavio' |
4564
|
|
|
); |
4565
|
|
|
$this->dom->addChild( |
4566
|
|
|
$this->aquav, |
4567
|
|
|
'nViag', |
4568
|
|
|
$std->nViag, |
4569
|
|
|
true, |
4570
|
|
|
$identificador . 'nViag' |
4571
|
|
|
); |
4572
|
|
|
$this->dom->addChild( |
4573
|
|
|
$this->aquav, |
4574
|
|
|
'direc', |
4575
|
|
|
$std->direc, |
4576
|
|
|
true, |
4577
|
|
|
$identificador . 'direc' |
4578
|
|
|
); |
4579
|
|
|
$this->dom->addChild( |
4580
|
|
|
$this->aquav, |
4581
|
|
|
'irin', |
4582
|
|
|
$std->irin, |
4583
|
|
|
true, |
4584
|
|
|
$identificador . 'irin' |
4585
|
|
|
); |
4586
|
|
|
$this->dom->addChild( |
4587
|
|
|
$this->aquav, |
4588
|
|
|
'tpNav', |
4589
|
|
|
$std->tpNav, |
4590
|
|
|
false, |
4591
|
|
|
$identificador . 'tpNav' |
4592
|
|
|
); |
4593
|
|
|
return $this->aquav; |
4594
|
|
|
} |
4595
|
|
|
|
4596
|
|
|
/** |
4597
|
|
|
* Leiaute - Aquaviario |
4598
|
|
|
* Gera as tags de balsa para o elemento: "aquav" (informações do modal Aquaviario) |
4599
|
|
|
* @return DOMElement|\DOMNode |
4600
|
|
|
* @author Gabriel Kliemaschewsk Rondon |
4601
|
|
|
* #5 |
4602
|
|
|
* Nivel: 1 |
4603
|
|
|
*/ |
4604
|
|
|
public function tagbalsa($std) |
4605
|
|
|
{ |
4606
|
|
|
$possible = [ |
4607
|
|
|
'xBalsa', |
4608
|
|
|
]; |
4609
|
|
|
|
4610
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4611
|
|
|
|
4612
|
|
|
$identificador = '#5 <balsa> - '; |
4613
|
|
|
$this->balsa[] = $this->dom->createElement('balsa'); |
4614
|
|
|
|
4615
|
|
|
$this->dom->addChild( |
4616
|
|
|
$this->balsa[count($this->balsa) - 1], |
4617
|
|
|
'xBalsa', |
4618
|
|
|
$std->xBalsa, |
4619
|
|
|
true, |
4620
|
|
|
$identificador . 'xBalsa' |
4621
|
|
|
); |
4622
|
|
|
return $this->balsa; |
4623
|
|
|
} |
4624
|
|
|
|
4625
|
|
|
/** |
4626
|
|
|
* Leiaute - Aquaviario |
4627
|
|
|
* Gera as tags de Conteiner específicas do modal aquaviário |
4628
|
|
|
* @return DOMElement|\DOMNode |
4629
|
|
|
* @author Gabriel Kliemaschewsk Rondon |
4630
|
|
|
* #10 |
4631
|
|
|
* Nivel: 1 |
4632
|
|
|
*/ |
4633
|
|
|
public function tagdetCont($std) |
4634
|
|
|
{ |
4635
|
|
|
$possible = [ |
4636
|
|
|
'nCont', |
4637
|
|
|
]; |
4638
|
|
|
|
4639
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4640
|
|
|
|
4641
|
|
|
$identificador = '#10 <detCont> - '; |
4642
|
|
|
$this->detCont[] = $this->dom->createElement('detCont'); |
4643
|
|
|
|
4644
|
|
|
$this->dom->addChild( |
4645
|
|
|
$this->detCont[count($this->detCont) - 1], |
4646
|
|
|
'nCont', |
4647
|
|
|
$std->nCont, |
4648
|
|
|
true, |
4649
|
|
|
$identificador . 'detCont' |
4650
|
|
|
); |
4651
|
|
|
return $this->detCont; |
4652
|
|
|
} |
4653
|
|
|
|
4654
|
|
|
/** |
4655
|
|
|
* Leiaute - Aquaviario |
4656
|
|
|
* Gera as tags de lacre para os containeres do elemento: "aquav" (informações do modal Aquaviario) |
4657
|
|
|
* @return DOMElement|\DOMNode |
4658
|
|
|
* @author Gabriel Kliemaschewsk Rondon |
4659
|
|
|
* #12 |
4660
|
|
|
* Nivel: 2 |
4661
|
|
|
*/ |
4662
|
|
|
public function taglacre($std) |
4663
|
|
|
{ |
4664
|
|
|
$possible = [ |
4665
|
|
|
'nLacre', |
4666
|
|
|
]; |
4667
|
|
|
|
4668
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4669
|
|
|
|
4670
|
|
|
$identificador = '#12 <detCont> - '; |
4671
|
|
|
$this->lacre[count($this->detCont) - 1][] = $this->dom->createElement('lacre'); |
4672
|
|
|
$posicao = (int)count($this->lacre[count($this->detCont) - 1]) - 1; |
4673
|
|
|
|
4674
|
|
|
$this->dom->addChild( |
4675
|
|
|
$this->lacre[count($this->detCont) - 1][$posicao], |
4676
|
|
|
'nLacre', |
4677
|
|
|
$std->nLacre, |
4678
|
|
|
true, |
4679
|
|
|
$identificador . 'Lacre' |
4680
|
|
|
); |
4681
|
|
|
return $this->lacre[count($this->detCont) - 1][$posicao]; |
4682
|
|
|
} |
4683
|
|
|
|
4684
|
|
|
public function taginfDocCont() |
4685
|
|
|
{ |
4686
|
|
|
$this->infDocCont[count($this->detCont) - 1] = $this->dom->createElement('infDoc'); |
4687
|
|
|
return $this->infDocCont; |
4688
|
|
|
} |
4689
|
|
|
|
4690
|
|
|
public function taginfNFCont($std) |
4691
|
|
|
{ |
4692
|
|
|
$possible = [ |
4693
|
|
|
'serie', |
4694
|
|
|
'nDoc', |
4695
|
|
|
'unidRat', |
4696
|
|
|
]; |
4697
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4698
|
|
|
$identificador = '#15 <detCont> <infNF> - '; |
4699
|
|
|
$this->infNFCont[count($this->detCont) - 1][] = $this->dom->createElement('infNF'); |
4700
|
|
|
$posicao = (int)count($this->infNFCont[count($this->detCont) - 1]) - 1; |
4701
|
|
|
|
4702
|
|
|
$this->dom->addChild( |
4703
|
|
|
$this->infNFCont[count($this->detCont) - 1][$posicao], |
4704
|
|
|
'serie', |
4705
|
|
|
$std->serie, |
4706
|
|
|
true, |
4707
|
|
|
$identificador . 'serie' |
4708
|
|
|
); |
4709
|
|
|
|
4710
|
|
|
$this->dom->addChild( |
4711
|
|
|
$this->infNFCont[count($this->detCont) - 1][$posicao], |
4712
|
|
|
'nDoc', |
4713
|
|
|
$std->nDoc, |
4714
|
|
|
true, |
4715
|
|
|
$identificador . 'nDoc' |
4716
|
|
|
); |
4717
|
|
|
|
4718
|
|
|
$this->dom->addChild( |
4719
|
|
|
$this->infNFCont[count($this->detCont) - 1][$posicao], |
4720
|
|
|
'unidRat', |
4721
|
|
|
$std->unidRat, |
4722
|
|
|
false, |
4723
|
|
|
$identificador . 'unidRat' |
4724
|
|
|
); |
4725
|
|
|
|
4726
|
|
|
return $this->infNFCont[count($this->detCont) - 1][$posicao]; |
4727
|
|
|
} |
4728
|
|
|
|
4729
|
|
|
public function taginfNFeCont($std) |
4730
|
|
|
{ |
4731
|
|
|
$possible = [ |
4732
|
|
|
'chave', |
4733
|
|
|
'unidRat', |
4734
|
|
|
]; |
4735
|
|
|
|
4736
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4737
|
|
|
$identificador = '#19 <infNFe> - '; |
4738
|
|
|
$this->infNFeCont[count($this->detCont) - 1][] = $this->dom->createElement('infNFe'); |
4739
|
|
|
$posicao = (int)count($this->infNFeCont[count($this->detCont) - 1]) - 1; |
4740
|
|
|
|
4741
|
|
|
$this->dom->addChild( |
4742
|
|
|
$this->infNFeCont[count($this->detCont) - 1][$posicao], |
4743
|
|
|
'chave', |
4744
|
|
|
$std->chave, |
4745
|
|
|
true, |
4746
|
|
|
$identificador . 'chave' |
4747
|
|
|
); |
4748
|
|
|
|
4749
|
|
|
$this->dom->addChild( |
4750
|
|
|
$this->infNFeCont[count($this->detCont) - 1][$posicao], |
4751
|
|
|
'unidRat', |
4752
|
|
|
$std->unidRat, |
4753
|
|
|
false, |
4754
|
|
|
$identificador . 'unidRat' |
4755
|
|
|
); |
4756
|
|
|
} |
4757
|
|
|
/** |
4758
|
|
|
* Leiaute - Rodoviário |
4759
|
|
|
* Gera as tags para o elemento: "rodo" (Informações do modal Rodoviário) CT-e OS |
4760
|
|
|
* #1 |
4761
|
|
|
* Nível: 0 |
4762
|
|
|
* @return DOMElement|\DOMNode |
4763
|
|
|
*/ |
4764
|
|
|
public function tagrodoOS($std) |
4765
|
|
|
{ |
4766
|
|
|
|
4767
|
|
|
$possible = [ |
4768
|
|
|
'TAF', |
4769
|
|
|
'NroRegEstadual' |
4770
|
|
|
]; |
4771
|
|
|
|
4772
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4773
|
|
|
|
4774
|
|
|
$identificador = '#1 <rodoOS> - '; |
4775
|
|
|
$this->rodo = $this->dom->createElement('rodoOS'); |
4776
|
|
|
$this->dom->addChild( |
4777
|
|
|
$this->rodo, |
4778
|
|
|
'TAF', |
4779
|
|
|
$std->TAF, |
4780
|
|
|
false, |
4781
|
|
|
$identificador . 'Termo de Autorização de Fretamento - TAF' |
4782
|
|
|
); |
4783
|
|
|
$this->dom->addChild( |
4784
|
|
|
$this->rodo, |
4785
|
|
|
'NroRegEstadual', |
4786
|
|
|
$std->NroRegEstadual, |
4787
|
|
|
false, |
4788
|
|
|
$identificador . 'Número do Registro Estadual' |
4789
|
|
|
); |
4790
|
|
|
return $this->rodo; |
4791
|
|
|
} |
4792
|
|
|
|
4793
|
|
|
/** |
4794
|
|
|
* Leiaute - Aéreo |
4795
|
|
|
* Gera as tags para o elemento: "aereo" (Informações do modal Aéreo) |
4796
|
|
|
* @return DOMElement|\DOMNode |
4797
|
|
|
* @author Newton Pasqualini Filho |
4798
|
|
|
* #1 |
4799
|
|
|
* Nível: 0 |
4800
|
|
|
*/ |
4801
|
|
|
public function tagaereo($std) |
4802
|
|
|
{ |
4803
|
|
|
|
4804
|
|
|
$possible = [ |
4805
|
|
|
'nMinu', |
4806
|
|
|
'nOCA', |
4807
|
|
|
'dPrevAereo', |
4808
|
|
|
'natCarga_xDime', |
4809
|
|
|
'natCarga_cInfManu', |
4810
|
|
|
'tarifa_CL', |
4811
|
|
|
'tarifa_cTar', |
4812
|
|
|
'tarifa_vTar' |
4813
|
|
|
]; |
4814
|
|
|
|
4815
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4816
|
|
|
|
4817
|
|
|
$identificador = '#1 <aereo> - '; |
4818
|
|
|
$this->aereo = $this->dom->createElement('aereo'); |
4819
|
|
|
$this->dom->addChild( |
4820
|
|
|
$this->aereo, |
4821
|
|
|
'nMinu', |
4822
|
|
|
$std->nMinu, |
4823
|
|
|
false, |
4824
|
|
|
$identificador . 'Número da Minuta' |
4825
|
|
|
); |
4826
|
|
|
$this->dom->addChild( |
4827
|
|
|
$this->aereo, |
4828
|
|
|
'nOCA', |
4829
|
|
|
$std->nOCA, |
4830
|
|
|
false, |
4831
|
|
|
$identificador . 'Número Operacional do Conhecimento Aéreo' |
4832
|
|
|
); |
4833
|
|
|
$this->dom->addChild( |
4834
|
|
|
$this->aereo, |
4835
|
|
|
'dPrevAereo', |
4836
|
|
|
$std->dPrevAereo, |
4837
|
|
|
true, |
4838
|
|
|
$identificador . 'Data prevista da entrega' |
4839
|
|
|
); |
4840
|
|
|
if (isset($std->natCarga_xDime) || isset($std->natCarga_cInfManu)) { |
4841
|
|
|
$identificador = '#1 <aereo> - <natCarga> - '; |
4842
|
|
|
$natCarga = $this->dom->createElement('natCarga'); |
4843
|
|
|
$this->dom->addChild( |
4844
|
|
|
$natCarga, |
4845
|
|
|
'xDime', |
4846
|
|
|
$std->natCarga_xDime, |
4847
|
|
|
false, |
4848
|
|
|
$identificador . 'Dimensões da carga, formato: 1234x1234x1234 (cm)' |
4849
|
|
|
); |
4850
|
|
|
if (isset($std->natCarga_cInfManu) && !is_array($std->natCarga_cInfManu)) { |
4851
|
|
|
$std->natCarga_cInfManu = [$std->natCarga_cInfManu]; |
4852
|
|
|
} |
4853
|
|
|
$cInfManuX = 0; |
4854
|
|
|
foreach ($std->natCarga_cInfManu as $cInfManu) { |
|
|
|
|
4855
|
|
|
$cInfManuX++; |
4856
|
|
|
$this->dom->addChild( |
4857
|
|
|
$natCarga, |
4858
|
|
|
'cInfManu', |
4859
|
|
|
$cInfManu, |
4860
|
|
|
false, |
4861
|
|
|
$identificador . 'Informação de manuseio, com dois dígitos, pode ter mais de uma ocorrência.' |
4862
|
|
|
); |
4863
|
|
|
} |
4864
|
|
|
$this->aereo->appendChild($natCarga); |
4865
|
|
|
} |
4866
|
|
|
$identificador = '#1 <aereo> - <tarifa> - '; |
4867
|
|
|
$tarifa = $this->dom->createElement('tarifa'); |
4868
|
|
|
$this->dom->addChild( |
4869
|
|
|
$tarifa, |
4870
|
|
|
'CL', |
4871
|
|
|
$std->tarifa_CL, |
4872
|
|
|
true, |
4873
|
|
|
$identificador . 'Classe da tarifa: M - Tarifa Mínima / G - Tarifa Geral / E - Tarifa Específica' |
4874
|
|
|
); |
4875
|
|
|
$this->dom->addChild( |
4876
|
|
|
$tarifa, |
4877
|
|
|
'cTar', |
4878
|
|
|
$std->tarifa_cTar, |
4879
|
|
|
false, |
4880
|
|
|
$identificador . 'Código de três digítos correspondentes à tarifa.' |
4881
|
|
|
); |
4882
|
|
|
$this->dom->addChild( |
4883
|
|
|
$tarifa, |
4884
|
|
|
'vTar', |
4885
|
|
|
$std->tarifa_vTar, |
4886
|
|
|
true, |
4887
|
|
|
$identificador . 'Valor da tarifa. 15 posições, sendo 13 inteiras e 2 decimais.' |
4888
|
|
|
); |
4889
|
|
|
$this->aereo->appendChild($tarifa); |
4890
|
|
|
return $this->aereo; |
4891
|
|
|
} |
4892
|
|
|
|
4893
|
|
|
/** |
4894
|
|
|
* Leiaute - Aéreo |
4895
|
|
|
* Gera as tags para o elemento: "aereo" (Informações do modal Aéreo) |
4896
|
|
|
* #1 |
4897
|
|
|
* Nível: 0 |
4898
|
|
|
* @return DOMElement|\DOMNode |
4899
|
|
|
*/ |
4900
|
|
|
public function tagperi($std) |
4901
|
|
|
{ |
4902
|
|
|
|
4903
|
|
|
$possible = [ |
4904
|
|
|
'nONU', |
4905
|
|
|
'qTotEmb', |
4906
|
|
|
'qTotProd', |
4907
|
|
|
'uniAP' |
4908
|
|
|
]; |
4909
|
|
|
|
4910
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4911
|
|
|
|
4912
|
|
|
$identificador = '#1 <aereo> - <peri> - '; |
4913
|
|
|
$peri = $this->dom->createElement('peri'); |
4914
|
|
|
$this->dom->addChild( |
4915
|
|
|
$peri, |
4916
|
|
|
'nONU', |
4917
|
|
|
$std->nONU, |
4918
|
|
|
true, |
4919
|
|
|
$identificador . 'Número ONU/UN' |
4920
|
|
|
); |
4921
|
|
|
$this->dom->addChild( |
4922
|
|
|
$peri, |
4923
|
|
|
'qTotEmb', |
4924
|
|
|
$std->qTotEmb, |
4925
|
|
|
true, |
4926
|
|
|
$identificador . 'Quantidade total de volumes contendo artigos perigosos' |
4927
|
|
|
); |
4928
|
|
|
$identificador = '#1 <peri> - <infTotAP> - '; |
4929
|
|
|
$infTotAP = $this->dom->createElement('infTotAP'); |
4930
|
|
|
$this->dom->addChild( |
4931
|
|
|
$infTotAP, |
4932
|
|
|
'qTotProd', |
4933
|
|
|
$std->qTotProd, |
4934
|
|
|
false, |
4935
|
|
|
$identificador . 'Quantidade total de artigos perigosos' |
4936
|
|
|
); |
4937
|
|
|
$this->dom->addChild( |
4938
|
|
|
$infTotAP, |
4939
|
|
|
'uniAP', |
4940
|
|
|
$std->uniAP, |
4941
|
|
|
true, |
4942
|
|
|
$identificador . 'Unidade de medida' |
4943
|
|
|
); |
4944
|
|
|
$peri->appendChild($infTotAP); |
4945
|
|
|
$this->peri[] = $peri; |
4946
|
|
|
return $peri; |
4947
|
|
|
} |
4948
|
|
|
|
4949
|
|
|
public function tagferrov($std) |
4950
|
|
|
{ |
4951
|
|
|
|
4952
|
|
|
$possible = [ |
4953
|
|
|
'tpTraf', |
4954
|
|
|
'respFat', |
4955
|
|
|
'ferrEmi', |
4956
|
|
|
'vFrete', |
4957
|
|
|
'chCTeFerroOrigem ', |
4958
|
|
|
'fluxo' |
4959
|
|
|
]; |
4960
|
|
|
|
4961
|
|
|
$std = $this->equilizeParameters($std, $possible); |
4962
|
|
|
|
4963
|
|
|
$identificador = '#1 <ferrov> - '; |
4964
|
|
|
$this->ferrov = $this->dom->createElement('ferrov'); |
4965
|
|
|
$this->dom->addChild( |
4966
|
|
|
$this->ferrov, |
4967
|
|
|
'tpTraf', |
4968
|
|
|
$std->tpTraf, |
4969
|
|
|
true, |
4970
|
|
|
$identificador . 'Tipo de Tráfego' |
4971
|
|
|
); |
4972
|
|
|
$identificador = '#1 <ferrov> - <trafMut> - '; |
4973
|
|
|
$trafMut = $this->dom->createElement('trafMut'); |
4974
|
|
|
$this->dom->addChild( |
4975
|
|
|
$trafMut, |
4976
|
|
|
'respFat', |
4977
|
|
|
$std->respFat, |
4978
|
|
|
true, |
4979
|
|
|
$identificador . 'Responsável pelo Faturamento' |
4980
|
|
|
); |
4981
|
|
|
$this->dom->addChild( |
4982
|
|
|
$trafMut, |
4983
|
|
|
'ferrEmi', |
4984
|
|
|
$std->ferrEmi, |
4985
|
|
|
true, |
4986
|
|
|
$identificador . 'Ferrovia Emitente do CTe' |
4987
|
|
|
); |
4988
|
|
|
$this->dom->addChild( |
4989
|
|
|
$trafMut, |
4990
|
|
|
'vFrete', |
4991
|
|
|
$std->vFrete, |
4992
|
|
|
true, |
4993
|
|
|
$identificador . 'Valor do Frete do Tráfego Mútuo ' |
4994
|
|
|
); |
4995
|
|
|
$this->dom->addChild( |
4996
|
|
|
$trafMut, |
4997
|
|
|
'chCTeFerroOrigem', |
4998
|
|
|
$std->chCTeFerroOrigem, |
4999
|
|
|
false, |
5000
|
|
|
$identificador . 'Chave de acesso do CT-e emitido pelo ferrovia de origem' |
5001
|
|
|
); |
5002
|
|
|
$this->ferrov->appendChild($trafMut); |
5003
|
|
|
$this->dom->addChild( |
5004
|
|
|
$this->ferrov, |
5005
|
|
|
'fluxo', |
5006
|
|
|
$std->fluxo, |
5007
|
|
|
true, |
5008
|
|
|
$identificador . 'Fluxo Ferroviário ' |
5009
|
|
|
); |
5010
|
|
|
} |
5011
|
|
|
|
5012
|
|
|
public function tagferroEnv($std) |
5013
|
|
|
{ |
5014
|
|
|
|
5015
|
|
|
$possible = [ |
5016
|
|
|
'CNPJ', |
5017
|
|
|
'cInt', |
5018
|
|
|
'IE', |
5019
|
|
|
'xNome', |
5020
|
|
|
'xLgr', |
5021
|
|
|
'nro', |
5022
|
|
|
'xCpl', |
5023
|
|
|
'xBairro', |
5024
|
|
|
'cMun', |
5025
|
|
|
'xMun', |
5026
|
|
|
'CEP', |
5027
|
|
|
'UF', |
5028
|
|
|
'fluxo' |
5029
|
|
|
]; |
5030
|
|
|
|
5031
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5032
|
|
|
|
5033
|
|
|
$identificador = '#1 <trafMut> - <ferroEnv> - '; |
5034
|
|
|
$ferroEnv = $this->dom->createElement('ferroEnv'); |
5035
|
|
|
$this->dom->addChild( |
5036
|
|
|
$ferroEnv, |
5037
|
|
|
'CNPJ', |
5038
|
|
|
$std->CNPJ, |
5039
|
|
|
true, |
5040
|
|
|
$identificador . 'Número do CNPJ' |
5041
|
|
|
); |
5042
|
|
|
$this->dom->addChild( |
5043
|
|
|
$ferroEnv, |
5044
|
|
|
'cInt', |
5045
|
|
|
$std->cInt, |
5046
|
|
|
false, |
5047
|
|
|
$identificador . 'Código interno da Ferrovia envolvida' |
5048
|
|
|
); |
5049
|
|
|
$this->dom->addChild( |
5050
|
|
|
$ferroEnv, |
5051
|
|
|
'IE', |
5052
|
|
|
$std->IE, |
5053
|
|
|
false, |
5054
|
|
|
$identificador . 'Inscrição Estadual' |
5055
|
|
|
); |
5056
|
|
|
$this->dom->addChild( |
5057
|
|
|
$ferroEnv, |
5058
|
|
|
'xNome', |
5059
|
|
|
$std->xNome, |
5060
|
|
|
false, |
5061
|
|
|
$identificador . 'Razão Social ou Nome' |
5062
|
|
|
); |
5063
|
|
|
$identificador = '#1 <ferroEnv> - <enderFerro> - '; |
5064
|
|
|
$enderFerro = $this->dom->createElement('enderFerro'); |
5065
|
|
|
$this->dom->addChild( |
5066
|
|
|
$enderFerro, |
5067
|
|
|
'xLgr', |
5068
|
|
|
$std->xLgr, |
5069
|
|
|
true, |
5070
|
|
|
$identificador . 'Logradouro' |
5071
|
|
|
); |
5072
|
|
|
$this->dom->addChild( |
5073
|
|
|
$enderFerro, |
5074
|
|
|
'nro', |
5075
|
|
|
$std->nro, |
5076
|
|
|
false, |
5077
|
|
|
$identificador . 'Número' |
5078
|
|
|
); |
5079
|
|
|
$this->dom->addChild( |
5080
|
|
|
$enderFerro, |
5081
|
|
|
'xCpl', |
5082
|
|
|
$std->xCpl, |
5083
|
|
|
false, |
5084
|
|
|
$identificador . 'Complemento' |
5085
|
|
|
); |
5086
|
|
|
$this->dom->addChild( |
5087
|
|
|
$enderFerro, |
5088
|
|
|
'xBairro', |
5089
|
|
|
$std->xBairro, |
5090
|
|
|
false, |
5091
|
|
|
$identificador . 'Bairro' |
5092
|
|
|
); |
5093
|
|
|
$this->dom->addChild( |
5094
|
|
|
$enderFerro, |
5095
|
|
|
'cMun', |
5096
|
|
|
$std->cMun, |
5097
|
|
|
true, |
5098
|
|
|
$identificador . 'Código do município' |
5099
|
|
|
); |
5100
|
|
|
$this->dom->addChild( |
5101
|
|
|
$enderFerro, |
5102
|
|
|
'xMun', |
5103
|
|
|
$std->xMun, |
5104
|
|
|
true, |
5105
|
|
|
$identificador . 'Nome do município' |
5106
|
|
|
); |
5107
|
|
|
$this->dom->addChild( |
5108
|
|
|
$enderFerro, |
5109
|
|
|
'CEP', |
5110
|
|
|
$std->CEP, |
5111
|
|
|
true, |
5112
|
|
|
$identificador . 'CEP' |
5113
|
|
|
); |
5114
|
|
|
$this->dom->addChild( |
5115
|
|
|
$enderFerro, |
5116
|
|
|
'UF', |
5117
|
|
|
$std->UF, |
5118
|
|
|
true, |
5119
|
|
|
$identificador . 'Sigla da UF' |
5120
|
|
|
); |
5121
|
|
|
$ferroEnv->appendChild($enderFerro); |
5122
|
|
|
$this->ferroEnv[] = $ferroEnv; |
5123
|
|
|
return $ferroEnv; |
5124
|
|
|
} |
5125
|
|
|
|
5126
|
|
|
/** |
5127
|
|
|
* Leiaute - Multimodal |
5128
|
|
|
* Gera as tags do leaiute específico de multimodal |
5129
|
|
|
* @return DOMElement|\DOMNode |
5130
|
|
|
* @author Gabriel Kliemaschewsk Rondon |
5131
|
|
|
* Nivel: 1 |
5132
|
|
|
*/ |
5133
|
|
|
public function tagmultimodal($std) |
5134
|
|
|
{ |
5135
|
|
|
|
5136
|
|
|
$possible = [ |
5137
|
|
|
'COTM', |
5138
|
|
|
'indNegociavel', |
5139
|
|
|
]; |
5140
|
|
|
|
5141
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5142
|
|
|
|
5143
|
|
|
$identificador = '#1 <multimodal> - '; |
5144
|
|
|
$this->multimodal = $this->dom->createElement('multimodal'); |
5145
|
|
|
$this->dom->addChild( |
5146
|
|
|
$this->multimodal, |
5147
|
|
|
'COTM', |
5148
|
|
|
$std->COTM, |
5149
|
|
|
true, |
5150
|
|
|
$identificador . 'COTM' |
5151
|
|
|
); |
5152
|
|
|
$this->dom->addChild( |
5153
|
|
|
$this->multimodal, |
5154
|
|
|
'indNegociavel', |
5155
|
|
|
$std->indNegociavel, |
5156
|
|
|
true, |
5157
|
|
|
$identificador . 'indNegociavel' |
5158
|
|
|
); |
5159
|
|
|
|
5160
|
|
|
return $this->multimodal; |
5161
|
|
|
} |
5162
|
|
|
|
5163
|
|
|
public function tagSegMultimodal($std) |
5164
|
|
|
{ |
5165
|
|
|
|
5166
|
|
|
$possible = [ |
5167
|
|
|
'xSeg', |
5168
|
|
|
'CNPJ', |
5169
|
|
|
'nApol', |
5170
|
|
|
'nAver' |
5171
|
|
|
]; |
5172
|
|
|
|
5173
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5174
|
|
|
|
5175
|
|
|
$identificador = '#4 <multimodal> - '; |
5176
|
|
|
$this->segMultim = $this->dom->createElement('seg'); |
5177
|
|
|
$infSeg = $this->dom->createElement('infSeg'); |
5178
|
|
|
$this->dom->addChild( |
5179
|
|
|
$infSeg, |
5180
|
|
|
'xSeg', |
5181
|
|
|
$std->xSeg, |
5182
|
|
|
true, |
5183
|
|
|
$identificador . 'xSeg' |
5184
|
|
|
); |
5185
|
|
|
$this->dom->addChild( |
5186
|
|
|
$infSeg, |
5187
|
|
|
'CNPJ', |
5188
|
|
|
$std->CNPJ, |
5189
|
|
|
false, |
5190
|
|
|
$identificador . 'indNegociavel' |
5191
|
|
|
); |
5192
|
|
|
$this->segMultim->appendChild($infSeg); |
5193
|
|
|
$this->dom->addChild( |
5194
|
|
|
$this->segMultim, |
5195
|
|
|
'nApol', |
5196
|
|
|
$std->nApol, |
5197
|
|
|
true, |
5198
|
|
|
$identificador . 'nApol' |
5199
|
|
|
); |
5200
|
|
|
$this->dom->addChild( |
5201
|
|
|
$this->segMultim, |
5202
|
|
|
'nAver', |
5203
|
|
|
$std->nAver, |
5204
|
|
|
false, |
5205
|
|
|
$identificador . 'nAver' |
5206
|
|
|
); |
5207
|
|
|
|
5208
|
|
|
return $this->segMultim; |
5209
|
|
|
} |
5210
|
|
|
/** |
5211
|
|
|
* CT-e de substituição |
5212
|
|
|
* @return type |
5213
|
|
|
*/ |
5214
|
|
|
public function taginfCteSub($std) |
5215
|
|
|
{ |
5216
|
|
|
|
5217
|
|
|
$possible = [ |
5218
|
|
|
'chCte', |
5219
|
|
|
'refCteAnu' |
5220
|
|
|
]; |
5221
|
|
|
|
5222
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5223
|
|
|
|
5224
|
|
|
$identificador = '#149 <infCteSub> - '; |
5225
|
|
|
$this->infCteSub = $this->dom->createElement('infCteSub'); |
5226
|
|
|
$this->dom->addChild( |
5227
|
|
|
$this->infCteSub, |
5228
|
|
|
'chCte', |
5229
|
|
|
$std->chCte, |
5230
|
|
|
false, |
5231
|
|
|
"$identificador Chave de acesso do CTe a ser substituído (original)" |
5232
|
|
|
); |
5233
|
|
|
$this->dom->addChild( |
5234
|
|
|
$this->infCteSub, |
5235
|
|
|
'refCteAnu', |
5236
|
|
|
$std->refCteAnu, |
5237
|
|
|
false, |
5238
|
|
|
"$identificador Chave de acesso do CT-e de Anulação" |
5239
|
|
|
); |
5240
|
|
|
return $this->infCteSub; |
5241
|
|
|
} |
5242
|
|
|
|
5243
|
|
|
/** |
5244
|
|
|
* Informações do Serviço Vinculado a Multimodal |
5245
|
|
|
* @return type |
5246
|
|
|
*/ |
5247
|
|
|
public function infCTeMultimodal($std) |
5248
|
|
|
{ |
5249
|
|
|
$possible = [ |
5250
|
|
|
'chCTeMultimodal', |
5251
|
|
|
]; |
5252
|
|
|
|
5253
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5254
|
|
|
|
5255
|
|
|
if (empty($this->infServVinc)) { |
5256
|
|
|
$this->infServVinc = $this->dom->createElement('infServVinc'); |
5257
|
|
|
} |
5258
|
|
|
|
5259
|
|
|
$identificador = '#388 <infCTeMultimodal> - '; |
5260
|
|
|
$infCTeMultimodal = $this->dom->createElement('infCTeMultimodal'); |
5261
|
|
|
$this->dom->addChild( |
5262
|
|
|
$infCTeMultimodal, |
5263
|
|
|
'chCTeMultimodal', |
5264
|
|
|
$std->chCTeMultimodal, |
5265
|
|
|
true, |
5266
|
|
|
$identificador . 'Chave de acesso do CT-e Multimodal ' |
5267
|
|
|
); |
5268
|
|
|
|
5269
|
|
|
$this->infCTeMultimodal[] = $infCTeMultimodal; |
5270
|
|
|
return $infCTeMultimodal; |
5271
|
|
|
} |
5272
|
|
|
|
5273
|
|
|
/** |
5274
|
|
|
* CT-e de substituição - tomaICMS |
5275
|
|
|
* @param type $std |
|
|
|
|
5276
|
|
|
* @return type |
5277
|
|
|
*/ |
5278
|
|
|
public function tagtomaICMS() |
5279
|
|
|
{ |
5280
|
|
|
$this->tomaICMS = $this->dom->createElement('tomaICMS'); |
5281
|
|
|
return $this->tomaICMS; |
5282
|
|
|
} |
5283
|
|
|
|
5284
|
|
|
/** |
5285
|
|
|
* CT-e de substituição - NF-e |
5286
|
|
|
* @param type $std |
5287
|
|
|
* @return type |
5288
|
|
|
*/ |
5289
|
|
|
public function tagrefNFe($std) |
5290
|
|
|
{ |
5291
|
|
|
|
5292
|
|
|
$possible = [ |
5293
|
|
|
'refNFe' |
5294
|
|
|
]; |
5295
|
|
|
|
5296
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5297
|
|
|
|
5298
|
|
|
if (empty($this->tomICMS)) { |
|
|
|
|
5299
|
|
|
$this->tomaICMS = $this->dom->createElement('tomaICMS'); |
5300
|
|
|
} |
5301
|
|
|
$identificador = '#153 <refNFe> - '; |
5302
|
|
|
$this->dom->addChild( |
5303
|
|
|
$this->tomaICMS, |
5304
|
|
|
'refNFe', |
5305
|
|
|
$std->refNFe, |
5306
|
|
|
false, |
5307
|
|
|
"$identificador Chave de acesso da NF-e emitida pelo tomador" |
5308
|
|
|
); |
5309
|
|
|
|
5310
|
|
|
return $this->tomaICMS; |
5311
|
|
|
} |
5312
|
|
|
|
5313
|
|
|
/** |
5314
|
|
|
* CT-e de substituição - NF |
5315
|
|
|
* @param type $std |
5316
|
|
|
* @return type |
5317
|
|
|
*/ |
5318
|
|
|
public function tagrefNF($std) |
5319
|
|
|
{ |
5320
|
|
|
|
5321
|
|
|
$possible = [ |
5322
|
|
|
'CNPJ', |
5323
|
|
|
'CPF', |
5324
|
|
|
'mod', |
5325
|
|
|
'serie', |
5326
|
|
|
'subserie', |
5327
|
|
|
'nro', |
5328
|
|
|
'valor', |
5329
|
|
|
'dEmi' |
5330
|
|
|
]; |
5331
|
|
|
|
5332
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5333
|
|
|
|
5334
|
|
|
$identificador = '#154 <refNFe> - '; |
5335
|
|
|
if (empty($this->tomICMS)) { |
|
|
|
|
5336
|
|
|
$this->tomaICMS = $this->dom->createElement('tomaICMS'); |
5337
|
|
|
} |
5338
|
|
|
$this->refNF = $this->dom->createElement('refNF'); |
5339
|
|
|
if ($std->CNPJ != '') { |
5340
|
|
|
$this->dom->addChild( |
5341
|
|
|
$this->refNF, |
5342
|
|
|
'CNPJ', |
5343
|
|
|
$std->CNPJ, |
5344
|
|
|
true, |
5345
|
|
|
$identificador . 'CNPJ do emitente' |
5346
|
|
|
); |
5347
|
|
|
} elseif ($std->CPF != '') { |
5348
|
|
|
$this->dom->addChild( |
5349
|
|
|
$this->refNF, |
5350
|
|
|
'CPF', |
5351
|
|
|
$std->CPF, |
5352
|
|
|
true, |
5353
|
|
|
$identificador . 'CPF do emitente' |
5354
|
|
|
); |
5355
|
|
|
} |
5356
|
|
|
$this->dom->addChild( |
5357
|
|
|
$this->refNF, |
5358
|
|
|
'mod', |
5359
|
|
|
$std->mod, |
5360
|
|
|
false, |
5361
|
|
|
$identificador . 'Modelo' |
5362
|
|
|
); |
5363
|
|
|
$this->dom->addChild( |
5364
|
|
|
$this->refNF, |
5365
|
|
|
'serie', |
5366
|
|
|
$std->serie, |
5367
|
|
|
false, |
5368
|
|
|
$identificador . 'Série do documento' |
5369
|
|
|
); |
5370
|
|
|
$this->dom->addChild( |
5371
|
|
|
$this->refNF, |
5372
|
|
|
'subserie', |
5373
|
|
|
$std->subserie, |
5374
|
|
|
false, |
5375
|
|
|
$identificador . 'Subserie do documento' |
5376
|
|
|
); |
5377
|
|
|
$this->dom->addChild( |
5378
|
|
|
$this->refNF, |
5379
|
|
|
'nro', |
5380
|
|
|
$std->nro, |
5381
|
|
|
false, |
5382
|
|
|
$identificador . 'Número' |
5383
|
|
|
); |
5384
|
|
|
$this->dom->addChild( |
5385
|
|
|
$this->refNF, |
5386
|
|
|
'valor', |
5387
|
|
|
$std->valor, |
5388
|
|
|
false, |
5389
|
|
|
$identificador . 'Valor' |
5390
|
|
|
); |
5391
|
|
|
$this->dom->addChild( |
5392
|
|
|
$this->refNF, |
5393
|
|
|
'dEmi', |
5394
|
|
|
$std->dEmi, |
5395
|
|
|
false, |
5396
|
|
|
$identificador . 'Emissão' |
5397
|
|
|
); |
5398
|
|
|
$this->tomaICMS->appendChild($this->refNF); |
5399
|
|
|
return $this->tomaICMS; |
5400
|
|
|
} |
5401
|
|
|
|
5402
|
|
|
/** |
5403
|
|
|
* CT-e de substituição - CT-e |
5404
|
|
|
* @param type $std |
5405
|
|
|
* @return type |
5406
|
|
|
*/ |
5407
|
|
|
public function tagrefCTe($std) |
5408
|
|
|
{ |
5409
|
|
|
|
5410
|
|
|
$possible = [ |
5411
|
|
|
'refCte' |
5412
|
|
|
]; |
5413
|
|
|
|
5414
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5415
|
|
|
|
5416
|
|
|
if (empty($this->tomICMS)) { |
|
|
|
|
5417
|
|
|
$this->tomaICMS = $this->dom->createElement('tomaICMS'); |
5418
|
|
|
} |
5419
|
|
|
$identificador = '#163 <refCte> - '; |
5420
|
|
|
$this->dom->addChild( |
5421
|
|
|
$this->tomaICMS, |
5422
|
|
|
'refCte', |
5423
|
|
|
$std->refCte, |
5424
|
|
|
false, |
5425
|
|
|
"$identificador Chave de acesso do CT-e emitida pelo tomador" |
5426
|
|
|
); |
5427
|
|
|
|
5428
|
|
|
return $this->tomaICMS; |
5429
|
|
|
} |
5430
|
|
|
|
5431
|
|
|
/** |
5432
|
|
|
* Leiaute - Rodoviário |
5433
|
|
|
* Gera as tags para o elemento: "veic" (Dados dos Veículos) |
5434
|
|
|
* #21 |
5435
|
|
|
* Nível: 1 |
5436
|
|
|
* @return mixed |
5437
|
|
|
*/ |
5438
|
|
|
public function tagveicCTeOS($std) |
5439
|
|
|
{ |
5440
|
|
|
|
5441
|
|
|
$possible = [ |
5442
|
|
|
'placa', |
5443
|
|
|
'RENAVAM', |
5444
|
|
|
'CNPJ', |
5445
|
|
|
'CPF', |
5446
|
|
|
'TAF', |
5447
|
|
|
'NroRegEstadual', |
5448
|
|
|
'xNome', |
5449
|
|
|
'IE', |
5450
|
|
|
'ufProp', |
5451
|
|
|
'tpProp', |
5452
|
|
|
'uf' |
5453
|
|
|
]; |
5454
|
|
|
|
5455
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5456
|
|
|
|
5457
|
|
|
$identificador = '#21 <veic> - '; |
5458
|
|
|
$this->veic = $this->dom->createElement('veic'); |
5459
|
|
|
$this->dom->addChild( |
5460
|
|
|
$this->veic, |
5461
|
|
|
'placa', |
5462
|
|
|
$std->placa, |
5463
|
|
|
false, |
5464
|
|
|
$identificador . 'Placa do veículo' |
5465
|
|
|
); |
5466
|
|
|
$this->dom->addChild( |
5467
|
|
|
$this->veic, |
5468
|
|
|
'RENAVAM', |
5469
|
|
|
$std->RENAVAM, |
5470
|
|
|
false, |
5471
|
|
|
$identificador . 'RENAVAM do veículo' |
5472
|
|
|
); |
5473
|
|
|
if ($std->xNome != '') { // CASO FOR VEICULO DE TERCEIRO |
5474
|
|
|
$this->prop = $this->dom->createElement('prop'); |
5475
|
|
|
if ($std->CNPJ != '') { |
5476
|
|
|
$this->dom->addChild( |
5477
|
|
|
$this->prop, |
5478
|
|
|
'CNPJ', |
5479
|
|
|
$std->CNPJ, |
5480
|
|
|
true, |
5481
|
|
|
$identificador . 'CNPJ do proprietario' |
5482
|
|
|
); |
5483
|
|
|
} elseif ($std->CPF != '') { |
5484
|
|
|
$this->dom->addChild( |
5485
|
|
|
$this->prop, |
5486
|
|
|
'CPF', |
5487
|
|
|
$std->CPF, |
5488
|
|
|
true, |
5489
|
|
|
$identificador . 'CPF do proprietario' |
5490
|
|
|
); |
5491
|
|
|
} |
5492
|
|
|
if ($std->taf != '') { |
5493
|
|
|
$this->dom->addChild( |
5494
|
|
|
$this->prop, |
5495
|
|
|
'TAF', |
5496
|
|
|
$std->taf, |
5497
|
|
|
false, |
5498
|
|
|
$identificador . 'TAF' |
5499
|
|
|
); |
5500
|
|
|
} else { |
5501
|
|
|
$this->dom->addChild( |
5502
|
|
|
$this->prop, |
5503
|
|
|
'NroRegEstadual', |
5504
|
|
|
$std->nroRegEstadual, |
5505
|
|
|
false, |
5506
|
|
|
$identificador . 'Número do Registro Estadual' |
5507
|
|
|
); |
5508
|
|
|
} |
5509
|
|
|
$this->dom->addChild( |
5510
|
|
|
$this->prop, |
5511
|
|
|
'xNome', |
5512
|
|
|
$std->xNome, |
5513
|
|
|
true, |
5514
|
|
|
$identificador . 'Nome do proprietario' |
5515
|
|
|
); |
5516
|
|
|
$this->dom->addChild( |
5517
|
|
|
$this->prop, |
5518
|
|
|
'IE', |
5519
|
|
|
Strings::onlyNumbers($std->IE), |
5520
|
|
|
false, |
5521
|
|
|
$identificador . 'IE do proprietario' |
5522
|
|
|
); |
5523
|
|
|
$this->dom->addChild( |
5524
|
|
|
$this->prop, |
5525
|
|
|
'UF', |
5526
|
|
|
$std->ufProp, |
5527
|
|
|
true, |
5528
|
|
|
$identificador . 'UF do proprietario' |
5529
|
|
|
); |
5530
|
|
|
$this->dom->addChild( |
5531
|
|
|
$this->prop, |
5532
|
|
|
'tpProp', |
5533
|
|
|
$std->tpProp, |
5534
|
|
|
true, |
5535
|
|
|
$identificador . 'Tipo Proprietário' |
5536
|
|
|
); |
5537
|
|
|
$this->dom->appChild($this->veic, $this->prop, 'Falta tag "prop"'); |
5538
|
|
|
} |
5539
|
|
|
$this->dom->addChild( |
5540
|
|
|
$this->veic, |
5541
|
|
|
'UF', |
5542
|
|
|
$std->uf, |
5543
|
|
|
true, |
5544
|
|
|
$identificador . 'UF em que veículo está licenciado' |
5545
|
|
|
); |
5546
|
|
|
return $this->veic; |
5547
|
|
|
} |
5548
|
|
|
|
5549
|
|
|
public function infFretamento($std) |
5550
|
|
|
{ |
5551
|
|
|
|
5552
|
|
|
$possible = [ |
5553
|
|
|
'tpFretamento', |
5554
|
|
|
'dhViagem' |
5555
|
|
|
]; |
5556
|
|
|
|
5557
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5558
|
|
|
|
5559
|
|
|
$identificador = '#21 <infFretamento> - '; |
5560
|
|
|
$this->infFretamento = $this->dom->createElement('infFretamento'); |
5561
|
|
|
$this->dom->addChild( |
5562
|
|
|
$this->infFretamento, |
5563
|
|
|
'tpFretamento', |
5564
|
|
|
$std->tpFretamento, |
5565
|
|
|
true, |
5566
|
|
|
$identificador . 'Tipo do Fretamento de Pessoas' |
5567
|
|
|
); |
5568
|
|
|
$this->dom->addChild( |
5569
|
|
|
$this->infFretamento, |
5570
|
|
|
'dhViagem', |
5571
|
|
|
$std->dhViagem, |
5572
|
|
|
false, |
5573
|
|
|
$identificador . 'Data e hora da viagem' |
5574
|
|
|
); |
5575
|
|
|
return $this->infFretamento; |
5576
|
|
|
} |
5577
|
|
|
|
5578
|
|
|
/** |
5579
|
|
|
* Gera as tags para o elemento: "infCteComp" (Detalhamento do CT-e complementado) |
5580
|
|
|
* #410 |
5581
|
|
|
* Nível: 1 |
5582
|
|
|
* @return DOMElement|\DOMNode |
5583
|
|
|
*/ |
5584
|
|
|
public function taginfCTeComp($std) |
5585
|
|
|
{ |
5586
|
|
|
|
5587
|
|
|
$possible = [ |
5588
|
|
|
'chCTe' |
5589
|
|
|
]; |
5590
|
|
|
|
5591
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5592
|
|
|
|
5593
|
|
|
$identificador = '#410 <infCteComp> - '; |
5594
|
|
|
$this->infCteComp = $this->dom->createElement('infCteComp'); |
5595
|
|
|
$this->dom->addChild( |
5596
|
|
|
$this->infCteComp, |
5597
|
|
|
'chCTe', |
5598
|
|
|
$std->chCTe, |
5599
|
|
|
true, |
5600
|
|
|
$identificador . ' Chave do CT-e complementado' |
5601
|
|
|
); |
5602
|
|
|
return $this->infCteComp; |
5603
|
|
|
} |
5604
|
|
|
|
5605
|
|
|
/** |
5606
|
|
|
* Gera as tags para o elemento: "infCteAnu" (Detalhamento do CT-e de Anulação) |
5607
|
|
|
* #411 |
5608
|
|
|
* Nível: 1 |
5609
|
|
|
* @return DOMElement|\DOMNode |
5610
|
|
|
*/ |
5611
|
|
|
public function taginfCteAnu($std) |
5612
|
|
|
{ |
5613
|
|
|
|
5614
|
|
|
$possible = [ |
5615
|
|
|
'chCte', |
5616
|
|
|
'dEmi' |
5617
|
|
|
]; |
5618
|
|
|
|
5619
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5620
|
|
|
|
5621
|
|
|
$identificador = '#411 <infCteAnu> - '; |
5622
|
|
|
$this->infCteAnu = $this->dom->createElement('infCteAnu'); |
5623
|
|
|
$this->dom->addChild( |
5624
|
|
|
$this->infCteAnu, |
5625
|
|
|
'chCte', |
5626
|
|
|
$std->chCte, |
5627
|
|
|
true, |
5628
|
|
|
$identificador . ' Chave do CT-e anulado' |
5629
|
|
|
); |
5630
|
|
|
$this->dom->addChild( |
5631
|
|
|
$this->infCteAnu, |
5632
|
|
|
'dEmi', |
5633
|
|
|
$std->dEmi, |
5634
|
|
|
true, |
5635
|
|
|
$identificador . ' Data de Emissão do CT-e anulado' |
5636
|
|
|
); |
5637
|
|
|
return $this->infCteAnu; |
5638
|
|
|
} |
5639
|
|
|
|
5640
|
|
|
/** |
5641
|
|
|
* Gera as tags para o elemento: "autXML" (Autorizados para download do XML) |
5642
|
|
|
* #396 |
5643
|
|
|
* Nível: 1 |
5644
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "autXML" |
5645
|
|
|
* |
5646
|
|
|
* @return boolean |
5647
|
|
|
*/ |
5648
|
|
|
public function tagveicNovos($std) |
5649
|
|
|
{ |
5650
|
|
|
|
5651
|
|
|
$possible = [ |
5652
|
|
|
'chassi', |
5653
|
|
|
'cCor', |
5654
|
|
|
'xCor', |
5655
|
|
|
'cMod', |
5656
|
|
|
'vUnit', |
5657
|
|
|
'vFrete' |
5658
|
|
|
]; |
5659
|
|
|
|
5660
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5661
|
|
|
|
5662
|
|
|
$identificador = '#396 <veicNovos> - '; |
5663
|
|
|
$veicNovos = $this->dom->createElement('veicNovos'); |
5664
|
|
|
$this->dom->addChild( |
5665
|
|
|
$veicNovos, |
5666
|
|
|
'chassi', |
5667
|
|
|
$std->chassi, |
5668
|
|
|
true, |
5669
|
|
|
$identificador . 'Chassi do veículo ' |
5670
|
|
|
); |
5671
|
|
|
$this->dom->addChild( |
5672
|
|
|
$veicNovos, |
5673
|
|
|
'cCor', |
5674
|
|
|
$std->cCor, |
5675
|
|
|
true, |
5676
|
|
|
$identificador . 'Cor do veículo ' |
5677
|
|
|
); |
5678
|
|
|
$this->dom->addChild( |
5679
|
|
|
$veicNovos, |
5680
|
|
|
'xCor', |
5681
|
|
|
$std->xCor, |
5682
|
|
|
true, |
5683
|
|
|
$identificador . 'Descrição da cor ' |
5684
|
|
|
); |
5685
|
|
|
$this->dom->addChild( |
5686
|
|
|
$veicNovos, |
5687
|
|
|
'cMod', |
5688
|
|
|
$std->cMod, |
5689
|
|
|
true, |
5690
|
|
|
$identificador . 'Código Marca Modelo ' |
5691
|
|
|
); |
5692
|
|
|
$this->dom->addChild( |
5693
|
|
|
$veicNovos, |
5694
|
|
|
'vUnit', |
5695
|
|
|
$std->vUnit, |
5696
|
|
|
true, |
5697
|
|
|
$identificador . 'Valor Unitário do Veículo ' |
5698
|
|
|
); |
5699
|
|
|
$this->dom->addChild( |
5700
|
|
|
$veicNovos, |
5701
|
|
|
'vFrete', |
5702
|
|
|
$std->vFrete, |
5703
|
|
|
true, |
5704
|
|
|
$identificador . 'Frete Unitário ' |
5705
|
|
|
); |
5706
|
|
|
$this->veicNovos[] = $veicNovos; |
5707
|
|
|
return $veicNovos; |
5708
|
|
|
} |
5709
|
|
|
|
5710
|
|
|
/** |
5711
|
|
|
* Gera as tags para o elemento: "autXML" (Autorizados para download do XML) |
5712
|
|
|
* #396 |
5713
|
|
|
* Nível: 1 |
5714
|
|
|
* Os parâmetros para esta função são todos os elementos da tag "autXML" |
5715
|
|
|
* |
5716
|
|
|
* @return boolean |
5717
|
|
|
*/ |
5718
|
|
|
public function tagautXML($std) |
5719
|
|
|
{ |
5720
|
|
|
|
5721
|
|
|
$possible = [ |
5722
|
|
|
'CNPJ', |
5723
|
|
|
'CPF' |
5724
|
|
|
]; |
5725
|
|
|
|
5726
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5727
|
|
|
|
5728
|
|
|
$identificador = '#396 <autXML> - '; |
5729
|
|
|
$autXML = $this->dom->createElement('autXML'); |
5730
|
|
|
if (isset($std->CNPJ) && $std->CNPJ != '') { |
5731
|
|
|
$this->dom->addChild( |
5732
|
|
|
$autXML, |
5733
|
|
|
'CNPJ', |
5734
|
|
|
$std->CNPJ, |
5735
|
|
|
true, |
5736
|
|
|
$identificador . 'CNPJ do Cliente Autorizado' |
5737
|
|
|
); |
5738
|
|
|
} elseif (isset($std->CPF) && $std->CPF != '') { |
5739
|
|
|
$this->dom->addChild( |
5740
|
|
|
$autXML, |
5741
|
|
|
'CPF', |
5742
|
|
|
$std->CPF, |
5743
|
|
|
true, |
5744
|
|
|
$identificador . 'CPF do Cliente Autorizado' |
5745
|
|
|
); |
5746
|
|
|
} |
5747
|
|
|
$this->autXML[] = $autXML; |
5748
|
|
|
return $autXML; |
5749
|
|
|
} |
5750
|
|
|
|
5751
|
|
|
/** |
5752
|
|
|
* #359 |
5753
|
|
|
* tag CTe/infCTe/cobr (opcional) |
5754
|
|
|
* Depende de fat |
5755
|
|
|
*/ |
5756
|
|
|
protected function buildCobr() |
5757
|
|
|
{ |
5758
|
|
|
if (empty($this->cobr)) { |
5759
|
|
|
$this->cobr = $this->dom->createElement("cobr"); |
5760
|
|
|
} |
5761
|
|
|
} |
5762
|
|
|
|
5763
|
|
|
/** |
5764
|
|
|
* #360 |
5765
|
|
|
* tag CTe/infCTe/cobr/fat (opcional) |
5766
|
|
|
* @param stdClass $std |
5767
|
|
|
* @return DOMElement |
5768
|
|
|
*/ |
5769
|
|
|
public function tagfat(stdClass $std) |
5770
|
|
|
{ |
5771
|
|
|
|
5772
|
|
|
$possible = [ |
5773
|
|
|
'nFat', |
5774
|
|
|
'vOrig', |
5775
|
|
|
'vDesc', |
5776
|
|
|
'vLiq' |
5777
|
|
|
]; |
5778
|
|
|
|
5779
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5780
|
|
|
|
5781
|
|
|
$this->buildCobr(); |
5782
|
|
|
$fat = $this->dom->createElement("fat"); |
5783
|
|
|
$this->dom->addChild( |
5784
|
|
|
$fat, |
5785
|
|
|
"nFat", |
5786
|
|
|
$std->nFat, |
5787
|
|
|
false, |
5788
|
|
|
"Número da Fatura" |
5789
|
|
|
); |
5790
|
|
|
$this->dom->addChild( |
5791
|
|
|
$fat, |
5792
|
|
|
"vOrig", |
5793
|
|
|
$std->vOrig, |
5794
|
|
|
false, |
5795
|
|
|
"Valor Original da Fatura" |
5796
|
|
|
); |
5797
|
|
|
if ($std->vDesc > 0) { |
5798
|
|
|
$this->dom->addChild( |
5799
|
|
|
$fat, |
5800
|
|
|
"vDesc", |
5801
|
|
|
$std->vDesc, |
5802
|
|
|
false, |
5803
|
|
|
"Valor do desconto" |
5804
|
|
|
); |
5805
|
|
|
} |
5806
|
|
|
$this->dom->addChild( |
5807
|
|
|
$fat, |
5808
|
|
|
"vLiq", |
5809
|
|
|
$std->vLiq, |
5810
|
|
|
false, |
5811
|
|
|
"Valor Líquido da Fatura" |
5812
|
|
|
); |
5813
|
|
|
$this->dom->appChild($this->cobr, $fat); |
5814
|
|
|
return $fat; |
5815
|
|
|
} |
5816
|
|
|
|
5817
|
|
|
/** |
5818
|
|
|
* #365 |
5819
|
|
|
* tag CTe/infCTe/cobr/fat/dup (opcional) |
5820
|
|
|
* É necessário criar a tag fat antes de criar as duplicatas |
5821
|
|
|
* @param stdClass $std |
5822
|
|
|
* @return DOMElement |
5823
|
|
|
*/ |
5824
|
|
|
public function tagdup(stdClass $std) |
5825
|
|
|
{ |
5826
|
|
|
|
5827
|
|
|
$possible = [ |
5828
|
|
|
'nDup', |
5829
|
|
|
'dVenc', |
5830
|
|
|
'vDup' |
5831
|
|
|
]; |
5832
|
|
|
|
5833
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5834
|
|
|
|
5835
|
|
|
$this->buildCobr(); |
5836
|
|
|
$dup = $this->dom->createElement("dup"); |
5837
|
|
|
$this->dom->addChild( |
5838
|
|
|
$dup, |
5839
|
|
|
"nDup", |
5840
|
|
|
$std->nDup, |
5841
|
|
|
false, |
5842
|
|
|
"Número da Duplicata" |
5843
|
|
|
); |
5844
|
|
|
$this->dom->addChild( |
5845
|
|
|
$dup, |
5846
|
|
|
"dVenc", |
5847
|
|
|
$std->dVenc, |
5848
|
|
|
false, |
5849
|
|
|
"Data de vencimento" |
5850
|
|
|
); |
5851
|
|
|
$this->dom->addChild( |
5852
|
|
|
$dup, |
5853
|
|
|
"vDup", |
5854
|
|
|
$std->vDup, |
5855
|
|
|
true, |
5856
|
|
|
"Valor da duplicata" |
5857
|
|
|
); |
5858
|
|
|
$this->dom->appChild($this->cobr, $dup, 'Inclui duplicata na tag cobr'); |
5859
|
|
|
return $dup; |
5860
|
|
|
} |
5861
|
|
|
|
5862
|
|
|
/** |
5863
|
|
|
* Informações do Responsável técnico |
5864
|
|
|
* tag CTe/infCte/infRespTec (opcional) |
5865
|
|
|
* @return DOMElement |
5866
|
|
|
* @throws RuntimeException |
5867
|
|
|
*/ |
5868
|
|
|
public function taginfRespTec(stdClass $std) |
5869
|
|
|
{ |
5870
|
|
|
|
5871
|
|
|
$possible = [ |
5872
|
|
|
'CNPJ', |
5873
|
|
|
'xContato', |
5874
|
|
|
'email', |
5875
|
|
|
'fone', |
5876
|
|
|
'idCSRT', |
5877
|
|
|
'CSRT' |
5878
|
|
|
]; |
5879
|
|
|
|
5880
|
|
|
$std = $this->equilizeParameters($std, $possible); |
5881
|
|
|
|
5882
|
|
|
$infRespTec = $this->dom->createElement("infRespTec"); |
5883
|
|
|
$this->dom->addChild( |
5884
|
|
|
$infRespTec, |
5885
|
|
|
"CNPJ", |
5886
|
|
|
$std->CNPJ, |
5887
|
|
|
true, |
5888
|
|
|
"Informar o CNPJ da pessoa jurídica responsável pelo sistema " |
5889
|
|
|
. "utilizado na emissão do documento fiscal eletrônico" |
5890
|
|
|
); |
5891
|
|
|
$this->dom->addChild( |
5892
|
|
|
$infRespTec, |
5893
|
|
|
"xContato", |
5894
|
|
|
$std->xContato, |
5895
|
|
|
true, |
5896
|
|
|
"Informar o nome da pessoa a ser contatada na empresa desenvolvedora " |
5897
|
|
|
. "do sistema utilizado na emissão do documento fiscal eletrônico" |
5898
|
|
|
); |
5899
|
|
|
$this->dom->addChild( |
5900
|
|
|
$infRespTec, |
5901
|
|
|
"email", |
5902
|
|
|
$std->email, |
5903
|
|
|
true, |
5904
|
|
|
"Informar o e-mail da pessoa a ser contatada na empresa " |
5905
|
|
|
. "desenvolvedora do sistema." |
5906
|
|
|
); |
5907
|
|
|
$this->dom->addChild( |
5908
|
|
|
$infRespTec, |
5909
|
|
|
"fone", |
5910
|
|
|
$std->fone, |
5911
|
|
|
true, |
5912
|
|
|
"Informar o telefone da pessoa a ser contatada na empresa " |
5913
|
|
|
. "desenvolvedora do sistema." |
5914
|
|
|
); |
5915
|
|
|
if (!empty($std->CSRT) && !empty($std->idCSRT)) { |
5916
|
|
|
$this->csrt = $std->CSRT; |
|
|
|
|
5917
|
|
|
$this->dom->addChild( |
5918
|
|
|
$infRespTec, |
5919
|
|
|
"idCSRT", |
5920
|
|
|
$std->idCSRT, |
5921
|
|
|
true, |
5922
|
|
|
"Identificador do CSRT utilizado para montar o hash do CSRT" |
5923
|
|
|
); |
5924
|
|
|
$this->dom->addChild( |
5925
|
|
|
$infRespTec, |
5926
|
|
|
"hashCSRT", |
5927
|
|
|
$this->hashCSRT($std->CSRT), |
|
|
|
|
5928
|
|
|
true, |
5929
|
|
|
"hash do CSRT" |
5930
|
|
|
); |
5931
|
|
|
} |
5932
|
|
|
$this->infRespTec = $infRespTec; |
5933
|
|
|
return $infRespTec; |
5934
|
|
|
} |
5935
|
|
|
|
5936
|
|
|
protected function checkCTeKey(Dom $dom) |
5937
|
|
|
{ |
5938
|
|
|
$infCTe = $dom->getElementsByTagName("infCte")->item(0); |
5939
|
|
|
$ide = $dom->getElementsByTagName("ide")->item(0); |
5940
|
|
|
$emit = $dom->getElementsByTagName("emit")->item(0); |
5941
|
|
|
$cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue; |
5942
|
|
|
$dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue; |
5943
|
|
|
$cnpj = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
5944
|
|
|
$mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue; |
5945
|
|
|
$serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue; |
5946
|
|
|
$nNF = $ide->getElementsByTagName('nCT')->item(0)->nodeValue; |
5947
|
|
|
$tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue; |
5948
|
|
|
$cCT = $ide->getElementsByTagName('cCT')->item(0)->nodeValue; |
5949
|
|
|
$chave = str_replace('CTe', '', $infCTe->getAttribute("Id")); |
5950
|
|
|
|
5951
|
|
|
$dt = new \DateTime($dhEmi); |
5952
|
|
|
|
5953
|
|
|
$chaveMontada = Keys::build( |
5954
|
|
|
$cUF, |
5955
|
|
|
$dt->format('y'), |
5956
|
|
|
$dt->format('m'), |
5957
|
|
|
$cnpj, |
5958
|
|
|
$mod, |
5959
|
|
|
$serie, |
5960
|
|
|
$nNF, |
5961
|
|
|
$tpEmis, |
5962
|
|
|
$cCT |
5963
|
|
|
); |
5964
|
|
|
//caso a chave contida no CTe esteja errada |
5965
|
|
|
//substituir a chave |
5966
|
|
|
if ($chaveMontada != $chave) { |
5967
|
|
|
$ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chaveMontada, -1); |
5968
|
|
|
$infCTe = $dom->getElementsByTagName("infCte")->item(0); |
5969
|
|
|
$infCTe->setAttribute("Id", "CTe" . $chaveMontada); |
5970
|
|
|
$this->chCTe = $chaveMontada; |
5971
|
|
|
} |
5972
|
|
|
} |
5973
|
|
|
|
5974
|
|
|
/** |
5975
|
|
|
* Retorna os erros detectados |
5976
|
|
|
* @return array |
5977
|
|
|
*/ |
5978
|
|
|
public function getErrors() |
5979
|
|
|
{ |
5980
|
|
|
return $this->errors; |
5981
|
|
|
} |
5982
|
|
|
|
5983
|
|
|
/** |
5984
|
|
|
* Includes missing or unsupported properties in stdClass |
5985
|
|
|
* Replace all unsuported chars |
5986
|
|
|
* |
5987
|
|
|
* @param stdClass $std |
5988
|
|
|
* @param array $possible |
5989
|
|
|
* @return stdClass |
5990
|
|
|
*/ |
5991
|
|
|
private function equilizeParameters(stdClass $std, $possible) |
5992
|
|
|
{ |
5993
|
|
|
return Strings::equilizeParameters($std, $possible, $this->replaceAccentedChars); |
5994
|
|
|
} |
5995
|
|
|
} |
5996
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..