These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace NFePHP\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 NFePHP\Common\Keys; |
||
17 | use NFePHP\Common\DOMImproved as Dom; |
||
18 | use NFePHP\Common\Strings; |
||
19 | use stdClass; |
||
20 | use RuntimeException; |
||
21 | use DOMElement; |
||
22 | use DateTime; |
||
23 | |||
24 | class Make |
||
25 | { |
||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | public $errors = []; |
||
30 | |||
31 | /** |
||
32 | * versao |
||
33 | * numero da versão do xml da CTe |
||
34 | * @var string |
||
35 | */ |
||
36 | public $versao = '3.00'; |
||
37 | /** |
||
38 | * mod |
||
39 | * modelo da CTe 57 |
||
40 | * @var integer |
||
41 | */ |
||
42 | public $mod = 57; |
||
43 | /** |
||
44 | * chave da MDFe |
||
45 | * @var string |
||
46 | */ |
||
47 | public $chCTe = ''; |
||
48 | /** |
||
49 | * xml |
||
50 | * String com o xml do documento fiscal montado |
||
51 | * @var string |
||
52 | */ |
||
53 | public $xml = ''; |
||
54 | /** |
||
55 | * dom |
||
56 | * Variável onde será montado o xml do documento fiscal |
||
57 | * @var \NFePHP\Common\Dom\Dom |
||
58 | */ |
||
59 | public $dom; |
||
60 | /** |
||
61 | * tpAmb |
||
62 | * tipo de ambiente |
||
63 | * @var string |
||
64 | */ |
||
65 | public $tpAmb = '2'; |
||
66 | /** |
||
67 | * Modal do Cte |
||
68 | * @var integer |
||
69 | */ |
||
70 | private $modal = 0; |
||
71 | /** |
||
72 | * Tag CTe |
||
73 | * @var \DOMNode |
||
74 | */ |
||
75 | private $CTe = ''; |
||
76 | /** |
||
77 | * Informações do CT-e |
||
78 | * @var \DOMNode |
||
79 | */ |
||
80 | private $infCte = ''; |
||
81 | /** |
||
82 | * Identificação do CT-e |
||
83 | * @var \DOMNode |
||
84 | */ |
||
85 | private $ide = ''; |
||
86 | /** |
||
87 | * Percurso do CT-e OS |
||
88 | * @var \DOMNode |
||
89 | */ |
||
90 | private $infPercurso = []; |
||
91 | /** |
||
92 | * Tipo do Serviço |
||
93 | * @var integer |
||
94 | */ |
||
95 | private $tpServ = 0; |
||
96 | /** |
||
97 | * Indicador do "papel" do tomador do serviço no CT-e |
||
98 | * @var \DOMNode |
||
99 | */ |
||
100 | private $toma3 = ''; |
||
101 | /** |
||
102 | * Indicador do "papel" do tomador do serviço no CT-e |
||
103 | * @var \DOMNode |
||
104 | */ |
||
105 | private $toma4 = ''; |
||
106 | /** |
||
107 | * Indicador do "papel" do tomador do serviço no CT-e OS |
||
108 | * @var \DOMNode |
||
109 | */ |
||
110 | private $toma = ''; |
||
111 | /** |
||
112 | * Dados do endereço |
||
113 | * @var \DOMNode |
||
114 | */ |
||
115 | private $enderToma = ''; |
||
116 | /** |
||
117 | * Dados complementares do CT-e para fins operacionais ou comerciais |
||
118 | * @var \DOMNode |
||
119 | */ |
||
120 | private $compl = ''; |
||
121 | /** |
||
122 | * Previsão do fluxo da carga |
||
123 | * @var \DOMNode |
||
124 | */ |
||
125 | private $fluxo = ''; |
||
126 | /** |
||
127 | * Passagem |
||
128 | * @var array |
||
129 | */ |
||
130 | private $pass = array(); |
||
131 | /** |
||
132 | * Informações ref. a previsão de entrega |
||
133 | * @var \DOMNode |
||
134 | */ |
||
135 | private $entrega = ''; |
||
136 | /** |
||
137 | * Entrega sem data definida |
||
138 | * @var \DOMNode |
||
139 | */ |
||
140 | private $semData = ''; |
||
141 | /** |
||
142 | * Entrega com data definida |
||
143 | * @var \DOMNode |
||
144 | */ |
||
145 | private $comData = ''; |
||
146 | /** |
||
147 | * Entrega no período definido |
||
148 | * @var \DOMNode |
||
149 | */ |
||
150 | private $noPeriodo = ''; |
||
151 | /** |
||
152 | * Entrega sem hora definida |
||
153 | * @var \DOMNode |
||
154 | */ |
||
155 | private $semHora = ''; |
||
156 | /** |
||
157 | * Entrega com hora definida |
||
158 | * @var \DOMNode |
||
159 | */ |
||
160 | private $comHora = ''; |
||
161 | /** |
||
162 | * Entrega no intervalo de horário definido |
||
163 | * @var \DOMNode |
||
164 | */ |
||
165 | private $noInter = ''; |
||
166 | /** |
||
167 | * Campo de uso livre do contribuinte |
||
168 | * @var array |
||
169 | */ |
||
170 | private $obsCont = array(); |
||
171 | /** |
||
172 | * Campo de uso livre do contribuinte |
||
173 | * @var array |
||
174 | */ |
||
175 | private $obsFisco = array(); |
||
176 | /** |
||
177 | * Identificação do Emitente do CT-e |
||
178 | * @var \DOMNode |
||
179 | */ |
||
180 | private $emit = ''; |
||
181 | /** |
||
182 | * Endereço do emitente |
||
183 | * @var \DOMNode |
||
184 | */ |
||
185 | private $enderEmit = ''; |
||
186 | /** |
||
187 | * Informações do Remetente das mercadorias transportadas pelo CT-e |
||
188 | * @var \DOMNode |
||
189 | */ |
||
190 | private $rem = ''; |
||
191 | /** |
||
192 | * Dados do endereço |
||
193 | * @var \DOMNode |
||
194 | */ |
||
195 | private $enderReme = ''; |
||
196 | /** |
||
197 | * Informações do Expedidor da Carga |
||
198 | * @var \DOMNode |
||
199 | */ |
||
200 | private $exped = ''; |
||
201 | /** |
||
202 | * Dados do endereço |
||
203 | * @var \DOMNode |
||
204 | */ |
||
205 | private $enderExped = ''; |
||
206 | /** |
||
207 | * Informações do Recebedor da Carga |
||
208 | * @var \DOMNode |
||
209 | */ |
||
210 | private $receb = ''; |
||
211 | /** |
||
212 | * Dados do endereço |
||
213 | * @var \DOMNode |
||
214 | */ |
||
215 | private $enderReceb = ''; |
||
216 | /** |
||
217 | * Informações do Destinatário do CT-e |
||
218 | * @var \DOMNode |
||
219 | */ |
||
220 | private $dest = ''; |
||
221 | /** |
||
222 | * Dados do endereço |
||
223 | * @var \DOMNode |
||
224 | */ |
||
225 | private $enderDest = ''; |
||
226 | /** |
||
227 | * Valores da Prestação de Serviço |
||
228 | * @var \DOMNode |
||
229 | */ |
||
230 | private $vPrest = ''; |
||
231 | /** |
||
232 | * Componentes do Valor da Prestação |
||
233 | * @var array |
||
234 | */ |
||
235 | private $comp = array(); |
||
236 | /** |
||
237 | * Informações relativas aos Impostos |
||
238 | * @var \DOMNode |
||
239 | */ |
||
240 | private $imp = ''; |
||
241 | /** |
||
242 | * Informações relativas ao ICMS |
||
243 | * @var \DOMNode |
||
244 | */ |
||
245 | private $ICMS = ''; |
||
246 | /** |
||
247 | * Prestação sujeito à tributação normal do ICMS |
||
248 | * @var \DOMNode |
||
249 | */ |
||
250 | private $ICMS00 = ''; |
||
251 | /** |
||
252 | * Prestação sujeito à tributação com redução de BC do ICMS |
||
253 | * @var \DOMNode |
||
254 | */ |
||
255 | private $ICMS20 = ''; |
||
256 | /** |
||
257 | * ICMS Isento, não Tributado ou diferido |
||
258 | * @var \DOMNode |
||
259 | */ |
||
260 | private $ICMS45 = ''; |
||
261 | /** |
||
262 | * Tributação pelo ICMS60 - ICMS cobrado por substituição tributária. |
||
263 | * Responsabilidade do recolhimento do ICMS atribuído ao tomador ou 3º por ST |
||
264 | * @var \DOMNode |
||
265 | */ |
||
266 | private $ICMS60 = ''; |
||
267 | /** |
||
268 | * ICMS Outros |
||
269 | * @var \DOMNode |
||
270 | */ |
||
271 | private $ICMS90 = ''; |
||
272 | /** |
||
273 | * ICMS devido à UF de origem da prestação, quando diferente da UF do emitente |
||
274 | * @var \DOMNode |
||
275 | */ |
||
276 | private $ICMSOutraUF = ''; |
||
277 | /** |
||
278 | * Simples Nacional |
||
279 | * @var \DOMNode |
||
280 | */ |
||
281 | private $ICMSSN = ''; |
||
282 | /** |
||
283 | * Observações adicionais da CT-e |
||
284 | * @var string |
||
285 | */ |
||
286 | private $xObs = ''; |
||
287 | /** |
||
288 | * Grupo de informações do CT-e Normal e Substituto |
||
289 | * @var \DOMNode |
||
290 | */ |
||
291 | private $infCTeNorm = ''; |
||
292 | /** |
||
293 | * Informações da Carga do CT-e |
||
294 | * @var \DOMNode |
||
295 | */ |
||
296 | private $infCarga = ''; |
||
297 | /** |
||
298 | * Informações da Prestação do Serviço |
||
299 | * @var \DOMNode |
||
300 | */ |
||
301 | private $infServico = ''; |
||
302 | /** |
||
303 | * Informações de quantidades da Carga do CT-e |
||
304 | * @var \DOMNode |
||
305 | */ |
||
306 | private $infQ = array(); |
||
307 | /** |
||
308 | * Informações dos documentos transportados pelo CT-e Opcional para Redespacho Intermediario |
||
309 | * e Serviço vinculado a multimodal. |
||
310 | * @var \DOMNode |
||
311 | */ |
||
312 | private $infDoc = array(); |
||
313 | /** |
||
314 | * Informações das NF |
||
315 | * @var array |
||
316 | */ |
||
317 | private $infNF = array(); |
||
318 | /** |
||
319 | * Informações das NF-e |
||
320 | * @var array |
||
321 | */ |
||
322 | private $infNFe = array(); |
||
323 | /** |
||
324 | * Informações dos demais documentos |
||
325 | * @var array |
||
326 | */ |
||
327 | private $infOutros = array(); |
||
328 | /** |
||
329 | * Informações dos demais documentos |
||
330 | * @var array |
||
331 | */ |
||
332 | private $infDocRef = array(); |
||
333 | /** |
||
334 | * Informações das Unidades de Transporte (Carreta/Reboque/Vagão) |
||
335 | * @var array |
||
336 | */ |
||
337 | private $infUnidTransp = array(); |
||
338 | /** |
||
339 | * Lacres das Unidades de Transporte |
||
340 | * @var array |
||
341 | */ |
||
342 | private $lacUnidTransp = array(); |
||
343 | /** |
||
344 | * Informações das Unidades de Carga (Containeres/ULD/Outros) |
||
345 | * @var array |
||
346 | */ |
||
347 | private $infUnidCarga = array(); |
||
348 | /** |
||
349 | * Lacres das Unidades de Carga |
||
350 | * @var array |
||
351 | */ |
||
352 | private $lacUnidCarga = array(); |
||
353 | /** |
||
354 | * Documentos de Transporte Anterior |
||
355 | * @var \DOMNode |
||
356 | */ |
||
357 | private $docAnt = array(); |
||
358 | /** |
||
359 | * Emissor do documento anterior |
||
360 | * @var array |
||
361 | */ |
||
362 | private $emiDocAnt = array(); |
||
363 | /** |
||
364 | * Informações de identificação dos documentos de Transporte Anterior |
||
365 | * @var array |
||
366 | */ |
||
367 | private $idDocAnt = array(); |
||
368 | /** |
||
369 | * Documentos de transporte anterior em papel |
||
370 | * @var array |
||
371 | */ |
||
372 | private $idDocAntPap = array(); |
||
373 | /** |
||
374 | * Documentos de transporte anterior eletrônicos |
||
375 | * @var array |
||
376 | */ |
||
377 | private $idDocAntEle = array(); |
||
378 | /** |
||
379 | * Informações de Seguro da Carga |
||
380 | * @var array |
||
381 | */ |
||
382 | private $seg = array(); |
||
383 | /** |
||
384 | * Informações do modal |
||
385 | * @var \DOMNode |
||
386 | */ |
||
387 | private $infModal = ''; |
||
388 | /** |
||
389 | * Preenchido quando for transporte de produtos classificados pela ONU como perigosos. |
||
390 | * @var array |
||
391 | */ |
||
392 | private $peri = array(); |
||
393 | /** |
||
394 | * informações dos veículos transportados |
||
395 | * @var array |
||
396 | */ |
||
397 | private $veicNovos = array(); |
||
398 | /** |
||
399 | * Dados da cobrança do CT-e |
||
400 | * @var \DOMNode |
||
401 | */ |
||
402 | private $cobr = ''; |
||
403 | /** |
||
404 | * Dados da fatura |
||
405 | * @var \DOMNode |
||
406 | */ |
||
407 | private $fat = ''; |
||
408 | /** |
||
409 | * Dados das duplicatas |
||
410 | * @var array |
||
411 | */ |
||
412 | private $dup = array(); |
||
413 | /** |
||
414 | * Informações do CT-e de substituição |
||
415 | * @var \DOMNode |
||
416 | */ |
||
417 | private $infCteSub = ''; |
||
418 | /** |
||
419 | * Tomador é contribuinte do ICMS |
||
420 | * @var \DOMNode |
||
421 | */ |
||
422 | private $tomaICMS = ''; |
||
423 | /** |
||
424 | * Informação da NFe emitida pelo Tomador |
||
425 | * @var \DOMNode |
||
426 | */ |
||
427 | private $refNFe = ''; |
||
428 | /** |
||
429 | * Informação da NF ou CT emitido pelo Tomador |
||
430 | * @var \DOMNode |
||
431 | */ |
||
432 | private $refNF = ''; |
||
433 | /** |
||
434 | * Informação do CTe emitido pelo Tomador |
||
435 | * @var \DOMNode |
||
436 | */ |
||
437 | private $refCte = ''; |
||
438 | /** |
||
439 | * Informação da NF ou CT emitido pelo Tomador |
||
440 | * @var \DOMNode |
||
441 | */ |
||
442 | private $infCteComp = ''; |
||
443 | /** |
||
444 | * Detalhamento do CT-e do tipo Anulação |
||
445 | * @var \DOMNode |
||
446 | */ |
||
447 | private $infCteAnu = ''; |
||
448 | /** |
||
449 | * Informações do modal Rodoviário |
||
450 | * @var \DOMNode |
||
451 | */ |
||
452 | private $rodo = ''; |
||
453 | /** |
||
454 | * Informações do modal Aéreo |
||
455 | * @var \DOMNode |
||
456 | */ |
||
457 | private $aereo = ''; |
||
458 | /** |
||
459 | * Informações do modal Aéreo -> Dados da Carga |
||
460 | * @var \DOMNode |
||
461 | */ |
||
462 | private $natCarga = ''; |
||
463 | /** |
||
464 | * Informações do modal Aéreo -> Tarifas |
||
465 | * @var \DOMNode |
||
466 | */ |
||
467 | private $tarifa = ''; |
||
468 | /** |
||
469 | * Ordens de Coleta associados |
||
470 | * @var array |
||
471 | */ |
||
472 | private $occ = array(); |
||
473 | /** |
||
474 | * @var \DOMNode |
||
475 | */ |
||
476 | private $emiOcc = array(); |
||
477 | /** |
||
478 | * Informações de Vale Pedágio |
||
479 | * @var array |
||
480 | */ |
||
481 | private $valePed = array(); |
||
482 | /** |
||
483 | * Dados dos Veículos |
||
484 | * @var array |
||
485 | */ |
||
486 | private $veic = array(); |
||
487 | /** |
||
488 | * Proprietários do Veículo. Só preenchido quando o veículo não pertencer à empresa emitente do CT-e |
||
489 | * @var array |
||
490 | */ |
||
491 | private $prop = array(); |
||
492 | /** |
||
493 | * Autorizados para download do XML do DF-e |
||
494 | * @var array |
||
495 | */ |
||
496 | private $autXML = array(); |
||
497 | /** |
||
498 | * Dados do Fretamento - CTe-OS |
||
499 | * @var |
||
500 | */ |
||
501 | private $infFretamento; |
||
502 | /** |
||
503 | * @var DOMElement |
||
504 | */ |
||
505 | protected $infRespTec; |
||
506 | |||
507 | public function __construct() |
||
508 | 1 | { |
|
509 | $this->dom = new Dom('1.0', 'UTF-8'); |
||
510 | 1 | $this->dom->preserveWhiteSpace = false; |
|
511 | 1 | $this->dom->formatOutput = false; |
|
512 | 1 | } |
|
513 | 1 | ||
514 | /** |
||
515 | * Returns xml string and assembly it is necessary |
||
516 | * @return string |
||
517 | */ |
||
518 | public function getXML() |
||
519 | { |
||
520 | if (empty($this->xml)) { |
||
521 | $this->montaCTe(); |
||
522 | } |
||
523 | return $this->xml; |
||
524 | } |
||
525 | |||
526 | /** |
||
527 | * Retorns the key number of NFe (44 digits) |
||
528 | * @return string |
||
529 | */ |
||
530 | public function getChave() |
||
531 | { |
||
532 | return $this->chCTe; |
||
533 | } |
||
534 | |||
535 | /** |
||
536 | * Returns the model of CTe 57 or 67 |
||
537 | * @return int |
||
538 | */ |
||
539 | public function getModelo() |
||
540 | { |
||
541 | return $this->mod; |
||
542 | } |
||
543 | |||
544 | /** |
||
545 | * Call method of xml assembly. For compatibility only. |
||
546 | * @return boolean |
||
547 | */ |
||
548 | public function montaCTe() |
||
549 | { |
||
550 | return $this->monta(); |
||
551 | } |
||
552 | |||
553 | /** |
||
554 | * Monta o arquivo XML usando as tag's já preenchidas |
||
555 | * |
||
556 | * @return bool |
||
557 | */ |
||
558 | public function monta() |
||
559 | { |
||
560 | $this->errors = $this->dom->errors; |
||
561 | if (count($this->errors) > 0) { |
||
562 | return false; |
||
563 | } |
||
564 | if ($this->mod == 57) { |
||
565 | $this->buildCTe(); |
||
566 | } else { |
||
567 | return $this->montaCTeOS(); |
||
568 | } |
||
569 | if ($this->toma3 != '') { |
||
570 | $this->dom->appChild($this->ide, $this->toma3, 'Falta tag "ide"'); |
||
571 | } else { |
||
572 | $this->dom->appChild($this->ide, $this->toma4, 'Falta tag "ide"'); |
||
573 | } |
||
574 | $this->dom->appChild($this->infCte, $this->ide, 'Falta tag "infCte"'); |
||
575 | if ($this->compl != '') { |
||
576 | if ($this->fluxo != '') { |
||
577 | foreach ($this->pass as $pass) { |
||
578 | $this->dom->appChild($this->fluxo, $pass, 'Falta tag "fluxo"'); |
||
579 | } |
||
580 | $this->dom->appChild($this->compl, $this->fluxo, 'Falta tag "infCte"'); |
||
581 | } |
||
582 | if ($this->semData != '') { |
||
583 | $this->tagEntrega(); |
||
584 | $this->dom->appChild($this->entrega, $this->semData, 'Falta tag "Entrega"'); |
||
585 | } |
||
586 | if ($this->comData != '') { |
||
587 | $this->tagEntrega(); |
||
588 | $this->dom->appChild($this->entrega, $this->comData, 'Falta tag "Entrega"'); |
||
589 | } |
||
590 | if ($this->noPeriodo != '') { |
||
591 | $this->tagEntrega(); |
||
592 | $this->dom->appChild($this->entrega, $this->noPeriodo, 'Falta tag "Entrega"'); |
||
593 | } |
||
594 | if ($this->semHora != '') { |
||
595 | $this->tagEntrega(); |
||
596 | $this->dom->appChild($this->entrega, $this->semHora, 'Falta tag "Entrega"'); |
||
597 | } |
||
598 | if ($this->comHora != '') { |
||
599 | $this->tagEntrega(); |
||
600 | $this->dom->appChild($this->entrega, $this->comHora, 'Falta tag "Entrega"'); |
||
601 | } |
||
602 | if ($this->noInter != '') { |
||
603 | $this->tagEntrega(); |
||
604 | $this->dom->appChild($this->entrega, $this->noInter, 'Falta tag "Entrega"'); |
||
605 | } |
||
606 | foreach ($this->obsCont as $obsCont) { |
||
607 | $this->dom->appChild($this->compl, $obsCont, 'Falta tag "compl"'); |
||
608 | } |
||
609 | foreach ($this->obsFisco as $obsFisco) { |
||
610 | $this->dom->appChild($this->compl, $obsFisco, 'Falta tag "compl"'); |
||
611 | } |
||
612 | $this->dom->appChild($this->infCte, $this->compl, 'Falta tag "infCte"'); |
||
613 | } |
||
614 | $this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "emit"'); |
||
615 | $this->dom->appChild($this->infCte, $this->emit, 'Falta tag "infCte"'); |
||
616 | if ($this->rem != '') { |
||
617 | $this->dom->appChild($this->infCte, $this->rem, 'Falta tag "infCte"'); |
||
618 | } |
||
619 | if ($this->exped != '') { |
||
620 | $this->dom->appChild($this->infCte, $this->exped, 'Falta tag "infCte"'); |
||
621 | } |
||
622 | if ($this->receb != '') { |
||
623 | $this->dom->appChild($this->infCte, $this->receb, 'Falta tag "infCte"'); |
||
624 | } |
||
625 | if ($this->dest != '') { |
||
626 | $this->dom->appChild($this->infCte, $this->dest, 'Falta tag "infCte"'); |
||
627 | } |
||
628 | foreach ($this->comp as $comp) { |
||
629 | $this->dom->appChild($this->vPrest, $comp, 'Falta tag "vPrest"'); |
||
630 | } |
||
631 | $this->dom->appChild($this->infCte, $this->vPrest, 'Falta tag "infCte"'); |
||
632 | $this->dom->appChild($this->infCte, $this->imp, 'Falta tag "imp"'); |
||
633 | if ($this->infCteComp != '') { // Caso seja um CTe tipo complemento de valores |
||
634 | $this->dom->appChild($this->infCte, $this->infCteComp, 'Falta tag "infCteComp"'); |
||
635 | } |
||
636 | if ($this->infCteAnu != '') { // Caso seja um CTe tipo anulação |
||
637 | $this->dom->appChild($this->infCte, $this->infCteAnu, 'Falta tag "infCteAnu"'); |
||
638 | } |
||
639 | if ($this->infCTeNorm != '') { // Caso seja um CTe tipo normal |
||
640 | $this->dom->appChild($this->infCte, $this->infCTeNorm, 'Falta tag "infCTeNorm"'); |
||
641 | $this->dom->appChild($this->infCTeNorm, $this->infCarga, 'Falta tag "infCarga"'); |
||
642 | foreach ($this->infQ as $infQ) { |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
643 | $this->dom->appChild($this->infCarga, $infQ, 'Falta tag "infQ"'); |
||
644 | } |
||
645 | foreach ($this->infNF as $infNF) { |
||
646 | $this->dom->appChild($this->infDoc, $infNF, 'Falta tag "infNF"'); |
||
647 | } |
||
648 | foreach ($this->infNFe as $infNFe) { |
||
649 | $this->dom->appChild($this->infDoc, $infNFe, 'Falta tag "infNFe"'); |
||
650 | } |
||
651 | foreach ($this->infOutros as $infOutros) { |
||
652 | $this->dom->appChild($this->infDoc, $infOutros, 'Falta tag "infOutros"'); |
||
653 | } |
||
654 | $this->dom->appChild($this->infCTeNorm, $this->infDoc, 'Falta tag "infCTeNorm"'); |
||
655 | if ($this->idDocAntEle != []) { //Caso tenha CT-es Anteriores viculados |
||
656 | $this->dom->appChild($this->infCTeNorm, $this->docAnt, 'Falta tag "docAnt"'); |
||
657 | foreach ($this->emiDocAnt as $emiDocAnt) { |
||
658 | $this->dom->appChild($this->docAnt, $emiDocAnt, 'Falta tag "emiDocAnt"'); |
||
659 | $this->dom->appChild($emiDocAnt, $this->idDocAnt, 'Falta tag "idDocAnt"'); |
||
660 | foreach ($this->idDocAntEle as $idDocAntEle) { |
||
661 | $this->dom->appChild($this->idDocAnt, $idDocAntEle, 'Falta tag "emiDocAnt"'); |
||
662 | } |
||
663 | } |
||
664 | } |
||
665 | foreach ($this->seg as $seg) { |
||
666 | $this->dom->appChild($this->infCTeNorm, $seg, 'Falta tag "seg"'); |
||
667 | } |
||
668 | $this->dom->appChild($this->infCTeNorm, $this->infModal, 'Falta tag "infModal"'); |
||
669 | if ($this->modal == '01') { |
||
670 | $this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "rodo"'); |
||
671 | } elseif ($this->modal == '02') { |
||
672 | $this->dom->appChild($this->infModal, $this->aereo, 'Falta tag "aereo"'); |
||
673 | } else { |
||
674 | throw new Exception('Modal não informado ou não suportado.'); |
||
675 | } |
||
676 | } |
||
677 | foreach ($this->veicNovos as $veicNovos) { |
||
678 | $this->dom->appChild($this->infCte, $veicNovos, 'Falta tag "infCte"'); |
||
679 | } |
||
680 | if ($this->cobr != '') { |
||
681 | $this->dom->appChild($this->infCte, $this->cobr, 'Falta tag "infCte"'); |
||
682 | } |
||
683 | foreach ($this->autXML as $autXML) { |
||
684 | $this->dom->appChild($this->infCte, $autXML, 'Falta tag "infCte"'); |
||
685 | } |
||
686 | $this->dom->appChild($this->infCte, $this->infRespTec, 'Falta tag "infCte"'); |
||
687 | //[1] tag infCTe |
||
688 | $this->dom->appChild($this->CTe, $this->infCte, 'Falta tag "CTe"'); |
||
689 | //[0] tag CTe |
||
690 | $this->dom->appendChild($this->CTe); |
||
691 | // testa da chave |
||
692 | $this->checkCTeKey($this->dom); |
||
693 | $this->xml = $this->dom->saveXML(); |
||
694 | return true; |
||
695 | } |
||
696 | |||
697 | /** |
||
698 | * Monta o arquivo XML usando as tag's já preenchidas |
||
699 | * |
||
700 | * @return bool |
||
701 | */ |
||
702 | public function montaCTeOS() |
||
703 | { |
||
704 | $this->errors = $this->dom->errors; |
||
705 | if (count($this->errors) > 0) { |
||
706 | return false; |
||
707 | } |
||
708 | $this->buildCTeOS(); |
||
709 | if ($this->infPercurso != '') { |
||
710 | foreach ($this->infPercurso as $perc) { |
||
711 | $this->dom->appChild($this->ide, $perc, 'Falta tag "infPercurso"'); |
||
712 | } |
||
713 | } |
||
714 | $this->dom->appChild($this->infCte, $this->ide, 'Falta tag "infCte"'); |
||
715 | if ($this->compl != '') { |
||
716 | $this->dom->appChild($this->infCte, $this->compl, 'Falta tag "infCte"'); |
||
717 | } |
||
718 | $this->dom->appChild($this->emit, $this->enderEmit, 'Falta tag "emit"'); |
||
719 | $this->dom->appChild($this->infCte, $this->emit, 'Falta tag "infCte"'); |
||
720 | if ($this->toma != '') { |
||
721 | $this->dom->appChild($this->infCte, $this->toma, 'Falta tag "infCte"'); |
||
722 | } |
||
723 | foreach ($this->comp as $comp) { |
||
724 | $this->dom->appChild($this->vPrest, $comp, 'Falta tag "vPrest"'); |
||
725 | } |
||
726 | $this->dom->appChild($this->infCte, $this->vPrest, 'Falta tag "infCte"'); |
||
727 | $this->dom->appChild($this->infCte, $this->imp, 'Falta tag "imp"'); |
||
728 | if ($this->infCteComp != '') { // Caso seja um CTe tipo complemento de valores |
||
729 | $this->dom->appChild($this->infCte, $this->infCteComp, 'Falta tag "infCteComp"'); |
||
730 | } elseif ($this->infCteAnu != '') { // Caso seja um CTe tipo anulação |
||
731 | $this->dom->appChild($this->infCte, $this->infCteAnu, 'Falta tag "infCteAnu"'); |
||
732 | } elseif ($this->infCTeNorm != '') { // Caso seja um CTe tipo normal |
||
733 | $this->dom->appChild($this->infCte, $this->infCTeNorm, 'Falta tag "infCTeNorm"'); |
||
734 | $this->dom->appChild($this->infCTeNorm, $this->infServico, 'Falta tag "infServico"'); |
||
735 | foreach ($this->infDocRef as $infDocRef) { |
||
736 | $this->dom->appChild($this->infCTeNorm, $infDocRef, 'Falta tag "infDocRef"'); |
||
737 | } |
||
738 | foreach ($this->seg as $seg) { |
||
739 | $this->dom->appChild($this->infCTeNorm, $seg, 'Falta tag "seg"'); |
||
740 | } |
||
741 | if ($this->infModal != '') { |
||
742 | $this->dom->appChild($this->infCTeNorm, $this->infModal, 'Falta tag "infModal"'); |
||
743 | $this->dom->appChild($this->rodo, $this->veic, 'Falta tag "veic"'); |
||
744 | $this->dom->appChild($this->rodo, $this->infFretamento, 'Falta tag "infFretamento"'); |
||
745 | $this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "rodo"'); |
||
746 | } |
||
747 | } |
||
748 | if ($this->cobr != '') { |
||
749 | $this->dom->appChild($this->infCte, $this->cobr, 'Falta tag "infCte"'); |
||
750 | } |
||
751 | foreach ($this->autXML as $autXML) { |
||
752 | $this->dom->appChild($this->infCte, $autXML, 'Falta tag "infCte"'); |
||
753 | } |
||
754 | $this->dom->appChild($this->infCte, $this->infRespTec, 'Falta tag "infCte"'); |
||
755 | $this->dom->appChild($this->CTe, $this->infCte, 'Falta tag "CTe"'); |
||
756 | $this->dom->appendChild($this->CTe); |
||
757 | // testa da chave |
||
758 | $this->checkCTeKey($this->dom); |
||
759 | $this->xml = $this->dom->saveXML(); |
||
760 | return true; |
||
761 | } |
||
762 | |||
763 | /** |
||
764 | * Gera o grupo básico: Informações do CT-e |
||
765 | * #1 |
||
766 | * Nível: 0 |
||
767 | * @param stdClass $std |
||
768 | * @return \DOMElement |
||
769 | */ |
||
770 | public function taginfCTe($std) |
||
771 | { |
||
772 | $chave = preg_replace('/[^0-9]/', '', $std->Id); |
||
773 | $this->infCte = $this->dom->createElement('infCte'); |
||
774 | $this->infCte->setAttribute('Id', 'CTe' . $chave); |
||
775 | $this->infCte->setAttribute('versao', $std->versao); |
||
776 | return $this->infCte; |
||
777 | } |
||
778 | |||
779 | /** |
||
780 | 1 | * Gera as tags para o elemento: Identificação do CT-e |
|
781 | * #4 |
||
782 | 1 | * Nível: 1 |
|
783 | 1 | * @param stdClass $std |
|
784 | 1 | * @return DOMElement|\DOMNode |
|
785 | 1 | */ |
|
786 | 1 | public function tagide($std) |
|
787 | { |
||
788 | $this->tpAmb = $std->tpAmb; |
||
789 | $this->mod = $std->mod; |
||
790 | $identificador = '#4 <ide> - '; |
||
791 | $this->ide = $this->dom->createElement('ide'); |
||
792 | $this->dom->addChild( |
||
793 | $this->ide, |
||
794 | 'cUF', |
||
795 | $std->cUF, |
||
796 | true, |
||
797 | $identificador . 'Código da UF do emitente do CT-e' |
||
798 | ); |
||
799 | $this->dom->addChild( |
||
800 | $this->ide, |
||
801 | 'cCT', |
||
802 | str_pad($std->cCT, 8, '0', STR_PAD_LEFT), |
||
803 | true, |
||
804 | $identificador . 'Código numérico que compõe a Chave de Acesso' |
||
805 | ); |
||
806 | $this->dom->addChild( |
||
807 | $this->ide, |
||
808 | 'CFOP', |
||
809 | $std->CFOP, |
||
810 | true, |
||
811 | $identificador . 'Código Fiscal de Operações e Prestações' |
||
812 | ); |
||
813 | $this->dom->addChild( |
||
814 | $this->ide, |
||
815 | 'natOp', |
||
816 | Strings::replaceSpecialsChars(substr(trim($std->natOp), 0, 60)), |
||
817 | true, |
||
818 | $identificador . 'Natureza da Operação' |
||
819 | ); |
||
820 | $this->dom->addChild( |
||
821 | $this->ide, |
||
822 | 'mod', |
||
823 | $std->mod, |
||
824 | true, |
||
825 | $identificador . 'Modelo do documento fiscal' |
||
826 | ); |
||
827 | $this->dom->addChild( |
||
828 | $this->ide, |
||
829 | 'serie', |
||
830 | $std->serie, |
||
831 | true, |
||
832 | $identificador . 'Série do CT-e' |
||
833 | ); |
||
834 | $this->dom->addChild( |
||
835 | $this->ide, |
||
836 | 'nCT', |
||
837 | $std->nCT, |
||
838 | true, |
||
839 | $identificador . 'Número do CT-e' |
||
840 | ); |
||
841 | $this->dom->addChild( |
||
842 | $this->ide, |
||
843 | 'dhEmi', |
||
844 | $std->dhEmi, |
||
845 | true, |
||
846 | $identificador . 'Data e hora de emissão do CT-e' |
||
847 | ); |
||
848 | $this->dom->addChild( |
||
849 | $this->ide, |
||
850 | 'tpImp', |
||
851 | $std->tpImp, |
||
852 | true, |
||
853 | $identificador . 'Formato de impressão do DACTE' |
||
854 | ); |
||
855 | $this->dom->addChild( |
||
856 | $this->ide, |
||
857 | 'tpEmis', |
||
858 | $std->tpEmis, |
||
859 | true, |
||
860 | $identificador . 'Forma de emissão do CT-e' |
||
861 | ); |
||
862 | $this->dom->addChild( |
||
863 | $this->ide, |
||
864 | 'cDV', |
||
865 | $std->cDV, |
||
866 | false, |
||
867 | $identificador . 'Digito Verificador da chave de acesso do CT-e' |
||
868 | ); |
||
869 | $this->dom->addChild( |
||
870 | $this->ide, |
||
871 | 'tpAmb', |
||
872 | $std->tpAmb, |
||
873 | true, |
||
874 | $identificador . 'Tipo do Ambiente' |
||
875 | ); |
||
876 | $this->dom->addChild( |
||
877 | $this->ide, |
||
878 | 'tpCTe', |
||
879 | $std->tpCTe, |
||
880 | true, |
||
881 | $identificador . 'Tipo do CT-e' |
||
882 | ); |
||
883 | $this->dom->addChild( |
||
884 | $this->ide, |
||
885 | 'procEmi', |
||
886 | $std->procEmi, |
||
887 | true, |
||
888 | $identificador . 'Identificador do processo de emissão do CT-e' |
||
889 | ); |
||
890 | $this->dom->addChild( |
||
891 | $this->ide, |
||
892 | 'verProc', |
||
893 | $std->verProc, |
||
894 | true, |
||
895 | $identificador . 'Versão do processo de emissão' |
||
896 | ); |
||
897 | if ($this->mod == 57) { |
||
898 | $this->dom->addChild( |
||
899 | $this->ide, |
||
900 | 'indGlobalizado', |
||
901 | $std->indGlobalizado, |
||
902 | false, |
||
903 | $identificador . 'Indicador de CT-e Globalizado' |
||
904 | ); |
||
905 | } |
||
906 | $this->dom->addChild( |
||
907 | $this->ide, |
||
908 | 'cMunEnv', |
||
909 | $std->cMunEnv, |
||
910 | true, |
||
911 | $identificador . 'Código do Município de envio do CT-e (de onde o documento foi transmitido)' |
||
912 | ); |
||
913 | $this->dom->addChild( |
||
914 | $this->ide, |
||
915 | 'xMunEnv', |
||
916 | $std->xMunEnv, |
||
917 | true, |
||
918 | $identificador . 'Nome do Município de envio do CT-e (de onde o documento foi transmitido)' |
||
919 | ); |
||
920 | $this->dom->addChild( |
||
921 | $this->ide, |
||
922 | 'UFEnv', |
||
923 | $std->UFEnv, |
||
924 | true, |
||
925 | $identificador . 'Sigla da UF de envio do CT-e (de onde o documento foi transmitido)' |
||
926 | ); |
||
927 | $this->dom->addChild( |
||
928 | $this->ide, |
||
929 | 'modal', |
||
930 | $std->modal, |
||
931 | true, |
||
932 | $identificador . 'Modal' |
||
933 | ); |
||
934 | $this->modal = $std->modal; |
||
935 | $this->dom->addChild( |
||
936 | $this->ide, |
||
937 | 'tpServ', |
||
938 | $std->tpServ, |
||
939 | true, |
||
940 | $identificador . 'Tipo do Serviço' |
||
941 | ); |
||
942 | if ($this->mod == 67) { |
||
943 | $this->dom->addChild( |
||
944 | $this->ide, |
||
945 | 'indIEToma', |
||
946 | $std->indIEToma, |
||
947 | true, |
||
948 | $identificador . 'Indicador do papel do tomador na prestação do serviço' |
||
949 | ); |
||
950 | } |
||
951 | $this->dom->addChild( |
||
952 | $this->ide, |
||
953 | 'cMunIni', |
||
954 | $std->cMunIni, |
||
955 | true, |
||
956 | $identificador . 'Nome do Município do início da prestação' |
||
957 | ); |
||
958 | $this->dom->addChild( |
||
959 | $this->ide, |
||
960 | 'xMunIni', |
||
961 | $std->xMunIni, |
||
962 | true, |
||
963 | $identificador . 'Nome do Município do início da prestação' |
||
964 | ); |
||
965 | $this->dom->addChild( |
||
966 | $this->ide, |
||
967 | 'UFIni', |
||
968 | $std->UFIni, |
||
969 | true, |
||
970 | $identificador . 'UF do início da prestação' |
||
971 | ); |
||
972 | $this->dom->addChild( |
||
973 | $this->ide, |
||
974 | 'cMunFim', |
||
975 | $std->cMunFim, |
||
976 | true, |
||
977 | $identificador . 'Código do Município de término da prestação' |
||
978 | ); |
||
979 | $this->dom->addChild( |
||
980 | $this->ide, |
||
981 | 'xMunFim', |
||
982 | $std->xMunFim, |
||
983 | true, |
||
984 | $identificador . 'Nome do Município do término da prestação' |
||
985 | ); |
||
986 | $this->dom->addChild( |
||
987 | $this->ide, |
||
988 | 'UFFim', |
||
989 | $std->UFFim, |
||
990 | true, |
||
991 | $identificador . 'UF do término da prestação' |
||
992 | ); |
||
993 | if ($this->mod == 57) { |
||
994 | $this->dom->addChild( |
||
995 | $this->ide, |
||
996 | 'retira', |
||
997 | $std->retira, |
||
998 | true, |
||
999 | $identificador . 'Indicador se o Recebedor retira no Aeroporto, Filial, Porto ou Estação de Destino' |
||
1000 | ); |
||
1001 | $this->dom->addChild( |
||
1002 | $this->ide, |
||
1003 | 'xDetRetira', |
||
1004 | $std->xDetRetira, |
||
1005 | false, |
||
1006 | $identificador . 'Detalhes do retira' |
||
1007 | ); |
||
1008 | $this->dom->addChild( |
||
1009 | $this->ide, |
||
1010 | 'indIEToma', |
||
1011 | $std->indIEToma, |
||
1012 | true, |
||
1013 | $identificador . 'Indicador do papel do tomador na prestação do serviço' |
||
1014 | ); |
||
1015 | } |
||
1016 | $this->dom->addChild( |
||
1017 | $this->ide, |
||
1018 | 'dhCont', |
||
1019 | $std->dhCont, |
||
1020 | false, |
||
1021 | $identificador . 'Data e Hora da entrada em contingência' |
||
1022 | ); |
||
1023 | $this->dom->addChild( |
||
1024 | $this->ide, |
||
1025 | 'xJust', |
||
1026 | Strings::replaceSpecialsChars(substr(trim($std->xJust), 0, 256)), |
||
1027 | false, |
||
1028 | $identificador . 'Justificativa da entrada em contingência' |
||
1029 | ); |
||
1030 | $this->tpServ = $std->tpServ; |
||
1031 | return $this->ide; |
||
1032 | } |
||
1033 | |||
1034 | public function taginfPercurso($std) |
||
1035 | { |
||
1036 | $identificador = '#4 <infPercurso> - '; |
||
1037 | $this->infPercurso[] = $this->dom->createElement('infPercurso'); |
||
1038 | $posicao = (int) count($this->infPercurso) - 1; |
||
1039 | $this->dom->addChild( |
||
1040 | $this->infPercurso[$posicao], |
||
1041 | 'UFPer', |
||
1042 | $std->uf, |
||
1043 | true, |
||
1044 | $identificador . 'Código da UF do percurso' |
||
1045 | ); |
||
1046 | |||
1047 | return $this->infPercurso[$posicao]; |
||
1048 | } |
||
1049 | |||
1050 | /** |
||
1051 | * Gera as tags para o elemento: toma3 (Indicador do "papel" do tomador do serviço no CT-e) |
||
1052 | * e adiciona ao grupo ide |
||
1053 | * #35 |
||
1054 | * Nível: 2 |
||
1055 | * @param string $toma Tomador do Serviço |
||
1056 | * @param stdClass $std |
||
1057 | * @return \DOMElement |
||
1058 | */ |
||
1059 | public function tagtoma3($std) |
||
1060 | { |
||
1061 | $identificador = '#35 <toma3> - '; |
||
1062 | $this->toma3 = $this->dom->createElement('toma3'); |
||
1063 | $this->dom->addChild( |
||
1064 | $this->toma3, |
||
1065 | 'toma', |
||
1066 | $std->toma, |
||
1067 | true, |
||
1068 | $identificador . 'Tomador do Serviço' |
||
1069 | ); |
||
1070 | return $this->toma3; |
||
1071 | } |
||
1072 | |||
1073 | /** |
||
1074 | * Gera as tags para o elemento: toma4 (Indicador do "papel" do tomador |
||
1075 | * do serviço no CT-e) e adiciona ao grupo ide |
||
1076 | * #37 |
||
1077 | * Nível: 2 |
||
1078 | * @param stdClass $std |
||
1079 | * @return \DOMElement |
||
1080 | */ |
||
1081 | public function tagtoma4($std) |
||
1082 | { |
||
1083 | $identificador = '#37 <toma4> - '; |
||
1084 | $this->toma4 = $this->dom->createElement('toma4'); |
||
1085 | $this->dom->addChild( |
||
1086 | $this->toma4, |
||
1087 | 'toma', |
||
1088 | $std->toma, |
||
1089 | true, |
||
1090 | $identificador . 'Tomador do Serviço' |
||
1091 | ); |
||
1092 | if ($std->CNPJ != '') { |
||
1093 | $this->dom->addChild( |
||
1094 | $this->toma4, |
||
1095 | 'CNPJ', |
||
1096 | $std->CNPJ, |
||
1097 | true, |
||
1098 | $identificador . 'Número do CNPJ' |
||
1099 | ); |
||
1100 | } elseif ($std->CPF != '') { |
||
1101 | $this->dom->addChild( |
||
1102 | $this->toma4, |
||
1103 | 'CPF', |
||
1104 | $std->CPF, |
||
1105 | true, |
||
1106 | $identificador . 'Número do CPF' |
||
1107 | ); |
||
1108 | } else { |
||
1109 | $this->dom->addChild( |
||
1110 | $this->toma4, |
||
1111 | 'CNPJ', |
||
1112 | $std->CNPJ, |
||
1113 | true, |
||
1114 | $identificador . 'Número do CNPJ' |
||
1115 | ); |
||
1116 | $this->dom->addChild( |
||
1117 | $this->toma4, |
||
1118 | 'CPF', |
||
1119 | $std->CPF, |
||
1120 | true, |
||
1121 | $identificador . 'Número do CPF' |
||
1122 | ); |
||
1123 | } |
||
1124 | $this->dom->addChild( |
||
1125 | $this->toma4, |
||
1126 | 'IE', |
||
1127 | $std->IE, |
||
1128 | false, |
||
1129 | $identificador . 'Inscrição Estadual' |
||
1130 | ); |
||
1131 | $this->dom->addChild( |
||
1132 | $this->toma4, |
||
1133 | 'xNome', |
||
1134 | $std->xNome, |
||
1135 | true, |
||
1136 | $identificador . 'Razão Social ou Nome' |
||
1137 | ); |
||
1138 | $this->dom->addChild( |
||
1139 | $this->toma4, |
||
1140 | 'xFant', |
||
1141 | $std->xFant, |
||
1142 | false, |
||
1143 | $identificador . 'Nome Fantasia' |
||
1144 | ); |
||
1145 | $this->dom->addChild( |
||
1146 | $this->toma4, |
||
1147 | 'fone', |
||
1148 | $std->fone, |
||
1149 | false, |
||
1150 | $identificador . 'Telefone' |
||
1151 | ); |
||
1152 | $this->dom->addChild( |
||
1153 | $this->toma4, |
||
1154 | 'email', |
||
1155 | $std->email, |
||
1156 | false, |
||
1157 | $identificador . 'Endereço de email' |
||
1158 | ); |
||
1159 | return $this->toma4; |
||
1160 | } |
||
1161 | |||
1162 | /** |
||
1163 | * Gera as tags para o elemento: toma4 (Indicador do "papel" do tomador |
||
1164 | * do serviço no CT-e OS) e adiciona ao grupo ide |
||
1165 | * #37 |
||
1166 | * Nível: 2 |
||
1167 | * |
||
1168 | * @return \DOMElement |
||
1169 | */ |
||
1170 | public function tagtomador($std) |
||
1171 | { |
||
1172 | $identificador = '#37 <toma> - '; |
||
1173 | $this->toma = $this->dom->createElement('toma'); |
||
1174 | if ($std->CNPJ != '') { |
||
1175 | $this->dom->addChild( |
||
1176 | $this->toma, |
||
1177 | 'CNPJ', |
||
1178 | $std->CNPJ, |
||
1179 | true, |
||
1180 | $identificador . 'Número do CNPJ' |
||
1181 | ); |
||
1182 | } elseif ($std->CPF != '') { |
||
1183 | $this->dom->addChild( |
||
1184 | $this->toma, |
||
1185 | 'CPF', |
||
1186 | $std->CPF, |
||
1187 | true, |
||
1188 | $identificador . 'Número do CPF' |
||
1189 | ); |
||
1190 | } else { |
||
1191 | $this->dom->addChild( |
||
1192 | $this->toma, |
||
1193 | 'CNPJ', |
||
1194 | $std->CNPJ, |
||
1195 | true, |
||
1196 | $identificador . 'Número do CNPJ' |
||
1197 | ); |
||
1198 | $this->dom->addChild( |
||
1199 | $this->toma, |
||
1200 | 'CPF', |
||
1201 | $std->CPF, |
||
1202 | true, |
||
1203 | $identificador . 'Número do CPF' |
||
1204 | ); |
||
1205 | } |
||
1206 | $this->dom->addChild( |
||
1207 | $this->toma, |
||
1208 | 'IE', |
||
1209 | $std->IE, |
||
1210 | false, |
||
1211 | $identificador . 'Inscrição Estadual' |
||
1212 | ); |
||
1213 | $this->dom->addChild( |
||
1214 | $this->toma, |
||
1215 | 'xNome', |
||
1216 | $std->xNome, |
||
1217 | true, |
||
1218 | $identificador . 'Razão Social ou Nome' |
||
1219 | ); |
||
1220 | $this->dom->addChild( |
||
1221 | $this->toma, |
||
1222 | 'xFant', |
||
1223 | $std->xFant, |
||
1224 | false, |
||
1225 | $identificador . 'Nome Fantasia' |
||
1226 | ); |
||
1227 | $this->dom->addChild( |
||
1228 | $this->toma, |
||
1229 | 'fone', |
||
1230 | $std->fone, |
||
1231 | false, |
||
1232 | $identificador . 'Telefone' |
||
1233 | ); |
||
1234 | //Endereço Tomador |
||
1235 | $this->enderToma = $this->dom->createElement('enderToma'); |
||
1236 | $this->dom->addChild( |
||
1237 | $this->enderToma, |
||
1238 | 'xLgr', |
||
1239 | $std->xLgr, |
||
1240 | true, |
||
1241 | $identificador . 'Logradouro' |
||
1242 | ); |
||
1243 | $this->dom->addChild( |
||
1244 | $this->enderToma, |
||
1245 | 'nro', |
||
1246 | $std->nro, |
||
1247 | true, |
||
1248 | $identificador . 'Número' |
||
1249 | ); |
||
1250 | $this->dom->addChild( |
||
1251 | $this->enderToma, |
||
1252 | 'xCpl', |
||
1253 | $std->xCpl, |
||
1254 | false, |
||
1255 | $identificador . 'Complemento' |
||
1256 | ); |
||
1257 | $this->dom->addChild( |
||
1258 | $this->enderToma, |
||
1259 | 'xBairro', |
||
1260 | $std->xBairro, |
||
1261 | true, |
||
1262 | $identificador . 'Bairro' |
||
1263 | ); |
||
1264 | $this->dom->addChild( |
||
1265 | $this->enderToma, |
||
1266 | 'cMun', |
||
1267 | $std->cMun, |
||
1268 | true, |
||
1269 | $identificador . 'Código do município (utilizar a tabela do IBGE)' |
||
1270 | ); |
||
1271 | $this->dom->addChild( |
||
1272 | $this->enderToma, |
||
1273 | 'xMun', |
||
1274 | $std->xMun, |
||
1275 | true, |
||
1276 | $identificador . 'Nome do município' |
||
1277 | ); |
||
1278 | $this->dom->addChild( |
||
1279 | $this->enderToma, |
||
1280 | 'CEP', |
||
1281 | $std->CEP, |
||
1282 | false, |
||
1283 | $identificador . 'CEP' |
||
1284 | ); |
||
1285 | $this->dom->addChild( |
||
1286 | $this->enderToma, |
||
1287 | 'UF', |
||
1288 | $std->UF, |
||
1289 | true, |
||
1290 | $identificador . 'Sigla da UF' |
||
1291 | ); |
||
1292 | $this->dom->addChild( |
||
1293 | $this->enderToma, |
||
1294 | 'cPais', |
||
1295 | $std->cPais, |
||
1296 | false, |
||
1297 | $identificador . 'Código do país' |
||
1298 | ); |
||
1299 | $this->dom->addChild( |
||
1300 | $this->enderToma, |
||
1301 | 'xPais', |
||
1302 | $std->xPais, |
||
1303 | false, |
||
1304 | $identificador . 'Nome do país' |
||
1305 | ); |
||
1306 | $this->dom->appChild($this->toma, $this->enderToma, 'Falta tag "enderToma"'); |
||
1307 | $this->dom->addChild( |
||
1308 | $this->toma, |
||
1309 | 'email', |
||
1310 | $std->email, |
||
1311 | false, |
||
1312 | $identificador . 'Endereço de email' |
||
1313 | ); |
||
1314 | return $this->toma; |
||
1315 | } |
||
1316 | |||
1317 | /** |
||
1318 | * Gera as tags para o elemento: "enderToma" (Dados do endereço) e adiciona ao grupo "toma4" |
||
1319 | * #45 |
||
1320 | * Nível: 3 |
||
1321 | * |
||
1322 | * @return \DOMElement |
||
1323 | */ |
||
1324 | public function tagenderToma($std) |
||
1325 | { |
||
1326 | $identificador = '#45 <enderToma> - '; |
||
1327 | $this->enderToma = $this->dom->createElement('enderToma'); |
||
1328 | $this->dom->addChild( |
||
1329 | $this->enderToma, |
||
1330 | 'xLgr', |
||
1331 | $std->xLgr, |
||
1332 | true, |
||
1333 | $identificador . 'Logradouro' |
||
1334 | ); |
||
1335 | $this->dom->addChild( |
||
1336 | $this->enderToma, |
||
1337 | 'nro', |
||
1338 | $std->nro, |
||
1339 | true, |
||
1340 | $identificador . 'Número' |
||
1341 | ); |
||
1342 | $this->dom->addChild( |
||
1343 | $this->enderToma, |
||
1344 | 'xCpl', |
||
1345 | $std->xCpl, |
||
1346 | false, |
||
1347 | $identificador . 'Complemento' |
||
1348 | ); |
||
1349 | $this->dom->addChild( |
||
1350 | $this->enderToma, |
||
1351 | 'xBairro', |
||
1352 | $std->xBairro, |
||
1353 | true, |
||
1354 | $identificador . 'Bairro' |
||
1355 | ); |
||
1356 | $this->dom->addChild( |
||
1357 | $this->enderToma, |
||
1358 | 'cMun', |
||
1359 | $std->cMun, |
||
1360 | true, |
||
1361 | $identificador . 'Código do município (utilizar a tabela do IBGE)' |
||
1362 | ); |
||
1363 | $this->dom->addChild( |
||
1364 | $this->enderToma, |
||
1365 | 'xMun', |
||
1366 | $std->xMun, |
||
1367 | true, |
||
1368 | $identificador . 'Nome do município' |
||
1369 | ); |
||
1370 | $this->dom->addChild( |
||
1371 | $this->enderToma, |
||
1372 | 'CEP', |
||
1373 | $std->CEP, |
||
1374 | false, |
||
1375 | $identificador . 'CEP' |
||
1376 | ); |
||
1377 | $this->dom->addChild( |
||
1378 | $this->enderToma, |
||
1379 | 'UF', |
||
1380 | $std->UF, |
||
1381 | true, |
||
1382 | $identificador . 'Sigla da UF' |
||
1383 | ); |
||
1384 | $this->dom->addChild( |
||
1385 | $this->enderToma, |
||
1386 | 'cPais', |
||
1387 | $std->cPais, |
||
1388 | false, |
||
1389 | $identificador . 'Código do país' |
||
1390 | ); |
||
1391 | $this->dom->addChild( |
||
1392 | $this->enderToma, |
||
1393 | 'xPais', |
||
1394 | $std->xPais, |
||
1395 | false, |
||
1396 | $identificador . 'Nome do país' |
||
1397 | ); |
||
1398 | |||
1399 | if (!empty($this->toma4)) { |
||
1400 | $this->toma4->insertBefore($this->enderToma, $this->toma4->getElementsByTagName("email")->item(0)); |
||
1401 | } |
||
1402 | return $this->enderToma; |
||
1403 | } |
||
1404 | |||
1405 | /** |
||
1406 | * Gera as tags para o elemento: "compl" (Dados complementares do CT-e para fins operacionais ou comerciais) |
||
1407 | * #59 |
||
1408 | * Nível: 1 |
||
1409 | * |
||
1410 | * @return \DOMElement |
||
1411 | */ |
||
1412 | public function tagcompl($std) |
||
1413 | { |
||
1414 | $identificador = '#59 <compl> - '; |
||
1415 | if ($this->compl == '') { |
||
1416 | $this->compl = $this->dom->createElement('compl'); |
||
1417 | } |
||
1418 | $this->dom->addChild( |
||
1419 | $this->compl, |
||
1420 | 'xCaracAd', |
||
1421 | $std->xCaracAd, |
||
1422 | false, |
||
1423 | $identificador . 'Característica adicional do transporte' |
||
1424 | ); |
||
1425 | $this->dom->addChild( |
||
1426 | $this->compl, |
||
1427 | 'xCaracSer', |
||
1428 | $std->xCaracSer, |
||
1429 | false, |
||
1430 | $identificador . 'Característica adicional do serviço' |
||
1431 | ); |
||
1432 | $this->dom->addChild( |
||
1433 | $this->compl, |
||
1434 | 'xEmi', |
||
1435 | $std->xEmi, |
||
1436 | false, |
||
1437 | $identificador . 'Funcionário emissor do CTe' |
||
1438 | ); |
||
1439 | if ($this->mod == 57) { |
||
1440 | $this->dom->addChild( |
||
1441 | $this->compl, |
||
1442 | 'origCalc', |
||
1443 | $std->origCalc, |
||
1444 | false, |
||
1445 | $identificador . 'Município de origem para efeito de cálculo do frete' |
||
1446 | ); |
||
1447 | $this->dom->addChild( |
||
1448 | $this->compl, |
||
1449 | 'destCalc', |
||
1450 | $std->destCalc, |
||
1451 | false, |
||
1452 | $identificador . 'Município de destino para efeito de cálculo do frete' |
||
1453 | ); |
||
1454 | } |
||
1455 | $this->dom->addChild( |
||
1456 | $this->compl, |
||
1457 | 'xObs', |
||
1458 | $std->xObs, |
||
1459 | false, |
||
1460 | $identificador . 'Observações Gerais' |
||
1461 | ); |
||
1462 | return $this->compl; |
||
1463 | } |
||
1464 | |||
1465 | /** |
||
1466 | * Gera as tags para o elemento: "compl" (Dados complementares do CT-e OS para fins operacionais ou comerciais) |
||
1467 | * #59 |
||
1468 | * Nível: 1 |
||
1469 | * |
||
1470 | * @return \DOMElement |
||
1471 | */ |
||
1472 | public function tagcomplCTeOs($std) |
||
1473 | { |
||
1474 | $identificador = '#59 <compl> - '; |
||
1475 | $this->compl = $this->dom->createElement('compl'); |
||
1476 | $this->dom->addChild( |
||
1477 | $this->compl, |
||
1478 | 'xCaracAd', |
||
1479 | $std->xCaracAd, |
||
1480 | false, |
||
1481 | $identificador . 'Característica adicional do transporte' |
||
1482 | ); |
||
1483 | $this->dom->addChild( |
||
1484 | $this->compl, |
||
1485 | 'xCaracSer', |
||
1486 | $std->xCaracSer, |
||
1487 | false, |
||
1488 | $identificador . 'Característica adicional do serviço' |
||
1489 | ); |
||
1490 | $this->dom->addChild( |
||
1491 | $this->compl, |
||
1492 | 'xEmi', |
||
1493 | $std->xEmi, |
||
1494 | false, |
||
1495 | $identificador . 'Funcionário emissor do CTe' |
||
1496 | ); |
||
1497 | $this->dom->addChild( |
||
1498 | $this->compl, |
||
1499 | 'xObs', |
||
1500 | $std->xObs, |
||
1501 | false, |
||
1502 | $identificador . 'Observações Gerais' |
||
1503 | ); |
||
1504 | return $this->compl; |
||
1505 | } |
||
1506 | |||
1507 | /** |
||
1508 | * Gera as tags para o elemento: "fluxo" (Previsão do fluxo da carga) |
||
1509 | * #63 |
||
1510 | * Nível: 2 |
||
1511 | * Os parâmetros para esta função são todos os elementos da tag "fluxo" do |
||
1512 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
1513 | * |
||
1514 | * @return \DOMElement |
||
1515 | */ |
||
1516 | public function tagfluxo($std) |
||
1517 | { |
||
1518 | $identificador = '#63 <fluxo> - '; |
||
1519 | $this->fluxo = $this->dom->createElement('fluxo'); |
||
1520 | $this->dom->addChild( |
||
1521 | $this->fluxo, |
||
1522 | 'xOrig', |
||
1523 | $std->xOrig, |
||
1524 | false, |
||
1525 | $identificador . 'Sigla ou código interno da Filial/Porto/Estação/ Aeroporto de Origem' |
||
1526 | ); |
||
1527 | $this->dom->addChild( |
||
1528 | $this->fluxo, |
||
1529 | 'xDest', |
||
1530 | $std->xDest, |
||
1531 | false, |
||
1532 | $identificador . 'Sigla ou código interno da Filial/Porto/Estação/Aeroporto de Destino' |
||
1533 | ); |
||
1534 | $this->dom->addChild( |
||
1535 | $this->fluxo, |
||
1536 | 'xRota', |
||
1537 | $std->xRota, |
||
1538 | false, |
||
1539 | $identificador . 'Código da Rota de Entrega' |
||
1540 | ); |
||
1541 | return $this->fluxo; |
||
1542 | } |
||
1543 | |||
1544 | /** |
||
1545 | * Gera as tags para o elemento: "pass" |
||
1546 | * #65 |
||
1547 | * Nível: 3 |
||
1548 | * |
||
1549 | * @return \DOMElement |
||
1550 | */ |
||
1551 | public function tagpass($std) |
||
1552 | { |
||
1553 | $identificador = '#65 <pass> - '; |
||
1554 | $this->pass[] = $this->dom->createElement('pass'); |
||
1555 | $posicao = (int) count($this->pass) - 1; |
||
1556 | $this->dom->addChild( |
||
1557 | $this->pass[$posicao], |
||
1558 | 'xPass', |
||
1559 | $std->xPass, |
||
1560 | false, |
||
1561 | $identificador . 'Sigla ou código interno da Filial/Porto/Estação/Aeroporto de Passagem' |
||
1562 | ); |
||
1563 | return $this->pass[$posicao]; |
||
1564 | } |
||
1565 | |||
1566 | /** |
||
1567 | * Gera as tags para o elemento: "semData" (Entrega sem data definida) |
||
1568 | * #70 |
||
1569 | * Nível: 3 |
||
1570 | * |
||
1571 | * @return \DOMElement |
||
1572 | */ |
||
1573 | public function tagsemData($std) |
||
1574 | { |
||
1575 | $identificador = '#70 <semData> - '; |
||
1576 | $this->semData = $this->dom->createElement('semData'); |
||
1577 | $this->dom->addChild( |
||
1578 | $this->semData, |
||
1579 | 'tpPer', |
||
1580 | $std->tpPer, |
||
1581 | true, |
||
1582 | $identificador . 'Tipo de data/período programado para entrega' |
||
1583 | ); |
||
1584 | return $this->semData; |
||
1585 | } |
||
1586 | |||
1587 | /** |
||
1588 | * Gera as tags para o elemento: "comData" (Entrega com data definida) |
||
1589 | * #72 |
||
1590 | * Nível: 3 |
||
1591 | * |
||
1592 | * @return \DOMElement |
||
1593 | */ |
||
1594 | public function tagcomData($std) |
||
1595 | { |
||
1596 | $identificador = '#72 <comData> - '; |
||
1597 | $this->comData = $this->dom->createElement('comData'); |
||
1598 | $this->dom->addChild( |
||
1599 | $this->comData, |
||
1600 | 'tpPer', |
||
1601 | $std->tpPer, |
||
1602 | true, |
||
1603 | $identificador . 'Tipo de data/período programado para entrega' |
||
1604 | ); |
||
1605 | $this->dom->addChild( |
||
1606 | $this->comData, |
||
1607 | 'dProg', |
||
1608 | $std->dProg, |
||
1609 | true, |
||
1610 | $identificador . 'Data programada' |
||
1611 | ); |
||
1612 | return $this->comData; |
||
1613 | } |
||
1614 | |||
1615 | /** |
||
1616 | * Gera as tags para o elemento: "noPeriodo" (Entrega no período definido) |
||
1617 | * #75 |
||
1618 | * Nível: 3 |
||
1619 | * |
||
1620 | * @return \DOMElement |
||
1621 | */ |
||
1622 | public function tagnoPeriodo($std) |
||
1623 | { |
||
1624 | $identificador = '#75 <noPeriodo> - '; |
||
1625 | $this->noPeriodo = $this->dom->createElement('noPeriodo'); |
||
1626 | $this->dom->addChild( |
||
1627 | $this->noPeriodo, |
||
1628 | 'tpPer', |
||
1629 | $std->tpPer, |
||
1630 | true, |
||
1631 | $identificador . 'Tipo de data/período programado para entrega' |
||
1632 | ); |
||
1633 | $this->dom->addChild( |
||
1634 | $this->noPeriodo, |
||
1635 | 'dIni', |
||
1636 | $std->dIni, |
||
1637 | true, |
||
1638 | $identificador . 'Data inicial' |
||
1639 | ); |
||
1640 | $this->dom->addChild( |
||
1641 | $this->noPeriodo, |
||
1642 | 'dFim', |
||
1643 | $std->dFim, |
||
1644 | true, |
||
1645 | $identificador . 'Data final' |
||
1646 | ); |
||
1647 | return $this->noPeriodo; |
||
1648 | } |
||
1649 | |||
1650 | /** |
||
1651 | * Gera as tags para o elemento: "semHora" (Entrega sem hora definida) |
||
1652 | * #79 |
||
1653 | * Nível: 3 |
||
1654 | * Os parâmetros para esta função são todos os elementos da tag "semHora" do |
||
1655 | * tipo elemento (Ele = E|CE|A) e nível 4 |
||
1656 | * |
||
1657 | * @return \DOMElement |
||
1658 | */ |
||
1659 | public function tagsemHora($std) |
||
1660 | { |
||
1661 | $identificador = '#79 <semHora> - '; |
||
1662 | $this->semHora = $this->dom->createElement('semHora'); |
||
1663 | $this->dom->addChild( |
||
1664 | $this->semHora, |
||
1665 | 'tpHor', |
||
1666 | $std->tpHor, |
||
1667 | true, |
||
1668 | $identificador . 'Tipo de hora' |
||
1669 | ); |
||
1670 | return $this->semHora; |
||
1671 | } |
||
1672 | |||
1673 | /** |
||
1674 | * Gera as tags para o elemento: "comHora" (Entrega sem hora definida) |
||
1675 | * # = 81 |
||
1676 | * Nível = 3 |
||
1677 | * Os parâmetros para esta função são todos os elementos da tag "comHora" do |
||
1678 | * tipo elemento (Ele = E|CE|A) e nível 4 |
||
1679 | * |
||
1680 | * @return \DOMElement |
||
1681 | */ |
||
1682 | public function tagcomHora($std) |
||
1683 | { |
||
1684 | $identificador = '#81 <comHora> - '; |
||
1685 | $this->comHora = $this->dom->createElement('comHora'); |
||
1686 | $this->dom->addChild( |
||
1687 | $this->comHora, |
||
1688 | 'tpHor', |
||
1689 | $std->tpHor, |
||
1690 | true, |
||
1691 | $identificador . 'Tipo de hora' |
||
1692 | ); |
||
1693 | $this->dom->addChild( |
||
1694 | $this->comHora, |
||
1695 | 'hProg', |
||
1696 | $std->hProg, |
||
1697 | true, |
||
1698 | $identificador . 'Hora programada' |
||
1699 | ); |
||
1700 | return $this->comHora; |
||
1701 | } |
||
1702 | |||
1703 | /** |
||
1704 | * Gera as tags para o elemento: "noInter" (Entrega no intervalo de horário definido) |
||
1705 | * #84 |
||
1706 | * Nível: 3 |
||
1707 | * Os parâmetros para esta função são todos os elementos da tag "noInter" do |
||
1708 | * tipo elemento (Ele = E|CE|A) e nível 4 |
||
1709 | * |
||
1710 | * @return \DOMElement |
||
1711 | */ |
||
1712 | public function tagnoInter($std) |
||
1713 | { |
||
1714 | $identificador = '#84 <noInter> - '; |
||
1715 | $this->noInter = $this->dom->createElement('noInter'); |
||
1716 | $this->dom->addChild( |
||
1717 | $this->noInter, |
||
1718 | 'tpHor', |
||
1719 | $std->tpHor, |
||
1720 | true, |
||
1721 | $identificador . 'Tipo de hora' |
||
1722 | ); |
||
1723 | $this->dom->addChild( |
||
1724 | $this->noInter, |
||
1725 | 'hIni', |
||
1726 | $std->hIni, |
||
1727 | true, |
||
1728 | $identificador . 'Hora inicial' |
||
1729 | ); |
||
1730 | $this->dom->addChild( |
||
1731 | $this->noInter, |
||
1732 | 'hFim', |
||
1733 | $std->hFim, |
||
1734 | true, |
||
1735 | $identificador . 'Hora final' |
||
1736 | ); |
||
1737 | return $this->noInter; |
||
1738 | } |
||
1739 | |||
1740 | /** |
||
1741 | * Gera as tags para o elemento: "ObsCont" (Campo de uso livre do contribuinte) |
||
1742 | * #91 |
||
1743 | * Nível: 2 |
||
1744 | * Os parâmetros para esta função são todos os elementos da tag "ObsCont" do |
||
1745 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
1746 | * |
||
1747 | * @return boolean |
||
1748 | */ |
||
1749 | public function tagobsCont($std) |
||
1750 | { |
||
1751 | $identificador = '#91 <ObsCont> - '; |
||
1752 | if (count($this->obsCont) <= 10) { |
||
1753 | $this->obsCont[] = $this->dom->createElement('ObsCont'); |
||
1754 | $posicao = (int) count($this->obsCont) - 1; |
||
1755 | $this->obsCont[$posicao]->setAttribute('xCampo', $std->xCampo); |
||
1756 | $this->dom->addChild( |
||
1757 | $this->obsCont[$posicao], |
||
1758 | 'xTexto', |
||
1759 | $std->xTexto, |
||
1760 | true, |
||
1761 | $identificador . 'Conteúdo do campo' |
||
1762 | ); |
||
1763 | return true; |
||
1764 | } |
||
1765 | $this->errors[] = array( |
||
1766 | 'tag' => (string) '<ObsCont>', |
||
1767 | 'desc' => (string) 'Campo de uso livre do contribuinte', |
||
1768 | 'erro' => (string) 'Tag deve aparecer de 0 a 10 vezes' |
||
1769 | ); |
||
1770 | return false; |
||
1771 | } |
||
1772 | |||
1773 | /** |
||
1774 | * Gera as tags para o elemento: "ObsFisco" (Campo de uso livre do contribuinte) |
||
1775 | * #94 |
||
1776 | * Nível: 2 |
||
1777 | * Os parâmetros para esta função são todos os elementos da tag "ObsFisco" do tipo |
||
1778 | * elemento (Ele = E|CE|A) e nível 3 |
||
1779 | * |
||
1780 | * @return boolean |
||
1781 | */ |
||
1782 | public function tagobsFisco($std) |
||
1783 | { |
||
1784 | $identificador = '#94 <ObsFisco> - '; |
||
1785 | if (count($this->obsFisco) <= 10) { |
||
1786 | $this->obsFisco[] = $this->dom->createElement('ObsFisco'); |
||
1787 | $posicao = (int) count($this->obsFisco) - 1; |
||
1788 | $this->obsFisco[$posicao]->setAttribute('xCampo', $std->xCampo); |
||
1789 | $this->dom->addChild( |
||
1790 | $this->obsFisco[$posicao], |
||
1791 | 'xTexto', |
||
1792 | $std->xTexto, |
||
1793 | true, |
||
1794 | $identificador . 'Conteúdo do campo' |
||
1795 | ); |
||
1796 | return true; |
||
1797 | } |
||
1798 | $this->errors[] = array( |
||
1799 | 'tag' => (string) '<ObsFisco>', |
||
1800 | 'desc' => (string) 'Campo de uso livre do contribuinte', |
||
1801 | 'erro' => (string) 'Tag deve aparecer de 0 a 10 vezes' |
||
1802 | ); |
||
1803 | return false; |
||
1804 | } |
||
1805 | |||
1806 | /** |
||
1807 | * Gera as tags para o elemento: "emit" (Identificação do Emitente do CT-e) |
||
1808 | * #97 |
||
1809 | * Nível: 1 |
||
1810 | * Os parâmetros para esta função são todos os elementos da tag "emit" do |
||
1811 | * tipo elemento (Ele = E|CE|A) e nível 2 |
||
1812 | * |
||
1813 | * @return \DOMElement |
||
1814 | */ |
||
1815 | public function tagemit($std) |
||
1816 | { |
||
1817 | $identificador = '#97 <emit> - '; |
||
1818 | $this->emit = $this->dom->createElement('emit'); |
||
1819 | $this->dom->addChild( |
||
1820 | $this->emit, |
||
1821 | 'CNPJ', |
||
1822 | $std->CNPJ, |
||
1823 | true, |
||
1824 | $identificador . 'CNPJ do emitente' |
||
1825 | ); |
||
1826 | $this->dom->addChild( |
||
1827 | $this->emit, |
||
1828 | 'IE', |
||
1829 | Strings::onlyNumbers($std->IE), |
||
1830 | false, |
||
1831 | $identificador . 'Inscrição Estadual do Emitente' |
||
1832 | ); |
||
1833 | $this->dom->addChild( |
||
1834 | $this->emit, |
||
1835 | 'IEST', |
||
1836 | Strings::onlyNumbers($std->IEST), |
||
1837 | false, |
||
1838 | $identificador . 'Inscrição Estadual do Substituto Tributário' |
||
1839 | ); |
||
1840 | $this->dom->addChild( |
||
1841 | $this->emit, |
||
1842 | 'xNome', |
||
1843 | $std->xNome, |
||
1844 | true, |
||
1845 | $identificador . 'Razão social ou Nome do emitente' |
||
1846 | ); |
||
1847 | $this->dom->addChild( |
||
1848 | $this->emit, |
||
1849 | 'xFant', |
||
1850 | $std->xFant, |
||
1851 | false, |
||
1852 | $identificador . 'Nome fantasia' |
||
1853 | ); |
||
1854 | return $this->emit; |
||
1855 | } |
||
1856 | |||
1857 | /** |
||
1858 | * Gera as tags para o elemento: "enderEmit" (Endereço do emitente) |
||
1859 | * #102 |
||
1860 | * Nível: 2 |
||
1861 | * Os parâmetros para esta função são todos os elementos da tag "enderEmit" do |
||
1862 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
1863 | * |
||
1864 | * @return \DOMElement |
||
1865 | */ |
||
1866 | public function tagenderEmit($std) |
||
1867 | { |
||
1868 | $identificador = '#102 <enderEmit> - '; |
||
1869 | $this->enderEmit = $this->dom->createElement('enderEmit'); |
||
1870 | $this->dom->addChild( |
||
1871 | $this->enderEmit, |
||
1872 | 'xLgr', |
||
1873 | $std->xLgr, |
||
1874 | true, |
||
1875 | $identificador . 'Logradouro' |
||
1876 | ); |
||
1877 | $this->dom->addChild( |
||
1878 | $this->enderEmit, |
||
1879 | 'nro', |
||
1880 | $std->nro, |
||
1881 | true, |
||
1882 | $identificador . 'Número' |
||
1883 | ); |
||
1884 | $this->dom->addChild( |
||
1885 | $this->enderEmit, |
||
1886 | 'xCpl', |
||
1887 | $std->xCpl, |
||
1888 | false, |
||
1889 | $identificador . 'Complemento' |
||
1890 | ); |
||
1891 | $this->dom->addChild( |
||
1892 | $this->enderEmit, |
||
1893 | 'xBairro', |
||
1894 | $std->xBairro, |
||
1895 | true, |
||
1896 | $identificador . 'Bairro' |
||
1897 | ); |
||
1898 | $this->dom->addChild( |
||
1899 | $this->enderEmit, |
||
1900 | 'cMun', |
||
1901 | $std->cMun, |
||
1902 | true, |
||
1903 | $identificador . 'Código do município' |
||
1904 | ); |
||
1905 | $this->dom->addChild( |
||
1906 | $this->enderEmit, |
||
1907 | 'xMun', |
||
1908 | $std->xMun, |
||
1909 | true, |
||
1910 | $identificador . 'Nome do município' |
||
1911 | ); |
||
1912 | $this->dom->addChild( |
||
1913 | $this->enderEmit, |
||
1914 | 'CEP', |
||
1915 | $std->CEP, |
||
1916 | false, |
||
1917 | $identificador . 'CEP' |
||
1918 | ); |
||
1919 | $this->dom->addChild( |
||
1920 | $this->enderEmit, |
||
1921 | 'UF', |
||
1922 | $std->UF, |
||
1923 | true, |
||
1924 | $identificador . 'Sigla da UF' |
||
1925 | ); |
||
1926 | $this->dom->addChild( |
||
1927 | $this->enderEmit, |
||
1928 | 'fone', |
||
1929 | $std->fone, |
||
1930 | false, |
||
1931 | $identificador . 'Telefone' |
||
1932 | ); |
||
1933 | return $this->enderEmit; |
||
1934 | } |
||
1935 | |||
1936 | /** |
||
1937 | * Gera as tags para o elemento: "rem" (Informações do Remetente das mercadorias |
||
1938 | * transportadas pelo CT-e) |
||
1939 | * #112 |
||
1940 | * Nível = 1 |
||
1941 | * Os parâmetros para esta função são todos os elementos da tag "rem" do |
||
1942 | * tipo elemento (Ele = E|CE|A) e nível 2 |
||
1943 | * |
||
1944 | * @return \DOMElement |
||
1945 | */ |
||
1946 | public function tagrem($std) |
||
1947 | { |
||
1948 | $identificador = '#97 <rem> - '; |
||
1949 | $this->rem = $this->dom->createElement('rem'); |
||
1950 | if ($std->CNPJ != '') { |
||
1951 | $this->dom->addChild( |
||
1952 | $this->rem, |
||
1953 | 'CNPJ', |
||
1954 | $std->CNPJ, |
||
1955 | true, |
||
1956 | $identificador . 'CNPJ do Remente' |
||
1957 | ); |
||
1958 | } elseif ($std->CPF != '') { |
||
1959 | $this->dom->addChild( |
||
1960 | $this->rem, |
||
1961 | 'CPF', |
||
1962 | $std->CPF, |
||
1963 | true, |
||
1964 | $identificador . 'CPF do Remente' |
||
1965 | ); |
||
1966 | } else { |
||
1967 | $this->dom->addChild( |
||
1968 | $this->rem, |
||
1969 | 'CNPJ', |
||
1970 | $std->CNPJ, |
||
1971 | true, |
||
1972 | $identificador . 'CNPJ do Remente' |
||
1973 | ); |
||
1974 | $this->dom->addChild( |
||
1975 | $this->rem, |
||
1976 | 'CPF', |
||
1977 | $std->CPF, |
||
1978 | true, |
||
1979 | $identificador . 'CPF do remente' |
||
1980 | ); |
||
1981 | } |
||
1982 | $this->dom->addChild( |
||
1983 | $this->rem, |
||
1984 | 'IE', |
||
1985 | $std->IE, |
||
1986 | false, |
||
1987 | $identificador . 'Inscrição Estadual do remente' |
||
1988 | ); |
||
1989 | $xNome = $std->xNome; |
||
1990 | if ($this->tpAmb == '2') { |
||
1991 | $xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
1992 | } |
||
1993 | $this->dom->addChild( |
||
1994 | $this->rem, |
||
1995 | 'xNome', |
||
1996 | Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
||
1997 | true, |
||
1998 | $identificador . 'Razão social ou Nome do remente' |
||
1999 | ); |
||
2000 | $this->dom->addChild( |
||
2001 | $this->rem, |
||
2002 | 'xFant', |
||
2003 | $std->xFant, |
||
2004 | false, |
||
2005 | $identificador . 'Nome fantasia' |
||
2006 | ); |
||
2007 | $this->dom->addChild( |
||
2008 | $this->rem, |
||
2009 | 'fone', |
||
2010 | $std->fone, |
||
2011 | false, |
||
2012 | $identificador . 'Telefone' |
||
2013 | ); |
||
2014 | $this->dom->addChild( |
||
2015 | $this->rem, |
||
2016 | 'email', |
||
2017 | $std->email, |
||
2018 | false, |
||
2019 | $identificador . 'Endereço de email' |
||
2020 | ); |
||
2021 | return $this->rem; |
||
2022 | } |
||
2023 | |||
2024 | /** |
||
2025 | * Gera as tags para o elemento: "enderReme" (Dados do endereço) |
||
2026 | * #120 |
||
2027 | * Nível: 2 |
||
2028 | * Os parâmetros para esta função são todos os elementos da tag "enderReme" do |
||
2029 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
2030 | * |
||
2031 | * @return \DOMElement |
||
2032 | */ |
||
2033 | public function tagenderReme($std) |
||
2034 | { |
||
2035 | $identificador = '#119 <enderReme> - '; |
||
2036 | $this->enderReme = $this->dom->createElement('enderReme'); |
||
2037 | $this->dom->addChild( |
||
2038 | $this->enderReme, |
||
2039 | 'xLgr', |
||
2040 | $std->xLgr, |
||
2041 | true, |
||
2042 | $identificador . 'Logradouro' |
||
2043 | ); |
||
2044 | $this->dom->addChild( |
||
2045 | $this->enderReme, |
||
2046 | 'nro', |
||
2047 | $std->nro, |
||
2048 | true, |
||
2049 | $identificador . 'Número' |
||
2050 | ); |
||
2051 | $this->dom->addChild( |
||
2052 | $this->enderReme, |
||
2053 | 'xCpl', |
||
2054 | $std->xCpl, |
||
2055 | false, |
||
2056 | $identificador . 'Complemento' |
||
2057 | ); |
||
2058 | $this->dom->addChild( |
||
2059 | $this->enderReme, |
||
2060 | 'xBairro', |
||
2061 | $std->xBairro, |
||
2062 | true, |
||
2063 | $identificador . 'Bairro' |
||
2064 | ); |
||
2065 | $this->dom->addChild( |
||
2066 | $this->enderReme, |
||
2067 | 'cMun', |
||
2068 | $std->cMun, |
||
2069 | true, |
||
2070 | $identificador . 'Código do município (utilizar a tabela do IBGE)' |
||
2071 | ); |
||
2072 | $this->dom->addChild( |
||
2073 | $this->enderReme, |
||
2074 | 'xMun', |
||
2075 | $std->xMun, |
||
2076 | true, |
||
2077 | $identificador . 'Nome do município' |
||
2078 | ); |
||
2079 | $this->dom->addChild( |
||
2080 | $this->enderReme, |
||
2081 | 'CEP', |
||
2082 | $std->CEP, |
||
2083 | false, |
||
2084 | $identificador . 'CEP' |
||
2085 | ); |
||
2086 | $this->dom->addChild( |
||
2087 | $this->enderReme, |
||
2088 | 'UF', |
||
2089 | $std->UF, |
||
2090 | true, |
||
2091 | $identificador . 'Sigla da UF' |
||
2092 | ); |
||
2093 | $this->dom->addChild( |
||
2094 | $this->enderReme, |
||
2095 | 'cPais', |
||
2096 | $std->cPais, |
||
2097 | false, |
||
2098 | $identificador . 'Código do país' |
||
2099 | ); |
||
2100 | $this->dom->addChild( |
||
2101 | $this->enderReme, |
||
2102 | 'xPais', |
||
2103 | $std->xPais, |
||
2104 | false, |
||
2105 | $identificador . 'Nome do país' |
||
2106 | ); |
||
2107 | |||
2108 | $node = $this->rem->getElementsByTagName("email")->item(0); |
||
2109 | $this->rem->insertBefore($this->enderReme, $node); |
||
2110 | return $this->enderReme; |
||
2111 | } |
||
2112 | |||
2113 | /** |
||
2114 | * Gera as tags para o elemento: "exped" (Informações do Expedidor da Carga) |
||
2115 | * #132 |
||
2116 | * Nível: 1 |
||
2117 | * Os parâmetros para esta função são todos os elementos da tag "exped" do |
||
2118 | * tipo elemento (Ele = E|CE|A) e nível 2 |
||
2119 | * |
||
2120 | * @return \DOMElement |
||
2121 | */ |
||
2122 | public function tagexped($std) |
||
2123 | { |
||
2124 | $identificador = '#142 <exped> - '; |
||
2125 | $this->exped = $this->dom->createElement('exped'); |
||
2126 | if ($std->CNPJ != '') { |
||
2127 | $this->dom->addChild( |
||
2128 | $this->exped, |
||
2129 | 'CNPJ', |
||
2130 | $std->CNPJ, |
||
2131 | true, |
||
2132 | $identificador . 'Número do CNPJ' |
||
2133 | ); |
||
2134 | } elseif ($std->CPF != '') { |
||
2135 | $this->dom->addChild( |
||
2136 | $this->exped, |
||
2137 | 'CPF', |
||
2138 | $std->CPF, |
||
2139 | true, |
||
2140 | $identificador . 'Número do CPF' |
||
2141 | ); |
||
2142 | } else { |
||
2143 | $this->dom->addChild( |
||
2144 | $this->exped, |
||
2145 | 'CNPJ', |
||
2146 | $std->CNPJ, |
||
2147 | true, |
||
2148 | $identificador . 'Número do CNPJ' |
||
2149 | ); |
||
2150 | $this->dom->addChild( |
||
2151 | $this->exped, |
||
2152 | 'CPF', |
||
2153 | $std->CPF, |
||
2154 | true, |
||
2155 | $identificador . 'Número do CPF' |
||
2156 | ); |
||
2157 | } |
||
2158 | if (!empty($std->IE)) { |
||
2159 | $this->dom->addChild( |
||
2160 | $this->exped, |
||
2161 | 'IE', |
||
2162 | $std->IE, |
||
2163 | true, |
||
2164 | $identificador . 'Inscrição Estadual' |
||
2165 | ); |
||
2166 | } |
||
2167 | $xNome = $std->xNome; |
||
2168 | if ($this->tpAmb == '2') { |
||
2169 | $xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
2170 | } |
||
2171 | $this->dom->addChild( |
||
2172 | $this->exped, |
||
2173 | 'xNome', |
||
2174 | Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
||
2175 | true, |
||
2176 | $identificador . 'Razão social ou Nome' |
||
2177 | ); |
||
2178 | $this->dom->addChild( |
||
2179 | $this->exped, |
||
2180 | 'fone', |
||
2181 | $std->fone, |
||
2182 | false, |
||
2183 | $identificador . 'Telefone' |
||
2184 | ); |
||
2185 | $this->dom->addChild( |
||
2186 | $this->exped, |
||
2187 | 'email', |
||
2188 | $std->email, |
||
2189 | false, |
||
2190 | $identificador . 'Endereço de email' |
||
2191 | ); |
||
2192 | return $this->exped; |
||
2193 | } |
||
2194 | |||
2195 | /** |
||
2196 | * Gera as tags para o elemento: "enderExped" (Dados do endereço) |
||
2197 | * #138 |
||
2198 | * Nível: 2 |
||
2199 | * Os parâmetros para esta função são todos os elementos da tag "enderExped" do |
||
2200 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
2201 | * |
||
2202 | * @return \DOMElement |
||
2203 | */ |
||
2204 | public function tagenderExped($std) |
||
2205 | { |
||
2206 | $identificador = '#148 <enderExped> - '; |
||
2207 | $this->enderExped = $this->dom->createElement('enderExped'); |
||
2208 | $this->dom->addChild( |
||
2209 | $this->enderExped, |
||
2210 | 'xLgr', |
||
2211 | $std->xLgr, |
||
2212 | true, |
||
2213 | $identificador . 'Logradouro' |
||
2214 | ); |
||
2215 | $this->dom->addChild( |
||
2216 | $this->enderExped, |
||
2217 | 'nro', |
||
2218 | $std->nro, |
||
2219 | true, |
||
2220 | $identificador . 'Número' |
||
2221 | ); |
||
2222 | $this->dom->addChild( |
||
2223 | $this->enderExped, |
||
2224 | 'xCpl', |
||
2225 | $std->xCpl, |
||
2226 | false, |
||
2227 | $identificador . 'Complemento' |
||
2228 | ); |
||
2229 | $this->dom->addChild( |
||
2230 | $this->enderExped, |
||
2231 | 'xBairro', |
||
2232 | $std->xBairro, |
||
2233 | true, |
||
2234 | $identificador . 'Bairro' |
||
2235 | ); |
||
2236 | $this->dom->addChild( |
||
2237 | $this->enderExped, |
||
2238 | 'cMun', |
||
2239 | $std->cMun, |
||
2240 | true, |
||
2241 | $identificador . 'Código do município (utilizar a tabela do IBGE)' |
||
2242 | ); |
||
2243 | $this->dom->addChild( |
||
2244 | $this->enderExped, |
||
2245 | 'xMun', |
||
2246 | $std->xMun, |
||
2247 | true, |
||
2248 | $identificador . 'Nome do município' |
||
2249 | ); |
||
2250 | $this->dom->addChild( |
||
2251 | $this->enderExped, |
||
2252 | 'CEP', |
||
2253 | $std->CEP, |
||
2254 | false, |
||
2255 | $identificador . 'CEP' |
||
2256 | ); |
||
2257 | $this->dom->addChild( |
||
2258 | $this->enderExped, |
||
2259 | 'UF', |
||
2260 | $std->UF, |
||
2261 | true, |
||
2262 | $identificador . 'Sigla da UF' |
||
2263 | ); |
||
2264 | $this->dom->addChild( |
||
2265 | $this->enderExped, |
||
2266 | 'cPais', |
||
2267 | $std->cPais, |
||
2268 | false, |
||
2269 | $identificador . 'Código do país' |
||
2270 | ); |
||
2271 | $this->dom->addChild( |
||
2272 | $this->enderExped, |
||
2273 | 'xPais', |
||
2274 | $std->xPais, |
||
2275 | false, |
||
2276 | $identificador . 'Nome do país' |
||
2277 | ); |
||
2278 | $node = $this->exped->getElementsByTagName("email")->item(0); |
||
2279 | $this->exped->insertBefore($this->enderExped, $node); |
||
2280 | return $this->enderExped; |
||
2281 | } |
||
2282 | |||
2283 | /** |
||
2284 | * Gera as tags para o elemento: "receb" (Informações do Recebedor da Carga) |
||
2285 | * #150 |
||
2286 | * Nível: 1 |
||
2287 | * Os parâmetros para esta função são todos os elementos da tag "receb" do |
||
2288 | * tipo elemento (Ele = E|CE|A) e nível 2 |
||
2289 | * |
||
2290 | * @return \DOMElement |
||
2291 | */ |
||
2292 | public function tagreceb($std) |
||
2293 | { |
||
2294 | $identificador = '#160 <receb> - '; |
||
2295 | $this->receb = $this->dom->createElement('receb'); |
||
2296 | if ($std->CNPJ != '') { |
||
2297 | $this->dom->addChild( |
||
2298 | $this->receb, |
||
2299 | 'CNPJ', |
||
2300 | $std->CNPJ, |
||
2301 | true, |
||
2302 | $identificador . 'Número do CNPJ' |
||
2303 | ); |
||
2304 | } elseif ($std->CPF != '') { |
||
2305 | $this->dom->addChild( |
||
2306 | $this->receb, |
||
2307 | 'CPF', |
||
2308 | $std->CPF, |
||
2309 | true, |
||
2310 | $identificador . 'Número do CPF' |
||
2311 | ); |
||
2312 | } else { |
||
2313 | $this->dom->addChild( |
||
2314 | $this->receb, |
||
2315 | 'CNPJ', |
||
2316 | $std->CNPJ, |
||
2317 | true, |
||
2318 | $identificador . 'Número do CNPJ' |
||
2319 | ); |
||
2320 | $this->dom->addChild( |
||
2321 | $this->receb, |
||
2322 | 'CPF', |
||
2323 | $std->CPF, |
||
2324 | true, |
||
2325 | $identificador . 'Número do CPF' |
||
2326 | ); |
||
2327 | } |
||
2328 | if (!empty($std->IE)) { |
||
2329 | $this->dom->addChild( |
||
2330 | $this->receb, |
||
2331 | 'IE', |
||
2332 | $std->IE, |
||
2333 | true, |
||
2334 | $identificador . 'Inscrição Estadual' |
||
2335 | ); |
||
2336 | } |
||
2337 | $xNome = $std->xNome; |
||
2338 | if ($this->tpAmb == '2') { |
||
2339 | $xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
2340 | } |
||
2341 | $this->dom->addChild( |
||
2342 | $this->receb, |
||
2343 | 'xNome', |
||
2344 | Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
||
2345 | true, |
||
2346 | $identificador . 'Razão social ou Nome' |
||
2347 | ); |
||
2348 | $this->dom->addChild( |
||
2349 | $this->receb, |
||
2350 | 'fone', |
||
2351 | $std->fone, |
||
2352 | false, |
||
2353 | $identificador . 'Telefone' |
||
2354 | ); |
||
2355 | $this->dom->addChild( |
||
2356 | $this->receb, |
||
2357 | 'email', |
||
2358 | $std->email, |
||
2359 | false, |
||
2360 | $identificador . 'Endereço de email' |
||
2361 | ); |
||
2362 | return $this->receb; |
||
2363 | } |
||
2364 | |||
2365 | /** |
||
2366 | * Gera as tags para o elemento: "enderReceb" (Informações do Recebedor da Carga) |
||
2367 | * #156 |
||
2368 | * Nível: 2 |
||
2369 | * Os parâmetros para esta função são todos os elementos da tag "enderReceb" do |
||
2370 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
2371 | * |
||
2372 | * @return \DOMElement |
||
2373 | */ |
||
2374 | public function tagenderReceb($std) |
||
2375 | { |
||
2376 | $identificador = '#160 <enderReceb> - '; |
||
2377 | $this->enderReceb = $this->dom->createElement('enderReceb'); |
||
2378 | $this->dom->addChild( |
||
2379 | $this->enderReceb, |
||
2380 | 'xLgr', |
||
2381 | $std->xLgr, |
||
2382 | true, |
||
2383 | $identificador . 'Logradouro' |
||
2384 | ); |
||
2385 | $this->dom->addChild( |
||
2386 | $this->enderReceb, |
||
2387 | 'nro', |
||
2388 | $std->nro, |
||
2389 | true, |
||
2390 | $identificador . 'Número' |
||
2391 | ); |
||
2392 | $this->dom->addChild( |
||
2393 | $this->enderReceb, |
||
2394 | 'xCpl', |
||
2395 | $std->xCpl, |
||
2396 | false, |
||
2397 | $identificador . 'Complemento' |
||
2398 | ); |
||
2399 | $this->dom->addChild( |
||
2400 | $this->enderReceb, |
||
2401 | 'xBairro', |
||
2402 | $std->xBairro, |
||
2403 | true, |
||
2404 | $identificador . 'Bairro' |
||
2405 | ); |
||
2406 | $this->dom->addChild( |
||
2407 | $this->enderReceb, |
||
2408 | 'cMun', |
||
2409 | $std->cMun, |
||
2410 | true, |
||
2411 | $identificador . 'Código do município (utilizar a tabela do IBGE)' |
||
2412 | ); |
||
2413 | $this->dom->addChild( |
||
2414 | $this->enderReceb, |
||
2415 | 'xMun', |
||
2416 | $std->xMun, |
||
2417 | true, |
||
2418 | $identificador . 'Nome do município' |
||
2419 | ); |
||
2420 | $this->dom->addChild( |
||
2421 | $this->enderReceb, |
||
2422 | 'CEP', |
||
2423 | $std->CEP, |
||
2424 | false, |
||
2425 | $identificador . 'CEP' |
||
2426 | ); |
||
2427 | $this->dom->addChild( |
||
2428 | $this->enderReceb, |
||
2429 | 'UF', |
||
2430 | $std->UF, |
||
2431 | true, |
||
2432 | $identificador . 'Sigla da UF' |
||
2433 | ); |
||
2434 | $this->dom->addChild( |
||
2435 | $this->enderReceb, |
||
2436 | 'cPais', |
||
2437 | $std->cPais, |
||
2438 | false, |
||
2439 | $identificador . 'Código do país' |
||
2440 | ); |
||
2441 | $this->dom->addChild( |
||
2442 | $this->enderReceb, |
||
2443 | 'xPais', |
||
2444 | $std->xPais, |
||
2445 | false, |
||
2446 | $identificador . 'Nome do país' |
||
2447 | ); |
||
2448 | $node = $this->receb->getElementsByTagName("email")->item(0); |
||
2449 | $this->receb->insertBefore($this->enderReceb, $node); |
||
2450 | return $this->enderReceb; |
||
2451 | } |
||
2452 | |||
2453 | /** |
||
2454 | * Gera as tags para o elemento: "dest" (Informações do Destinatário do CT-e) |
||
2455 | * #168 |
||
2456 | * Nível: 1 |
||
2457 | * Os parâmetros para esta função são todos os elementos da tag "dest" do |
||
2458 | * tipo elemento (Ele = E|CE|A) e nível 2 |
||
2459 | * |
||
2460 | * @return \DOMElement |
||
2461 | */ |
||
2462 | public function tagdest($std) |
||
2463 | { |
||
2464 | $identificador = '#178 <dest> - '; |
||
2465 | $this->dest = $this->dom->createElement('dest'); |
||
2466 | if ($std->CNPJ != '') { |
||
2467 | $this->dom->addChild( |
||
2468 | $this->dest, |
||
2469 | 'CNPJ', |
||
2470 | $std->CNPJ, |
||
2471 | true, |
||
2472 | $identificador . 'Número do CNPJ' |
||
2473 | ); |
||
2474 | } elseif ($std->CPF != '') { |
||
2475 | $this->dom->addChild( |
||
2476 | $this->dest, |
||
2477 | 'CPF', |
||
2478 | $std->CPF, |
||
2479 | true, |
||
2480 | $identificador . 'Número do CPF' |
||
2481 | ); |
||
2482 | } else { |
||
2483 | $this->dom->addChild( |
||
2484 | $this->dest, |
||
2485 | 'CNPJ', |
||
2486 | $std->CNPJ, |
||
2487 | true, |
||
2488 | $identificador . 'Número do CNPJ' |
||
2489 | ); |
||
2490 | $this->dom->addChild( |
||
2491 | $this->dest, |
||
2492 | 'CPF', |
||
2493 | $std->CPF, |
||
2494 | true, |
||
2495 | $identificador . 'Número do CPF' |
||
2496 | ); |
||
2497 | } |
||
2498 | if (!empty($std->IE)) { |
||
2499 | $this->dom->addChild( |
||
2500 | $this->dest, |
||
2501 | 'IE', |
||
2502 | $std->IE, |
||
2503 | true, |
||
2504 | $identificador . 'Inscrição Estadual' |
||
2505 | ); |
||
2506 | } |
||
2507 | $xNome = $std->xNome; |
||
2508 | if ($this->tpAmb == '2') { |
||
2509 | $xNome = 'CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL'; |
||
2510 | } |
||
2511 | $this->dom->addChild( |
||
2512 | $this->dest, |
||
2513 | 'xNome', |
||
2514 | Strings::replaceSpecialsChars(substr(trim($xNome), 0, 60)), |
||
2515 | true, |
||
2516 | $identificador . 'Razão social ou Nome' |
||
2517 | ); |
||
2518 | $this->dom->addChild( |
||
2519 | $this->dest, |
||
2520 | 'fone', |
||
2521 | $std->fone, |
||
2522 | false, |
||
2523 | $identificador . 'Telefone' |
||
2524 | ); |
||
2525 | $this->dom->addChild( |
||
2526 | $this->dest, |
||
2527 | 'ISUF', |
||
2528 | $std->ISUF, |
||
2529 | false, |
||
2530 | $identificador . 'Inscrição na SUFRAMA' |
||
2531 | ); |
||
2532 | $this->dom->addChild( |
||
2533 | $this->dest, |
||
2534 | 'email', |
||
2535 | $std->email, |
||
2536 | false, |
||
2537 | $identificador . 'Endereço de email' |
||
2538 | ); |
||
2539 | return $this->dest; |
||
2540 | } |
||
2541 | |||
2542 | /** |
||
2543 | * Gera as tags para o elemento: "enderDest" (Informações do Recebedor da Carga) |
||
2544 | * # = 175 |
||
2545 | * Nível = 2 |
||
2546 | * Os parâmetros para esta função são todos os elementos da tag "enderDest" do |
||
2547 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
2548 | * |
||
2549 | * @return \DOMElement |
||
2550 | */ |
||
2551 | public function tagenderDest($std) |
||
2552 | { |
||
2553 | $identificador = '#185 <enderDest> - '; |
||
2554 | $this->enderDest = $this->dom->createElement('enderDest'); |
||
2555 | $this->dom->addChild( |
||
2556 | $this->enderDest, |
||
2557 | 'xLgr', |
||
2558 | $std->xLgr, |
||
2559 | true, |
||
2560 | $identificador . 'Logradouro' |
||
2561 | ); |
||
2562 | $this->dom->addChild( |
||
2563 | $this->enderDest, |
||
2564 | 'nro', |
||
2565 | $std->nro, |
||
2566 | true, |
||
2567 | $identificador . 'Número' |
||
2568 | ); |
||
2569 | $this->dom->addChild( |
||
2570 | $this->enderDest, |
||
2571 | 'xCpl', |
||
2572 | $std->xCpl, |
||
2573 | false, |
||
2574 | $identificador . 'Complemento' |
||
2575 | ); |
||
2576 | $this->dom->addChild( |
||
2577 | $this->enderDest, |
||
2578 | 'xBairro', |
||
2579 | $std->xBairro, |
||
2580 | true, |
||
2581 | $identificador . 'Bairro' |
||
2582 | ); |
||
2583 | $this->dom->addChild( |
||
2584 | $this->enderDest, |
||
2585 | 'cMun', |
||
2586 | $std->cMun, |
||
2587 | true, |
||
2588 | $identificador . 'Código do município (utilizar a tabela do IBGE)' |
||
2589 | ); |
||
2590 | $this->dom->addChild( |
||
2591 | $this->enderDest, |
||
2592 | 'xMun', |
||
2593 | $std->xMun, |
||
2594 | true, |
||
2595 | $identificador . 'Nome do município' |
||
2596 | ); |
||
2597 | $this->dom->addChild( |
||
2598 | $this->enderDest, |
||
2599 | 'CEP', |
||
2600 | $std->CEP, |
||
2601 | false, |
||
2602 | $identificador . 'CEP' |
||
2603 | ); |
||
2604 | $this->dom->addChild( |
||
2605 | $this->enderDest, |
||
2606 | 'UF', |
||
2607 | $std->UF, |
||
2608 | true, |
||
2609 | $identificador . 'Sigla da UF' |
||
2610 | ); |
||
2611 | $this->dom->addChild( |
||
2612 | $this->enderDest, |
||
2613 | 'cPais', |
||
2614 | $std->cPais, |
||
2615 | false, |
||
2616 | $identificador . 'Código do país' |
||
2617 | ); |
||
2618 | $this->dom->addChild( |
||
2619 | $this->enderDest, |
||
2620 | 'xPais', |
||
2621 | $std->xPais, |
||
2622 | false, |
||
2623 | $identificador . 'Nome do país' |
||
2624 | ); |
||
2625 | $node = $this->dest->getElementsByTagName("email")->item(0); |
||
2626 | $this->dest->insertBefore($this->enderDest, $node); |
||
2627 | return $this->enderDest; |
||
2628 | } |
||
2629 | |||
2630 | /** |
||
2631 | * Gera as tags para o elemento: "vPrest" (Valores da Prestação de Serviço) |
||
2632 | * #187 |
||
2633 | * Nível: 1 |
||
2634 | * Os parâmetros para esta função são todos os elementos da tag "vPrest" do |
||
2635 | * tipo elemento (Ele = E|CE|A) e nível 2 |
||
2636 | * |
||
2637 | * @return \DOMElement |
||
2638 | */ |
||
2639 | public function tagvPrest($std) |
||
2640 | { |
||
2641 | $identificador = '#208 <vPrest> - '; |
||
2642 | $this->vPrest = $this->dom->createElement('vPrest'); |
||
2643 | $this->dom->addChild( |
||
2644 | $this->vPrest, |
||
2645 | 'vTPrest', |
||
2646 | $std->vTPrest, |
||
2647 | true, |
||
2648 | $identificador . 'Valor Total da Prestação do Serviço' |
||
2649 | ); |
||
2650 | $this->dom->addChild( |
||
2651 | $this->vPrest, |
||
2652 | 'vRec', |
||
2653 | $std->vRec, |
||
2654 | true, |
||
2655 | $identificador . 'Valor a Receber' |
||
2656 | ); |
||
2657 | return $this->vPrest; |
||
2658 | } |
||
2659 | |||
2660 | /** |
||
2661 | * Gera as tags para o elemento: "Comp" (Componentes do Valor da Prestação) |
||
2662 | * #211 |
||
2663 | * Nível: 2 |
||
2664 | * Os parâmetros para esta função são todos os elementos da tag "Comp" do |
||
2665 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
2666 | * |
||
2667 | * @return \DOMElement |
||
2668 | */ |
||
2669 | public function tagComp($std) |
||
2670 | { |
||
2671 | $identificador = '#65 <pass> - '; |
||
2672 | $this->comp[] = $this->dom->createElement('Comp'); |
||
2673 | $posicao = (int) count($this->comp) - 1; |
||
2674 | $this->dom->addChild( |
||
2675 | $this->comp[$posicao], |
||
2676 | 'xNome', |
||
2677 | $std->xNome, |
||
2678 | false, |
||
2679 | $identificador . 'Nome do componente' |
||
2680 | ); |
||
2681 | $this->dom->addChild( |
||
2682 | $this->comp[$posicao], |
||
2683 | 'vComp', |
||
2684 | $std->vComp, |
||
2685 | false, |
||
2686 | $identificador . 'Valor do componente' |
||
2687 | ); |
||
2688 | return $this->comp[$posicao]; |
||
2689 | } |
||
2690 | |||
2691 | /** |
||
2692 | * tagICMS |
||
2693 | * Informações relativas ao ICMS |
||
2694 | * #194 |
||
2695 | * |
||
2696 | * @return DOMElement |
||
2697 | */ |
||
2698 | public function tagicms($std) |
||
2699 | { |
||
2700 | $identificador = 'N01 <ICMSxx> - '; |
||
2701 | switch ($std->cst) { |
||
2702 | case '00': |
||
2703 | $icms = $this->dom->createElement("ICMS00"); |
||
2704 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 00"); |
||
2705 | $this->dom->addChild($icms, 'vBC', $std->vBC, true, "$identificador Valor da BC do ICMS"); |
||
2706 | $this->dom->addChild($icms, 'pICMS', $std->pICMS, true, "$identificador Alíquota do imposto"); |
||
2707 | $this->dom->addChild($icms, 'vICMS', $std->vICMS, true, "$identificador Valor do ICMS"); |
||
2708 | break; |
||
2709 | case '20': |
||
2710 | $icms = $this->dom->createElement("ICMS20"); |
||
2711 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 20"); |
||
2712 | $this->dom->addChild( |
||
2713 | $icms, |
||
2714 | 'pRedBC', |
||
2715 | $std->pRedBC, |
||
2716 | true, |
||
2717 | "$identificador Percentual da Redução de BC" |
||
2718 | ); |
||
2719 | $this->dom->addChild($icms, 'vBC', $std->vBC, true, "$identificador Valor da BC do ICMS"); |
||
2720 | $this->dom->addChild($icms, 'pICMS', $std->pICMS, true, "$identificador Alíquota do imposto"); |
||
2721 | $this->dom->addChild($icms, 'vICMS', $std->vICMS, true, "$identificador Valor do ICMS"); |
||
2722 | break; |
||
2723 | case '40': |
||
2724 | $icms = $this->dom->createElement("ICMS45"); |
||
2725 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 40"); |
||
2726 | break; |
||
2727 | case '41': |
||
2728 | $icms = $this->dom->createElement("ICMS45"); |
||
2729 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 41"); |
||
2730 | break; |
||
2731 | case '51': |
||
2732 | $icms = $this->dom->createElement("ICMS45"); |
||
2733 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 51"); |
||
2734 | break; |
||
2735 | case '60': |
||
2736 | $icms = $this->dom->createElement("ICMS60"); |
||
2737 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 60"); |
||
2738 | $this->dom->addChild( |
||
2739 | $icms, |
||
2740 | 'vBCSTRet', |
||
2741 | $std->vBCSTRet, |
||
2742 | true, |
||
2743 | "$identificador Valor BC do ICMS ST retido" |
||
2744 | ); |
||
2745 | $this->dom->addChild( |
||
2746 | $icms, |
||
2747 | 'vICMSSTRet', |
||
2748 | $std->vICMSSTRet, |
||
2749 | true, |
||
2750 | "$identificador Valor do ICMS ST retido" |
||
2751 | ); |
||
2752 | $this->dom->addChild( |
||
2753 | $icms, |
||
2754 | 'pICMSSTRet', |
||
2755 | $std->pICMSSTRet, |
||
2756 | true, |
||
2757 | "$identificador Valor do ICMS ST retido" |
||
2758 | ); |
||
2759 | if ($std->vCred > 0) { |
||
2760 | $this->dom->addChild($icms, 'vCred', $std->vCred, false, "$identificador Valor do Crédito"); |
||
2761 | } |
||
2762 | break; |
||
2763 | case '90': |
||
2764 | if ($std->outraUF == true) { |
||
2765 | $icms = $this->dom->createElement("ICMSOutraUF"); |
||
2766 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 90"); |
||
2767 | if ($std->pRedBC > 0) { |
||
2768 | $this->dom->addChild( |
||
2769 | $icms, |
||
2770 | 'pRedBCOutraUF', |
||
2771 | $std->pRedBC, |
||
2772 | false, |
||
2773 | "$identificador Percentual Red " |
||
2774 | . "BC Outra UF" |
||
2775 | ); |
||
2776 | } |
||
2777 | $this->dom->addChild($icms, 'vBCOutraUF', $std->vBC, true, "$identificador Valor BC ICMS Outra UF"); |
||
2778 | $this->dom->addChild($icms, 'pICMSOutraUF', $std->pICMS, true, "$identificador Alíquota do " |
||
2779 | . "imposto Outra UF"); |
||
2780 | $this->dom->addChild( |
||
2781 | $icms, |
||
2782 | 'vICMSOutraUF', |
||
2783 | $std->vICMS, |
||
2784 | true, |
||
2785 | "$identificador Valor ICMS Outra UF" |
||
2786 | ); |
||
2787 | } else { |
||
2788 | $icms = $this->dom->createElement("ICMS90"); |
||
2789 | $this->dom->addChild($icms, 'CST', $std->cst, true, "$identificador Tributação do ICMS = 90"); |
||
2790 | if ($std->pRedBC > 0) { |
||
2791 | $this->dom->addChild( |
||
2792 | $icms, |
||
2793 | 'pRedBC', |
||
2794 | $std->pRedBC, |
||
2795 | false, |
||
2796 | "$identificador Percentual Redução BC" |
||
2797 | ); |
||
2798 | } |
||
2799 | $this->dom->addChild($icms, 'vBC', $std->vBC, true, "$identificador Valor da BC do ICMS"); |
||
2800 | $this->dom->addChild($icms, 'pICMS', $std->pICMS, true, "$identificador Alíquota do imposto"); |
||
2801 | $this->dom->addChild($icms, 'vICMS', $std->vICMS, true, "$identificador Valor do ICMS"); |
||
2802 | if ($std->vCred > 0) { |
||
2803 | $this->dom->addChild($icms, 'vCred', $std->vCred, false, "$identificador Valor do Crédido"); |
||
2804 | } |
||
2805 | } |
||
2806 | break; |
||
2807 | case 'SN': |
||
2808 | $icms = $this->dom->createElement("ICMSSN"); |
||
2809 | $this->dom->addChild($icms, 'CST', 90, true, "$identificador Tributação do ICMS = 90"); |
||
2810 | $this->dom->addChild($icms, 'indSN', '1', true, "$identificador Indica se contribuinte é SN"); |
||
2811 | break; |
||
2812 | } |
||
2813 | $this->imp = $this->dom->createElement('imp'); |
||
2814 | $tagIcms = $this->dom->createElement('ICMS'); |
||
2815 | if (isset($icms)) { |
||
2816 | $this->imp->appendChild($tagIcms); |
||
2817 | } |
||
2818 | if (isset($icms)) { |
||
2819 | $tagIcms->appendChild($icms); |
||
2820 | } |
||
2821 | if ($std->vTotTrib > 0) { |
||
2822 | $this->dom->addChild( |
||
2823 | $this->imp, |
||
2824 | 'vTotTrib', |
||
2825 | $std->vTotTrib, |
||
2826 | false, |
||
2827 | "$identificador Valor Total dos Tributos" |
||
2828 | ); |
||
2829 | } |
||
2830 | if (isset($std->infAdFisco)) { |
||
2831 | $this->dom->addChild( |
||
2832 | $this->imp, |
||
2833 | 'infAdFisco', |
||
2834 | $std->infAdFisco, |
||
2835 | false, |
||
2836 | "$identificador Informações adicionais de interesse do Fisco" |
||
2837 | ); |
||
2838 | } |
||
2839 | |||
2840 | if ($std->vICMSUFFim != '' || $std->vICMSUFIni != '') { |
||
2841 | $icmsDifal = $this->dom->createElement("ICMSUFFim"); |
||
2842 | $this->dom->addChild( |
||
2843 | $icmsDifal, |
||
2844 | 'vBCUFFim', |
||
2845 | $std->vBCUFFim, |
||
2846 | true, |
||
2847 | "$identificador Valor da BC do ICMS na UF |
||
2848 | de término da prestação do serviço de transporte" |
||
2849 | ); |
||
2850 | $this->dom->addChild( |
||
2851 | $icmsDifal, |
||
2852 | 'pFCPUFFim', |
||
2853 | $std->pFCPUFFim, |
||
2854 | true, |
||
2855 | "$identificador Percentual do ICMS |
||
2856 | relativo ao Fundo de Combate à pobreza (FCP) na UF de término da prestação do serviço de |
||
2857 | transporte" |
||
2858 | ); |
||
2859 | $this->dom->addChild( |
||
2860 | $icmsDifal, |
||
2861 | 'pICMSUFFim', |
||
2862 | $std->pICMSUFFim, |
||
2863 | true, |
||
2864 | "$identificador Alíquota interna da UF |
||
2865 | de término da prestação do serviço de transporte" |
||
2866 | ); |
||
2867 | $this->dom->addChild( |
||
2868 | $icmsDifal, |
||
2869 | 'pICMSInter', |
||
2870 | $std->pICMSInter, |
||
2871 | true, |
||
2872 | "$identificador Alíquota interestadual |
||
2873 | das UF envolvidas" |
||
2874 | ); |
||
2875 | $this->dom->addChild( |
||
2876 | $icmsDifal, |
||
2877 | 'pICMSInterPart', |
||
2878 | $std->pICMSInterPart, |
||
2879 | true, |
||
2880 | "$identificador Percentual |
||
2881 | provisório de partilha entre os estados" |
||
2882 | ); |
||
2883 | $this->dom->addChild( |
||
2884 | $icmsDifal, |
||
2885 | 'vFCPUFFim', |
||
2886 | $std->vFCPUFFim, |
||
2887 | true, |
||
2888 | "$identificador Valor do ICMS relativo |
||
2889 | ao Fundo de Combate á Pobreza (FCP) da UF de término da prestação" |
||
2890 | ); |
||
2891 | $this->dom->addChild( |
||
2892 | $icmsDifal, |
||
2893 | 'vICMSUFFim', |
||
2894 | $std->vICMSUFFim, |
||
2895 | true, |
||
2896 | "$identificador Valor do ICMS de |
||
2897 | partilha para a UF de término da prestação do serviço de transporte" |
||
2898 | ); |
||
2899 | $this->dom->addChild( |
||
2900 | $icmsDifal, |
||
2901 | 'vICMSUFIni', |
||
2902 | $std->vICMSUFIni, |
||
2903 | true, |
||
2904 | "$identificador Valor do ICMS de |
||
2905 | partilha para a UF de início da prestação do serviço de transporte" |
||
2906 | ); |
||
2907 | |||
2908 | $this->imp->appendChild($icmsDifal); |
||
2909 | } |
||
2910 | |||
2911 | return $tagIcms; |
||
2912 | } |
||
2913 | |||
2914 | /** |
||
2915 | * tagInfTribFed |
||
2916 | * Informações do Impostos Federais |
||
2917 | * CTe OS |
||
2918 | * @return DOMElement |
||
2919 | */ |
||
2920 | public function taginfTribFed($std) |
||
2921 | { |
||
2922 | $identificador = 'N02 <imp> - '; |
||
2923 | $tagInfTribFed = $this->dom->createElement('infTribFed'); |
||
2924 | |||
2925 | $this->dom->addChild($tagInfTribFed, 'vPIS', $std->vPIS, false, "$identificador Valor de PIS"); |
||
2926 | $this->dom->addChild($tagInfTribFed, 'vCOFINS', $std->vCOFINS, false, "$identificador Valor de COFINS"); |
||
2927 | $this->dom->addChild($tagInfTribFed, 'vIR', $std->vIR, false, "$identificador Valor de IR"); |
||
2928 | $this->dom->addChild($tagInfTribFed, 'vINSS', $std->vINSS, false, "$identificador Valor de INSS"); |
||
2929 | $this->dom->addChild($tagInfTribFed, 'vCSLL', $std->vCSLL, false, "$identificador Valor de CSLL"); |
||
2930 | |||
2931 | $this->imp->appendChild($tagInfTribFed); |
||
2932 | } |
||
2933 | |||
2934 | |||
2935 | /** |
||
2936 | * Tag raiz do documento xml |
||
2937 | * Função chamada pelo método [ monta ] |
||
2938 | * @return \DOMElement |
||
2939 | */ |
||
2940 | private function buildCTe() |
||
2941 | { |
||
2942 | if (empty($this->CTe)) { |
||
2943 | $this->CTe = $this->dom->createElement('CTe'); |
||
2944 | $this->CTe->setAttribute('xmlns', 'http://www.portalfiscal.inf.br/cte'); |
||
2945 | } |
||
2946 | return $this->CTe; |
||
2947 | } |
||
2948 | |||
2949 | /** |
||
2950 | * Tag raiz do documento xml |
||
2951 | * Função chamada pelo método [ monta ] |
||
2952 | * @return \DOMElement |
||
2953 | */ |
||
2954 | private function buildCTeOS() |
||
2955 | { |
||
2956 | if (empty($this->CTe)) { |
||
2957 | $this->CTe = $this->dom->createElement('CTeOS'); |
||
2958 | $this->CTe->setAttribute('versao', '3.00'); |
||
2959 | $this->CTe->setAttribute('xmlns', 'http://www.portalfiscal.inf.br/cte'); |
||
2960 | } |
||
2961 | return $this->CTe; |
||
2962 | } |
||
2963 | |||
2964 | /** |
||
2965 | * Gera as tags para o elemento: "Entrega" (Informações ref. a previsão de entrega) |
||
2966 | * #69 |
||
2967 | * Nível: 2 |
||
2968 | * Os parâmetros para esta função são todos os elementos da tag "Entrega" do |
||
2969 | * tipo elemento (Ele = E|CE|A) e nível 3 |
||
2970 | * |
||
2971 | * @return \DOMElement |
||
2972 | */ |
||
2973 | private function tagEntrega() |
||
2974 | { |
||
2975 | if ($this->compl == '') { |
||
2976 | $this->compl = $this->dom->createElement('compl'); |
||
2977 | } |
||
2978 | if ($this->entrega == '') { |
||
2979 | $this->entrega = $this->dom->createElement('Entrega'); |
||
2980 | $this->dom->appChild($this->compl, $this->entrega, 'Falta tag "compl"'); |
||
2981 | } |
||
2982 | return $this->entrega; |
||
2983 | } |
||
2984 | |||
2985 | /** |
||
2986 | * #241 |
||
2987 | * @return type |
||
2988 | */ |
||
2989 | public function taginfCTeNorm() |
||
2990 | { |
||
2991 | $this->infCTeNorm = $this->dom->createElement('infCTeNorm'); |
||
2992 | return $this->infCTeNorm; |
||
2993 | } |
||
2994 | |||
2995 | /** |
||
2996 | * Gera as tags para o elemento: "infCarga" (Informações da Carga do CT-e) |
||
2997 | * #242 |
||
2998 | * Nível: 2 |
||
2999 | * |
||
3000 | * @return \DOMElement |
||
3001 | */ |
||
3002 | public function taginfCarga($std) |
||
3003 | { |
||
3004 | $identificador = '#242 <infCarga> - '; |
||
3005 | $this->infCarga = $this->dom->createElement('infCarga'); |
||
3006 | $this->dom->addChild( |
||
3007 | $this->infCarga, |
||
3008 | 'vCarga', |
||
3009 | $std->vCarga, |
||
3010 | false, |
||
3011 | $identificador . 'Valor Total da Carga' |
||
3012 | ); |
||
3013 | $this->dom->addChild( |
||
3014 | $this->infCarga, |
||
3015 | 'proPred', |
||
3016 | $std->proPred, |
||
3017 | true, |
||
3018 | $identificador . 'Produto Predominante' |
||
3019 | ); |
||
3020 | $this->dom->addChild( |
||
3021 | $this->infCarga, |
||
3022 | 'xOutCat', |
||
3023 | $std->xOutCat, |
||
3024 | false, |
||
3025 | $identificador . 'Outras Caract. da Carga' |
||
3026 | ); |
||
3027 | return $this->infCarga; |
||
3028 | } |
||
3029 | |||
3030 | /** |
||
3031 | * Gera as tags para o elemento: "infCTeNorm" (Informações da Carga do CT-e OS) |
||
3032 | * #253 |
||
3033 | * Nível: 2 |
||
3034 | * Os parâmetros para esta função são todos os elementos da tag "infServico" |
||
3035 | * |
||
3036 | * @return \DOMElement |
||
3037 | */ |
||
3038 | public function taginfServico($std) |
||
3039 | { |
||
3040 | $identificador = '#253 <infServico> - '; |
||
3041 | |||
3042 | $this->infServico = $this->dom->createElement('infServico'); |
||
3043 | $this->dom->addChild( |
||
3044 | $this->infServico, |
||
3045 | 'xDescServ', |
||
3046 | $std->xDescServ, |
||
3047 | true, |
||
3048 | $identificador . 'Descrição do Serviço Prestado' |
||
3049 | ); |
||
3050 | $infQ = $this->dom->createElement('infQ'); |
||
3051 | $this->dom->addChild($infQ, 'qCarga', $std->qCarga, false, $identificador . 'Quantidade'); |
||
3052 | |||
3053 | $this->infServico->appendChild($infQ); |
||
3054 | |||
3055 | return $this->infServico; |
||
3056 | } |
||
3057 | |||
3058 | /** |
||
3059 | * Gera as tags para o elemento: "infQ" (Informações de quantidades da Carga do CT-e) |
||
3060 | * #246 |
||
3061 | * Nível: 3 |
||
3062 | * Os parâmetros para esta função são todos os elementos da tag "infQ" |
||
3063 | * |
||
3064 | * @return mixed |
||
3065 | */ |
||
3066 | public function taginfQ($std) |
||
3067 | { |
||
3068 | $identificador = '#257 <infQ> - '; |
||
3069 | $this->infQ[] = $this->dom->createElement('infQ'); |
||
3070 | $posicao = (int) count($this->infQ) - 1; |
||
3071 | $this->dom->addChild($this->infQ[$posicao], 'cUnid', $std->cUnid, true, $identificador . 'Código da |
||
3072 | Unidade de Medida'); |
||
3073 | $this->dom->addChild($this->infQ[$posicao], 'tpMed', $std->tpMed, true, $identificador . 'Tipo da Medida'); |
||
3074 | $this->dom->addChild($this->infQ[$posicao], 'qCarga', $std->qCarga, true, $identificador . 'Quantidade'); |
||
3075 | $this->dom->addChild($this->infQ[$posicao], 'vCargaAverb', $std->vCargaAverb, false, $identificador . 'Valor da Carga para efeito de averbação'); |
||
3076 | |||
3077 | return $this->infQ[$posicao]; |
||
3078 | } |
||
3079 | |||
3080 | public function taginfDoc() |
||
3081 | { |
||
3082 | $this->infDoc = $this->dom->createElement('infDoc'); |
||
3083 | return $this->infDoc; |
||
3084 | } |
||
3085 | |||
3086 | /** |
||
3087 | * Documentos de Transporte Anterior |
||
3088 | * @return DOMElement|\DOMNode |
||
3089 | */ |
||
3090 | public function tagdocAnt() |
||
3091 | { |
||
3092 | $this->docAnt = $this->dom->createElement('docAnt'); |
||
3093 | return $this->docAnt; |
||
3094 | } |
||
3095 | |||
3096 | /** |
||
3097 | * Informações de identificação dos documentos de Transporte Anterior |
||
3098 | * @return array|DOMElement |
||
3099 | */ |
||
3100 | public function tagidDocAnt() |
||
3101 | { |
||
3102 | $this->idDocAnt = $this->dom->createElement('idDocAnt'); |
||
3103 | return $this->idDocAnt; |
||
3104 | } |
||
3105 | |||
3106 | /** |
||
3107 | * Gera as tags para o elemento: "infNF" (Informações das NF) |
||
3108 | * #262 |
||
3109 | * Nível: 3 |
||
3110 | * @return mixed |
||
3111 | */ |
||
3112 | public function taginfNF($std) |
||
3113 | { |
||
3114 | $identificador = '#262 <infNF> - '; |
||
3115 | $this->infNF[] = $this->dom->createElement('infNF'); |
||
3116 | $posicao = (int) count($this->infNF) - 1; |
||
3117 | |||
3118 | $this->dom->addChild($this->infNF[$posicao], 'nRoma', $std->nRoma, false, $identificador . 'Número do |
||
3119 | Romaneio da NF'); |
||
3120 | $this->dom->addChild($this->infNF[$posicao], 'nPed', $std->nPed, false, $identificador . 'Número do |
||
3121 | Pedido da NF'); |
||
3122 | $this->dom->addChild($this->infNF[$posicao], 'mod', $std->mod, true, $identificador . 'Modelo da |
||
3123 | Nota Fiscal'); |
||
3124 | $this->dom->addChild($this->infNF[$posicao], 'serie', $std->serie, true, $identificador . 'Série'); |
||
3125 | $this->dom->addChild($this->infNF[$posicao], 'nDoc', $std->nDoc, true, $identificador . 'Número'); |
||
3126 | $this->dom->addChild($this->infNF[$posicao], 'dEmi', $std->dEmi, true, $identificador . 'Data de Emissão'); |
||
3127 | $this->dom->addChild($this->infNF[$posicao], 'vBC', $std->vBC, true, $identificador . 'Valor da Base |
||
3128 | de Cálculo do ICMS'); |
||
3129 | $this->dom->addChild($this->infNF[$posicao], 'vICMS', $std->vICMS, true, $identificador . 'Valor Total |
||
3130 | do ICMS'); |
||
3131 | $this->dom->addChild($this->infNF[$posicao], 'vBCST', $std->vBCST, true, $identificador . 'Valor da |
||
3132 | Base de Cálculo do ICMS ST'); |
||
3133 | $this->dom->addChild($this->infNF[$posicao], 'vST', $std->vST, true, $identificador . 'Valor Total |
||
3134 | do ICMS ST'); |
||
3135 | $this->dom->addChild($this->infNF[$posicao], 'vProd', $std->vProd, true, $identificador . 'Valor Total |
||
3136 | dos Produtos'); |
||
3137 | $this->dom->addChild($this->infNF[$posicao], 'vNF', $std->vNF, true, $identificador . 'Valor Total da NF'); |
||
3138 | $this->dom->addChild($this->infNF[$posicao], 'nCFOP', $std->nCFOP, true, $identificador . 'CFOP Predominante'); |
||
3139 | $this->dom->addChild($this->infNF[$posicao], 'nPeso', $std->nPeso, false, $identificador . 'Peso total em Kg'); |
||
3140 | $this->dom->addChild($this->infNF[$posicao], 'PIN', $std->PIN, false, $identificador . 'PIN SUFRAMA'); |
||
3141 | $this->dom->addChild($this->infNF[$posicao], 'dPrev', $std->dPrev, false, $identificador . 'Data prevista |
||
3142 | de entrega'); |
||
3143 | |||
3144 | return $this->infNF[$posicao]; |
||
3145 | } |
||
3146 | |||
3147 | /** |
||
3148 | * Gera as tags para o elemento: "infNFe" (Informações das NF-e) |
||
3149 | * #297 |
||
3150 | * Nível: 3 |
||
3151 | * @return mixed |
||
3152 | */ |
||
3153 | public function taginfNFe($std) |
||
3154 | { |
||
3155 | $identificador = '#297 <infNFe> - '; |
||
3156 | $this->infNFe[] = $this->dom->createElement('infNFe'); |
||
3157 | $posicao = (int) count($this->infNFe) - 1; |
||
3158 | $this->dom->addChild( |
||
3159 | $this->infNFe[$posicao], |
||
3160 | 'chave', |
||
3161 | $std->chave, |
||
3162 | true, |
||
3163 | $identificador . 'Chave de acesso da NF-e' |
||
3164 | ); |
||
3165 | $this->dom->addChild( |
||
3166 | $this->infNFe[$posicao], |
||
3167 | 'PIN', |
||
3168 | $std->PIN, |
||
3169 | false, |
||
3170 | $identificador . 'PIN SUFRAMA' |
||
3171 | ); |
||
3172 | $this->dom->addChild( |
||
3173 | $this->infNFe[$posicao], |
||
3174 | 'dPrev', |
||
3175 | $std->dPrev, |
||
3176 | false, |
||
3177 | $identificador . 'Data prevista de entrega' |
||
3178 | ); |
||
3179 | return $this->infNFe[$posicao]; |
||
3180 | } |
||
3181 | |||
3182 | /** |
||
3183 | * Gera as tags para o elemento: "infOutros" (Informações dos demais documentos) |
||
3184 | * #319 |
||
3185 | * Nível: 3 |
||
3186 | * @return mixed |
||
3187 | */ |
||
3188 | public function taginfOutros($std) |
||
3189 | { |
||
3190 | $ident = '#319 <infOutros> - '; |
||
3191 | $this->infOutros[] = $this->dom->createElement('infOutros'); |
||
3192 | $posicao = (int) count($this->infOutros) - 1; |
||
3193 | $this->dom->addChild($this->infOutros[$posicao], 'tpDoc', $std->tpDoc, true, $ident . 'Tipo ' |
||
3194 | . 'de documento originário'); |
||
3195 | $this->dom->addChild($this->infOutros[$posicao], 'descOutros', $std->descOutros, false, $ident . 'Descrição ' |
||
3196 | . 'do documento'); |
||
3197 | $this->dom->addChild($this->infOutros[$posicao], 'nDoc', $std->nDoc, false, $ident . 'Número ' |
||
3198 | . 'do documento'); |
||
3199 | $this->dom->addChild($this->infOutros[$posicao], 'dEmi', $std->dEmi, false, $ident . 'Data de Emissão'); |
||
3200 | $this->dom->addChild($this->infOutros[$posicao], 'vDocFisc', $std->vDocFisc, false, $ident . 'Valor ' |
||
3201 | . 'do documento'); |
||
3202 | $this->dom->addChild($this->infOutros[$posicao], 'dPrev', $std->dPrev, false, $ident . 'Data ' |
||
3203 | . 'prevista de entrega'); |
||
3204 | return $this->infOutros[$posicao]; |
||
3205 | } |
||
3206 | |||
3207 | /** |
||
3208 | * Gera as tags para o elemento: "infDocRef" (Informações dos demais documentos) |
||
3209 | * #319 |
||
3210 | * Nível: 3 |
||
3211 | * @return mixed |
||
3212 | */ |
||
3213 | public function taginfDocRef($std) |
||
3214 | { |
||
3215 | $ident = '#319 <infDocRef> - '; |
||
3216 | $this->infDocRef[] = $this->dom->createElement('infDocRef'); |
||
3217 | $posicao = (int) count($this->infDocRef) - 1; |
||
3218 | $this->dom->addChild($this->infDocRef[$posicao], 'nDoc', $std->nDoc, false, $ident . 'Número ' |
||
3219 | . 'do documento'); |
||
3220 | $this->dom->addChild($this->infDocRef[$posicao], 'serie', $std->serie, false, $ident . 'Série ' |
||
3221 | . 'do documento'); |
||
3222 | $this->dom->addChild($this->infDocRef[$posicao], 'subserie', $std->subserie, false, $ident . 'Subserie ' |
||
3223 | . 'do documento'); |
||
3224 | $this->dom->addChild($this->infDocRef[$posicao], 'dEmi', $std->dEmi, false, $ident . 'Data de Emissão'); |
||
3225 | $this->dom->addChild($this->infDocRef[$posicao], 'vDoc', $std->vDoc, false, $ident . 'Valor ' |
||
3226 | . 'do documento'); |
||
3227 | return $this->infDocRef[$posicao]; |
||
3228 | } |
||
3229 | |||
3230 | /** |
||
3231 | * Gera as tags para o elemento: "emiDocAnt" (Informações dos CT-es Anteriores) |
||
3232 | * #345 |
||
3233 | * Nível: 3 |
||
3234 | * @return mixed |
||
3235 | */ |
||
3236 | public function tagemiDocAnt($std) |
||
3237 | { |
||
3238 | $identificador = '#345 <emiDocAnt> - '; |
||
3239 | $this->emiDocAnt[] = $this->dom->createElement('emiDocAnt'); |
||
3240 | $posicao = (int) count($this->emiDocAnt) - 1; |
||
3241 | if ($std->CNPJ != '') { |
||
3242 | $this->dom->addChild( |
||
3243 | $this->emiDocAnt[$posicao], |
||
3244 | 'CNPJ', |
||
3245 | $std->CNPJ, |
||
3246 | true, |
||
3247 | $identificador . 'Número do CNPJ' |
||
3248 | ); |
||
3249 | $this->dom->addChild( |
||
3250 | $this->emiDocAnt[$posicao], |
||
3251 | 'IE', |
||
3252 | Strings::onlyNumbers($std->IE), |
||
3253 | true, |
||
3254 | $identificador . 'Inscrição Estadual' |
||
3255 | ); |
||
3256 | $this->dom->addChild($this->emiDocAnt[$posicao], 'UF', $std->UF, true, $identificador . 'Sigla da UF'); |
||
3257 | } else { |
||
3258 | $this->dom->addChild($this->emiDocAnt[$posicao], 'CPF', $std->CPF, true, $identificador . 'Número do CPF'); |
||
3259 | } |
||
3260 | $this->dom->addChild( |
||
3261 | $this->emiDocAnt[$posicao], |
||
3262 | 'xNome', |
||
3263 | $std->xNome, |
||
3264 | true, |
||
3265 | $identificador . 'Razão Social ou Nome do Expedidor' |
||
3266 | ); |
||
3267 | |||
3268 | return $this->emiDocAnt[$posicao]; |
||
3269 | } |
||
3270 | |||
3271 | /** |
||
3272 | * Gera as tags para o elemento: "idDocAntEle" (Informações dos CT-es Anteriores) |
||
3273 | * #348 |
||
3274 | * Nível: 4 |
||
3275 | * @return mixed |
||
3276 | */ |
||
3277 | public function tagidDocAntEle($std) |
||
3278 | { |
||
3279 | $identificador = '#358 <idDocAntEle> - '; |
||
3280 | $this->idDocAntEle[] = $this->dom->createElement('idDocAntEle'); |
||
3281 | $posicao = (int) count($this->idDocAntEle) - 1; |
||
3282 | $this->dom->addChild($this->idDocAntEle[$posicao], 'chCTe', $std->chCTe, true, $identificador . 'Chave de ' |
||
3283 | . 'Acesso do CT-e'); |
||
3284 | |||
3285 | return $this->idDocAntEle[$posicao]; |
||
3286 | } |
||
3287 | |||
3288 | |||
3289 | /** |
||
3290 | * Gera as tags para o elemento: "seg" (Informações de Seguro da Carga) |
||
3291 | * #360 |
||
3292 | * Nível: 2 |
||
3293 | * @return mixed |
||
3294 | */ |
||
3295 | public function tagseg($std) |
||
3296 | { |
||
3297 | $identificador = '#360 <seg> - '; |
||
3298 | $this->seg[] = $this->dom->createElement('seg'); |
||
3299 | $posicao = (int) count($this->seg) - 1; |
||
3300 | |||
3301 | $this->dom->addChild($this->seg[$posicao], 'respSeg', $std->respSeg, true, $identificador . 'Responsável |
||
3302 | pelo Seguro'); |
||
3303 | $this->dom->addChild($this->seg[$posicao], 'xSeg', $std->xSeg, false, $identificador . 'Nome da |
||
3304 | Seguradora'); |
||
3305 | $this->dom->addChild($this->seg[$posicao], 'nApol', $std->nApol, false, $identificador . 'Número da Apólice'); |
||
3306 | return $this->seg[$posicao]; |
||
3307 | } |
||
3308 | |||
3309 | /** |
||
3310 | * Gera as tags para o elemento: "infModal" (Informações do modal) |
||
3311 | * #366 |
||
3312 | * Nível: 2 |
||
3313 | * @param string $versaoModal |
||
3314 | * @return DOMElement|\DOMNode |
||
3315 | */ |
||
3316 | public function taginfModal($std) |
||
3317 | { |
||
3318 | $identificador = '#366 <infModal> - '; |
||
3319 | $this->infModal = $this->dom->createElement('infModal'); |
||
3320 | $this->infModal->setAttribute('versaoModal', $std->versaoModal); |
||
3321 | return $this->infModal; |
||
3322 | } |
||
3323 | |||
3324 | /** |
||
3325 | * Leiaute - Rodoviário |
||
3326 | * Gera as tags para o elemento: "rodo" (Informações do modal Rodoviário) |
||
3327 | * #1 |
||
3328 | * Nível: 0 |
||
3329 | * @return DOMElement|\DOMNode |
||
3330 | */ |
||
3331 | public function tagrodo($std) |
||
3332 | { |
||
3333 | $identificador = '#1 <rodo> - '; |
||
3334 | $this->rodo = $this->dom->createElement('rodo'); |
||
3335 | $this->dom->addChild( |
||
3336 | $this->rodo, |
||
3337 | 'RNTRC', |
||
3338 | $std->RNTRC, |
||
3339 | true, |
||
3340 | $identificador . 'Registro nacional de transportadores |
||
3341 | rodoviários de carga' |
||
3342 | ); |
||
3343 | |||
3344 | return $this->rodo; |
||
3345 | } |
||
3346 | |||
3347 | /** |
||
3348 | * Leiaute - Rodoviário |
||
3349 | * Gera as tags para o elemento: "rodo" (Informações do modal Rodoviário) CT-e OS |
||
3350 | * #1 |
||
3351 | * Nível: 0 |
||
3352 | * @return DOMElement|\DOMNode |
||
3353 | */ |
||
3354 | public function tagrodoOS($std) |
||
3355 | { |
||
3356 | $identificador = '#1 <rodoOS> - '; |
||
3357 | $this->rodo = $this->dom->createElement('rodoOS'); |
||
3358 | $this->dom->addChild($this->rodo, 'TAF', $std->TAF, false, $identificador . |
||
3359 | 'Termo de Autorização de Fretamento - TAF'); |
||
3360 | $this->dom->addChild($this->rodo, 'NroRegEstadual', $std->nroRegEstadual, false, $identificador . |
||
3361 | 'Número do Registro Estadual'); |
||
3362 | |||
3363 | return $this->rodo; |
||
3364 | } |
||
3365 | |||
3366 | /** |
||
3367 | * Leiaute - Aéreo |
||
3368 | * Gera as tags para o elemento: "aereo" (Informações do modal Aéreo) |
||
3369 | * @author Newton Pasqualini Filho |
||
3370 | * #1 |
||
3371 | * Nível: 0 |
||
3372 | * @return DOMElement|\DOMNode |
||
3373 | */ |
||
3374 | public function tagaereo($std) |
||
3375 | { |
||
3376 | $identificador = '#1 <aereo> - '; |
||
3377 | $this->aereo = $this->dom->createElement('aereo'); |
||
3378 | $this->dom->addChild( |
||
3379 | $this->aereo, |
||
3380 | 'nMinu', |
||
3381 | $std->nMinu, |
||
3382 | false, |
||
3383 | $identificador . 'Número da Minuta' |
||
3384 | ); |
||
3385 | $this->dom->addChild( |
||
3386 | $this->aereo, |
||
3387 | 'nOCA', |
||
3388 | $std->nOCA, |
||
3389 | false, |
||
3390 | $identificador . 'Número Operacional do Conhecimento Aéreo' |
||
3391 | ); |
||
3392 | $this->dom->addChild( |
||
3393 | $this->aereo, |
||
3394 | 'dPrevAereo', |
||
3395 | $std->dPrevAereo, |
||
3396 | true, |
||
3397 | $identificador . 'Data prevista da entrega' |
||
3398 | ); |
||
3399 | if (isset($std->natCarga_xDime) || isset($std->natCarga_cInfManu)) { |
||
3400 | $identificador = '#1 <aereo> - <natCarga> - '; |
||
3401 | $this->natCarga = $this->dom->createElement('natCarga'); |
||
3402 | $this->dom->addChild( |
||
3403 | $this->natCarga, |
||
3404 | 'xDime', |
||
3405 | $std->natCarga_xDime, |
||
3406 | false, |
||
3407 | $identificador . 'Dimensões da carga, formato: 1234x1234x1234 (cm)' |
||
3408 | ); |
||
3409 | if (isset($std->natCarga_cInfManu) && !is_array($std->natCarga_cInfManu)) { |
||
3410 | $std->natCarga_cInfManu = [$std->natCarga_cInfManu]; |
||
3411 | } |
||
3412 | $cInfManuX = 0; |
||
3413 | foreach ($std->natCarga_cInfManu as $cInfManu) { |
||
3414 | $cInfManuX++; |
||
3415 | $this->dom->addChild( |
||
3416 | $this->natCarga, |
||
3417 | 'cInfManu', |
||
3418 | $cInfManu, |
||
3419 | false, |
||
3420 | $identificador . 'Informação de manuseio, com dois dígitos, pode ter mais de uma ocorrência.' |
||
3421 | ); |
||
3422 | } |
||
3423 | $this->aereo->appendChild($this->natCarga); |
||
3424 | } |
||
3425 | $identificador = '#1 <aereo> - <tarifa> - '; |
||
3426 | $this->tarifa = $this->dom->createElement('tarifa'); |
||
3427 | $this->dom->addChild( |
||
3428 | $this->tarifa, |
||
3429 | 'CL', |
||
3430 | $std->tarifa_CL, |
||
3431 | true, |
||
3432 | $identificador . 'Classe da tarifa: M - Tarifa Mínima / G - Tarifa Geral / E - Tarifa Específica' |
||
3433 | ); |
||
3434 | $this->dom->addChild( |
||
3435 | $this->tarifa, |
||
3436 | 'cTar', |
||
3437 | $std->tarifa_cTar, |
||
3438 | false, |
||
3439 | $identificador . 'Código de três digítos correspondentes à tarifa.' |
||
3440 | ); |
||
3441 | $this->dom->addChild( |
||
3442 | $this->tarifa, |
||
3443 | 'vTar', |
||
3444 | $std->tarifa_vTar, |
||
3445 | true, |
||
3446 | $identificador . 'Valor da tarifa. 15 posições, sendo 13 inteiras e 2 decimais.' |
||
3447 | ); |
||
3448 | $this->aereo->appendChild($this->tarifa); |
||
3449 | return $this->aereo; |
||
3450 | } |
||
3451 | |||
3452 | /** |
||
3453 | * CT-e de substituição |
||
3454 | * @return type |
||
3455 | */ |
||
3456 | public function taginfCteSub($std) |
||
3457 | { |
||
3458 | $identificador = '#149 <infCteSub> - '; |
||
3459 | $this->infCteSub = $this->dom->createElement('infCteSub'); |
||
3460 | |||
3461 | $this->dom->addChild( |
||
3462 | $this->infCteSub, |
||
3463 | 'chCTe', |
||
3464 | $std->chCTe, |
||
3465 | false, |
||
3466 | "$identificador Chave de acesso do CTe a ser substituído (original)" |
||
3467 | ); |
||
3468 | $this->dom->addChild( |
||
3469 | $this->infCteSub, |
||
3470 | 'retCteAnu', |
||
3471 | $std->retCteAnu, |
||
3472 | false, |
||
3473 | "$identificador Chave de acesso do CT-e de Anulação" |
||
3474 | ); |
||
3475 | return $this->infCteSub; |
||
3476 | } |
||
3477 | |||
3478 | |||
3479 | /** |
||
3480 | * CT-e de substituição - tomaICMS |
||
3481 | * @param type $std |
||
3482 | * @return type |
||
3483 | */ |
||
3484 | public function tagtomaICMS() |
||
3485 | { |
||
3486 | $this->tomaICMS = $this->dom->createElement('tomaICMS'); |
||
3487 | |||
3488 | return $this->tomaICMS; |
||
3489 | } |
||
3490 | |||
3491 | /** |
||
3492 | * CT-e de substituição - NF-e |
||
3493 | * @param type $std |
||
3494 | * @return type |
||
3495 | */ |
||
3496 | public function tagrefNFe($std) |
||
3497 | { |
||
3498 | if (empty($this->tomICMS)) { |
||
3499 | $this->tomaICMS = $this->dom->createElement('tomaICMS'); |
||
3500 | } |
||
3501 | $identificador = '#153 <refNFe> - '; |
||
3502 | $this->dom->addChild( |
||
3503 | $this->tomaICMS, |
||
3504 | 'refNFe', |
||
3505 | $std->refNFe, |
||
3506 | false, |
||
3507 | "$identificador Chave de acesso da NF-e emitida pelo tomador" |
||
3508 | ); |
||
3509 | |||
3510 | return $this->tomaICMS; |
||
3511 | } |
||
3512 | |||
3513 | /** |
||
3514 | * CT-e de substituição - NF |
||
3515 | * @param type $std |
||
3516 | * @return type |
||
3517 | */ |
||
3518 | public function tagrefNF($std) |
||
3519 | { |
||
3520 | $identificador = '#154 <refNFe> - '; |
||
3521 | if (empty($this->tomICMS)) { |
||
3522 | $this->tomaICMS = $this->dom->createElement('tomaICMS'); |
||
3523 | } |
||
3524 | $this->refNF = $this->dom->createElement('refNF'); |
||
3525 | if ($std->CNPJ != '') { |
||
3526 | $this->dom->addChild( |
||
3527 | $this->refNF, |
||
3528 | 'CNPJ', |
||
3529 | $std->CNPJ, |
||
3530 | true, |
||
3531 | $identificador . 'CNPJ do emitente' |
||
3532 | ); |
||
3533 | } elseif ($std->CPF != '') { |
||
3534 | $this->dom->addChild( |
||
3535 | $this->refNF, |
||
3536 | 'CPF', |
||
3537 | $std->CPF, |
||
3538 | true, |
||
3539 | $identificador . 'CPF do emitente' |
||
3540 | ); |
||
3541 | } |
||
3542 | $this->dom->addChild($this->refNF, 'mod', $std->mod, false, $identificador . 'Modelo'); |
||
3543 | $this->dom->addChild($this->refNF, 'serie', $std->serie, false, $identificador . 'Série ' |
||
3544 | . 'do documento'); |
||
3545 | $this->dom->addChild($this->refNF, 'subserie', $std->subserie, false, $identificador . 'Subserie ' |
||
3546 | . 'do documento'); |
||
3547 | $this->dom->addChild($this->refNF, 'nro', $std->nro, false, $identificador . 'Número'); |
||
3548 | $this->dom->addChild($this->refNF, 'valor', $std->valor, false, $identificador . 'Valor'); |
||
3549 | $this->dom->addChild($this->refNF, 'dEmi', $std->dEmi, false, $identificador . 'Emissão'); |
||
3550 | |||
3551 | $this->tomaICMS->appendChild($this->refNF); |
||
3552 | |||
3553 | return $this->tomaICMS; |
||
3554 | } |
||
3555 | |||
3556 | /** |
||
3557 | * CT-e de substituição - CT-e |
||
3558 | * @param type $std |
||
3559 | * @return type |
||
3560 | */ |
||
3561 | public function tagrefCTe($std) |
||
3562 | { |
||
3563 | if (empty($this->tomICMS)) { |
||
3564 | $this->tomaICMS = $this->dom->createElement('tomaICMS'); |
||
3565 | } |
||
3566 | $identificador = '#163 <refCTe> - '; |
||
3567 | $this->dom->addChild( |
||
3568 | $this->tomaICMS, |
||
3569 | 'refCTe', |
||
3570 | $std->refCTe, |
||
3571 | false, |
||
3572 | "$identificador Chave de acesso do CT-e emitida pelo tomador" |
||
3573 | ); |
||
3574 | |||
3575 | return $this->tomaICMS; |
||
3576 | } |
||
3577 | |||
3578 | /** |
||
3579 | * Leiaute - Rodoviário |
||
3580 | * Gera as tags para o elemento: "veic" (Dados dos Veículos) |
||
3581 | * #21 |
||
3582 | * Nível: 1 |
||
3583 | * @return mixed |
||
3584 | */ |
||
3585 | public function tagveicCTeOS($std) |
||
3586 | { |
||
3587 | $identificador = '#21 <veic> - '; |
||
3588 | $this->veic = $this->dom->createElement('veic'); |
||
3589 | |||
3590 | $this->dom->addChild( |
||
3591 | $this->veic, |
||
3592 | 'placa', |
||
3593 | $std->placa, |
||
3594 | false, |
||
3595 | $identificador . 'Placa do veículo' |
||
3596 | ); |
||
3597 | $this->dom->addChild( |
||
3598 | $this->veic, |
||
3599 | 'RENAVAM', |
||
3600 | $std->RENAVAM, |
||
3601 | false, |
||
3602 | $identificador . 'RENAVAM do veículo' |
||
3603 | ); |
||
3604 | if ($std->xNome != '') { // CASO FOR VEICULO DE TERCEIRO |
||
3605 | $this->prop = $this->dom->createElement('prop'); |
||
3606 | if ($std->CNPJ != '') { |
||
3607 | $this->dom->addChild( |
||
3608 | $this->prop, |
||
3609 | 'CNPJ', |
||
3610 | $std->CNPJ, |
||
3611 | true, |
||
3612 | $identificador . 'CNPJ do proprietario' |
||
3613 | ); |
||
3614 | } elseif ($std->CPF != '') { |
||
3615 | $this->dom->addChild( |
||
3616 | $this->prop, |
||
3617 | 'CPF', |
||
3618 | $std->CPF, |
||
3619 | true, |
||
3620 | $identificador . 'CPF do proprietario' |
||
3621 | ); |
||
3622 | } |
||
3623 | if ($std->taf != '') { |
||
3624 | $this->dom->addChild( |
||
3625 | $this->prop, |
||
3626 | 'TAF', |
||
3627 | $std->taf, |
||
3628 | false, |
||
3629 | $identificador . 'TAF' |
||
3630 | ); |
||
3631 | } else { |
||
3632 | $this->dom->addChild( |
||
3633 | $this->prop, |
||
3634 | 'NroRegEstadual', |
||
3635 | $std->nroRegEstadual, |
||
3636 | false, |
||
3637 | $identificador . 'Número do Registro Estadual' |
||
3638 | ); |
||
3639 | } |
||
3640 | $this->dom->addChild( |
||
3641 | $this->prop, |
||
3642 | 'xNome', |
||
3643 | $std->xNome, |
||
3644 | true, |
||
3645 | $identificador . 'Nome do proprietario' |
||
3646 | ); |
||
3647 | $this->dom->addChild( |
||
3648 | $this->prop, |
||
3649 | 'IE', |
||
3650 | Strings::onlyNumbers($std->IE), |
||
3651 | false, |
||
3652 | $identificador . 'IE do proprietario' |
||
3653 | ); |
||
3654 | $this->dom->addChild( |
||
3655 | $this->prop, |
||
3656 | 'UF', |
||
3657 | $std->ufProp, |
||
3658 | true, |
||
3659 | $identificador . 'UF do proprietario' |
||
3660 | ); |
||
3661 | $this->dom->addChild( |
||
3662 | $this->prop, |
||
3663 | 'tpProp', |
||
3664 | $std->tpProp, |
||
3665 | true, |
||
3666 | $identificador . 'Tipo Proprietário' |
||
3667 | ); |
||
3668 | $this->dom->appChild($this->veic, $this->prop, 'Falta tag "prop"'); |
||
3669 | } |
||
3670 | $this->dom->addChild( |
||
3671 | $this->veic, |
||
3672 | 'UF', |
||
3673 | $std->uf, |
||
3674 | true, |
||
3675 | $identificador . 'UF em que veículo está licenciado' |
||
3676 | ); |
||
3677 | return $this->veic; |
||
3678 | } |
||
3679 | |||
3680 | public function infFretamento($std) |
||
3681 | { |
||
3682 | $identificador = '#21 <infFretamento> - '; |
||
3683 | $this->infFretamento = $this->dom->createElement('infFretamento'); |
||
3684 | |||
3685 | $this->dom->addChild( |
||
3686 | $this->infFretamento, |
||
3687 | 'tpFretamento', |
||
3688 | $std->tpFretamento, |
||
3689 | true, |
||
3690 | $identificador . 'Tipo do Fretamento de Pessoas' |
||
3691 | ); |
||
3692 | $this->dom->addChild( |
||
3693 | $this->infFretamento, |
||
3694 | 'dhViagem', |
||
3695 | $std->dhViagem, |
||
3696 | false, |
||
3697 | $identificador . 'Data e hora da viagem' |
||
3698 | ); |
||
3699 | return $this->infFretamento; |
||
3700 | } |
||
3701 | |||
3702 | /** |
||
3703 | * Gera as tags para o elemento: "infCteComp" (Detalhamento do CT-e complementado) |
||
3704 | * #410 |
||
3705 | * Nível: 1 |
||
3706 | * @return DOMElement|\DOMNode |
||
3707 | */ |
||
3708 | public function taginfCTeComp($std) |
||
3709 | { |
||
3710 | $identificador = '#410 <infCteComp> - '; |
||
3711 | $this->infCteComp = $this->dom->createElement('infCteComp'); |
||
3712 | $this->dom->addChild( |
||
3713 | $this->infCteComp, |
||
3714 | 'chCTe', |
||
3715 | $std->chCTe, |
||
3716 | true, |
||
3717 | $identificador . ' Chave do CT-e complementado' |
||
3718 | ); |
||
3719 | return $this->infCteComp; |
||
3720 | } |
||
3721 | |||
3722 | /** |
||
3723 | * Gera as tags para o elemento: "infCteAnu" (Detalhamento do CT-e de Anulação) |
||
3724 | * #411 |
||
3725 | * Nível: 1 |
||
3726 | * @return DOMElement|\DOMNode |
||
3727 | */ |
||
3728 | public function taginfCteAnu($std) |
||
3729 | { |
||
3730 | $identificador = '#411 <infCteAnu> - '; |
||
3731 | $this->infCteAnu = $this->dom->createElement('infCteAnu'); |
||
3732 | $this->dom->addChild( |
||
3733 | $this->infCteAnu, |
||
3734 | 'chCte', |
||
3735 | $std->chave, |
||
3736 | true, |
||
3737 | $identificador . ' Chave do CT-e anulado' |
||
3738 | ); |
||
3739 | $this->dom->addChild( |
||
3740 | $this->infCteAnu, |
||
3741 | 'dEmi', |
||
3742 | $std->data, |
||
3743 | true, |
||
3744 | $identificador . ' Data de Emissão do CT-e anulado' |
||
3745 | ); |
||
3746 | return $this->infCteAnu; |
||
3747 | } |
||
3748 | |||
3749 | /** |
||
3750 | * Gera as tags para o elemento: "autXML" (Autorizados para download do XML) |
||
3751 | * #396 |
||
3752 | * Nível: 1 |
||
3753 | * Os parâmetros para esta função são todos os elementos da tag "autXML" |
||
3754 | * |
||
3755 | * @return boolean |
||
3756 | */ |
||
3757 | public function tagveicNovos($std) |
||
3758 | { |
||
3759 | $identificador = '#396 <veicNovos> - '; |
||
3760 | $veicNovos = $this->dom->createElement('veicNovos'); |
||
3761 | $this->dom->addChild( |
||
3762 | $veicNovos, |
||
3763 | 'chassi', |
||
3764 | $std->chassi, |
||
3765 | true, |
||
3766 | $identificador . 'Chassi do veículo ' |
||
3767 | ); |
||
3768 | $this->dom->addChild( |
||
3769 | $veicNovos, |
||
3770 | 'cCor', |
||
3771 | $std->cCor, |
||
3772 | true, |
||
3773 | $identificador . 'Cor do veículo ' |
||
3774 | ); |
||
3775 | $this->dom->addChild( |
||
3776 | $veicNovos, |
||
3777 | 'xCor', |
||
3778 | $std->xCor, |
||
3779 | true, |
||
3780 | $identificador . 'Descrição da cor ' |
||
3781 | ); |
||
3782 | $this->dom->addChild( |
||
3783 | $veicNovos, |
||
3784 | 'cMod', |
||
3785 | $std->cMod, |
||
3786 | true, |
||
3787 | $identificador . 'Código Marca Modelo ' |
||
3788 | ); |
||
3789 | $this->dom->addChild( |
||
3790 | $veicNovos, |
||
3791 | 'vUnit', |
||
3792 | $std->vUnit, |
||
3793 | true, |
||
3794 | $identificador . 'Valor Unitário do Veículo ' |
||
3795 | ); |
||
3796 | $this->dom->addChild( |
||
3797 | $veicNovos, |
||
3798 | 'vFrete', |
||
3799 | $std->vFrete, |
||
3800 | true, |
||
3801 | $identificador . 'Frete Unitário ' |
||
3802 | ); |
||
3803 | $this->veicNovos[] = $veicNovos; |
||
3804 | return $veicNovos; |
||
3805 | } |
||
3806 | |||
3807 | /** |
||
3808 | * Gera as tags para o elemento: "autXML" (Autorizados para download do XML) |
||
3809 | * #396 |
||
3810 | * Nível: 1 |
||
3811 | * Os parâmetros para esta função são todos os elementos da tag "autXML" |
||
3812 | * |
||
3813 | * @return boolean |
||
3814 | */ |
||
3815 | public function tagautXML($std) |
||
3816 | { |
||
3817 | $identificador = '#396 <autXML> - '; |
||
3818 | $autXML = $this->dom->createElement('autXML'); |
||
3819 | if (isset($std->CNPJ) && $std->CNPJ != '') { |
||
3820 | $this->dom->addChild( |
||
3821 | $autXML, |
||
3822 | 'CNPJ', |
||
3823 | $std->CNPJ, |
||
3824 | true, |
||
3825 | $identificador . 'CNPJ do Cliente Autorizado' |
||
3826 | ); |
||
3827 | } elseif (isset($std->CPF) && $std->CPF != '') { |
||
3828 | $this->dom->addChild( |
||
3829 | $autXML, |
||
3830 | 'CPF', |
||
3831 | $std->CPF, |
||
3832 | true, |
||
3833 | $identificador . 'CPF do Cliente Autorizado' |
||
3834 | ); |
||
3835 | } |
||
3836 | |||
3837 | $this->autXML[] = $autXML; |
||
3838 | return $autXML; |
||
3839 | } |
||
3840 | |||
3841 | /** |
||
3842 | * #359 |
||
3843 | * tag CTe/infCTe/cobr (opcional) |
||
3844 | * Depende de fat |
||
3845 | */ |
||
3846 | protected function buildCobr() |
||
3847 | { |
||
3848 | if (empty($this->cobr)) { |
||
3849 | $this->cobr = $this->dom->createElement("cobr"); |
||
3850 | } |
||
3851 | } |
||
3852 | |||
3853 | /** |
||
3854 | * #360 |
||
3855 | * tag CTe/infCTe/cobr/fat (opcional) |
||
3856 | * @param stdClass $std |
||
3857 | * @return DOMElement |
||
3858 | */ |
||
3859 | public function tagfat(stdClass $std) |
||
3860 | { |
||
3861 | $this->buildCobr(); |
||
3862 | $fat = $this->dom->createElement("fat"); |
||
3863 | $this->dom->addChild( |
||
3864 | $fat, |
||
3865 | "nFat", |
||
3866 | $std->nFat, |
||
3867 | false, |
||
3868 | "Número da Fatura" |
||
3869 | ); |
||
3870 | $this->dom->addChild( |
||
3871 | $fat, |
||
3872 | "vOrig", |
||
3873 | $std->vOrig, |
||
3874 | false, |
||
3875 | "Valor Original da Fatura" |
||
3876 | ); |
||
3877 | $this->dom->addChild( |
||
3878 | $fat, |
||
3879 | "vDesc", |
||
3880 | $std->vDesc, |
||
3881 | false, |
||
3882 | "Valor do desconto" |
||
3883 | ); |
||
3884 | $this->dom->addChild( |
||
3885 | $fat, |
||
3886 | "vLiq", |
||
3887 | $std->vLiq, |
||
3888 | false, |
||
3889 | "Valor Líquido da Fatura" |
||
3890 | ); |
||
3891 | $this->dom->appChild($this->cobr, $fat); |
||
3892 | return $fat; |
||
3893 | } |
||
3894 | |||
3895 | /** |
||
3896 | * #365 |
||
3897 | * tag CTe/infCTe/cobr/fat/dup (opcional) |
||
3898 | * É necessário criar a tag fat antes de criar as duplicatas |
||
3899 | * @param stdClass $std |
||
3900 | * @return DOMElement |
||
3901 | */ |
||
3902 | public function tagdup(stdClass $std) |
||
3903 | { |
||
3904 | $this->buildCobr(); |
||
3905 | $dup = $this->dom->createElement("dup"); |
||
3906 | $this->dom->addChild( |
||
3907 | $dup, |
||
3908 | "nDup", |
||
3909 | $std->nDup, |
||
3910 | false, |
||
3911 | "Número da Duplicata" |
||
3912 | ); |
||
3913 | $this->dom->addChild( |
||
3914 | $dup, |
||
3915 | "dVenc", |
||
3916 | $std->dVenc, |
||
3917 | false, |
||
3918 | "Data de vencimento" |
||
3919 | ); |
||
3920 | $this->dom->addChild( |
||
3921 | $dup, |
||
3922 | "vDup", |
||
3923 | $std->vDup, |
||
3924 | true, |
||
3925 | "Valor da duplicata" |
||
3926 | ); |
||
3927 | $this->dom->appChild($this->cobr, $dup, 'Inclui duplicata na tag cobr'); |
||
3928 | return $dup; |
||
3929 | } |
||
3930 | |||
3931 | /** |
||
3932 | * Informações do Responsável técnico |
||
3933 | * tag CTe/infCte/infRespTec (opcional) |
||
3934 | * @return DOMElement |
||
3935 | * @throws RuntimeException |
||
3936 | */ |
||
3937 | public function taginfRespTec(stdClass $std) |
||
3938 | { |
||
3939 | $infRespTec = $this->dom->createElement("infRespTec"); |
||
3940 | $this->dom->addChild( |
||
3941 | $infRespTec, |
||
3942 | "CNPJ", |
||
3943 | $std->CNPJ, |
||
3944 | true, |
||
3945 | "Informar o CNPJ da pessoa jurídica responsável pelo sistema " |
||
3946 | . "utilizado na emissão do documento fiscal eletrônico" |
||
3947 | ); |
||
3948 | $this->dom->addChild( |
||
3949 | $infRespTec, |
||
3950 | "xContato", |
||
3951 | $std->xContato, |
||
3952 | true, |
||
3953 | "Informar o nome da pessoa a ser contatada na empresa desenvolvedora " |
||
3954 | . "do sistema utilizado na emissão do documento fiscal eletrônico" |
||
3955 | ); |
||
3956 | $this->dom->addChild( |
||
3957 | $infRespTec, |
||
3958 | "email", |
||
3959 | $std->email, |
||
3960 | true, |
||
3961 | "Informar o e-mail da pessoa a ser contatada na empresa " |
||
3962 | . "desenvolvedora do sistema." |
||
3963 | ); |
||
3964 | $this->dom->addChild( |
||
3965 | $infRespTec, |
||
3966 | "fone", |
||
3967 | $std->fone, |
||
3968 | true, |
||
3969 | "Informar o telefone da pessoa a ser contatada na empresa " |
||
3970 | . "desenvolvedora do sistema." |
||
3971 | ); |
||
3972 | if (!empty($std->CSRT) && !empty($std->idCSRT)) { |
||
3973 | $this->csrt = $std->CSRT; |
||
3974 | $this->dom->addChild( |
||
3975 | $infRespTec, |
||
3976 | "idCSRT", |
||
3977 | $std->idCSRT, |
||
3978 | true, |
||
3979 | "Identificador do CSRT utilizado para montar o hash do CSRT" |
||
3980 | ); |
||
3981 | $this->dom->addChild( |
||
3982 | $infRespTec, |
||
3983 | "hashCSRT", |
||
3984 | $this->hashCSRT($std->CSRT), |
||
3985 | true, |
||
3986 | "hash do CSRT" |
||
3987 | ); |
||
3988 | } |
||
3989 | $this->infRespTec = $infRespTec; |
||
3990 | return $infRespTec; |
||
3991 | } |
||
3992 | |||
3993 | protected function checkCTeKey(Dom $dom) |
||
3994 | { |
||
3995 | $infCTe = $dom->getElementsByTagName("infCte")->item(0); |
||
3996 | $ide = $dom->getElementsByTagName("ide")->item(0); |
||
3997 | $emit = $dom->getElementsByTagName("emit")->item(0); |
||
3998 | $cUF = $ide->getElementsByTagName('cUF')->item(0)->nodeValue; |
||
3999 | $dhEmi = $ide->getElementsByTagName('dhEmi')->item(0)->nodeValue; |
||
4000 | $cnpj = $emit->getElementsByTagName('CNPJ')->item(0)->nodeValue; |
||
4001 | $mod = $ide->getElementsByTagName('mod')->item(0)->nodeValue; |
||
4002 | $serie = $ide->getElementsByTagName('serie')->item(0)->nodeValue; |
||
4003 | $nNF = $ide->getElementsByTagName('nCT')->item(0)->nodeValue; |
||
4004 | $tpEmis = $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue; |
||
4005 | $cCT = $ide->getElementsByTagName('cCT')->item(0)->nodeValue; |
||
4006 | $chave = str_replace('CTe', '', $infCTe->getAttribute("Id")); |
||
4007 | |||
4008 | $dt = new DateTime($dhEmi); |
||
4009 | |||
4010 | $chaveMontada = Keys::build( |
||
4011 | $cUF, |
||
4012 | $dt->format('y'), |
||
4013 | $dt->format('m'), |
||
4014 | $cnpj, |
||
4015 | $mod, |
||
4016 | $serie, |
||
4017 | $nNF, |
||
4018 | $tpEmis, |
||
4019 | $cCT |
||
4020 | ); |
||
4021 | //caso a chave contida no CTe esteja errada |
||
4022 | //substituir a chave |
||
4023 | if ($chaveMontada != $chave) { |
||
4024 | $ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chaveMontada, -1); |
||
4025 | $infCTe = $dom->getElementsByTagName("infCte")->item(0); |
||
4026 | $infCTe->setAttribute("Id", "CTe" . $chaveMontada); |
||
4027 | $this->chCTe = $chaveMontada; |
||
4028 | } |
||
4029 | } |
||
4030 | } |
||
4031 |