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