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