root/trunk/libs/DanfeNFePHP.class.php
| 91 | 97 | ||
|---|---|---|---|
13 | * | 13 | * |
14 | * Você deve ter recebido uma cópia da Licença Publica GNU junto com este | 14 | * Você deve ter recebido uma cópia da Licença Publica GNU junto com este |
15 | * programa. Caso contrário consulte <http://www.fsfla.org/svnwiki/trad/GPLv3>. | 15 | * programa. Caso contrário consulte <http://www.fsfla.org/svnwiki/trad/GPLv3>. |
16 | * [ALT] Correções de campos | ||
17 | * [ALT] Adptação a PHP 5.3 | ||
16 | * | 18 | * |
17 | * @package NFePHP | 19 | * @package NFePHP |
18 | * @name DanfeNFePHP.class.php | 20 | * @name DanfeNFePHP.class.php |
21 | * @version 0.2 | ||
19 | * @license http://www.gnu.org/licenses/gpl.html GNU/GPL v.3 | 22 | * @license http://www.gnu.org/licenses/gpl.html GNU/GPL v.3 |
20 | * @copyright 2009 © NFePHP | 23 | * @copyright 2009 © NFePHP |
21 | * @link http://www.nfephp.org/ | 24 | * @link http://www.nfephp.org/ |
... | ... | ||
220 | */ | 223 | */ |
221 | public function printDANFE($nome='',$destino='I',$printer=''){ | 224 | public function printDANFE($nome='',$destino='I',$printer=''){ |
222 | $arq = $this->pdf->Output($nome,$destino); | 225 | $arq = $this->pdf->Output($nome,$destino); |
223 | return ''; | 226 | if ( $destino == 'S' ){ |
227 | //aqui rotina de impressão direta | ||
228 | // não completada ainda | ||
229 | } | ||
230 | return $arq; | ||
224 | 231 | ||
225 | /** | 232 | /** |
226 | * Opção 1 - exemplo de script shell usando acroread | 233 | * Opção 1 - exemplo de script shell usando acroread |
... | ... | ||
237 | echo PDF Print: No filename defined! | 244 | echo PDF Print: No filename defined! |
238 | fi | 245 | fi |
239 | 246 | ||
247 | Opção 2 - | ||
248 | salvar pdf em arquivo temporario | ||
249 | converter pdf para ps usando pdf2ps do linux | ||
250 | imprimir ps para printer usando lp ou lpr | ||
251 | remover os arquivos temporarios pdf e ps | ||
252 | |||
240 | **/ | 253 | **/ |
241 | } //fim função printDANFE | 254 | } //fim função printDANFE |
242 | 255 | ||
... | ... | ||
283 | //endereço | 296 | //endereço |
284 | $y1 = $y1+5; | 297 | $y1 = $y1+5; |
285 | $aFont = array('font'=>'Arial','size'=>7,'style'=>''); | 298 | $aFont = array('font'=>'Arial','size'=>7,'style'=>''); |
286 | $fone = $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue; | 299 | $fone = !empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue : ''; |
287 | $foneLen = strlen($fone); | 300 | $foneLen = strlen($fone); |
288 | $fone2 = substr($fone,0,$foneLen-4); | 301 | $fone2 = substr($fone,0,$foneLen-4); |
289 | $fone1 = substr($fone,0,$foneLen-8); | 302 | $fone1 = substr($fone,0,$foneLen-8); |
290 | $fone = '(' . $fone1 . ') ' . substr($fone2,-4) . '-' . substr($fone,-4); | 303 | $fone = '(' . $fone1 . ') ' . substr($fone2,-4) . '-' . substr($fone,-4); |
291 | $texto = $this->enderEmit->getElementsByTagName("xLgr")->item(0)->nodeValue . ', ' . $this->enderEmit->getElementsByTagName("nro")->item(0)->nodeValue . ' ' . $this->enderEmit->getElementsByTagName("xCpl")->item(0)->nodeValue . ' - ' . $this->enderEmit->getElementsByTagName("xBairro")->item(0)->nodeValue . "\n" . $this->__format($this->enderEmit->getElementsByTagName("CEP")->item(0)->nodeValue,"#####-###") . ' ' . $this->enderEmit->getElementsByTagName("xMun")->item(0)->nodeValue . ' - ' . $this->enderEmit->getElementsByTagName("UF")->item(0)->nodeValue . "\n" . "Fone/Fax: " . $fone; | 304 | $lgr = !empty($this->enderEmit->getElementsByTagName("xLgr")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xLgr")->item(0)->nodeValue : ''; |
305 | $nro = !empty($this->enderEmit->getElementsByTagName("nro")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("nro")->item(0)->nodeValue : ''; | ||
306 | $cpl = !empty($this->enderEmit->getElementsByTagName("xCpl")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xCpl")->item(0)->nodeValue : ''; | ||
307 | $bairro = !empty($this->enderEmit->getElementsByTagName("xBairro")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xBairro")->item(0)->nodeValue : ''; | ||
308 | $CEP = !empty($this->enderEmit->getElementsByTagName("CEP")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("CEP")->item(0)->nodeValue : ' '; | ||
309 | $CEP = $this->__format($CEP,"#####-###"); | ||
310 | $mun = !empty($this->enderEmit->getElementsByTagName("xMun")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xMun")->item(0)->nodeValue : ''; | ||
311 | $UF = !empty($this->enderEmit->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("UF")->item(0)->nodeValue : ''; | ||
312 | $texto = $lgr . "," . $nro . " " . $cpl . "\n" . $bairro . " - " . $CEP . "\n" . $mun . " - " . $UF . "\n" . "Fone/Fax: " . $fone; | ||
292 | $texto = utf8_decode($texto); | 313 | $texto = utf8_decode($texto); |
293 | $this->__textBox($x,$y1,$w,8,$texto,$aFont,'T','C',0,''); | 314 | $this->__textBox($x,$y1,$w,8,$texto,$aFont,'T','C',0,''); |
294 | 315 | ||
... | ... | ||
346 | $this->__textBox($x,$y,$w,$h); | 367 | $this->__textBox($x,$y,$w,$h); |
347 | $this->pdf->SetFillColor(0,0,0); | 368 | $this->pdf->SetFillColor(0,0,0); |
348 | $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id")); | 369 | $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id")); |
349 | $bW = 80; | 370 | $bW = 75; |
350 | $bH = 12; | 371 | $bH = 12; |
351 | //codigo de barras | 372 | //codigo de barras |
352 | $this->pdf->Code128($x+(($w-$bW)/2),$y+2,$chave_acesso,$bW,$bH); | 373 | $this->pdf->Code128($x+(($w-$bW)/2),$y+2,$chave_acesso,$bW,$bH); |
... | ... | ||
399 | $texto = utf8_decode($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue); | 420 | $texto = utf8_decode($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue); |
400 | $tsHora = $this->__convertTime($this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue); | 421 | $tsHora = $this->__convertTime($this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue); |
401 | $texto .= " - " . date('d/m/Y H:i:s',$tsHora); | 422 | $texto .= " - " . date('d/m/Y H:i:s',$tsHora); |
423 | $cStat = $this->nfeProc->getElementsByTagName("cStat")->item(0)->nodeValue; | ||
402 | } else { | 424 | } else { |
403 | $texto = ''; | 425 | $texto = ''; |
426 | $cStat = ''; | ||
404 | } | 427 | } |
405 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 428 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
406 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 429 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
... | ... | ||
442 | //#################################################################################### | 465 | //#################################################################################### |
443 | //Indicação de NF Homologação | 466 | //Indicação de NF Homologação |
444 | $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue; | 467 | $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue; |
468 | if ( $cStat == '101') { | ||
469 | //101 Cancelamento | ||
470 | $x = 5; | ||
471 | $y = 160; | ||
472 | $h = 25; | ||
473 | $w = 200; | ||
474 | $this->pdf->SetTextColor(70,70,70); | ||
475 | $texto = "NFe CANCELADA"; | ||
476 | $aFont = array('font'=>'Arial','size'=>42,'style'=>'B'); | ||
477 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,''); | ||
478 | } | ||
479 | |||
445 | if ( $tpAmb != 1 ) { | 480 | if ( $tpAmb != 1 ) { |
446 | $x = 5; | 481 | $x = 5; |
447 | $y=120; | 482 | $y=120; |
... | ... | ||
492 | $texto = utf8_decode('CNPJ / CPF'); | 527 | $texto = utf8_decode('CNPJ / CPF'); |
493 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 528 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
494 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 529 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
495 | $texto = $this->__format(utf8_decode($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue),"###.###.###/####-##"); | 530 | $texto = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue) ? $this->__format(utf8_decode($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue),"###.###.###/####-##") : ''; |
531 | if ($texto == ''){ | ||
532 | $texto = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) ? $this->__format(utf8_decode($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue),"###.###.###.###-##") : ''; | ||
533 | } | ||
496 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 534 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
497 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 535 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
498 | //DATA DA EMISSÃO | 536 | //DATA DA EMISSÃO |
... | ... | ||
513 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 551 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
514 | $texto = utf8_decode($this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue); | 552 | $texto = utf8_decode($this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue); |
515 | $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue; | 553 | $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue; |
516 | $aFont = array('font'=>'Arial','size'=>9,'style'=>'B'); | 554 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
517 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); | 555 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,'',TRUE); |
518 | //BAIRRO / DISTRITO | 556 | //BAIRRO / DISTRITO |
519 | $x += $w; | 557 | $x += $w; |
520 | $w = 45; | 558 | $w = 45; |
521 | $texto = utf8_decode('BAIRRO / DISTRITO'); | 559 | $texto = utf8_decode('BAIRRO / DISTRITO'); |
522 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 560 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
523 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 561 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
524 | $texto = utf8_decode($this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue); | 562 | $texto = !empty($this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue) ? utf8_decode($this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue) : ''; |
525 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 563 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
526 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 564 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
527 | //CEP | 565 | //CEP |
... | ... | ||
530 | $texto = utf8_decode('CEP'); | 568 | $texto = utf8_decode('CEP'); |
531 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 569 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
532 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 570 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
533 | $texto = $this->__format(utf8_decode($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue),"#####-###"); | 571 | $texto = !empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue) ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue : ''; |
572 | $texto = $this->__format(utf8_decode($texto),"#####-###"); | ||
534 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 573 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
535 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 574 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
536 | //DATA DA SAÍDA | 575 | //DATA DA SAÍDA |
... | ... | ||
550 | $texto = utf8_decode('MUNICÍPIO'); | 589 | $texto = utf8_decode('MUNICÍPIO'); |
551 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 590 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
552 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); | 591 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); |
553 | $texto = utf8_decode($this->dest->getElementsByTagName("xMun")->item(0)->nodeValue); | 592 | $texto = !empty($this->dest->getElementsByTagName("xMun")->item(0)->nodeValue) ? utf8_decode($this->dest->getElementsByTagName("xMun")->item(0)->nodeValue) : ''; |
554 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 593 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
555 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); | 594 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); |
556 | //UF | 595 | //UF |
... | ... | ||
578 | $texto = utf8_decode('INSCRIÇÃO ESTADUAL'); | 617 | $texto = utf8_decode('INSCRIÇÃO ESTADUAL'); |
579 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 618 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
580 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 619 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
581 | $texto = utf8_decode($this->dest->getElementsByTagName("IE")->item(0)->nodeValue); | 620 | $texto = !empty($this->dest->getElementsByTagName("IE")->item(0)->nodeValue) ? utf8_decode($this->dest->getElementsByTagName("IE")->item(0)->nodeValue) : ''; |
582 | $texto = $this->__format($texto,"###.###.###.###"); | 621 | if ( $texto != '') { |
622 | $texto = $this->__format($texto,"###.###.###.###"); | ||
623 | } | ||
583 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 624 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
584 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 625 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
585 | //HORA DA SAÍDA | 626 | //HORA DA SAÍDA |
... | ... | ||
603 | private function __faturaDANFE($x,$y){ | 644 | private function __faturaDANFE($x,$y){ |
604 | $h = 8+3; | 645 | $h = 8+3; |
605 | if ( $this->dup->length > 0 ) { | 646 | if ( $this->dup->length > 0 ) { |
606 | | 647 | |
607 | //##################################################################### | 648 | //##################################################################### |
608 | //FATURA / DUPLICATA | 649 | //FATURA / DUPLICATA |
609 | $texto = "FATURA / DUPLICATA"; | 650 | $texto = "FATURA / DUPLICATA"; |
... | ... | ||
647 | $x += $w+0.65; | 688 | $x += $w+0.65; |
648 | } | 689 | } |
649 | } | 690 | } |
650 | | 691 | |
651 | } | 692 | } |
652 | return ($y+$h); | 693 | return ($y+$h); |
653 | }//fim da função __faturaDANFE | 694 | }//fim da função __faturaDANFE |
... | ... | ||
796 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); | 837 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); |
797 | 838 | ||
798 | //verficar se existe o objeto transporta | 839 | //verficar se existe o objeto transporta |
799 | //se sim carregar variáveis | 840 | if( isset($this->transporta) ) { |
800 | //se não deixar variáveis em branco | 841 | //se sim carregar variáveis |
842 | //NOME / RAZÃO SOCIAL | ||
843 | $w = 62; | ||
844 | $y += 3; | ||
845 | $texto = utf8_decode('NOME / RAZÃO SOCIAL'); | ||
846 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | ||
847 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | ||
848 | $texto = !empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue : ''; | ||
849 | $texto = utf8_decode($texto); | ||
850 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | ||
851 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); | ||
801 | 852 | ||
802 | //NOME / RAZÃO SOCIAL | 853 | //FRETE POR CONTA |
803 | $w = 62; | 854 | $x += $w; |
804 | $y += 3; | 855 | $w = 32; |
805 | $texto = utf8_decode('NOME / RAZÃO SOCIAL'); | 856 | $texto = utf8_decode('FRETE POR CONTA'); |
806 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 857 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
807 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 858 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
808 | $texto = utf8_decode($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue); | 859 | $this->__textBox($x+1,$y+2,$w,$h-2,'0-EMITENTE',$aFont,'T','L',0,''); |
809 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 860 | $this->__textBox($x+1,$y+4,$w,$h-4,'1-DESTINATARIO',$aFont,'T','L',0,''); |
810 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); | 861 | $texto = $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue; |
811 | 862 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | |
812 | //FRETE POR CONTA | 863 | $this->__textBox($x+25,$y+1,5,5,$texto,$aFont,'C','C',1,''); |
813 | $x += $w; | 864 | //CÓDIGO ANTT |
814 | $w = 32; | 865 | $x += $w; |
815 | $texto = utf8_decode('FRETE POR CONTA'); | 866 | $w = 31; |
816 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 867 | $texto = utf8_decode('CÓDIGO ANTT'); |
817 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 868 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
818 | $this->__textBox($x+1,$y+2,$w,$h-2,'0-EMITENTE',$aFont,'T','L',0,''); | 869 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
819 | $this->__textBox($x+1,$y+4,$w,$h-4,'1-DESTINATARIO',$aFont,'T','L',0,''); | 870 | if ( isset($this->transporta)){ |
820 | $texto = $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue; | 871 | $texto = !empty($this->transporta->getElementsByTagName("RNTC")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("RNTC")->item(0)->nodeValue : ''; |
821 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 872 | } else { |
822 | $this->__textBox($x+25,$y+1,5,5,$texto,$aFont,'C','C',1,''); | 873 | $texto = ''; |
823 | //CÓDIGO ANTT | 874 | } |
824 | $x += $w; | 875 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
825 | $w = 31; | 876 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
826 | $texto = utf8_decode('CÓDIGO ANTT'); | 877 | //PLACA DO VEÍC |
827 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 878 | $x += $w; |
828 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 879 | $w = 32; |
829 | //$texto = $this->transporta->getElementsByTagName("RNTC")->item(0)->nodeValue; | 880 | $texto = utf8_decode('PLACA DO VEÍCULO'); |
830 | $texto = ''; | 881 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
831 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 882 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
832 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 883 | $texto = !empty($this->transporta->getElementsByTagName("placa")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("placa")->item(0)->nodeValue : ''; |
833 | //PLACA DO VEÍC | 884 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
834 | $x += $w; | 885 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
835 | $w = 32; | 886 | //UF |
836 | $texto = utf8_decode('PLACA DO VEÍCULO'); | 887 | $x += $w; |
837 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 888 | $w = 8; |
838 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 889 | $texto = utf8_decode('UF'); |
839 | //$texto = $this->transporta->getElementsByTagName("placa")->item(0)->nodeValue; | 890 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
840 | $texto = ''; | 891 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
841 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 892 | $texto = !empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue : ''; |
842 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 893 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
843 | //UF | 894 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
844 | $x += $w; | 895 | //CNPJ / CPF |
845 | $w = 8; | 896 | $x += $w; |
846 | $texto = utf8_decode('UF'); | 897 | $w = 35; |
847 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 898 | $texto = utf8_decode('CNPJ / CPF'); |
848 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 899 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
849 | //$texto = $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue; | 900 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
850 | $texto = ''; | 901 | $texto = !empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue) ? $this->__format($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,"##.###.###/####-##") : ''; |
851 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 902 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
852 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 903 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
853 | //CNPJ / CPF | 904 | //##################################################################### |
854 | $x += $w; | 905 | //ENDEREÇO |
855 | $w = 35; | 906 | $w = 94; |
856 | $texto = utf8_decode('CNPJ / CPF'); | 907 | $y += $h; |
857 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 908 | $x = $oldX; |
858 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 909 | $h = 7; |
859 | $texto = $this->__format($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,"##.###.###/####-##"); | 910 | $texto = utf8_decode('ENDEREÇO'); |
860 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 911 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
861 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 912 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
862 | //##################################################################### | 913 | $texto = !empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) ? utf8_decode($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) : ''; |
863 | //ENDEREÇO | 914 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
864 | $w = 94; | 915 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); |
865 | $y += $h; | 916 | //MUNICÍPIO |
866 | $x = $oldX; | 917 | $x += $w; |
867 | $h = 7; | 918 | $w = 63; |
868 | $texto = utf8_decode('ENDEREÇO'); | 919 | $texto = utf8_decode('MUNICÍPIO'); |
869 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 920 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
870 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 921 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
871 | $texto = utf8_decode($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue); | 922 | $texto = !empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue : ''; |
872 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 923 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
873 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); | 924 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); |
874 | //MUNICÍPIO | 925 | //UF |
875 | $x += $w; | 926 | $x += $w; |
876 | $w = 63; | 927 | $w = 8; |
877 | $texto = utf8_decode('MUNICÍPIO'); | 928 | $texto = utf8_decode('UF'); |
878 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 929 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
879 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 930 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
880 | $texto = $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue; | 931 | $texto = !empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue : ''; |
881 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 932 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
882 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); | 933 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
883 | //UF | 934 | //INSCRIÇÃO ESTADUAL |
884 | $x += $w; | 935 | $x += $w; |
885 | $w = 8; | 936 | $w = 35; |
886 | $texto = utf8_decode('UF'); | 937 | $texto = utf8_decode('INSCRIÇÃO ESTADUAL'); |
887 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 938 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
888 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 939 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
889 | $texto = $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue; | 940 | $texto = !empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue) ? $this->__format($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue,"###.###.###.###") : ''; |
890 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 941 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
891 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 942 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); |
892 | //INSCRIÇÃO ESTADUAL | 943 | //##################################################################### |
893 | $x += $w; | 944 | //QUANTIDADE |
894 | $w = 35; | 945 | $w = 20; |
895 | $texto = utf8_decode('INSCRIÇÃO ESTADUAL'); | 946 | $y += $h; |
896 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 947 | $x = $oldX; |
897 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 948 | $h = 7; |
898 | $texto = $this->__format($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue,"###.###.###.###"); | 949 | $texto = utf8_decode('QUANTIDADE'); |
899 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 950 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
900 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); | 951 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
901 | //##################################################################### | 952 | $texto = !empty($this->transp->getElementsByTagName("qVol")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("qVol")->item(0)->nodeValue : ''; |
902 | //QUANTIDADE | 953 | $texto = utf8_decode($texto); |
903 | $w = 20; | 954 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
904 | $y += $h; | 955 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); |
905 | $x = $oldX; | 956 | //ESPÉCIE |
906 | $h = 7; | 957 | $x += $w; |
907 | $texto = utf8_decode('QUANTIDADE'); | 958 | $w = 36; |
908 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 959 | $texto = utf8_decode('ESPÉCIE'); |
909 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 960 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
910 | $texto = utf8_decode($this->transp->getElementsByTagName("qVol")->item(0)->nodeValue); | 961 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
911 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 962 | $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; |
912 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); | 963 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
913 | //ESPÉCIE | 964 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); |
914 | $x += $w; | 965 | //MARCA |
915 | $w = 36; | 966 | $x += $w; |
916 | $texto = utf8_decode('ESPÉCIE'); | 967 | $w = 36; |
917 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 968 | $texto = utf8_decode('MARCA'); |
918 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 969 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
919 | $texto = $this->transp->getElementsByTagName("esp")->item(0)->nodeValue; | 970 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
920 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 971 | $texto = !empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ? utf8_decode($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) : ''; |
921 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); | 972 | $texto = ''; |
922 | //MARCA | 973 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
923 | $x += $w; | 974 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); |
924 | $w = 36; | 975 | //NÚMERO |
925 | $texto = utf8_decode('MARCA'); | 976 | $x += $w; |
926 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 977 | $w = 36; |
927 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 978 | $texto = utf8_decode('NÚMERO'); |
928 | //$texto = $this->transp->getElementsByTagName("esp")->item(0)->nodeValue; | 979 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
929 | $texto = ''; | 980 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
930 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 981 | $texto = !empty($this->transp->getElementsByTagName("numero")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("numero")->item(0)->nodeValue : ''; |
931 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); | 982 | $texto = ''; |
932 | //NÚMERO | 983 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
933 | $x += $w; | 984 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); |
934 | $w = 36; | 985 | //PESO BRUTO |
935 | $texto = utf8_decode('NÚMERO'); | 986 | $x += $w; |
936 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 987 | $w = 36; |
937 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 988 | $texto = utf8_decode('PESO BRUTO'); |
938 | //$texto = $this->transp->getElementsByTagName("esp")->item(0)->nodeValue; | 989 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
939 | $texto = ''; | 990 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
940 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 991 | $texto = !empty($this->transp->getElementsByTagName("pesoB")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("pesoB")->item(0)->nodeValue : '0.0'; |
941 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); | 992 | $texto = number_format($texto, 2, ",", "."); |
942 | //PESO BRUTO | 993 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
943 | $x += $w; | 994 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); |
944 | $w = 36; | 995 | //PESO LÍQUIDO |
945 | $texto = utf8_decode('PESO BRUTO'); | 996 | $x += $w; |
946 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 997 | $w = 36; |
947 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 998 | $texto = utf8_decode('PESO LÍQUIDO'); |
948 | $texto = number_format($this->transp->getElementsByTagName("pesoB")->item(0)->nodeValue, 2, ",", "."); | 999 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
949 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 1000 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
950 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); | 1001 | $texto = !empty($this->transp->getElementsByTagName("pesoL")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("pesoL")->item(0)->nodeValue : '0.0'; |
951 | //PESO LÍQUIDO | 1002 | $texto = number_format($texto, 2, ",", "."); |
952 | $x += $w; | 1003 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
953 | $w = 36; | 1004 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); |
954 | $texto = utf8_decode('PESO LÍQUIDO'); | 1005 | } |
955 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | ||
956 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | ||
957 | $texto = number_format($this->transp->getElementsByTagName("pesoL")->item(0)->nodeValue, 2, ",", "."); | ||
958 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | ||
959 | $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); | ||
960 | |||
961 | return ($y+$h); | 1006 | return ($y+$h); |
962 | } | 1007 | } |
963 | 1008 | ||
... | ... | ||
1095 | $i = 0; | 1140 | $i = 0; |
1096 | foreach ($this->det as $d) { | 1141 | foreach ($this->det as $d) { |
1097 | if ( $i >= $nInicio && $i < $max ) { | 1142 | if ( $i >= $nInicio && $i < $max ) { |
1098 | $prod = $this->det->item($i)->getElementsByTagName("prod")->item(0); | 1143 | $prod = $this->det->item($i)->getElementsByTagName("prod")->item(0); |
1099 | $infAdProd = $this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue; | 1144 | $infAdProd = !empty($this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue) ? $this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue : ''; |
1100 | $imposto = $this->det->item($i)->getElementsByTagName("imposto")->item(0); | 1145 | $imposto = $this->det->item($i)->getElementsByTagName("imposto")->item(0); |
1101 | $ICMS = $imposto->getElementsByTagName("ICMS")->item(0); | 1146 | $ICMS = $imposto->getElementsByTagName("ICMS")->item(0); |
1102 | $IPI = $imposto->getElementsByTagName("IPI")->item(0); | 1147 | $IPI = $imposto->getElementsByTagName("IPI")->item(0); |
1103 | 1148 | //codigo do produto | |
1104 | $y += $h; | 1149 | $y += $h; |
1105 | $x = $oldX; | 1150 | $x = $oldX; |
1106 | $w = 14; | 1151 | $w = 14; |
... | ... | ||
1116 | 1161 | ||
1117 | $x += $w+2; | 1162 | $x += $w+2; |
1118 | $w = 13; | 1163 | $w = 13; |
1119 | $texto = $prod->getElementsByTagName("NCM")->item(0)->nodeValue; | 1164 | $texto = !empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ? $prod->getElementsByTagName("NCM")->item(0)->nodeValue : ''; |
1120 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,''); | 1165 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,''); |
1121 | 1166 | ||
1122 | $x += $w; | 1167 | $x += $w; |
... | ... | ||
1215 | $h = 25; | 1260 | $h = 25; |
1216 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); | 1261 | $aFont = array('font'=>'Arial','size'=>6,'style'=>''); |
1217 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); | 1262 | $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); |
1218 | $texto = $this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue; | 1263 | if( isset($this->infAdic) ) { |
1219 | $texto = utf8_decode($texto); | 1264 | $texto = !empty($this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue) ? $this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue : ''; |
1265 | $texto .= !empty($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) ? ' Inf. de interesse do fisco: '.$this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue : ''; | ||
1266 | $texto = utf8_decode($texto); | ||
1267 | } else { | ||
1268 | $texto = ''; | ||
1269 | } | ||
1220 | $aFont = array('font'=>'Arial','size'=>8,'style'=>''); | 1270 | $aFont = array('font'=>'Arial','size'=>8,'style'=>''); |
1221 | $this->__textBox($x,$y+3,$w,$h-3,$texto,$aFont,'T','L',0,'',FALSE); | 1271 | $this->__textBox($x,$y+3,$w,$h-3,$texto,$aFont,'T','L',0,'',FALSE); |
1222 | //RESERVADO AO FISCO | 1272 | //RESERVADO AO FISCO |
... | ... | ||
1281 | $aFont = array('font'=>'Arial','size'=>14,'style'=>'B'); | 1331 | $aFont = array('font'=>'Arial','size'=>14,'style'=>'B'); |
1282 | $this->__textBox($x1,$y,40,18,$texto,$aFont,'T','C',0,''); | 1332 | $this->__textBox($x1,$y,40,18,$texto,$aFont,'T','C',0,''); |
1283 | $texto = "NF-e \n"; | 1333 | $texto = "NF-e \n"; |
1284 | $texto = "Nº." . $this->__format($numNF,"###.###.###") . " \n"; | 1334 | $texto = "Nº. " . $this->__format($numNF,"###.###.###") . " \n"; |
1285 | $texto .= "SRIE $serie"; | 1335 | $texto .= "Srie $serie"; |
1286 | $texto = utf8_decode($texto); | 1336 | $texto = utf8_decode($texto); |
1287 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); | 1337 | $aFont = array('font'=>'Arial','size'=>10,'style'=>'B'); |
1288 | $this->__textBox($x1,$y,40,18,$texto,$aFont,'C','C',1,''); | 1338 | $this->__textBox($x1,$y,40,18,$texto,$aFont,'C','C',1,''); |
... | ... | ||
1321 | } else { | 1371 | } else { |
1322 | $tMaior = $tMask; | 1372 | $tMaior = $tMask; |
1323 | } | 1373 | } |
1374 | //contar o numero de cerquilhas da marcara | ||
1375 | $aMask = str_split($mascara); | ||
1376 | $z=0; | ||
1377 | $flag=FALSE; | ||
1378 | foreach ( $aMask as $letra ){ | ||
1379 | if ($letra == '#'){ | ||
1380 | $z++; | ||
1381 | } | ||
1382 | } | ||
1383 | if ( $z > $tCampo ) { | ||
1384 | //o campo é menor que esperado | ||
1385 | $flag=TRUE; | ||
1386 | } | ||
1324 | //cria uma variável grande o suficiente para conter os dados | 1387 | //cria uma variável grande o suficiente para conter os dados |
1325 | $sRetorno = ''; | 1388 | $sRetorno = ''; |
1326 | $sRetorno = str_pad($sRetorno, $tCampo+$tMask, " ",STR_PAD_LEFT); | 1389 | $sRetorno = str_pad($sRetorno, $tCampo+$tMask, " ",STR_PAD_LEFT); |
... | ... | ||
1338 | if ( $x > 0 ) { | 1401 | if ( $x > 0 ) { |
1339 | $digMask = $mascara[--$x]; | 1402 | $digMask = $mascara[--$x]; |
1340 | } else { | 1403 | } else { |
1341 | $digMask = '#'; | 1404 | $digMask = '#'; |
1342 | } | 1405 | } |
1406 | //se o fim do campo for atingido antes do fim da mascara | ||
1407 | //verificar se é ( se não for não use | ||
1343 | if ( $digMask=='#' ) { | 1408 | if ( $digMask=='#' ) { |
1344 | if ( $y > 0 ) { | 1409 | if ( $y > 0 ) { |
1345 | $sRetorno[--$tRetorno] = $sLimpo[--$y]; | 1410 | $sRetorno[--$tRetorno] = $sLimpo[--$y]; |
1346 | } else { | 1411 | } else { |
1347 | //$sRetorno[--$tRetorno] = ''; | 1412 | //$sRetorno[--$tRetorno] = ''; |
1348 | } | 1413 | } |
1349 | } else { | 1414 | } else { |
1350 | $sRetorno[--$tRetorno] = $mascara[$x]; | 1415 | if ( $y > 0 ) { |
1416 | $sRetorno[--$tRetorno] = $mascara[$x]; | ||
1417 | } else { | ||
1418 | if ($mascara[$x] =='('){ | ||
1419 | $sRetorno[--$tRetorno] = $mascara[$x]; | ||
1420 | } | ||
1421 | } | ||
1351 | $i++; | 1422 | $i++; |
1352 | } | 1423 | } |
1353 | } | 1424 | } |
... | ... | ||
1496 | * Converte a imformação de data e tempo contida na NFe | 1567 | * Converte a imformação de data e tempo contida na NFe |
1497 | * @package NFePHP | 1568 | * @package NFePHP |
1498 | * @name __convertTime | 1569 | * @name __convertTime |
1499 | * @version 1.0 | 1570 | * @version 1.1 |
1571 | * - Substituidas as funções split por explode | ||
1500 | * @author Roberto L. Machado <roberto.machado@superig.com.br> | 1572 | * @author Roberto L. Machado <roberto.machado@superig.com.br> |
1501 | * @param string $DH Informação de data e tempo extraida da NFe | 1573 | * @param string $DH Informação de data e tempo extraida da NFe |
1502 | * @return timestamp UNIX Para uso com a funçao date do php | 1574 | * @return timestamp UNIX Para uso com a funçao date do php |
1503 | */ | 1575 | */ |
1504 | private function __convertTime($DH){ | 1576 | private function __convertTime($DH){ |
1505 | if ($DH){ | 1577 | if ($DH){ |
1506 | $aDH = split('T',$DH); | 1578 | $aDH = explode('T',$DH); |
1507 | $adDH = split('-',$aDH[0]); | 1579 | $adDH = explode('-',$aDH[0]); |
1508 | $atDH = split(':',$aDH[1]); | 1580 | $atDH = explode(':',$aDH[1]); |
1509 | $timestampDH = mktime($atDH[0],$atDH[1],$atDH[2],$adDH[1],$adDH[2],$adDH[0]); | 1581 | $timestampDH = mktime($atDH[0],$atDH[1],$atDH[2],$adDH[1],$adDH[2],$adDH[0]); |
1510 | return $timestampDH; | 1582 | return $timestampDH; |
1511 | } | 1583 | } |
... | ... | ||
1513 | 1585 | ||
1514 | } //fim da classe | 1586 | } //fim da classe |
1515 | 1587 | ||
1516 | ?> | 1588 | ?> |
Download diff