Duvida infNFe

520 views
Skip to first unread message

Willian Renan

unread,
Jul 12, 2010, 2:49:08 PM7/12/10
to nfe...@googlegroups.com
Pessoal,

Estou trabalhando na geração dos XML's.  No Arquivo NFe.class.php tem no construtor o seguinte:

 function __construct() {
        $this->infNFe   = new infNFe;
        $this->situacao = new situacao;
    }

Este infNFe é usado no restante do arquivo, gostaria de saber de onde vem o new infNFe.

Obrigado

--
Willian Renan Becher

Acesse
http://www.nossajoinville.com.br

Roberto Leite Machado

unread,
Jul 12, 2010, 2:51:31 PM7/12/10
to nfe...@googlegroups.com
Desconheço esta classe !!

Use apenas o que esta em branches/1.0 Apha

Roberto

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".
Para Postar: nfe...@googlegroups.com
Para Sair do Grupo: nfephp+un...@googlegroups.com
Link: http://groups.google.com.br/group/nfephp?hl=pt-BR
-------
FAQ: https://www.assembla.com/wiki/show/nfephp/FAQ
Como Participar: https://www.assembla.com/wiki/show/nfephp/Como_participar

Willian Renan

unread,
Jul 12, 2010, 2:55:28 PM7/12/10
to nfe...@googlegroups.com
Certo Roberto.

Mas os XML você gera como? A partir do TXT?

Paulo Gabriel

unread,
Jul 12, 2010, 5:50:57 PM7/12/10
to nfe...@googlegroups.com
Isso!

walney moreira klein

unread,
Jul 12, 2010, 6:28:54 PM7/12/10
to nfephp

Boa Noite
 
 Gostaria de saber se alguem poderia me ajudar a configurar e implantar este projeto no meu host , desde já obrigado
 
 
Atenciosamente
WMK
Walney Moreira klein
www.wmknet.com
Videos para desenvolvedores
http://www.youtube.com/user/walney2008
Software OpenSource em Visual FoxPro
http://projetosec.codeplex.com
Software OpenSource para PAF-ECF e NF-e
http://vfpnfe.codeplex.com
Blog para ajuda desenvolvedores em FoxPro/Venda softwares com fontes
http://supervfp.blogspot.com
(22)2528-0212/8144-1606
msn: wal...@hotmail.com
skype: masterfacil




 

Date: Mon, 12 Jul 2010 18:50:57 -0300
Subject: Re: [nfephp] Duvida infNFe
From: paulo...@gmail.com
To: nfe...@googlegroups.com

Isso!


--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".
Para Postar: nfe...@googlegroups.com
Para Sair do Grupo: nfephp+un...@googlegroups.com
Link: http://groups.google.com.br/group/nfephp?hl=pt-BR
-------
FAQ: https://www.assembla.com/wiki/show/nfephp/FAQ
Como Participar: https://www.assembla.com/wiki/show/nfephp/Como_participar

LEVE SEU MESSENGER PARA ONDE VOCÊ ESTIVER PELO SEU CELULAR. CLIQUE E VEJA COMO FAZER.

Daniel Lemes

unread,
Jul 12, 2010, 8:54:18 PM7/12/10
to nfe...@googlegroups.com
Gera direto o XML ou gere TXT de acordo o manual.
----- Original Message -----
Sent: Monday, July 12, 2010 3:55 PM
Subject: Re: [nfephp] Duvida infNFe

Willian Renan

unread,
Jul 13, 2010, 9:03:59 AM7/13/10
to nfe...@googlegroups.com
Certo.. já consegui entender certinho...

Estou gerando meu XML no padrão e está dando tudo certo.

Obrigado pela ajuda.

André Moraes - Gmail

unread,
Jul 13, 2010, 9:46:07 PM7/13/10
to nfe...@googlegroups.com

Boa noite,

 

Primeiramente gostaria de me apresentar, meu nome é André Ferreira de Moraes e sou um dos administradores do Projeto ACBr – http://acbr.sf.net, e sou responsável principalmente pelo componente para Nota Fiscal Eletrônica – ACBrNFe.

 

Estou com um novo projeto e precisaria imprimir o DANFe via Web e pesquisando pela net encontrei o projeto NFePHP.

 

Fiz algumas alterações no DANFE da pasta trunk\libs para a impressão ficar mais parecida com a que uso no componente em Delphi e anexo estou enviando o arquivo que alterei para que possa ser analisado pelos administradores do NFePHP, e se for de interesse do projeto, que essas alterações sejam adicionadas ao SVN.

 

As principais alterações que realizei foram:

 

1 – Canhoto do DANFE impresso na parte superior da página;

2 – Impressão de até 21 duplicatas;

3 – Quando não houver duplicatas todos os demais quadros serão puxados pra cima, para não ficar um espaço em branco no meio do DANFE;

4 – Mudança da fonte para Times(estava como arial) para atender orientação do manual de integração(Item 7.7);

5 – Impressão das observações adicionadas nas tags obsCont;

6 – Impressão dos itens aproveitando melhor os espaços(itens estão sendo impressos com menos espaços entre eles);

7 – Alteração da posição das mensagens de homologação e cancelamento;

8 – O uso de ponto e vírgula está sendo considerado quebra de linha nas informações adicionais(igual funcionamento do ACBrNFe e do Uninfe);

9 – Diminuição do quadro com a identificação do emitente.

 

Ainda faltam alguns detalhes nestas alterações, como a impressão dos dados adicionais na folha seguinte quando não couber na primeira página e a impressão dos dados do ISQN.

 

Gostaria de parabenizá-los pelo ótimo projeto e mesmo que estas alterações não sejam aproveitadas pelo NFePHP gostaria de poder colaborar de alguma forma.

 

André F. Moraes

 

 

DanfeNFePHP.class.php
danfe-alterado.pdf
danfe-trunk.pdf

Leandro C. Lopez

unread,
Jul 14, 2010, 6:40:23 AM7/14/10
to nfe...@googlegroups.com
Grande Andre !!!!
 
Otima contribuição... seja muito bem-vindo ao projeto !!!
Alguem que tem acesso a gravar no SVN pode atualizar o arquivo pra nós no server ???
 
Att.: Leandro C. Lopez

--

Roberto Leite Machado

unread,
Jul 14, 2010, 7:47:29 AM7/14/10
to nfe...@googlegroups.com
Walney;

Qual é o sistema operacional ?

Roberto

2010/7/12 walney moreira klein <wal...@hotmail.com>

Roberto Leite Machado

unread,
Jul 14, 2010, 8:00:03 AM7/14/10
to nfe...@googlegroups.com
Muitissimo grato por sua contribuição André, vamos aproveitar sim estas alterações propostas por você.

Valeu mesmo !! Alias parabéns também pelo projeto ACBr uma grande iniciativa que tenho acompanhado já a algum tempo só não uso pois não conheço a linguagem e não uso windows. 

Roberto

Em 13 de julho de 2010 22:46, André Moraes - Gmail <andref...@gmail.com> escreveu:
--

Daniel Lemes

unread,
Jul 14, 2010, 9:48:28 AM7/14/10
to nfe...@googlegroups.com
Ficaram muito boas as tuas alterações. Parabéns, eu conheço o projeto acbr e é um ótimo exemplo de software open source, pena que meu conhecimento em delphi seja muito limitado a ponto de não poder colaborar com o projeto.
 
Abraço
__________ Informação do ESET Smart Security, versão da vacina 5276 (20100713) __________

A mensagem foi verificada pelo ESET Smart Security.

http://www.eset.com

Marcos

unread,
Jul 14, 2010, 11:08:15 AM7/14/10
to nfe...@googlegroups.com
Parab�ns.
Mesmo.

Marcos


Andr� Moraes - Gmail wrote:
> Boa noite,
>
>
>

> Primeiramente gostaria de me apresentar, meu nome � Andr� Ferreira de
> Moraes e sou um dos administradores do Projeto ACBr �
> http://acbr.sf.net, e sou respons�vel principalmente pelo componente
> para Nota Fiscal Eletr�nica � ACBrNFe.


>
>
>
> Estou com um novo projeto e precisaria imprimir o DANFe via Web e
> pesquisando pela net encontrei o projeto NFePHP.
>
>
>

> Fiz algumas altera��es no DANFE da pasta trunk\libs para a impress�o

> ficar mais parecida com a que uso no componente em Delphi e anexo estou
> enviando o arquivo que alterei para que possa ser analisado pelos
> administradores do NFePHP, e se for de interesse do projeto, que essas

> altera��es sejam adicionadas ao SVN.
>
>
>
> As principais altera��es que realizei foram:
>
>
>
> 1 � Canhoto do DANFE impresso na parte superior da p�gina;
>
> 2 � Impress�o de at� 21 duplicatas;
>
> 3 � Quando n�o houver duplicatas todos os demais quadros ser�o puxados
> pra cima, para n�o ficar um espa�o em branco no meio do DANFE;
>
> 4 � Mudan�a da fonte para Times(estava como arial) para atender
> orienta��o do manual de integra��o(Item 7.7);
>
> 5 � Impress�o das observa��es adicionadas nas tags obsCont;
>
> 6 � Impress�o dos itens aproveitando melhor os espa�os(itens est�o sendo
> impressos com menos espa�os entre eles);
>
> 7 � Altera��o da posi��o das mensagens de homologa��o e cancelamento;
>
> 8 � O uso de ponto e v�rgula est� sendo considerado quebra de linha nas
> informa��es adicionais(igual funcionamento do ACBrNFe e do Uninfe);
>
> 9 � Diminui��o do quadro com a identifica��o do emitente.
>
>
>
> Ainda faltam alguns detalhes nestas altera��es, como a impress�o dos
> dados adicionais na folha seguinte quando n�o couber na primeira p�gina
> e a impress�o dos dados do ISQN.
>
>
>
> Gostaria de parabeniz�-los pelo �timo projeto e mesmo que estas
> altera��es n�o sejam aproveitadas pelo NFePHP gostaria de poder
> colaborar de alguma forma.
>
>
>
> Andr� F. Moraes
>
>
>
>
>
> --
> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

Leandro Sprenger

unread,
Jul 14, 2010, 12:21:42 PM7/14/10
to nfe...@googlegroups.com
Boa tarde,

Alguém sabe se já foi atualizado no repositório?


Em 14 de julho de 2010 12:08, Marcos <mar...@unitron.com.br> escreveu:
Parabéns.
Mesmo.

Marcos



André Moraes - Gmail wrote:
Boa noite,

 
Primeiramente gostaria de me apresentar, meu nome é André Ferreira de Moraes e sou um dos administradores do Projeto ACBr – http://acbr.sf.net, e sou responsável principalmente pelo componente para Nota Fiscal Eletrônica – ACBrNFe.


 
Estou com um novo projeto e precisaria imprimir o DANFe via Web e pesquisando pela net encontrei o projeto NFePHP.

 
Fiz algumas alterações no DANFE da pasta trunk\libs para a impressão ficar mais parecida com a que uso no componente em Delphi e anexo estou enviando o arquivo que alterei para que possa ser analisado pelos administradores do NFePHP, e se for de interesse do projeto, que essas alterações sejam adicionadas ao SVN.

 
As principais alterações que realizei foram:

 
1 – Canhoto do DANFE impresso na parte superior da página;

2 – Impressão de até 21 duplicatas;

3 – Quando não houver duplicatas todos os demais quadros serão puxados pra cima, para não ficar um espaço em branco no meio do DANFE;

4 – Mudança da fonte para Times(estava como arial) para atender orientação do manual de integração(Item 7.7);

5 – Impressão das observações adicionadas nas tags obsCont;

6 – Impressão dos itens aproveitando melhor os espaços(itens estão sendo impressos com menos espaços entre eles);

7 – Alteração da posição das mensagens de homologação e cancelamento;

8 – O uso de ponto e vírgula está sendo considerado quebra de linha nas informações adicionais(igual funcionamento do ACBrNFe e do Uninfe);

9 – Diminuição do quadro com a identificação do emitente.

 
Ainda faltam alguns detalhes nestas alterações, como a impressão dos dados adicionais na folha seguinte quando não couber na primeira página e a impressão dos dados do ISQN.

 
Gostaria de parabenizá-los pelo ótimo projeto e mesmo que estas alterações não sejam aproveitadas pelo NFePHP gostaria de poder colaborar de alguma forma.

 
André F. Moraes

 
 
--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".



--
Att,
Leandro Cassel Sprenger

Daniel Lemes

unread,
Jul 14, 2010, 1:04:15 PM7/14/10
to nfe...@googlegroups.com
Eu poderia atualizar, mas vou esperar o roberto se manifestar

André Moraes - Gmail

unread,
Jul 14, 2010, 1:14:00 PM7/14/10
to nfe...@googlegroups.com

Anexo mais algumas alterações para o DANFE.

 

1 – Mudei o método construct para permitir passar a fonte que será usada na geração do DANFE, por padrão usa a Times

2 – Quadro do ISSQN será impresso quando o campo ISSQNtot->VServ for maior que 0

3 – Nas duplicatas, apenas serão impressos os quadros que possuem duplicatas, não ficando alguns quadros em branco qdo o número de vencimentos for menor q 7

 

Agora, pelos meus testes, falta apenas continuar a impressão do dados adicionais no corpo do DANFE qdo não couber no quadro de informações complementares da NFe.

 

André F. Moraes

DanfeNFePHP.class.php

André Moraes - Gmail

unread,
Jul 14, 2010, 1:19:03 PM7/14/10
to nfe...@googlegroups.com

Anexo exemplo de DANFEs gerados com as fontes Times, Arial e Courier

 

André F. Moraes

 

De: nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] Em nome de Daniel Lemes
Enviada em: quarta-feira, 14 de julho de 2010 14:04
Para: nfe...@googlegroups.com
Assunto: Re: [nfephp] Alterações DANFE

 

Eu poderia atualizar, mas vou esperar o roberto se manifestar

danfe-arial.pdf
danfe-courier.pdf
danfe-times.pdf

Leandro Santana

unread,
Jul 14, 2010, 1:27:21 PM7/14/10
to nfe...@googlegroups.com

Só eu estou enxergando mal ou abaixo da natureza de operação a tonalidade está mais fraca?

 

 

 


Leandro Santana

Tecnologia da Informação - TI
( Celular:  (11) 7232-0066
* leandro...@gmail.com

 

"de fazer convergir em Cristo, na dispensação da plenitude dos tempos, todas as coisas, tanto as do céu, como as da terra;" - Efésios 1:10

André Moraes - Gmail

unread,
Jul 14, 2010, 1:31:18 PM7/14/10
to nfe...@googlegroups.com

Está assim pq foi emitida em ambiente de homologação.

 

Em ambiente de produção imprime normal, basta alterar a tag tpAmb para 1.

 

André F. Moraes

danfe-producao.pdf

FerreiraH.

unread,
Jul 14, 2010, 5:22:21 PM7/14/10
to nfe...@googlegroups.com
Roberto acabei fazendo um sistema para rodar sob apache e que foi desenvolvido para comunicar com o b2stok e tem uma tabela de banco de dados que vai sendo pesquizada para saber a situação do projeto e salva o arquivo enviado ao cliente no banco de dados
na realidade são cinco scripts ou seis.
a tabela Chama nota_xml e faz parte do banco de dados do B2Stok.sql 
O b2stok gera o xml e salva no banco que esta no servidor ai vai chamando os scripts e estes vão atualizando os arquivos como é no NFePHP e tambem no banco de dados para não correr o risco de serem chamados fora da ordem.
a biblioteca é a NFePHP mas não sei de qual versão porque acabei fussando muito e me perdi
Mas continuo precisando de muita ajuda
--
Ferreira Helder
B2Stok.net ERP Php5-Gtk2
PhpGtkEditor
PhpSDL
PhpGladeTools
Voce pode colaborar

André Moraes - Gmail

unread,
Jul 14, 2010, 6:27:48 PM7/14/10
to nfe...@googlegroups.com

Anexo mais alguns ajustes no DANFE.

 

Corrigi a impressão quando o XML contiver apenas ISS e não tiver ICMS no item(versão 2.0 da NFe)

 

André F. Moraes

DanfeNFePHP.class.php

Leandro C. Lopez

unread,
Jul 15, 2010, 7:00:02 AM7/15/10
to nfe...@googlegroups.com
Andre, não tive tempo de olhar com mais atenção o codigo, mas me responde se essas alterações já contemplam quando nas informações adicionais contiver uma estrutura como abaixo:
 
<infAdic>
  <obsCont xCampo="obs1">
  <xTexto>ICMS DIFERIDO CFE L III,ART 1o.,AP II,SEC I,ITEM II</xTexto>
  </obsCont>
  <obsCont xCampo="obs2">
  <xTexto>DEV.TOTAL S/NFS 510939/511607 DE 26 E 30/06/10</xTexto>
  </obsCont>
</infAdic>

walney moreira klein

unread,
Jul 15, 2010, 7:25:46 AM7/15/10
to nfephp
Bom dia
 
 Gostaria da opnião dos parceiros para o seguinte;
 
 - Para a criação do software para emissão de NF-e como devem ser os impostos ?
 
  - Criar uma tabela de impostos e referenciar o produto a esta tabela ou no cadastro de cada produto colocar os impostos ?



Atenciosamente
WMK
Walney Moreira klein
www.wmknet.com
Videos para desenvolvedores
http://www.youtube.com/user/walney2008
Software OpenSource em Visual FoxPro
http://projetosec.codeplex.com
Software OpenSource para PAF-ECF e NF-e
http://vfpnfe.codeplex.com
Blog para ajuda desenvolvedores em FoxPro/Venda softwares com fontes
http://supervfp.blogspot.com
(22)2528-0212/9817-2712

msn: wal...@hotmail.com
skype: masterfacil




FIQUE MAIS PROTEGIDO ENQUANTO FAZ DOWNLOADS INSTALE GRÁTIS O INTERNET EXPLORER 8.

André Moraes - Gmail

unread,
Jul 15, 2010, 7:33:27 AM7/15/10
to nfe...@googlegroups.com

Já funciona. Você pode testar as alterações que fiz no site http://www.facilnfe.com.br

 

André F. Moraes

Abdenego

unread,
Jul 15, 2010, 7:37:13 AM7/15/10
to nfe...@googlegroups.com

Onde que ces tao botando o protocolo de retorno da visualização do danfe? eu abri aqui uns xml e o campo Protocolo de Autorização de Uso, impresso do lado da Natureza da Operação do DANFE não mostra o protocolo.

Paulo Gabriel

unread,
Jul 15, 2010, 8:15:29 AM7/15/10
to nfe...@googlegroups.com
Esses dados são gigantescamente extensos. Cada empresa tem um tipo de tributação. Cada ramo de atividade, cada enquadramento (ME, EPP, etc...).

Por isso você deve obter as informações sobre os seus impostos com seu contador.

Se você já emitia nota fiscal antes, use a mesma tributação. A diferença está no formato apenas: agora não é mais impresso, mas enviado eletronicamente. Só isso.


O NFePHP te dá todas as bibliotecas necessárias pra fazer seu sistema emissor de nota emitir as novas NFe.

Use seu sistema de emissão de nota em papel, criando nele uma rotina para escrever a nota no formato de TXT seguindo este layout:

Em seguida, chame as rotinas do NFePHP, descritos aqui:

Através das rotinas o NFePHP faz praticamente tudo automático, você só precisa configurá-lo com seus dados e certificado digital.


É isso!

Paulo Gabriel

unread,
Jul 15, 2010, 8:17:48 AM7/15/10
to nfe...@googlegroups.com
Desculpe.... acho que está na hora de eu dar um tempo no suporte aqui do grupo.

Entendi sua dúvida. Acho mais interessante criar uma tabela de impostos e referenciar o produto ao seu tipo de imposto.

Paulo Gabriel

unread,
Jul 15, 2010, 8:22:23 AM7/15/10
to nfe...@googlegroups.com
Seja bem vindo André!


Desde já nosso muitíssimo obrigado e parabéns pelas contribuições. Pode contar conosco!

Um grande abraço!

Roberto L. Machado

unread,
Jul 15, 2010, 8:35:46 AM7/15/10
to nfe...@googlegroups.com
Walney;

No Brasil o sistema tributário é um quebra cabeças gigantesco, os
impostos dependem de uma série interminável de leis e portarias mas
posso adiantar o seguinte :

ICMS
- depende de tipo de cliente (se é ou não contribuinte do ICMS)
- depende da localização do cliente (no estado ou fora dele)
- depende de isenções específicas (ex. fabricantes de cadeira de rodas,
intituições beneficienes, etc)
- depende de o cliente é SIMPLES NACIONAL
- depende do NCM do produto (ex. texteis tem redução da base de
calculo)
- depende da operação fiscal (CFOP)
- depende do tipo de emissor (quem esta gerando a nota fiscal é empresa
SIMPES, ou não)

IPI
- depende do NCM produto (ver tabela TIPI)
- depende da operação fiscal (CFOP)

PIS
- depende da operação fiscal (CFOP)
- pode depender do NCM do produto
- depende do regime de apuração do emitente (lucro presumido ou lucro
real)

COFINS
- depende da operação fiscal (CFOP)
- pode depender do NCM do produto
- depende do regime de apuração do emitente (lucro presumido ou lucro


Divirta-se

Roberto

> ______________________________________________________________________


> FIQUE MAIS PROTEGIDO ENQUANTO FAZ DOWNLOADS INSTALE GRÁTIS O INTERNET
> EXPLORER 8.
>

Leandro C. Lopez

unread,
Jul 15, 2010, 1:08:55 PM7/15/10
to nfe...@googlegroups.com
Andre !!!
 
Fiz um teste rapido e achei duas coisas que voce pode alterar no teu original, cfe. linhas indicadas:
 
// Para compatibilidade com PHP 5.3.x
1770: $sLimpo = preg_replace("[' '-./ t]",'',$campo);
 
//Para quantidades com 4 digitos, tenho recebido mercadorias com esta formatação necessaria.
1408: $texto = number_format($prod->getElementsByTagName("qCom")->item(0)->nodeValue, 4, ",", ".");
 
Att.: Leandro C. Lopez

Em 15 de julho de 2010 13:36, Leandro C. Lopez <leandro....@gmail.com> escreveu:


---------- Mensagem encaminhada ----------
De: André Moraes - Gmail <andref...@gmail.com>
Data: 14 de julho de 2010 19:27

Assunto: RES: [nfephp] Alterações DANFE

André Moraes - Gmail

unread,
Jul 15, 2010, 1:40:25 PM7/15/10
to nfe...@googlegroups.com

As duas linhas que vc citou já estavam no fonte que baixei do SVN, não mexi em nenhuma das duas.

 

Sobre a quantidade de casas decimais, seria bom termos um modo de calcular qtas casas são necessárias, pois na NFe 2.0 o campo preço unitário pode ter até 10 casas decimais e se deixarmos fixo em 10 pode atrapalhar outros usuários.

 

André F. Moraes

Paulo Vitor Bettini de Albuqerque Lima

unread,
Jul 15, 2010, 1:54:32 PM7/15/10
to nfe...@googlegroups.com
Sugiro a criação de descritores.

Que seriam arquivos de configuração para definir esse tipo de atributo.
Daí o mesmo código iria funcionar tanto para  versão 2.0 quanto para as anteriores apenas alterando os descritores quando necessário.

Mas é só uma idéia.

Atenciosamente,
Paulo Vitor Bettini de Albuquerque Lima



2010/7/15 André Moraes - Gmail <andref...@gmail.com>

Paulo Gabriel

unread,
Jul 17, 2010, 7:47:53 PM7/17/10
to nfe...@googlegroups.com
Idéia que eu apoio.

Marcos

unread,
Jul 18, 2010, 9:59:21 AM7/18/10
to nfe...@googlegroups.com
Senhores e Senhoras (h� alguma aqui ???),

aproveitando suas correcoes feitas pelo Andr� na classe DANFE, fiz mais
algumas.

Tomei como base a vers�o 125 do reposit�rio:

- pus de volta a verifica��o para s� mostrar o logo se o mesmo existir (
o Andr� deve ter tirado sem querer )

- chave de acesso agora aparece no formato
####-####-####-####-####-####-####-####-####-####-####
- destinat�rio agora aparece como "1 - Dest/Rem", como diz a NT2010.5
- codigo ANTT/RNTC da transportadora agora aparece
- placa do ve�culo agora aparece
- UF do ve�culo da transportadora agora aparece corretamente (antes
aparecia o UF da transportadora)
- CPF de transportadora agora aparece ( antes aparecia s� CNPJ )
- marca (tranpsortadora) agora aparece
- Numera��o dos volumes transportados (nVol) agora aparece


Marcos


Andr� Moraes - Gmail wrote:

> Anexo mais alguns ajustes no DANFE.
>
>
>

> Corrigi a impress�o quando o XML contiver apenas ISS e n�o tiver ICMS no
> item(vers�o 2.0 da NFe)
>
>
>
> Andr� F. Moraes
>
>
>
> *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome
> de *Leandro Santana
> *Enviada em:* quarta-feira, 14 de julho de 2010 14:27
> *Para:* nfe...@googlegroups.com
> *Assunto:* RES: [nfephp] Altera��es DANFE
>
>
>
> S� eu estou enxergando mal ou abaixo da natureza de opera��o a
> tonalidade est� mais fraca?
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> *Leandro Santana*
>
> Tecnologia da Informa��o - TI
> (* Celular: (11) 7232-0066
> *** **leandro...@gmail.com* <mailto:leandro...@gmail.com>**
>
> * *
>
> "de fazer convergir em Cristo, na dispensa��o da plenitude dos tempos,
> todas as coisas, tanto as do c�u, como as da terra;" - Ef�sios 1:10
>
>
>
> *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome
> de *Andr� Moraes - Gmail
> *Enviada em:* quarta-feira, 14 de julho de 2010 14:19
> *Para:* nfe...@googlegroups.com
> *Assunto:* RES: [nfephp] Altera��es DANFE


>
>
>
> Anexo exemplo de DANFEs gerados com as fontes Times, Arial e Courier
>
>
>

> Andr� F. Moraes
>
>
>
> *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome
> de *Daniel Lemes
> *Enviada em:* quarta-feira, 14 de julho de 2010 14:04
> *Para:* nfe...@googlegroups.com
> *Assunto:* Re: [nfephp] Altera��es DANFE


>
>
>
> Eu poderia atualizar, mas vou esperar o roberto se manifestar
>
> ----- Original Message -----
>

> *From:* Leandro Sprenger <mailto:leand...@gmail.com>
>
> *To:* nfe...@googlegroups.com <mailto:nfe...@googlegroups.com>
>
> *Sent:* Wednesday, July 14, 2010 1:21 PM
>
> *Subject:* Re: [nfephp] Altera��es DANFE
>
>
>
> Boa tarde,
>
>
>
> Algu�m sabe se j� foi atualizado no reposit�rio?


>
>
>
> Em 14 de julho de 2010 12:08, Marcos <mar...@unitron.com.br

> <mailto:mar...@unitron.com.br>> escreveu:
>
> Parab�ns.
> Mesmo.
>
> Marcos


>
>
>
>
> Andr� Moraes - Gmail wrote:
>
> Boa noite,
>
>

> Primeiramente gostaria de me apresentar, meu nome � Andr� Ferreira


> de Moraes e sou um dos administradores do Projeto ACBr �

> http://acbr.sf.net, e sou respons�vel principalmente pelo componente
> para Nota Fiscal Eletr�nica � ACBrNFe.


>
>
> Estou com um novo projeto e precisaria imprimir o DANFe via Web e
> pesquisando pela net encontrei o projeto NFePHP.
>
>

> Fiz algumas altera��es no DANFE da pasta trunk\libs para a impress�o


> ficar mais parecida com a que uso no componente em Delphi e anexo
> estou enviando o arquivo que alterei para que possa ser analisado
> pelos administradores do NFePHP, e se for de interesse do projeto,

> que essas altera��es sejam adicionadas ao SVN.
>
>
> As principais altera��es que realizei foram:
>
>
> 1 � Canhoto do DANFE impresso na parte superior da p�gina;
>
> 2 � Impress�o de at� 21 duplicatas;
>
> 3 � Quando n�o houver duplicatas todos os demais quadros ser�o

> puxados pra cima, para n�o ficar um espa�o em branco no meio do DANFE;
>
> 4 � Mudan�a da fonte para Times(estava como arial) para atender


> orienta��o do manual de integra��o(Item 7.7);
>
> 5 � Impress�o das observa��es adicionadas nas tags obsCont;
>
> 6 � Impress�o dos itens aproveitando melhor os espa�os(itens est�o
> sendo impressos com menos espa�os entre eles);
>
> 7 � Altera��o da posi��o das mensagens de homologa��o e cancelamento;
>

> 8 � O uso de ponto e v�rgula est� sendo considerado quebra de linha


> nas informa��es adicionais(igual funcionamento do ACBrNFe e do Uninfe);
>
> 9 � Diminui��o do quadro com a identifica��o do emitente.
>
>

> Ainda faltam alguns detalhes nestas altera��es, como a impress�o dos


> dados adicionais na folha seguinte quando n�o couber na primeira
> p�gina e a impress�o dos dados do ISQN.
>
>

> Gostaria de parabeniz�-los pelo �timo projeto e mesmo que estas
> altera��es n�o sejam aproveitadas pelo NFePHP gostaria de poder
> colaborar de alguma forma.
>
>
> Andr� F. Moraes
>
>
>
> --
> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".
> Para Postar: nfe...@googlegroups.com <mailto:nfe...@googlegroups.com>


> Para Sair do Grupo: nfephp+un...@googlegroups.com

> <mailto:nfephp%2Bunsu...@googlegroups.com>

> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".
> Para Postar: nfe...@googlegroups.com <mailto:nfe...@googlegroups.com>


> Para Sair do Grupo: nfephp+un...@googlegroups.com

> <mailto:nfephp%2Bunsu...@googlegroups.com>

> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

DanfeNFePHP.class.php

Roberto L. Machado

unread,
Jul 18, 2010, 10:42:20 AM7/18/10
to nfe...@googlegroups.com
Marcos;

Acho que você anexou o arquivo antigo ...


Roberto


Em Dom, 2010-07-18 às 10:59 -0300, Marcos escreveu:
> Senhores e Senhoras (há alguma aqui ???),
>
> aproveitando suas correcoes feitas pelo André na classe DANFE, fiz mais
> algumas.
>
> Tomei como base a versão 125 do repositório:
>
> - pus de volta a verificação para só mostrar o logo se o mesmo existir (
> o André deve ter tirado sem querer )


>
> - chave de acesso agora aparece no formato
> ####-####-####-####-####-####-####-####-####-####-####

> - destinatário agora aparece como "1 - Dest/Rem", como diz a NT2010.5


> - codigo ANTT/RNTC da transportadora agora aparece

> - placa do veículo agora aparece
> - UF do veículo da transportadora agora aparece corretamente (antes

> aparecia o UF da transportadora)

> - CPF de transportadora agora aparece ( antes aparecia só CNPJ )


> - marca (tranpsortadora) agora aparece

> - Numeração dos volumes transportados (nVol) agora aparece


>
>
> Marcos
>
>
> André Moraes - Gmail wrote:
> > Anexo mais alguns ajustes no DANFE.
> >
> >
> >

> > Corrigi a impressão quando o XML contiver apenas ISS e não tiver ICMS no
> > item(versão 2.0 da NFe)
> >
> >
> >

> > André F. Moraes


> >
> >
> >
> > *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome
> > de *Leandro Santana
> > *Enviada em:* quarta-feira, 14 de julho de 2010 14:27
> > *Para:* nfe...@googlegroups.com

> > *Assunto:* RES: [nfephp] Alterações DANFE
> >
> >
> >
> > Só eu estou enxergando mal ou abaixo da natureza de operação a
> > tonalidade está mais fraca?
> >
> >
> >
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > *Leandro Santana*
> >
> > Tecnologia da Informação - TI


> > (* Celular: (11) 7232-0066
> > *** **leandro...@gmail.com* <mailto:leandro...@gmail.com>**
> >
> > * *
> >

> > "de fazer convergir em Cristo, na dispensação da plenitude dos tempos,
> > todas as coisas, tanto as do céu, como as da terra;" - Efésios 1:10


> >
> >
> >
> > *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome

> > de *André Moraes - Gmail


> > *Enviada em:* quarta-feira, 14 de julho de 2010 14:19
> > *Para:* nfe...@googlegroups.com

> > *Assunto:* RES: [nfephp] Alterações DANFE


> >
> >
> >
> > Anexo exemplo de DANFEs gerados com as fontes Times, Arial e Courier
> >
> >
> >

> > André F. Moraes


> >
> >
> >
> > *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome
> > de *Daniel Lemes
> > *Enviada em:* quarta-feira, 14 de julho de 2010 14:04
> > *Para:* nfe...@googlegroups.com

> > *Assunto:* Re: [nfephp] Alterações DANFE


> >
> >
> >
> > Eu poderia atualizar, mas vou esperar o roberto se manifestar
> >
> > ----- Original Message -----
> >
> > *From:* Leandro Sprenger <mailto:leand...@gmail.com>
> >
> > *To:* nfe...@googlegroups.com <mailto:nfe...@googlegroups.com>
> >
> > *Sent:* Wednesday, July 14, 2010 1:21 PM
> >

> > *Subject:* Re: [nfephp] Alterações DANFE


> >
> >
> >
> > Boa tarde,
> >
> >
> >
> > Alguém sabe se já foi atualizado no repositório?
> >
> >
> >

> > Em 14 de julho de 2010 12:08, Marcos <mar...@unitron.com.br
> > <mailto:mar...@unitron.com.br>> escreveu:
> >

> > Parabéns.
> > Mesmo.
> >
> > Marcos


> >
> >
> >
> >
> > André Moraes - Gmail wrote:
> >
> > Boa noite,
> >
> >

> > Primeiramente gostaria de me apresentar, meu nome é André Ferreira
> > de Moraes e sou um dos administradores do Projeto ACBr –
> > http://acbr.sf.net, e sou responsável principalmente pelo componente
> > para Nota Fiscal Eletrônica – ACBrNFe.


> >
> >
> > Estou com um novo projeto e precisaria imprimir o DANFe via Web e
> > pesquisando pela net encontrei o projeto NFePHP.
> >
> >

> > Fiz algumas alterações no DANFE da pasta trunk\libs para a impressão


> > ficar mais parecida com a que uso no componente em Delphi e anexo
> > estou enviando o arquivo que alterei para que possa ser analisado
> > pelos administradores do NFePHP, e se for de interesse do projeto,

> > que essas alterações sejam adicionadas ao SVN.
> >
> >
> > As principais alterações que realizei foram:
> >
> >
> > 1 – Canhoto do DANFE impresso na parte superior da página;
> >
> > 2 – Impressão de até 21 duplicatas;
> >
> > 3 – Quando não houver duplicatas todos os demais quadros serão

> > puxados pra cima, para não ficar um espaço em branco no meio do DANFE;
> >
> > 4 – Mudança da fonte para Times(estava como arial) para atender


> > orientação do manual de integração(Item 7.7);
> >
> > 5 – Impressão das observações adicionadas nas tags obsCont;
> >
> > 6 – Impressão dos itens aproveitando melhor os espaços(itens estão
> > sendo impressos com menos espaços entre eles);
> >
> > 7 – Alteração da posição das mensagens de homologação e cancelamento;
> >

> > 8 – O uso de ponto e vírgula está sendo considerado quebra de linha


> > nas informações adicionais(igual funcionamento do ACBrNFe e do Uninfe);
> >

> > 9 – Diminuição do quadro com a identificação do emitente.
> >
> >
> > Ainda faltam alguns detalhes nestas alterações, como a impressão dos


> > dados adicionais na folha seguinte quando não couber na primeira

> > página e a impressão dos dados do ISQN.
> >
> >
> > Gostaria de parabenizá-los pelo ótimo projeto e mesmo que estas
> > alterações não sejam aproveitadas pelo NFePHP gostaria de poder
> > colaborar de alguma forma.
> >
> >
> > André F. Moraes
> >
> >
> >
> > --
> > Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

> > Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".


> > Para Postar: nfe...@googlegroups.com <mailto:nfe...@googlegroups.com>
> > Para Sair do Grupo: nfephp+un...@googlegroups.com
> > <mailto:nfephp%2Bunsu...@googlegroups.com>
> > Link: http://groups.google.com.br/group/nfephp?hl=pt-BR
> > -------
> > FAQ: https://www.assembla.com/wiki/show/nfephp/FAQ
> > Como Participar:
> > https://www.assembla.com/wiki/show/nfephp/Como_participar
> >
> >
> >
> >
> > --
> > Att,
> > Leandro Cassel Sprenger
> >
> > --

> > Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

> > Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

> > Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

> > Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

> > Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

> Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

> anexo Documento HTML (DanfeNFePHP.class.php)
> . * * @package NFePHP * @name DanfeNFePHP.class.php * @version
> 1.3 * @license http://www.gnu.org/licenses/gpl.html GNU/GPL v.3 *
> @copyright 2009 © NFePHP * @link http://www.nfephp.org/ * @author
> Roberto L. Machado * @author Leandro C. Lopez * @todo Formatação
> Paisagem * @todo Inclusão de campos para NF de serviços * @todo
> Adaptação para a nova versão 2.0 do manual SEFAZ */ //comente a linha
> abaixo para nao permitir qualquer aviso no codigo pdf, a linha abaixo
> é utilizada para debug //error_reporting(E_ALL); //ajuste do tempo
> limite de resposta do processo set_time_limit(1800); //definição do
> caminho para o diretorio com as fontes do FDPF
> define('FPDF_FONTPATH','font/'); //classe extendida da classe FPDF
> para montagem do arquivo pfd
> require_once('FPDF/code128.php'); //require_once('LoadClasses.class.php'); class DanfeNFePHP { private $pdf; // objeto fpdf() private $xml; // string XML NFe private $logomarca=''; // path para logomarca em jpg private $errMsg=''; // mesagens de erro private $errStatus=FALSE;// status de erro TRUE um erro ocorreu FALSE sem erros private $orientacao='P'; //orientação da DANFE P-Retrato ou L-Paisagem private $papel='A4'; //formato do papel private $destino = 'I'; //destivo do arquivo pdf I-borwser, S-retorna o arquivo, D-força download, F-salva em arquivo local private $pdfDir=''; //diretorio para salvar o pdf com a opção de destino = F private $fontePadrao='Times'; //Nome da Fonte para gerar o DANFE //objetos DOM da NFe private $dom; private $infNFe; private $ide; private $emit; private $dest; private $enderEmit; private $enderDest; private $det; private $cobr; private $dup; private $ICMSTot; private $ISSQNtot; private $transp; private $transporta; private $veicTransp; private $infAdic; /** *__construct * @package NFePHP * @name __construct * @version 1.0 * @param string $docXML Arquivo XML da NFe (com ou sem a tag nfeProc) * @param string $sOrientacao Orientação da impressão P-retrato L-Paisagem * @param string $sPapel Tamanho do papel (Ex. A4) * @param string $sPathLogo Caminho para o arquivo do logo * @param string $sDestino Estabelece a direção do envio do documento PDF I-browser D-browser com download S- * @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF */ function __construct($docXML='', $sOrientacao="P",$sPapel='A4',$sPathLogo='', $sDestino='I',$sDirPDF='',$fonteDANFE='') { $this->orientacao = $sOrientacao; $this->papel = $sPapel; $this->pdf = ''; $this->xml = $docXML; $this->logomarca= $sPathLogo; $this->destino = $sDestino; $this->pdfDir = $sDirPDF; // verifica se foi passa a fonte a ser usada if (empty($fonteDANFE)) { $this->fontePadrao = 'Times'; } else { $this->fontePadrao = $fonteDANFE; } if ( !empty($this->xml) ) { $this->dom = new DomDocument; $this->dom->loadXML($this->xml); $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0); $this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0); $this->ide = $this->dom->getElementsByTagName("ide")->item(0); $this->emit = $this->dom->getElementsByTagName("emit")->item(0); $this->dest = $this->dom->getElementsByTagName("dest")->item(0); $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0); $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0); $this->det = $this->dom->getElementsByTagName("det"); $this->cobr = $this->dom->getElementsByTagName("cobr")->item(0); $this->dup = $this->dom->getElementsByTagName('dup'); $this->ICMSTot = $this->dom->getElementsByTagName("ICMSTot")->item(0); $this->ISSQNtot = $this->dom->getElementsByTagName("ISSQNtot")->item(0); $this->transp = $this->dom->getElementsByTagName("transp")->item(0); $this->transporta = $this->dom->getElementsByTagName("transporta")->item(0); $this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0); $this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0); } } //fim construct /** * montaDANFE * Esta função monta a DANFE conforme as informações fornecidas para a classe * durante sua construção. * Esta função constroi DANFE's com até 3 páginas podendo conter até 56 itens. * A definição de margens e posições iniciais para a impressão são estabelecidas no * pelo conteúdo da funçao e podem ser modificados. * @package NFePHP * @name montaDANFE * @version 1.1 * @param string $orientacao (Opcional) Estabelece a orientação da impressão (ex. P-retrato) * @param string $papel (Opcional) Estabelece o tamanho do papel (ex. A4) * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML * @todo Impressão paisagem * @todo Inclusão de campos de NFe de serviços */ public function montaDANFE($orientacao='P',$papel='A4'){ $this->orientacao = $orientacao; $this->papel = $papel; //instancia a classe pdf $this->pdf = new PDF_Code128($this->orientacao, 'mm', $this->papel); // margens do PDF $margSup = 2; $margEsq = 2; $margDir = 2; // posição inicial do relatorio $y = 5; $x = 5; // estabelece contagem de paginas $this->pdf->AliasNbPages(); // fixa as margens $this->pdf->SetMargins($margEsq,$margSup,$margDir); $this->pdf->SetDrawColor(100,100,100); $this->pdf->SetFillColor(255,255,255); // inicia o documento $this->pdf->Open(); // adiciona a primeira página $this->pdf->AddPage($this->orientacao, $this->papel); $this->pdf->SetLineWidth(0.1); $this->pdf->SetTextColor(0,0,0); //Contagem de quantas linhas serão usadas para impressão dos itens. $i = 0; $totlinha = 0; $linhaDescr = 0; $linhaAdic = 0; while ($i < $this->det->length){ $prod = $this->det->item($i)->getElementsByTagName("prod")->item(0); $infAdProd = substr(!empty($this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue) ? $this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue : '',0,120); $infAdProd = str_replace(';',chr(13).chr(10), $infAdProd); if (!empty($infAdProd)){ $infAdProd = $infAdProd.chr(13).chr(10); } $texto = utf8_decode($prod->getElementsByTagName("xProd")->item(0)->nodeValue .chr(13).chr(10). $infAdProd); $linhas = explode("\n",$texto); $linhaAdic = count($linhas)-1; $linhaDescr = strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50; /* - round(strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50,0);*/ if ($linhaDescr > 1){ $linhaAdic += $linhaDescr; } if ($linhaAdic <= 0){ $linhaAdic = 1; } $totlinha += $linhaAdic; $i += 1; } $totPag = 1; //Verificando quantas linhas serão usadas para impressão das duplicatas $linhasDup = 0; if ( ($this->dup->length > 0) && ($this->dup->length <= 7) ) { $linhasDup = 1; } elseif ( ($this->dup->length > 7) && ($this->dup->length <= 14) ) { $linhasDup = 2; } elseif ( ($this->dup->length > 14) && ($this->dup->length <= 21) ) { $linhasDup = 3; } elseif ($this->dup->length > 21) { $linhasDup = 3; } else{ $linhasDup = 0; } if ($linhasDup == 0){ $maxite = 82; $totlinha = $totlinha - 27; } else { if ($linhasDup == 1){ $maxite = 69; $totlinha = $totlinha - 23; } elseif ($linhasDup == 2){ $maxite = 60; $totlinha = $totlinha - 20; } elseif ($linhasDup == 3){ $maxite = 51; $totlinha = $totlinha - 17; } else { $maxite = 51; $totlinha = $totlinha - 17; } } $temISSQN = FALSE; if ( isset($this->ISSQNtot) ){ if ($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue > 0 ) { $temISSQN = TRUE; $maxite = $maxite - 11; $totlinha = $totlinha - 3; } } else { $temISSQN = FALSE; } $pAdic = 0; if ($totlinha > 0){ $pAdic = 1; if (round(($totlinha/85),0) > 1) { $pAdic += round(($totlinha/85),0); } } $totPag = 1 + $pAdic; //montagem da primeira página $pag = 1; //coloca o canhoto da NFe $y = $this->__canhotoDANFE($x,$y); //coloca o cabeçalho $y = $this->__cabecalhoDANFE($x,$y,$pag,$totPag); //coloca os dados do destinatário $y = $this->__destinatarioDANFE($x,$y+1); //coloca os dados das faturas $y = $this->__faturaDANFE($x,$y+1); //coloca os dados dos impostos e totais da NFe $y = $this->__impostoDANFE($x,$y+1); //coloca os dados do trasnporte $y = $this->__transporteDANFE($x,$y+1); $nInicial = 0; $y = $this->__itensDANFE($x,$y+1,&$nInicial,$maxite,$pag,$totPag); //coloca os dados do ISSQN $incY = 0; if ($temISSQN) { $y = $this->__issqnDANFE($x,$y+4); $incY = 1; } else { $incY = 4; } //coloca os dados adicionais da NFe $temObs = FALSE; $y = $this->__dadosAdicionaisDANFE($x,$y+$incY,$pag,&$temObs); for ( $n = 2; $n <= $totPag; $n++ ) { //adiciona nova página $this->pdf->AddPage($this->orientacao, $this->papel); //ajusta espessura das linhas $this->pdf->SetLineWidth(0.1); //seta a cor do texto para petro $this->pdf->SetTextColor(0,0,0); // posição inicial do relatorio $y = 5; $x = 5; //coloca o cabeçalho na página adicional $y = $this->__cabecalhoDANFE($x,$y,$n,$totPag); //coloca os itens na página adicional $y = $this->__itensDANFE($x,$y+1,&$nInicial,225,$pag,$totPag); } //retorna o ID na NFe return str_replace('NFe', '', $this->infNFe->getAttribute("Id")); }//fim da função montaDANFE /** * printDANFE * Esta função envia a DANFE em PDF criada para o dispositivo informado. * O destino da impressão pode ser : * I-browser * D-browser com download * F-salva em um arquivo local com o nome informado * S-retorna o documento como uma string e o nome é ignorado. * Para enviar o pdf diretamente para uma impressora indique o * nome da impressora e o destino deve ser 'S'. * @package NFePHP * @name printDANFE * @version 1.0 * @param string $nome Path completo com o nome do arquivo pdf * @param string $destino Direção do envio do PDF * @param string $printer Identificação da impressora no sistema * @return string Caso o destino seja S o pdf é retornado como uma string * @todo Rotina de impressão direta do arquivo pdf criado */ public function printDANFE($nome='',$destino='I',$printer=''){ $arq = $this->pdf->Output($nome,$destino); if ( $destino == 'S' ){ //aqui rotina de impressão direta } return $arq; /** * Opção 1 - exemplo de script shell usando acroread #!/bin/sh if ( $# == 2 ) then set printer=$2 else set printer=$PRINTER fi if( $1 != "" ) then cat ${1} | acroread -toPostScript | lpr -P $printer echo ${1} sent to $printer ... OK! else echo PDF Print: No filename defined! fi Opção 2 - salvar pdf em arquivo temporario converter pdf para ps usando pdf2ps do linux imprimir ps para printer usando lp ou lpr remover os arquivos temporarios pdf e ps **/ } //fim função printDANFE /** *__cabecalhoDANFE * Monta o cabelhalho da DANFE * @package NFePHP * @name __cabecalhoDANFE * @version 1.1 * @param number $x Posição horizontal inicial, canto esquerdo * @param number $y Posição vertical inicial, canto superior * @param number $pag Número da Página * @param number$totPag Total de páginas * @return number Posição vertical final */ private function __cabecalhoDANFE($x=0,$y=0,$pag='1',$totPag='1'){ $oldX = $x; $oldY = $y; //#################################################################################### //coluna esquerda identificação do emitente $w=80; $h=32; $oldY += $h; $this->__textBox($x,$y,$w,$h); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'I'); $texto = utf8_decode('IDENTIFICAÇÃO DO EMITENTE'); $this->__textBox($x,$y,$w,5,$texto,$aFont,'T','C',0,''); // coloca o logo $logoInfo=getimagesize($this->logomarca); $logoW=$logoInfo[0]; $logoH=$logoInfo[1]; $logoWmm = ($logoW/72)*25.4; $imgW = $logoWmm; $logoHmm = ($logoH/72)*25.4; $imgH = $logoHmm; if ( $logoWmm > $w/2 ){ $imgW = $w/2; $imgH = $logoHmm * ($imgW/$logoWmm); } $this->pdf->Image($this->logomarca,$x+($w/4),$y+($h/12),$imgW,0,'','jpeg'); //Nome emitente $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>'B'); $texto = utf8_decode($this->emit->getElementsByTagName("xNome")->item(0)->nodeValue); $y1 = $y + 18;//$y+$imgH*1.5; $this->__textBox($x,$y1,$w,8,$texto,$aFont,'T','C',0,'',FALSE); //endereço $y1 = $y1+5; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $fone = !empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue : ''; $foneLen = strlen($fone); if ($foneLen > 0 ){ $fone2 = substr($fone,0,$foneLen-4); $fone1 = substr($fone,0,$foneLen-8); $fone = '(' . $fone1 . ') ' . substr($fone2,-4) . '-' . substr($fone,-4); } else { $fone = ''; } $lgr = !empty($this->enderEmit->getElementsByTagName("xLgr")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xLgr")->item(0)->nodeValue : ''; $nro = !empty($this->enderEmit->getElementsByTagName("nro")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("nro")->item(0)->nodeValue : ''; $cpl = !empty($this->enderEmit->getElementsByTagName("xCpl")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xCpl")->item(0)->nodeValue : ''; $bairro = !empty($this->enderEmit->getElementsByTagName("xBairro")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xBairro")->item(0)->nodeValue : ''; $CEP = !empty($this->enderEmit->getElementsByTagName("CEP")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("CEP")->item(0)->nodeValue : ' '; $CEP = $this->__format($CEP,"#####-###"); $mun = !empty($this->enderEmit->getElementsByTagName("xMun")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xMun")->item(0)->nodeValue : ''; $UF = !empty($this->enderEmit->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("UF")->item(0)->nodeValue : ''; $texto = $lgr . "," . $nro . " " . $cpl . "\n" . $bairro . " - " . $CEP . "\n" . $mun . " - " . $UF . " " . "Fone/Fax: " . $fone; $texto = utf8_decode($texto); $this->__textBox($x,$y1,$w,8,$texto,$aFont,'T','C',0,''); //#################################################################################### //coluna central Danfe $x += $w; $w=35; $h = 32; $this->__textBox($x,$y,$w,$h); $texto = "DANFE"; $aFont = array('font'=>$this->fontePadrao,'size'=>14,'style'=>'B'); $this->__textBox($x,$y+1,$w,$h,$texto,$aFont,'T','C',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>''); $texto = utf8_decode('Documento Auxiliar da Nota Fiscal Eletrônica'); $h = 20; $this->__textBox($x,$y+6,$w,$h,$texto,$aFont,'T','C',0,'',FALSE); $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>''); $texto = '0 - ENTRADA'; $y1 = $y + 14; $h = 8; $this->__textBox($x+2,$y1,$w,$h,$texto,$aFont,'T','L',0,''); $texto = utf8_decode('1 - SAÍDA'); $y1 = $y + 17; $this->__textBox($x+2,$y1,$w,$h,$texto,$aFont,'T','L',0,''); //tipo de nF $aFont = array('font'=>$this->fontePadrao,'size'=>12,'style'=>'B'); $y1 = $y + 13; $h = 7; $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue; $this->__textBox($x+27,$y1,5,$h,$texto,$aFont,'C','C',1,''); //numero da NF $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $y1 = $y + 20; $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT); $numNF = $this->__format($numNF,"###.###.###"); $texto = utf8_decode("Nº. " . $numNF); $this->__textBox($x,$y1,$w,$h,$texto,$aFont,'C','C',0,''); //Série $y1 = $y + 23; $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT); $texto = utf8_decode("Série " . $serie); $this->__textBox($x,$y1,$w,$h,$texto,$aFont,'C','C',0,''); //numero paginas $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>'I'); $y1 = $y + 26; $texto = "Folha " . $pag . "/" . $totPag; $this->__textBox($x,$y1,$w,$h,$texto,$aFont,'C','C',0,''); //#################################################################################### //coluna codigo de barras $x += $w; $w = 85; $h = 32; $this->__textBox($x,$y,$w,$h); $this->pdf->SetFillColor(0,0,0); $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id")); $bW = 75; $bH = 12; //codigo de barras $this->pdf->Code128($x+(($w-$bW)/2),$y+2,$chave_acesso,$bW,$bH); //linhas divisorias $this->pdf->Line($x,$y+4+$bH,$x+$w,$y+4+$bH); $this->pdf->Line($x,$y+12+$bH,$x+$w,$y+12+$bH); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $y1 = $y+4+$bH; $h = 7; $texto = 'CHAVE DE ACESSO'; $this->__textBox($x,$y1,$w,$h,$texto,$aFont,'T','L',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>'B'); $y1 = $y+8+$bH; $this->__textBox($x+2,$y1,$w-2,$h,$chave_acesso,$aFont,'T','C',0,''); $texto = 'Consulta de autenticidade no portal nacional da NF-e'; $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>''); $y1 = $y+12+$bH; $this->__textBox($x+2,$y1,$w-2,$h,$texto,$aFont,'T','C',0,''); $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'; $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>''); $y1 = $y+16+$bH; $this->__textBox($x+2,$y1,$w-2,$h,$texto,$aFont,'T','C',0,'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'); //#################################################################################### //natureza da operação $texto = utf8_decode('NATUREZA DA OPERAÇÃO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $w = 80+35; $y = $oldY; $oldY += $h; $x = $oldX; $h = 7; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->ide->getElementsByTagName("natOp")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //PROTOCOLO DE AUTORIZAÇÃO DE USO $texto = utf8_decode('PROTOCOLO DE AUTORIZAÇÃO DE USO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $x += $w; $w = 85; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser // testada antes de tentar obter a informação. // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!! if( isset( $this->nfeProc ) ) { $texto = !empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ? utf8_decode($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) : ''; $tsHora = $this->__convertTime($this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue); if ($texto != ''){ $texto .= " - " . date('d/m/Y H:i:s',$tsHora); } $cStat = $this->nfeProc->getElementsByTagName("cStat")->item(0)->nodeValue; } else { $texto = ''; $cStat = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //#################################################################################### //INSCRIÇÃO ESTADUAL $w = 67; $y += $h; $oldY += $h; $x = $oldX; $texto = utf8_decode('INSCRIÇÃO ESTADUAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->emit->getElementsByTagName("IE")->item(0)->nodeValue); if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT. $x += $w; $w = 67; $texto = utf8_decode('INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue) ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue : ''; if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //CNPJ $x += $w; $w = 66; $texto = utf8_decode('CNPJ'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue); $texto = $this->__format($texto,"##.###.###/####-##"); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //#################################################################################### //Indicação de NF Homologação $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue; if ( $cStat == '101') { //101 Cancelamento $x = 5; $y = 240; $h = 25; $w = 200; $this->pdf->SetTextColor(70,70,70); $texto = "NFe CANCELADA"; $aFont = array('font'=>$this->fontePadrao,'size'=>42,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,''); } if ( $tpAmb != 1 ) { $x = 5; $y = 200; $h = 5; $w = 200; $this->pdf->SetTextColor(90,90,90); $texto = "SEM VALOR FISCAL"; $aFont = array('font'=>$this->fontePadrao,'size'=>24,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>12,'style'=>'B'); $texto = utf8_decode("AMBIENTE DE HOMOLOGAÇÃO"); $this->__textBox($x,$y+20,$w,$h,$texto,$aFont,'C','C',0,''); } return $oldY; } /** * __destinatarioDANFE * Monta o cmapo com os dados do destinatário na DANFE. * @package NFePHP * @name __destinatarioDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @return number Posição vertical final */ private function __destinatarioDANFE($x=0,$y=0){ //#################################################################################### //DESTINATÁRIO / REMETENTE $oldX = $x; $oldY = $y; $w = 67; $h = 7; $texto = utf8_decode('DESTINATÁRIO / REMETENTE'); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); //NOME / RAZÃO SOCIAL $w = 120; $y += 3; $texto = utf8_decode('NOME / RAZÃO SOCIAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xNome")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','L',0,''); //CNPJ / CPF $x += $w; $w = 46; $texto = utf8_decode('CNPJ / CPF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue) ) { $texto = $this->__format(utf8_decode($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue),"###.###.###/####-##"); } else { $texto = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) ? $this->__format(utf8_decode($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue),"###.###.###-##") : ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //DATA DA EMISSÃO $x += $w; $w = 34; $texto = utf8_decode('DATA DA EMISSÃO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = $this->__ymd2dmy($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //ENDEREÇO $w = 98; $y += $h; $x = $oldX; $texto = utf8_decode('ENDEREÇO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue); $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,'',TRUE); //BAIRRO / DISTRITO $x += $w; $w = 45; $texto = utf8_decode('BAIRRO / DISTRITO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //CEP $x += $w; $w = 23; $texto = utf8_decode('CEP'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue) ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue : ''; $texto = $this->__format(utf8_decode($texto),"#####-###"); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //DATA DA SAÍDA $x += $w; $w = 34; $texto = utf8_decode('DATA DA SAÍDA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue) ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue:""; $texto = $this->__ymd2dmy($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //MUNICÍPIO $w = 94; $y += $h; $x = $oldX; $texto = utf8_decode('MUNICÍPIO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xMun")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //UF $x += $w; $w = 8; $texto = utf8_decode('UF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("UF")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //FONE / FAX $x += $w; $w = 34; $texto = utf8_decode('FONE / FAX'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue) ? $this->__format($this->dest->getElementsByTagName("fone")->item(0)->nodeValue,'(##) ####-####') : ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); //$texto = '(234) 3456-3455'; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //INSCRIÇÃO ESTADUAL $x += $w; $w = 30; $texto = utf8_decode('INSCRIÇÃO ESTADUAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("IE")->item(0)->nodeValue); if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //HORA DA SAÍDA $x += $w; $w = 34; $texto = utf8_decode('HORA DA SAÍDA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); return ($y + $h); } //fim da função __destinatarioDANFE /** * __faturaDANFE * Monta o campo de duplicatas da DANFE * @package NFePHP * @name __faturaDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @return number Posição vertical final */ private function __faturaDANFE($x,$y){ $linha = 1; $h = 8+3; $oldx = $x; if ( $this->dup->length > 0 ) { //##################################################################### //FATURA / DUPLICATA $texto = "FATURA / DUPLICATA"; $texto = utf8_decode($texto); $w = 80; $h = 8; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); $y += 3; $dups = ""; $dupcont = 0; $nFat = $this->dup->length; foreach ($this->dup as $k => $d) { $nDup = $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue; $dDup = $this->__ymd2dmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue); $vDup = 'R$ ' . number_format($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue, 2, ",", "."); $h = 8; $w = 28; $texto = ''; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,'Num.',$aFont,'T','L',1,''); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$nDup,$aFont,'T','R',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,'Venc.',$aFont,'C','L',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$dDup,$aFont,'C','R',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,'Valor',$aFont,'B','L',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$vDup,$aFont,'B','R',0,''); $x += $w+0.65; $dupcont += 1; if ($dupcont > 6) { $y += 9; $x = $oldx; $dupcont = 0; $linha += 1; } if ($linha == 4){ $linha = 3; break; } } if ($dupcont == 0){ $y = $y - 9; $linha = $linha -1; } return ($y+$h); } else { $linha = 0; return ($y-2); } }//fim da função __faturaDANFE /** * __impostoDANFE * Monta o campo de impostos e totais da DANFE * @package NFePHP * @name __impostoDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @return number Posição vertical final */ private function __impostoDANFE($x,$y){ $oldX = $x; //##################################################################### //CÁLCULO DO IMPOSTO $texto = "CÁLCULO DO IMPOSTO"; $texto = utf8_decode($texto); $w = 80; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',0,''); //BASE DE CÁLCULO DO ICMS $w = 43; $y += 3; $h = 7; $texto = utf8_decode('BASE DE CÁLCULO DO ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //VALOR DO ICMS $x += $w; $w = 38; $texto = utf8_decode('VALOR DO ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //BASE DE CÁLCULO DO ICMS S.T. $x += $w; $w = 38; $texto = utf8_decode('BASE DE CÁLCULO DO ICMS S.T.'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vBCST")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vBCST")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR DO ICMS SUBSTITUIÇÃO $x += $w; $w = 38; $texto = utf8_decode('VALOR DO ICMS SUBSTITUIÇÃO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vICMSST")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vICMSST")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR TOTAL DOS PRODUTOS $x += $w; $w = 43; $texto = utf8_decode('VALOR TOTAL DOS PRODUTOS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //##################################################################### //VALOR DO FRETE $w = 31; $y += $h; $x = $oldX; $h = 7; $texto = utf8_decode('VALOR DO FRETE'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vFrete")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //VALOR DO SEGURO $x += $w; $w = 31; $texto = utf8_decode('VALOR DO SEGURO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vSeg")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vSeg")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //DESCONTO $x += $w; $w = 32; $texto = utf8_decode('DESCONTO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vDesc")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vDesc")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //OUTRAS DESPESAS $x += $w; $w = 31; $texto = utf8_decode('OUTRAS DESPESAS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vOutro")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vOutro")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR TOTAL DO IPI $x += $w; $w = 32; $texto = utf8_decode('VALOR TOTAL DO IPI'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vIPI")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vIPI")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR TOTAL DA NOTA $x += $w; $w = 43; $texto = utf8_decode('VALOR TOTAL DA NOTA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); return ($y+$h); } //fim __impostoDANFE /** * __transporteDANFE * Monta o campo de transportes da DANFE * @package NFePHP * @name __transporteDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @return number Posição vertical final */ private function __transporteDANFE($x,$y){ $oldX = $x; //##################################################################### //TRANSPORTADOR / VOLUMES TRANSPORTADOS $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS"; $texto = utf8_decode($texto); $w = 80; $h = 7; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); //NOME / RAZÃO SOCIAL $w = 62; $y += 3; $texto = utf8_decode('NOME / RAZÃO SOCIAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ) { $texto = !empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) ? utf8_decode($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //FRETE POR CONTA $x += $w; $w = 32; $texto = utf8_decode('FRETE POR CONTA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $tipoFrete = !empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue : '0'; switch( $tipoFrete ){ case 0: default: $texto = "(0) Emitente"; break; case 1: $texto = utf8_decode("(1) Destinátario"); break; case 2: $texto = "(2) Terceiros"; break; case 9: $texto = "(9) Sem Frete"; break; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',1,''); //CÓDIGO ANTT $x += $w; $w = 31; $texto = utf8_decode('CÓDIGO ANTT'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("RNTC")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("RNTC")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //PLACA DO VEÍC $x += $w; $w = 32; $texto = utf8_decode('PLACA DO VEÍCULO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("placa")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("placa")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //UF $x += $w; $w = 8; $texto = utf8_decode('UF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //CNPJ / CPF $x += $w; $w = 35; $texto = utf8_decode('CNPJ / CPF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue) ? $this->__format($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,"##.###.###/####-##") : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //##################################################################### //ENDEREÇO $w = 94; $y += $h; $x = $oldX; $h = 7; $texto = utf8_decode('ENDEREÇO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) ? utf8_decode($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //MUNICÍPIO $x += $w; $w = 63; $texto = utf8_decode('MUNICÍPIO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //UF $x += $w; $w = 8; $texto = utf8_decode('UF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //INSCRIÇÃO ESTADUAL $x += $w; $w = 35; $texto = utf8_decode('INSCRIÇÃO ESTADUAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = utf8_decode($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue); if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //##################################################################### //QUANTIDADE $w = 20; $y += $h; $x = $oldX; $h = 7; $texto = utf8_decode('QUANTIDADE'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("qVol")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("qVol")->item(0)->nodeValue : ''; $texto = utf8_decode($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //ESPÉCIE $x += $w; $w = 36; $texto = utf8_decode('ESPÉCIE'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //MARCA $x += $w; $w = 36; $texto = utf8_decode('MARCA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; $texto = ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //NÚMERO $x += $w; $w = 36; $texto = utf8_decode('NÚMERO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; $texto = ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //PESO BRUTO $x += $w; $w = 36; $texto = utf8_decode('PESO BRUTO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("pesoB")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("pesoB")->item(0)->nodeValue : '0.0'; $texto = number_format($texto, 3, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //PESO LÍQUIDO $x += $w; $w = 36; $texto = utf8_decode('PESO LÍQUIDO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("pesoL")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("pesoL")->item(0)->nodeValue : '0.0'; $texto = number_format($texto, 3, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); return ($y+$h); } //fim __transporteDANFE /** * __itensDANFE * Monta o campo de itens da DANFE * @package NFePHP * @name __itensDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @param number $nInicio Número do item inicial * @param number $max Número do item final * @param number $hmax Haltura máxima do campo de itens em mm * @return number Posição vertical final */ private function __itensDANFE($x,$y,$nInicio,$hmax,$pag=0,$totpag=0) { $oldX = $x; $oldY = $y; //##################################################################### //DADOS DOS PRODUTOS / SERVIÇOS $texto = "DADOS DOS PRODUTOS / SERVIÇOS"; $texto = utf8_decode($texto); $w = 64; $h = 4; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); $y += 3; $w = 200; //desenha a caixa dos dados dos itens da NF $texto = ''; $this->__textBox($x,$y,$w,$hmax); //################################################################################## // cabecalho LOOP COM OS DADOS DOS PRODUTOS //CÓDIGO PRODUTO $texto = "CÓDIGO PRODUTO"; $texto = utf8_decode($texto); $w = 14; $h = 4; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //DESCRIÇÃO DO PRODUTO / SERVIÇO $x += $w; $w = 66; $texto = utf8_decode('DESCRIÇÃO DO PRODUTO / SERVIÇO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //NCM/SH $x += $w; $w = 13; $texto = utf8_decode('NCM/SH'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //O/CST $x += $w; $w = 7; $texto = utf8_decode('O/CST'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //CFOP $x += $w; $w = 7; $texto = utf8_decode('CFOP'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //UN $x += $w; $w = 6; $texto = utf8_decode('UN'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //QUANT $x += $w; $w = 10; $texto = utf8_decode('QUANT'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR UNIT $x += $w; $w = 13; $texto = utf8_decode('VALOR UNIT'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR TOTAL $x += $w; $w = 13; $texto = utf8_decode('VALOR TOTAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //B.CÁLC ICMS $x += $w; $w = 13; $texto = utf8_decode('B.CÁLC ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR ICMS $x += $w; $w = 13; $texto = utf8_decode('VALOR ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR IPI $x += $w; $w = 13; $texto = utf8_decode('VALOR IPI'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //ALÍQ. ICMS $x += $w; $w = 6; $texto = utf8_decode('ALÍQ. ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //ALÍQ. IPI $x += $w; $w = 6; $texto = utf8_decode('ALÍQ. IPI'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($oldX, $y+$h+1, $oldX + 200, $y+$h+1); //################################################################################## // LOOP COM OS DADOS DOS PRODUTOS $i = 0; $h = 5; $hprod = 5; $linProd = 1; $areatotal = ($y+$hmax) - 6; foreach ($this->det as $d) { if ( $i >= $nInicio /* && $i < $nInicio+$max */) { $prod = $this->det->item($i)->getElementsByTagName("prod")->item(0); $infAdProd = substr(!empty($this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue) ? $this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue : '',0,120); $infAdProd = str_replace(';',chr(13).chr(10), $infAdProd); if (!empty($infAdProd)){ $infAdProd = $infAdProd.chr(13).chr(10); } $imposto = $this->det->item($i)->getElementsByTagName("imposto")->item(0); $ICMS = $imposto->getElementsByTagName("ICMS")->item(0); $IPI = $imposto->getElementsByTagName("IPI")->item(0); $y += $hprod; $x = $oldX; $w = 14; $h = 3; //Verificando se a impressão irá ultrapassar o limite do DANFe $texto = utf8_decode($prod->getElementsByTagName("xProd")->item(0)->nodeValue .chr(13).chr(10). $infAdProd); $linhas = explode("\n",$texto); $linhaAdic = count($linhas)-2; $linhaDescr = strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50;/* - round(strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50,0);*/ if ($linhaDescr > 1){ $linhaAdic += $linhaDescr; } if ((($y+($h*$linhaAdic)) >= $areatotal) && $i > 0) { //ultrapassa a capacidade para uma única página //o restante dos dados serão usados nas proximas paginas $nInicio = $i; break; } //codigo do produto $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $texto = (is_numeric($prod->getElementsByTagName("cProd")->item(0)->nodeValue)) ? abs($prod->getElementsByTagName("cProd")->item(0)->nodeValue) : $prod->getElementsByTagName("cProd")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 64; $texto = utf8_decode($prod->getElementsByTagName("xProd")->item(0)->nodeValue .chr(13).chr(10). $infAdProd); $hprod = $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,'',FALSE,$hmax-5); $x += $w+2; $w = 13; $texto = !empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ? $prod->getElementsByTagName("NCM")->item(0)->nodeValue : ''; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 7; if ( isset($ICMS) ){ $texto = $ICMS->getElementsByTagName("orig")->item(0)->nodeValue . $ICMS->getElementsByTagName("CST")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); } $x += $w; $w = 7; $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 6; $texto = $prod->getElementsByTagName("uCom")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 10; $texto = number_format($prod->getElementsByTagName("qCom")->item(0)->nodeValue, 2, ",", "."); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 13; $texto = number_format($prod->getElementsByTagName("vUnCom")->item(0)->nodeValue, 4, ",", "."); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 13; $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", "."); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 13; if ( isset($ICMS) ){ $texto = !empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ? number_format($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); } $x += $w; $w = 13; if (isset($ICMS)){ $texto = !empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ? number_format($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); } $x += $w; $w = 13; if ( isset($IPI) ){ $texto = !empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue) ? number_format($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue, 2, ",", ".") :''; } else { $texto = ''; } $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 6; if (isset($ICMS)){ $texto = !empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ? number_format($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue, 0, ",", ".") : '0,00'; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); } $x += $w; $w = 6; if ( isset($IPI) ){ $texto = !empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue) ? number_format($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue, 0, ",", ".") : ''; } else { $texto = ''; } $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $i++; if ($y >= $areatotal) { //ultrapassa a capacidade para uma única página //o restante dos dados serão usados nas proximas paginas $nInicio = $i; break; } } else{ $i++; } } if ($pag == $totpag){ if ($y+3 < $areatotal) { if ( isset($this->infAdic) ){ $i = 0; $texto = ''; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item(0)->nodeValue; while (!empty($obsCont)){ $texto .= $this->infAdic->getElementsByTagName("obsCont")->item($i)->getAttribute("xCampo")." "; $texto .= $obsCont.chr(13).chr(10); $i += 1; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item($i)->nodeValue; } $texto .= !empty($this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue) ? $this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue : ''; $texto .= !empty($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) ? ' Inf. fisco: '.$this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue : ''; $texto = str_replace(';',chr(13).chr(10), $texto); $texto = utf8_decode($texto); } else { $texto = ''; } $x = $oldX+14; $w = 64; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y+3,$w,$h,$texto,$aFont,'T','L',0,'',FALSE,50,$areatotal); } } return $oldY+$hmax; } // fim __itensDANFE /** * __issqnDANFE * Monta o campo de serviços do DANFE * @package NFePHP * @name __issqnDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @return number Posição vertical final */ private function __issqnDANFE($x,$y){ $oldX = $x; //##################################################################### //CÁLCULO DO ISSQN $texto = "CÁLCULO DO ISSQN"; $texto = utf8_decode($texto); $w = 80; $h = 7; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); //INSCRIÇÃO MUNICIPAL $w = 50; $y += 3; $texto = utf8_decode('INSCRIÇÃO MUNICIPAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = $this->emit->getElementsByTagName("im")->item(0)->nodeValue; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //VALOR TOTAL DOS SERVIÇOS $x += $w; $w = 50; $texto = utf8_decode('VALOR TOTAL DOS SERVIÇOS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->ISSQNtot) ){ $texto = !empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ? $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : ''; $texto = number_format($texto, 2, ",", "."); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //BASE DE CÁLCULO DO ISSQN $x += $w; $w = 50; $texto = utf8_decode('BASE DE CÁLCULO DO ISSQN'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->ISSQNtot) ){ $texto = !empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ? $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : ''; $texto = number_format($texto, 2, ",", "."); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //VALOR TOTAL DO ISSQN $x += $w; $w = 50; $texto = utf8_decode('VALOR TOTAL DO ISSQN'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->ISSQNtot) ){ $texto = !empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ? $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : ''; $texto = number_format($texto, 2, ",", "."); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); return ($y+$h); } //fim __issqnDANFE /** *__dadosAdicionaisDANFE * Coloca o grupo de ados adicionais da NFe. * @package NFePHP * @name __dadosAdicionaisDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @return number Posição vertical final */ private function __dadosAdicionaisDANFE($x,$y,$pag,$temObs){ $oldX = $x; //################################################################################## //DADOS ADICIONAIS $texto = "DADOS ADICIONAIS"; $texto = utf8_decode($texto); $w = 40; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',0,''); //INFORMAÇÕES COMPLEMENTARES $texto = "INFORMAÇÕES COMPLEMENTARES"; $texto = utf8_decode($texto); $y += 3; $w = 140; $h = 50; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if (isset($this->infAdic)){ $i = 0; $texto = ''; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item(0)->nodeValue; while (!empty($obsCont)){ $texto .= $this->infAdic->getElementsByTagName("obsCont")->item($i)->getAttribute("xCampo")." "; $texto .= $obsCont.chr(13).chr(10); $i += 1; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item($i)->nodeValue; } $texto .= !empty($this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue) ? $this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue : ''; $texto .= !empty($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) ? ' Inf. fisco: '.$this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue : ''; $texto = str_replace(';',chr(13).chr(10), $texto); $texto = utf8_decode($texto); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y+2,$w-2,$h-3,$texto,$aFont,'T','L',0,'',FALSE,$h,0,&$temObs); //RESERVADO AO FISCO $texto = "RESERVADO AO FISCO"; $texto = utf8_decode($texto); $x += $w; $w = 60; $h = 50; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); //inserir texto informando caso de contingência //1 – Normal – emissão normal; //2 – Contingência FS – emissão em contingência com impressão do DANFE em Formulário de Segurança; //3 – Contingência SCAN – emissão em contingência no Sistema de Contingência do Ambiente Nacional – SCAN; //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de Emissão em Contingência – DPEC; //5 – Contingência FS-DA - emissão em contingência com impressão do DANFE em Formulário de Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA). $tpEmis = $this->ide->getElementsByTagName("tpEmis")->item(0)->nodeValue; $texto = ''; switch($tpEmis){ case 2: $texto = 'CONTINGÊNCIA FS emissão em contingência com impressão do DANFE em Formulário de Segurança'; break; case 3: $texto = 'CONTINGÊNCIA SCAN'; break; case 4: $texto = 'CONTINGÊNCIA DPEC'; break; case 5: $texto = 'CONTINGÊNCIA FSDA emissão em contingência com impressão do DANFE em Formulário de Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA)'; break; } $texto = utf8_decode($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y+3,$w-2,$h-3,$texto,$aFont,'T','L',0,'',FALSE); $y = $y + $h; $x -= 140; $texto = "DATA E HORA DA IMPRESSÃO: ". date('d/m/Y H:i:s'); $texto = utf8_decode($texto); $w = 200; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'I'); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',0,''); $texto = "NFePHP www.nfephp.org"; $texto = utf8_decode($texto); $w = 200; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','R',0,''); return $y+$h; } //fim __dadosAdicionaisDANFE /** * __canhotoDANFE * Monta o canho no final da DANFE * @package NFePHP * @name __canhotoDANFE * @version 1.1 * @param number $x Posição horizontal canto esquerdo * @param number $y Posição vertical canto superior * @return number Posição vertical final */ private function __canhotoDANFE($x,$y) { $oldX = $x; //################################################################################# //canhoto //identificação do sistema emissor //linha separadora do canhoto $w = 160; $y += 2; $h = 10; $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT); $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT); $texto = "RECEBEMOS DE "; $texto .= $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " "; $texto .= "OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA AO LADO. EMISSÃO: "; $texto .= $this->__ymd2dmy($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ." "; $texto .= "VALOR TOTAL: R$ "; $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " "; $texto .= "DESTINATÁRIO: "; $texto .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - "; $texto .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", "; $texto .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - "; $texto .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " "; $texto .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-"; $texto .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . ""; $texto = utf8_decode(strtoupper($texto)); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','L',1,'',FALSE); $x1 = $x + $w; $texto = "NF-e"; $aFont = array('font'=>$this->fontePadrao,'size'=>14,'style'=>'B'); $this->__textBox($x1,$y,40,18,$texto,$aFont,'T','C',0,''); $texto = "Nº. " . $this->__format($numNF,"###.###.###") . " \n"; $texto .= "Série $serie"; $texto = utf8_decode($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x1,$y,40,18,$texto,$aFont,'C','C',1,''); //DATA DO RECEBIMENTO $texto = "DATA DO RECEBIMENTO"; $y += $h; $w = 35; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',1,''); //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR $x += $w; $w = 125; $texto = utf8_decode("IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR"); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',1,''); $x -= 35; $y += 9; $this->__HdashedLine($x,$y,201,0.1,80); $y += 2; return $y; } //fim __canhotoDANFE /** * __format * Função de formatação de strings. * @package NFePHP * @name __format * @version 1.0 * @param string $campo String a ser formatada * @param string $mascara Regra de formatção da string (ex. ##.###.###/####-##) * @return string Retorna o campo formatado */ private function __format($campo='',$mascara=''){ //remove qualquer formatação que ainda exista $sLimpo = ereg_replace("/[' '-./ t]/",'',$campo); // pega o tamanho da string e da mascara $tCampo = strlen($sLimpo); $tMask = strlen($mascara); if ( $tCampo > $tMask ) { $tMaior = $tCampo; } else { $tMaior = $tMask; } //contar o numero de cerquilhas da marcara $aMask = str_split($mascara); $z=0; $flag=FALSE; foreach ( $aMask as $letra ){ if ($letra == '#'){ $z++; } } if ( $z > $tCampo ) { //o campo é menor que esperado $flag=TRUE; } //cria uma variável grande o suficiente para conter os dados $sRetorno = ''; $sRetorno = str_pad($sRetorno, $tCampo+$tMask, " ",STR_PAD_LEFT); //pega o tamanho da string de retorno $tRetorno = strlen($sRetorno); //se houve entrada de dados if( $sLimpo != '' && $mascara !='' ) { //inicia com a posição do ultimo digito da mascara $x = $tMask; $y = $tCampo; $cI = 0; for ( $i = $tMaior-1; $i >= 0; $i-- ) { if ($cI < $z){ // e o digito da mascara é # trocar pelo digito do campo // se o inicio da string da mascara for atingido antes de terminar // o campo considerar # if ( $x > 0 ) { $digMask = $mascara[--$x]; } else { $digMask = '#'; } //se o fim do campo for atingido antes do fim da mascara //verificar se é ( se não for não use if ( $digMask=='#' ) { $cI++; if ( $y > 0 ) { $sRetorno[--$tRetorno] = $sLimpo[--$y]; } else { //$sRetorno[--$tRetorno] = ''; } } else { if ( $y > 0 ) { $sRetorno[--$tRetorno] = $mascara[$x]; } else { if ($mascara[$x] =='('){ $sRetorno[--$tRetorno] = $mascara[$x]; } } $i++; } } } if (!$flag){ if ($mascara[0]!='#'){ $sRetorno = '(' . trim($sRetorno); } } return trim($sRetorno); } else { return ''; } } //fim __format /** *__textBox * Cria uma caixa de texto com ou sem bordas. Esta função perimite o alinhamento horizontal * ou vertical do texto dentro da caixa. * Atenção : Esta função é dependente de outras classes de FPDF * * Ex. $this->__textBox(2,20,34,8,'Texto',array('fonte'=>$this->fontePadrao,'size'=>10,'style='B'),'C','L',FALSE,'http://www.nfephp.org') * * @package NFePHP * @name __textBox * @version 1.0 * @param number $x Posição horizontal da caixa, canto esquerdo superior * @param number $y Posição vertical da caixa, canto esquerdo superior * @param number $w Largura da caixa * @param number $h Altura da caixa * @param string $text Conteúdo da caixa * @param array $aFont Matriz com as informações para formatação do texto com fonte, tamanho e estilo * @param string $vAlign Alinhamento vertical do texto, T-topo C-centro B-base * @param string $hAlign Alinhamento horizontal do texto, L-esquerda, C-centro, R-direita * @param boolean $border TRUE ou 1 desenha a borda, FALSE ou 0 Sem borda * @param string $link Insere um hiperlink * @return none */ private function __textBox($x,$y,$w,$h,$text='',$aFont=array('font'=>'Times','size'=>8,'style'=>''),$vAlign='T',$hAlign='L',$border=1,$link='',$force=TRUE,$hmax=0,$hini=0){ $oldY = $y; $temObs = FALSE; $resetou = FALSE; //desenhar a borda if ( $border ) { $this->pdf->RoundedRect($x,$y,$w,$h,0.8,'D'); } //estabelecer o fonte $this->pdf->SetFont($aFont['font'],$aFont['style'],$aFont['size']); //calcular o incremento $incY = $this->pdf->FontSize; //$aFont['size']/3;//$this->pdf->FontSize; if ( !$force ) { //verificar se o texto cabe no espaço $n = $this->pdf->WordWrap($text,$w); } else { $n = 1; } //calcular a altura do conjunto de texto $altText = $incY * $n; //separar o texto em linhas $lines = explode("\n", $text); //verificar o alinhamento vertical If ( $vAlign == 'T' ) { //alinhado ao topo $y1 = $y+$incY; } If ( $vAlign == 'C' ) { //alinhado ao centro $y1 = $y + $incY + (($h-$altText)/2); } If ( $vAlign == 'B' ) { //alinhado a base $y1 = ($y + $h)-0.5; //- ($altText/2); } //para cada linha foreach( $lines as $line ) { //verificar o comprimento da frase $texto = trim($line); $comp = $this->pdf->GetStringWidth($texto); if ( $force ) { $newSize = $aFont['size']; while ( $comp > $w ) { //estabelecer novo fonte $this->pdf->SetFont($aFont['font'],$aFont['style'],--$newSize); $comp = $this->pdf->GetStringWidth($texto); } } //ajustar ao alinhamento horizontal if ( $hAlign == 'L' ) { $x1 = $x+1; } if ( $hAlign == 'C' ) { $x1 = $x + (($w - $comp)/2); } if ( $hAlign == 'R' ) { $x1 = $x + $w - ($comp+0.5); } //escrever o texto if ($hini >0){ if ($y1 > ($oldY+$hini)){ if (!$resetou){ $y1 = oldY; $resetou = TRUE; } $this->pdf->Text($x1, $y1, $texto); } } else { $this->pdf->Text($x1, $y1, $texto); } //incrementar para escrever o proximo $y1 += $incY; if (($hmax > 0) && ($y1 > ($y+($hmax-1)))){ $temObs = TRUE; break; } } return ($y1-$y)-$incY; } // fim função __textBox /** *__HdashedLine * Desenha uma linha horizontal tracejada com o FPDF * * @package NFePHP * @name __HdashedLine * @version 1.0 * @author Roberto L. Machado * @param number $x Posição horizontal inicial, em mm * @param number $y Posição vertical inicial, em mm * @param number $w Comprimento da linha, em mm * @param number $h Espessura da linha, em mm * @param number $n Numero de traços na seção da linha com o comprimento $w * @return none */ private function __HdashedLine($x,$y,$w,$h,$n) { $this->pdf->SetLineWidth($h); $wDash=($w/$n)/2; // comprimento dos traços for( $i=$x; $i<=$x+$w; $i += $wDash+$wDash ) { for( $j=$i; $j<= ($i+$wDash); $j++ ) { if( $j <= ($x+$w-1) ) { $this->pdf->Line($j,$y,$j+1,$y); } } } } //fim função __HdashedLine /** *__ymd2dmy * Converte datas no formato YMD (ex. 2009-11-02) para o formato brasileiro 02/11/2009) * * @package NFePHP * @name __ymd2dmy * @version 1.0 * @author Roberto L. Machado * @param string $data Parâmetro extraido da NFe * @return string Formatada para apresnetação da data no padrão brasileiro */ private function __ymd2dmy($data) { if (!empty($data)) { $needle = "/"; if (strstr($data, "-")) { $needle = "-"; } $dt = explode($needle, $data); return "$dt[2]/$dt[1]/$dt[0]"; } } // fim da função __ymd2dmy /** * __convertTime * Converte a imformação de data e tempo contida na NFe * @package NFePHP * @name __convertTime * @version 1.0 * @author Roberto L. Machado * @param string $DH Informação de data e tempo extraida da NFe * @return timestamp UNIX Para uso com a funçao date do php */ private function __convertTime($DH){ if ($DH){ $aDH = explode('T',$DH); $adDH = explode('-',$aDH[0]); $atDH = explode(':',$aDH[1]); $timestampDH = mktime($atDH[0],$atDH[1],$atDH[2],$adDH[1],$adDH[2],$adDH[0]); return $timestampDH; } } //fim da função __convertTime } //fim da classe ?>


Marcos

unread,
Jul 18, 2010, 3:03:57 PM7/18/10
to nfe...@googlegroups.com

�.....
vc tinha raz�o.
Segue a vers�o certa...

Roberto L. Machado wrote:
> Marcos;
>
> Acho que voc� anexou o arquivo antigo ...
>
>
> Roberto
>
>
> Em Dom, 2010-07-18 �s 10:59 -0300, Marcos escreveu:
>> Senhores e Senhoras (h� alguma aqui ???),
>>
>> aproveitando suas correcoes feitas pelo Andr� na classe DANFE, fiz mais
>> algumas.
>>


>> Tomei como base a vers�o 125 do reposit�rio:
>>

>> - pus de volta a verifica��o para s� mostrar o logo se o mesmo existir (
>> o Andr� deve ter tirado sem querer )


>>
>> - chave de acesso agora aparece no formato
>> ####-####-####-####-####-####-####-####-####-####-####

>> - destinat�rio agora aparece como "1 - Dest/Rem", como diz a NT2010.5


>> - codigo ANTT/RNTC da transportadora agora aparece

>> - placa do ve�culo agora aparece
>> - UF do ve�culo da transportadora agora aparece corretamente (antes

>> aparecia o UF da transportadora)

>> - CPF de transportadora agora aparece ( antes aparecia s� CNPJ )


>> - marca (tranpsortadora) agora aparece

>> - Numera��o dos volumes transportados (nVol) agora aparece


>>
>>
>> Marcos
>>
>>
>> Andr� Moraes - Gmail wrote:
>>> Anexo mais alguns ajustes no DANFE.
>>>
>>>
>>>

>>> Corrigi a impress�o quando o XML contiver apenas ISS e n�o tiver ICMS no
>>> item(vers�o 2.0 da NFe)
>>>
>>>
>>>

>>> Andr� F. Moraes


>>>
>>>
>>>
>>> *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome
>>> de *Leandro Santana
>>> *Enviada em:* quarta-feira, 14 de julho de 2010 14:27
>>> *Para:* nfe...@googlegroups.com

>>> *Assunto:* RES: [nfephp] Altera��es DANFE
>>>
>>>
>>>
>>> S� eu estou enxergando mal ou abaixo da natureza de opera��o a

>>> tonalidade est� mais fraca?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> *Leandro Santana*
>>>
>>> Tecnologia da Informa��o - TI


>>> (* Celular: (11) 7232-0066
>>> *** **leandro...@gmail.com* <mailto:leandro...@gmail.com>**
>>>
>>> * *
>>>

>>> "de fazer convergir em Cristo, na dispensa��o da plenitude dos tempos,
>>> todas as coisas, tanto as do c�u, como as da terra;" - Ef�sios 1:10


>>>
>>>
>>>
>>> *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome

>>> de *Andr� Moraes - Gmail


>>> *Enviada em:* quarta-feira, 14 de julho de 2010 14:19
>>> *Para:* nfe...@googlegroups.com

>>> *Assunto:* RES: [nfephp] Altera��es DANFE


>>>
>>>
>>>
>>> Anexo exemplo de DANFEs gerados com as fontes Times, Arial e Courier
>>>
>>>
>>>

>>> Andr� F. Moraes


>>>
>>>
>>>
>>> *De:* nfe...@googlegroups.com [mailto:nfe...@googlegroups.com] *Em nome
>>> de *Daniel Lemes
>>> *Enviada em:* quarta-feira, 14 de julho de 2010 14:04
>>> *Para:* nfe...@googlegroups.com

>>> *Assunto:* Re: [nfephp] Altera��es DANFE


>>>
>>>
>>>
>>> Eu poderia atualizar, mas vou esperar o roberto se manifestar
>>>
>>> ----- Original Message -----
>>>
>>> *From:* Leandro Sprenger <mailto:leand...@gmail.com>
>>>
>>> *To:* nfe...@googlegroups.com <mailto:nfe...@googlegroups.com>
>>>
>>> *Sent:* Wednesday, July 14, 2010 1:21 PM
>>>

>>> *Subject:* Re: [nfephp] Altera��es DANFE
>>>
>>>
>>>
>>> Boa tarde,
>>>
>>>
>>>
>>> Algu�m sabe se j� foi atualizado no reposit�rio?
>>>
>>>
>>>

>>> Em 14 de julho de 2010 12:08, Marcos <mar...@unitron.com.br
>>> <mailto:mar...@unitron.com.br>> escreveu:
>>>

>>> Parab�ns.
>>> Mesmo.
>>>
>>> Marcos


>>>
>>>
>>>
>>>
>>> Andr� Moraes - Gmail wrote:
>>>
>>> Boa noite,
>>>
>>>

>>> Primeiramente gostaria de me apresentar, meu nome � Andr� Ferreira
>>> de Moraes e sou um dos administradores do Projeto ACBr �

>>> http://acbr.sf.net, e sou respons�vel principalmente pelo componente
>>> para Nota Fiscal Eletr�nica � ACBrNFe.


>>>
>>>
>>> Estou com um novo projeto e precisaria imprimir o DANFe via Web e
>>> pesquisando pela net encontrei o projeto NFePHP.
>>>
>>>

>>> Fiz algumas altera��es no DANFE da pasta trunk\libs para a impress�o


>>> ficar mais parecida com a que uso no componente em Delphi e anexo
>>> estou enviando o arquivo que alterei para que possa ser analisado
>>> pelos administradores do NFePHP, e se for de interesse do projeto,

>>> que essas altera��es sejam adicionadas ao SVN.
>>>
>>>
>>> As principais altera��es que realizei foram:
>>>
>>>
>>> 1 � Canhoto do DANFE impresso na parte superior da p�gina;
>>>
>>> 2 � Impress�o de at� 21 duplicatas;
>>>
>>> 3 � Quando n�o houver duplicatas todos os demais quadros ser�o
>>> puxados pra cima, para n�o ficar um espa�o em branco no meio do DANFE;
>>>
>>> 4 � Mudan�a da fonte para Times(estava como arial) para atender
>>> orienta��o do manual de integra��o(Item 7.7);
>>>
>>> 5 � Impress�o das observa��es adicionadas nas tags obsCont;
>>>
>>> 6 � Impress�o dos itens aproveitando melhor os espa�os(itens est�o
>>> sendo impressos com menos espa�os entre eles);
>>>
>>> 7 � Altera��o da posi��o das mensagens de homologa��o e cancelamento;
>>>
>>> 8 � O uso de ponto e v�rgula est� sendo considerado quebra de linha
>>> nas informa��es adicionais(igual funcionamento do ACBrNFe e do Uninfe);
>>>
>>> 9 � Diminui��o do quadro com a identifica��o do emitente.
>>>
>>>
>>> Ainda faltam alguns detalhes nestas altera��es, como a impress�o dos
>>> dados adicionais na folha seguinte quando n�o couber na primeira
>>> p�gina e a impress�o dos dados do ISQN.
>>>
>>>
>>> Gostaria de parabeniz�-los pelo �timo projeto e mesmo que estas

>>> altera��es n�o sejam aproveitadas pelo NFePHP gostaria de poder
>>> colaborar de alguma forma.
>>>
>>>
>>> Andr� F. Moraes
>>>
>>>
>>>
>>> --
>>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

>>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".


>>> Para Postar: nfe...@googlegroups.com <mailto:nfe...@googlegroups.com>
>>> Para Sair do Grupo: nfephp+un...@googlegroups.com
>>> <mailto:nfephp%2Bunsu...@googlegroups.com>
>>> Link: http://groups.google.com.br/group/nfephp?hl=pt-BR
>>> -------
>>> FAQ: https://www.assembla.com/wiki/show/nfephp/FAQ
>>> Como Participar:
>>> https://www.assembla.com/wiki/show/nfephp/Como_participar
>>>
>>>
>>>
>>>
>>> --
>>> Att,
>>> Leandro Cassel Sprenger
>>>
>>> --

>>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

>>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

>>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

>>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

>>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

>> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".


>> Para Postar: nfe...@googlegroups.com
>> Para Sair do Grupo: nfephp+un...@googlegroups.com
>> Link: http://groups.google.com.br/group/nfephp?hl=pt-BR
>> -------
>> FAQ: https://www.assembla.com/wiki/show/nfephp/FAQ
>> Como Participar: https://www.assembla.com/wiki/show/nfephp/Como_participar
>> anexo Documento HTML (DanfeNFePHP.class.php)
>> . * * @package NFePHP * @name DanfeNFePHP.class.php * @version
>> 1.3 * @license http://www.gnu.org/licenses/gpl.html GNU/GPL v.3 *

>> @copyright 2009 � NFePHP * @link http://www.nfephp.org/ * @author
>> Roberto L. Machado * @author Leandro C. Lopez * @todo Formata��o
>> Paisagem * @todo Inclus�o de campos para NF de servi�os * @todo
>> Adapta��o para a nova vers�o 2.0 do manual SEFAZ */ //comente a linha


>> abaixo para nao permitir qualquer aviso no codigo pdf, a linha abaixo

>> � utilizada para debug //error_reporting(E_ALL); //ajuste do tempo
>> limite de resposta do processo set_time_limit(1800); //defini��o do


>> caminho para o diretorio com as fontes do FDPF
>> define('FPDF_FONTPATH','font/'); //classe extendida da classe FPDF
>> para montagem do arquivo pfd

>> require_once('FPDF/code128.php'); //require_once('LoadClasses.class.php'); class DanfeNFePHP { private $pdf; // objeto fpdf() private $xml; // string XML NFe private $logomarca=''; // path para logomarca em jpg private $errMsg=''; // mesagens de erro private $errStatus=FALSE;// status de erro TRUE um erro ocorreu FALSE sem erros private $orientacao='P'; //orienta��o da DANFE P-Retrato ou L-Paisagem private $papel='A4'; //formato do papel private $destino = 'I'; //destivo do arquivo pdf I-borwser, S-retorna o arquivo, D-for�a download, F-salva em arquivo local private $pdfDir=''; //diretorio para salvar o pdf com a op��o de destino = F private $fontePadrao='Times'; //Nome da Fonte para gerar o DANFE //objetos DOM da NFe private $dom; private $infNFe; private $ide; private $emit; private $dest; private $enderEmit; private $enderDest; private $det; private $cobr; private $dup; private $ICMSTot; private $ISSQNtot; private $transp; private $transporta; private $veicTransp; pr
ivate $infAdic; /** *__construct * @package NFePHP * @name __construct * @version 1.0 * @param string $docXML Arquivo XML da NFe (com ou sem a tag nfeProc) * @param string $sOrientacao Orienta��o da impress�o P-retrato L-Paisagem * @param string $sPapel Tamanho do papel (Ex. A4) * @param string $sPathLogo Caminho para o arquivo do logo * @param string $sDestino Estabelece a dire��o do envio do documento PDF I-browser D-browser com download S- * @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF */ function __construct($docXML='', $sOrientacao="P",$sPapel='A4',$sPathLogo='', $sDestino='I',$sDirPDF='',$fonteDANFE='') { $this->orientacao = $sOrientacao; $this->papel = $sPapel; $this->pdf = ''; $this->xml = $docXML; $this->logomarca= $sPathLogo; $this->destino = $sDestino; $this->pdfDir = $sDirPDF; // verifica se foi passa a fonte a ser usada if (empty($fonteDANFE)) { $this->fontePadrao = 'Times'; } else { $this->fontePadrao = $fo


nteDANFE; } if ( !empty($this->xml) ) { $this->dom = new DomDocument; $this->dom->loadXML($this->xml); $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0); $this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0); $this->ide = $this->dom->getElementsByTagName("ide")->item(0); $this->emit = $this->dom->getElementsByTagName("emit")->item(0); $this->dest = $this->dom->getElementsByTagName("dest")->item(0); $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0); $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0); $this->det = $this->dom->getElementsByTagName("det"); $this->cobr = $this->dom->getElementsByTagName("cobr")->item(0); $this->dup = $this->dom->getElementsByTagName('dup'); $this->ICMSTot = $this->dom->getElementsByTagName("ICMSTot")->item(0); $this->ISSQNtot = $this->dom->getElementsByTagName("ISSQNtot")->item(0); $this->transp = $this->d

om->getElementsByTagName("transp")->item(0); $this->transporta = $this->dom->getElementsByTagName("transporta")->item(0); $this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0); $this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0); } } //fim construct /** * montaDANFE * Esta fun��o monta a DANFE conforme as informa��es fornecidas para a classe * durante sua constru��o. * Esta fun��o constroi DANFE's com at� 3 p�ginas podendo conter at� 56 itens. * A defini��o de margens e posi��es iniciais para a impress�o s�o estabelecidas no * pelo conte�do da fun�ao e podem ser modificados. * @package NFePHP * @name montaDANFE * @version 1.1 * @param string $orientacao (Opcional) Estabelece a orienta��o da impress�o (ex. P-retrato) * @param string $papel (Opcional) Estabelece o tamanho do papel (ex. A4) * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML * @todo Impress�o paisagem * @todo Inclus�o de campos de NFe de servi�os *
/ public function montaDANFE($orientacao='P',$papel='A4'){ $this->orientacao = $orientacao; $this->papel = $papel; //instancia a classe pdf $this->pdf = new PDF_Code128($this->orientacao, 'mm', $this->papel); // margens do PDF $margSup = 2; $margEsq = 2; $margDir = 2; // posi��o inicial do relatorio $y = 5; $x = 5; // estabelece contagem de paginas $this->pdf->AliasNbPages(); // fixa as margens $this->pdf->SetMargins($margEsq,$margSup,$margDir); $this->pdf->SetDrawColor(100,100,100); $this->pdf->SetFillColor(255,255,255); // inicia o documento $this->pdf->Open(); // adiciona a primeira p�gina $this->pdf->AddPage($this->orientacao, $this->papel); $this->pdf->SetLineWidth(0.1); $this->pdf->SetTextColor(0,0,0); //Contagem de quantas linhas ser�o usadas para impress�o dos itens. $i = 0; $totlinha = 0; $linhaDescr = 0; $linhaAdic = 0; while ($i < $this->det->length){ $prod = $this->det->item($i)->getElementsByTagName("prod")->item(0); $infAdProd = substr(!empty($this->det-
>item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue) ? $this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue : '',0,120); $infAdProd = str_replace(';',chr(13).chr(10), $infAdProd); if (!empty($infAdProd)){ $infAdProd = $infAdProd.chr(13).chr(10); } $texto = utf8_decode($prod->getElementsByTagName("xProd")->item(0)->nodeValue .chr(13).chr(10). $infAdProd); $linhas = explode("\n",$texto); $linhaAdic = count($linhas)-1; $linhaDescr = strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50; /* - round(strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50,0);*/ if ($linhaDescr > 1){ $linhaAdic += $linhaDescr; } if ($linhaAdic <= 0){ $linhaAdic = 1; } $totlinha += $linhaAdic; $i += 1; } $totPag = 1; //Verificando quantas linhas ser�o usadas para impress�o das duplicatas $linhasDup = 0; if ( ($this->dup->length > 0) && ($this->dup->length <= 7) ) { $linhasDup = 1; } elseif ( ($this->dup->le


ngth > 7) && ($this->dup->length <= 14) ) { $linhasDup = 2; } elseif ( ($this->dup->length > 14) && ($this->dup->length <= 21) ) { $linhasDup = 3; } elseif ($this->dup->length > 21) { $linhasDup = 3; } else{ $linhasDup = 0; } if ($linhasDup == 0){ $maxite = 82; $totlinha = $totlinha - 27; } else { if ($linhasDup == 1){ $maxite = 69; $totlinha = $totlinha - 23; } elseif ($linhasDup == 2){ $maxite = 60; $totlinha = $totlinha - 20; } elseif ($linhasDup == 3){ $maxite = 51; $totlinha = $totlinha - 17; } else { $maxite = 51; $totlinha = $totlinha - 17; } } $temISSQN = FALSE; if ( isset($this->ISSQNtot) ){ if ($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue > 0 ) { $temISSQN = TRUE; $maxite = $maxite - 11; $totlinha = $totlinha - 3; } } else { $temISSQN = FALSE; } $pAdic = 0; if ($totlinha > 0){ $pAdic = 1; if (round(($totlinha/

85),0) > 1) { $pAdic += round(($totlinha/85),0); } } $totPag = 1 + $pAdic; //montagem da primeira p�gina $pag = 1; //coloca o canhoto da NFe $y = $this->__canhotoDANFE($x,$y); //coloca o cabe�alho $y = $this->__cabecalhoDANFE($x,$y,$pag,$totPag); //coloca os dados do destinat�rio $y = $this->__destinatarioDANFE($x,$y+1); //coloca os dados das faturas $y = $this->__faturaDANFE($x,$y+1); //coloca os dados dos impostos e totais da NFe $y = $this->__impostoDANFE($x,$y+1); //coloca os dados do trasnporte $y = $this->__transporteDANFE($x,$y+1); $nInicial = 0; $y = $this->__itensDANFE($x,$y+1,&$nInicial,$maxite,$pag,$totPag); //coloca os dados do ISSQN $incY = 0; if ($temISSQN) { $y = $this->__issqnDANFE($x,$y+4); $incY = 1; } else { $incY = 4; } //coloca os dados adicionais da NFe $temObs = FALSE; $y = $this->__dadosAdicionaisDANFE($x,$y+$incY,$pag,&$temObs); for ( $n = 2; $n <= $totPag; $n++ ) { //adiciona nova p�gina $this->pdf->AddPage($this->orientacao, $this->pa
pel); //ajusta espessura das linhas $this->pdf->SetLineWidth(0.1); //seta a cor do texto para petro $this->pdf->SetTextColor(0,0,0); // posi��o inicial do relatorio $y = 5; $x = 5; //coloca o cabe�alho na p�gina adicional $y = $this->__cabecalhoDANFE($x,$y,$n,$totPag); //coloca os itens na p�gina adicional $y = $this->__itensDANFE($x,$y+1,&$nInicial,225,$pag,$totPag); } //retorna o ID na NFe return str_replace('NFe', '', $this->infNFe->getAttribute("Id")); }//fim da fun��o montaDANFE /** * printDANFE * Esta fun��o envia a DANFE em PDF criada para o dispositivo informado. * O destino da impress�o pode ser : * I-browser * D-browser com download * F-salva em um arquivo local com o nome informado * S-retorna o documento como uma string e o nome � ignorado. * Para enviar o pdf diretamente para uma impressora indique o * nome da impressora e o destino deve ser 'S'. * @package NFePHP * @name printDANFE * @version 1.0 * @param string $nome Path completo com o nome do arquivo pdf * @p
aram string $destino Dire��o do envio do PDF * @param string $printer Identifica��o da impressora no sistema * @return string Caso o destino seja S o pdf � retornado como uma string * @todo Rotina de impress�o direta do arquivo pdf criado */ public function printDANFE($nome='',$destino='I',$printer=''){ $arq = $this->pdf->Output($nome,$destino); if ( $destino == 'S' ){ //aqui rotina de impress�o direta } return $arq; /** * Op��o 1 - exemplo de script shell usando acroread #!/bin/sh if ( $# == 2 ) then set printer=$2 else set printer=$PRINTER fi if( $1 != "" ) then cat ${1} | acroread -toPostScript | lpr -P $printer echo ${1} sent to $printer ... OK! else echo PDF Print: No filename defined! fi Op��o 2 - salvar pdf em arquivo temporario converter pdf para ps usando pdf2ps do linux imprimir ps para printer usando lp ou lpr remover os arquivos temporarios pdf e ps **/ } //fim fun��o printDANFE /** *__cabecalhoDANFE * Monta o cabelhalho da DANFE * @package NFePHP * @name __cabeca
lhoDANFE * @version 1.1 * @param number $x Posi��o horizontal inicial, canto esquerdo * @param number $y Posi��o vertical inicial, canto superior * @param number $pag N�mero da P�gina * @param number$totPag Total de p�ginas * @return number Posi��o vertical final */ private function __cabecalhoDANFE($x=0,$y=0,$pag='1',$totPag='1'){ $oldX = $x; $oldY = $y; //#################################################################################### //coluna esquerda identifica��o do emitente $w=80; $h=32; $oldY += $h; $this->__textBox($x,$y,$w,$h); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'I'); $texto = utf8_decode('IDENTIFICA��O DO EMITENTE'); $this->__textBox($x,$y,$w,5,$texto,$aFont,'T','C',0,''); // coloca o logo $logoInfo=getimagesize($this->logomarca); $logoW=$logoInfo[0]; $logoH=$logoInfo[1]; $logoWmm = ($logoW/72)*25.4; $imgW = $logoWmm; $logoHmm = ($logoH/72)*25.4; $imgH = $logoHmm; if ( $logoWmm > $w/2 ){ $imgW = $w/2; $imgH = $logoHmm * ($imgW/$logoWmm)
; } $this->pdf->Image($this->logomarca,$x+($w/4),$y+($h/12),$imgW,0,'','jpeg'); //Nome emitente $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>'B'); $texto = utf8_decode($this->emit->getElementsByTagName("xNome")->item(0)->nodeValue); $y1 = $y + 18;//$y+$imgH*1.5; $this->__textBox($x,$y1,$w,8,$texto,$aFont,'T','C',0,'',FALSE); //endere�o $y1 = $y1+5; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $fone = !empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue : ''; $foneLen = strlen($fone); if ($foneLen > 0 ){ $fone2 = substr($fone,0,$foneLen-4); $fone1 = substr($fone,0,$foneLen-8); $fone = '(' . $fone1 . ') ' . substr($fone2,-4) . '-' . substr($fone,-4); } else { $fone = ''; } $lgr = !empty($this->enderEmit->getElementsByTagName("xLgr")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xLgr")->item(0)->nodeValue : ''; $nro = !empty($this->end


erEmit->getElementsByTagName("nro")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("nro")->item(0)->nodeValue : ''; $cpl = !empty($this->enderEmit->getElementsByTagName("xCpl")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xCpl")->item(0)->nodeValue : ''; $bairro = !empty($this->enderEmit->getElementsByTagName("xBairro")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xBairro")->item(0)->nodeValue : ''; $CEP = !empty($this->enderEmit->getElementsByTagName("CEP")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("CEP")->item(0)->nodeValue : ' '; $CEP = $this->__format($CEP,"#####-###"); $mun = !empty($this->enderEmit->getElementsByTagName("xMun")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("xMun")->item(0)->nodeValue : ''; $UF = !empty($this->enderEmit->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->enderEmit->getElementsByTagName("UF")->item(0)->nodeValue : ''; $texto = $lgr . "," .

$nro . " " . $cpl . "\n" . $bairro . " - " . $CEP . "\n" . $mun . " - " . $UF . " " . "Fone/Fax: " . $fone; $texto = utf8_decode($texto); $this->__textBox($x,$y1,$w,8,$texto,$aFont,'T','C',0,''); //#################################################################################### //coluna central Danfe $x += $w; $w=35; $h = 32; $this->__textBox($x,$y,$w,$h); $texto = "DANFE"; $aFont = array('font'=>$this->fontePadrao,'size'=>14,'style'=>'B'); $this->__textBox($x,$y+1,$w,$h,$texto,$aFont,'T','C',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>''); $texto = utf8_decode('Documento Auxiliar da Nota Fiscal Eletr�nica'); $h = 20; $this->__textBox($x,$y+6,$w,$h,$texto,$aFont,'T','C',0,'',FALSE); $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>''); $texto = '0 - ENTRADA'; $y1 = $y + 14; $h = 8; $this->__textBox($x+2,$y1,$w,$h,$texto,$aFont,'T','L',0,''); $texto = utf8_decode('1 - SA�DA'); $y1 = $y + 17; $this->__textBox($x+2,$y1,$w,$h,$t
exto,$aFont,'T','L',0,''); //tipo de nF $aFont = array('font'=>$this->fontePadrao,'size'=>12,'style'=>'B'); $y1 = $y + 13; $h = 7; $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue; $this->__textBox($x+27,$y1,5,$h,$texto,$aFont,'C','C',1,''); //numero da NF $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $y1 = $y + 20; $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT); $numNF = $this->__format($numNF,"###.###.###"); $texto = utf8_decode("N�. " . $numNF); $this->__textBox($x,$y1,$w,$h,$texto,$aFont,'C','C',0,''); //S�rie $y1 = $y + 23; $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT); $texto = utf8_decode("S�rie " . $serie); $this->__textBox($x,$y1,$w,$h,$texto,$aFont,'C','C',0,''); //numero paginas $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>'I'); $y1 = $y + 26; $texto = "Folha " . $pag . "/" . $totPag; $this->__textBo


x($x,$y1,$w,$h,$texto,$aFont,'C','C',0,''); //#################################################################################### //coluna codigo de barras $x += $w; $w = 85; $h = 32; $this->__textBox($x,$y,$w,$h); $this->pdf->SetFillColor(0,0,0); $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id")); $bW = 75; $bH = 12; //codigo de barras $this->pdf->Code128($x+(($w-$bW)/2),$y+2,$chave_acesso,$bW,$bH); //linhas divisorias $this->pdf->Line($x,$y+4+$bH,$x+$w,$y+4+$bH); $this->pdf->Line($x,$y+12+$bH,$x+$w,$y+12+$bH); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $y1 = $y+4+$bH; $h = 7; $texto = 'CHAVE DE ACESSO'; $this->__textBox($x,$y1,$w,$h,$texto,$aFont,'T','L',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>'B'); $y1 = $y+8+$bH; $this->__textBox($x+2,$y1,$w-2,$h,$chave_acesso,$aFont,'T','C',0,''); $texto = 'Consulta de autenticidade no portal nacional da NF-e'; $aFont = array('font'=>$this->fontePadrao,'size'=>8,'

style'=>''); $y1 = $y+12+$bH; $this->__textBox($x+2,$y1,$w-2,$h,$texto,$aFont,'T','C',0,''); $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'; $aFont = array('font'=>$this->fontePadrao,'size'=>8,'style'=>''); $y1 = $y+16+$bH; $this->__textBox($x+2,$y1,$w-2,$h,$texto,$aFont,'T','C',0,'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'); //#################################################################################### //natureza da opera��o $texto = utf8_decode('NATUREZA DA OPERA��O'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $w = 80+35; $y = $oldY; $oldY += $h; $x = $oldX; $h = 7; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->ide->getElementsByTagName("natOp")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //PROTOCOLO DE AUTORIZA��O DE USO $texto = utf8_decode('PRO
TOCOLO DE AUTORIZA��O DE USO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $x += $w; $w = 85; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser // testada antes de tentar obter a informa��o. // NOTA : DANFE sem protocolo deve existir somente no caso de conting�ncia !!! if( isset( $this->nfeProc ) ) { $texto = !empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ? utf8_decode($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) : ''; $tsHora = $this->__convertTime($this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue); if ($texto != ''){ $texto .= " - " . date('d/m/Y H:i:s',$tsHora); } $cStat = $this->nfeProc->getElementsByTagName("cStat")->item(0)->nodeValue; } else { $texto = ''; $cStat = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C
',0,''); //#################################################################################### //INSCRI��O ESTADUAL $w = 67; $y += $h; $oldY += $h; $x = $oldX; $texto = utf8_decode('INSCRI��O ESTADUAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->emit->getElementsByTagName("IE")->item(0)->nodeValue); if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //INSCRI��O ESTADUAL DO SUBST. TRIBUT. $x += $w; $w = 67; $texto = utf8_decode('INSCRI��O ESTADUAL DO SUBST. TRIBUT.'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue) ? $this->emit->getElementsByTagName
("IEST")->item(0)->nodeValue : ''; if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //CNPJ $x += $w; $w = 66; $texto = utf8_decode('CNPJ'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue); $texto = $this->__format($texto,"##.###.###/####-##"); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //#################################################################################### //Indica��o de NF Homologa��o $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue; if ( $cStat == '101') { //101 Cancelamento $x = 5; $y = 240; $h = 25; $w = 200; $this->pdf->SetTex
tColor(70,70,70); $texto = "NFe CANCELADA"; $aFont = array('font'=>$this->fontePadrao,'size'=>42,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,''); } if ( $tpAmb != 1 ) { $x = 5; $y = 200; $h = 5; $w = 200; $this->pdf->SetTextColor(90,90,90); $texto = "SEM VALOR FISCAL"; $aFont = array('font'=>$this->fontePadrao,'size'=>24,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>12,'style'=>'B'); $texto = utf8_decode("AMBIENTE DE HOMOLOGA��O"); $this->__textBox($x,$y+20,$w,$h,$texto,$aFont,'C','C',0,''); } return $oldY; } /** * __destinatarioDANFE * Monta o cmapo com os dados do destinat�rio na DANFE. * @package NFePHP * @name __destinatarioDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @return number Posi��o vertical final */ private function __destinatarioDANFE($x=0,$y=0){ //##############################
###################################################### //DESTINAT�RIO / REMETENTE $oldX = $x; $oldY = $y; $w = 67; $h = 7; $texto = utf8_decode('DESTINAT�RIO / REMETENTE'); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); //NOME / RAZ�O SOCIAL $w = 120; $y += 3; $texto = utf8_decode('NOME / RAZ�O SOCIAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xNome")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','L',0,''); //CNPJ / CPF $x += $w; $w = 46; $texto = utf8_decode('CNPJ / CPF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue) ) {
$texto = $this->__format(utf8_decode($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue),"###.###.###/####-##"); } else { $texto = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) ? $this->__format(utf8_decode($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue),"###.###.###-##") : ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //DATA DA EMISS�O $x += $w; $w = 34; $texto = utf8_decode('DATA DA EMISS�O'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = $this->__ymd2dmy($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //ENDERE�O $w = 98; $y += $h; $x = $oldX; $texto = utf8_decode('ENDERE�O'); $aFont = array('font'=>$this->fontePadrao


,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue); $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,'',TRUE); //BAIRRO / DISTRITO $x += $w; $w = 45; $texto = utf8_decode('BAIRRO / DISTRITO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //CEP $x += $w; $w = 23; $texto = utf8_decode('CEP'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $

texto = !empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue) ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue : ''; $texto = $this->__format(utf8_decode($texto),"#####-###"); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //DATA DA SA�DA $x += $w; $w = 34; $texto = utf8_decode('DATA DA SA�DA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue) ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue:""; $texto = $this->__ymd2dmy($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //MUNIC�PIO $w = 94; $y += $h; $x = $oldX; $texto = utf8_decode('MUNIC�PIO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this


->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("xMun")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //UF $x += $w; $w = 8; $texto = utf8_decode('UF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("UF")->item(0)->nodeValue); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //FONE / FAX $x += $w; $w = 34; $texto = utf8_decode('FONE / FAX'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue) ? $this->__format($this->dest->getElementsByTag

Name("fone")->item(0)->nodeValue,'(##) ####-####') : ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); //$texto = '(234) 3456-3455'; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //INSCRI��O ESTADUAL $x += $w; $w = 30; $texto = utf8_decode('INSCRI��O ESTADUAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = utf8_decode($this->dest->getElementsByTagName("IE")->item(0)->nodeValue); if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //HORA DA SA�DA $x += $w; $w = 34; $texto = utf8_decode('HORA DA SA�DA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); return ($y + $h); } //fim da fun��o __destinatarioDANFE /** * __fat
uraDANFE * Monta o campo de duplicatas da DANFE * @package NFePHP * @name __faturaDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @return number Posi��o vertical final */ private function __faturaDANFE($x,$y){ $linha = 1; $h = 8+3; $oldx = $x; if ( $this->dup->length > 0 ) { //##################################################################### //FATURA / DUPLICATA $texto = "FATURA / DUPLICATA"; $texto = utf8_decode($texto); $w = 80; $h = 8; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); $y += 3; $dups = ""; $dupcont = 0; $nFat = $this->dup->length; foreach ($this->dup as $k => $d) { $nDup = $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue; $dDup = $this->__ymd2dmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue); $vDup = 'R$ ' . number_format($this->dup->item($k)->getEleme


ntsByTagName('vDup')->item(0)->nodeValue, 2, ",", "."); $h = 8; $w = 28; $texto = ''; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,'Num.',$aFont,'T','L',1,''); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$nDup,$aFont,'T','R',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,'Venc.',$aFont,'C','L',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$dDup,$aFont,'C','R',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,'Valor',$aFont,'B','L',0,''); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$vDup,$aFont,'B','R',0,''); $x += $w+0.65; $dupcont += 1; if ($dupcont > 6) { $y += 9; $x = $oldx; $dupcont = 0; $linha += 1; } if ($linha == 4){ $linha = 3; break; } } if ($dupcont == 0

){ $y = $y - 9; $linha = $linha -1; } return ($y+$h); } else { $linha = 0; return ($y-2); } }//fim da fun��o __faturaDANFE /** * __impostoDANFE * Monta o campo de impostos e totais da DANFE * @package NFePHP * @name __impostoDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @return number Posi��o vertical final */ private function __impostoDANFE($x,$y){ $oldX = $x; //##################################################################### //C�LCULO DO IMPOSTO $texto = "C�LCULO DO IMPOSTO"; $texto = utf8_decode($texto); $w = 80; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',0,''); //BASE DE C�LCULO DO ICMS $w = 43; $y += 3; $h = 7; $texto = utf8_decode('BASE DE C�LCULO DO ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); $texto = number_for
mat($this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //VALOR DO ICMS $x += $w; $w = 38; $texto = utf8_decode('VALOR DO ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //BASE DE C�LCULO DO ICMS S.T. $x += $w; $w = 38; $texto = utf8_decode('BASE DE C�LCULO DO ICMS S.T.'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vBCST")->item(0)->nodeValue) ? number_format($this->ICMSTot
->getElementsByTagName("vBCST")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR DO ICMS SUBSTITUI��O $x += $w; $w = 38; $texto = utf8_decode('VALOR DO ICMS SUBSTITUI��O'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vICMSST")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vICMSST")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR TOTAL DOS PRODUTOS $x += $w; $w = 43; $texto = utf8_decode('VALOR TOTAL DOS PRODUTOS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = number_format($t


his->ICMSTot->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //##################################################################### //VALOR DO FRETE $w = 31; $y += $h; $x = $oldX; $h = 7; $texto = utf8_decode('VALOR DO FRETE'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vFrete")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //VALOR DO SEGURO $x += $w; $w = 31; $texto = utf8_decode('VALOR DO SEGURO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getE
lementsByTagName("vSeg")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vSeg")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //DESCONTO $x += $w; $w = 32; $texto = utf8_decode('DESCONTO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vDesc")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vDesc")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //OUTRAS DESPESAS $x += $w; $w = 31; $texto = utf8_decode('OUTRAS DESPESAS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto =
!empty($this->ICMSTot->getElementsByTagName("vOutro")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vOutro")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR TOTAL DO IPI $x += $w; $w = 32; $texto = utf8_decode('VALOR TOTAL DO IPI'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->ICMSTot->getElementsByTagName("vIPI")->item(0)->nodeValue) ? number_format($this->ICMSTot->getElementsByTagName("vIPI")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); //VALOR TOTAL DA NOTA $x += $w; $w = 43; $texto = utf8_decode('VALOR TOTAL DA NOTA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->_

_textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','R',0,''); return ($y+$h); } //fim __impostoDANFE /** * __transporteDANFE * Monta o campo de transportes da DANFE * @package NFePHP * @name __transporteDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @return number Posi��o vertical final */ private function __transporteDANFE($x,$y){ $oldX = $x; //##################################################################### //TRANSPORTADOR / VOLUMES TRANSPORTADOS $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS"; $texto = utf8_decode($texto); $w = 80; $h = 7; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); //NOME / RAZ�O
SOCIAL $w = 62; $y += 3; $texto = utf8_decode('NOME / RAZ�O SOCIAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ) { $texto = !empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) ? utf8_decode($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue) : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //FRETE POR CONTA $x += $w; $w = 32; $texto = utf8_decode('FRETE POR CONTA'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $tipoFrete = !empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue : '0'; switch( $tipoFrete ){ case 0: default: $texto = "(0) Em
itente"; break; case 1: $texto = utf8_decode("(1) Destin�tario"); break; case 2: $texto = "(2) Terceiros"; break; case 9: $texto = "(9) Sem Frete"; break; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',1,''); //C�DIGO ANTT $x += $w; $w = 31; $texto = utf8_decode('C�DIGO ANTT'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("RNTC")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("RNTC")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //PLACA DO VE�C $x += $w; $w = 32; $texto = utf8_decode('PLACA DO VE�CULO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,


$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("placa")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("placa")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //UF $x += $w; $w = 8; $texto = utf8_decode('UF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //CNPJ / CPF $x += $w; $w = 35; $texto = utf8_decode('CNPJ / CPF'); $aFont = array('font'=>$this-

>fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue) ? $this->__format($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,"##.###.###/####-##") : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //##################################################################### //ENDERE�O $w = 94; $y += $h; $x = $oldX; $h = 7; $texto = utf8_decode('ENDERE�O'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) ? utf8_decode($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue) : ''; } else { $texto = '';
} $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //MUNIC�PIO $x += $w; $w = 63; $texto = utf8_decode('MUNIC�PIO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue) ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //UF $x += $w; $w = 8; $texto = utf8_decode('UF'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = !empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue) ? $this->tran
sporta->getElementsByTagName("UF")->item(0)->nodeValue : ''; } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //INSCRI��O ESTADUAL $x += $w; $w = 35; $texto = utf8_decode('INSCRI��O ESTADUAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->transporta) ){ $texto = utf8_decode($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue); if (strtoupper($texto) != 'ISENTO'){ $texto = $this->__format($texto,"###.###.###.###"); } } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'B','C',0,''); //##################################################################### //QUANTIDADE $w = 20; $y += $h; $x = $oldX; $h = 7; $texto = utf8_decode('QUANTIDADE'); $aFont = array('font'=>$this->font
ePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("qVol")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("qVol")->item(0)->nodeValue : ''; $texto = utf8_decode($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //ESP�CIE $x += $w; $w = 36; $texto = utf8_decode('ESP�CIE'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //MARCA $x += $w; $w = 36; $texto = utf8_decode('MARCA'); $aFont = array('font'=>$this->fontePadrao,'siz
e'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; $texto = ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //N�MERO $x += $w; $w = 36; $texto = utf8_decode('N�MERO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : ''; $texto = ''; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','C',0,''); //PESO BRUTO $x += $w; $w = 36; $texto = utf8_decode('PESO BRUTO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'sty
le'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("pesoB")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("pesoB")->item(0)->nodeValue : '0.0'; $texto = number_format($texto, 3, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //PESO L�QUIDO $x += $w; $w = 36; $texto = utf8_decode('PESO L�QUIDO'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = !empty($this->transp->getElementsByTagName("pesoL")->item(0)->nodeValue) ? $this->transp->getElementsByTagName("pesoL")->item(0)->nodeValue : '0.0'; $texto = number_format($texto, 3, ",", "."); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); return ($y+$h); } //fim __transporteDANFE
/** * __itensDANFE * Monta o campo de itens da DANFE * @package NFePHP * @name __itensDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @param number $nInicio N�mero do item inicial * @param number $max N�mero do item final * @param number $hmax Haltura m�xima do campo de itens em mm * @return number Posi��o vertical final */ private function __itensDANFE($x,$y,$nInicio,$hmax,$pag=0,$totpag=0) { $oldX = $x; $oldY = $y; //##################################################################### //DADOS DOS PRODUTOS / SERVI�OS $texto = "DADOS DOS PRODUTOS / SERVI�OS"; $texto = utf8_decode($texto); $w = 64; $h = 4; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); $y += 3; $w = 200; //desenha a caixa dos dados dos itens da NF $texto = ''; $this->__textBox($x,$y,$w,$hmax); //############################################################
###################### // cabecalho LOOP COM OS DADOS DOS PRODUTOS //C�DIGO PRODUTO $texto = "C�DIGO PRODUTO"; $texto = utf8_decode($texto); $w = 14; $h = 4; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //DESCRI��O DO PRODUTO / SERVI�O $x += $w; $w = 66; $texto = utf8_decode('DESCRI��O DO PRODUTO / SERVI�O'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //NCM/SH $x += $w; $w = 13; $texto = utf8_decode('NCM/SH'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //O/CST $x += $w; $w = 7; $texto = utf8_decode('O/CST'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__text


Box($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //CFOP $x += $w; $w = 7; $texto = utf8_decode('CFOP'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //UN $x += $w; $w = 6; $texto = utf8_decode('UN'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //QUANT $x += $w; $w = 10; $texto = utf8_decode('QUANT'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR UNIT $x += $w; $w = 13; $texto = utf8_decode('VALOR UNIT'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $th

is->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR TOTAL $x += $w; $w = 13; $texto = utf8_decode('VALOR TOTAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //B.C�LC ICMS $x += $w; $w = 13; $texto = utf8_decode('B.C�LC ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR ICMS $x += $w; $w = 13; $texto = utf8_decode('VALOR ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //VALOR IPI $x += $w; $w = 13; $texto = utf8_decode('VALOR IPI'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Lin
e($x+$w, $y, $x+$w, $y+$hmax); //AL�Q. ICMS $x += $w; $w = 6; $texto = utf8_decode('AL�Q. ICMS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($x+$w, $y, $x+$w, $y+$hmax); //AL�Q. IPI $x += $w; $w = 6; $texto = utf8_decode('AL�Q. IPI'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','C',0,'',FALSE); $this->pdf->Line($oldX, $y+$h+1, $oldX + 200, $y+$h+1); //################################################################################## // LOOP COM OS DADOS DOS PRODUTOS $i = 0; $h = 5; $hprod = 5; $linProd = 1; $areatotal = ($y+$hmax) - 6; foreach ($this->det as $d) { if ( $i >= $nInicio /* && $i < $nInicio+$max */) { $prod = $this->det->item($i)->getElementsByTagName("prod")->item(0); $infAdProd = substr(!empty($this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue) ? $this->det->item($i)->getElementsByTagName("infAdProd")->item(0)->nodeValue : '
',0,120); $infAdProd = str_replace(';',chr(13).chr(10), $infAdProd); if (!empty($infAdProd)){ $infAdProd = $infAdProd.chr(13).chr(10); } $imposto = $this->det->item($i)->getElementsByTagName("imposto")->item(0); $ICMS = $imposto->getElementsByTagName("ICMS")->item(0); $IPI = $imposto->getElementsByTagName("IPI")->item(0); $y += $hprod; $x = $oldX; $w = 14; $h = 3; //Verificando se a impress�o ir� ultrapassar o limite do DANFe $texto = utf8_decode($prod->getElementsByTagName("xProd")->item(0)->nodeValue .chr(13).chr(10). $infAdProd); $linhas = explode("\n",$texto); $linhaAdic = count($linhas)-2; $linhaDescr = strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50;/* - round(strlen(trim($prod->getElementsByTagName("xProd")->item(0)->nodeValue))/50,0);*/ if ($linhaDescr > 1){ $linhaAdic += $linhaDescr; } if ((($y+($h*$linhaAdic)) >= $areatotal) && $i > 0) { //ultrapassa a capacidade para uma �nica p�gina //o restan
te dos dados ser�o usados nas proximas paginas $nInicio = $i; break; } //codigo do produto $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $texto = (is_numeric($prod->getElementsByTagName("cProd")->item(0)->nodeValue)) ? abs($prod->getElementsByTagName("cProd")->item(0)->nodeValue) : $prod->getElementsByTagName("cProd")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 64; $texto = utf8_decode($prod->getElementsByTagName("xProd")->item(0)->nodeValue .chr(13).chr(10). $infAdProd); $hprod = $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,'',FALSE,$hmax-5); $x += $w+2; $w = 13; $texto = !empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ? $prod->getElementsByTagName("NCM")->item(0)->nodeValue : ''; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 7; if ( isset($ICMS) ){ $texto = $ICMS->getElementsByTagName("orig")->item(0)->nodeValue . $ICMS->getElement


sByTagName("CST")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); } $x += $w; $w = 7; $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 6; $texto = $prod->getElementsByTagName("uCom")->item(0)->nodeValue; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $x += $w; $w = 10; $texto = number_format($prod->getElementsByTagName("qCom")->item(0)->nodeValue, 2, ",", "."); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 13; $texto = number_format($prod->getElementsByTagName("vUnCom")->item(0)->nodeValue, 4, ",", "."); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 13; $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", "."); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 13; if ( isset($ICMS) ){ $texto = !empty($ICMS->getElementsByTagName("vBC"
)->item(0)->nodeValue) ? number_format($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); } $x += $w; $w = 13; if (isset($ICMS)){ $texto = !empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ? number_format($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue, 2, ",", ".") : '0,00'; $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); } $x += $w; $w = 13; if ( isset($IPI) ){ $texto = !empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue) ? number_format($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue, 2, ",", ".") :''; } else { $texto = ''; } $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','R',0,''); $x += $w; $w = 6; if (isset($ICMS)){ $texto = !empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ? number_format($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue, 0, ",", ".") : '0,00'; $this->__textBox($x,$y,$w,$h,$te

xto,$aFont,'T','C',0,''); } $x += $w; $w = 6; if ( isset($IPI) ){ $texto = !empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue) ? number_format($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue, 0, ",", ".") : ''; } else { $texto = ''; } $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','C',0,''); $i++; if ($y >= $areatotal) { //ultrapassa a capacidade para uma �nica p�gina //o restante dos dados ser�o usados nas proximas paginas $nInicio = $i; break; } } else{ $i++; } } if ($pag == $totpag){ if ($y+3 < $areatotal) { if ( isset($this->infAdic) ){ $i = 0; $texto = ''; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item(0)->nodeValue; while (!empty($obsCont)){ $texto .= $this->infAdic->getElementsByTagName("obsCont")->item($i)->getAttribute("xCampo")." "; $texto .= $obsCont.chr(13).chr(10); $i += 1; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item($i)->nodeValue; } $texto .= !empty($this->infAdic->getEl
ementsByTagName("infCpl")->item(0)->nodeValue) ? $this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue : ''; $texto .= !empty($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) ? ' Inf. fisco: '.$this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue : ''; $texto = str_replace(';',chr(13).chr(10), $texto); $texto = utf8_decode($texto); } else { $texto = ''; } $x = $oldX+14; $w = 64; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y+3,$w,$h,$texto,$aFont,'T','L',0,'',FALSE,50,$areatotal); } } return $oldY+$hmax; } // fim __itensDANFE /** * __issqnDANFE * Monta o campo de servi�os do DANFE * @package NFePHP * @name __issqnDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @return number Posi��o vertical final */ private function __issqnDANFE($x,$y){ $oldX = $x; //#################################################
#################### //C�LCULO DO ISSQN $texto = "C�LCULO DO ISSQN"; $texto = utf8_decode($texto); $w = 80; $h = 7; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',0,''); //INSCRI��O MUNICIPAL $w = 50; $y += 3; $texto = utf8_decode('INSCRI��O MUNICIPAL'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); $texto = $this->emit->getElementsByTagName("im")->item(0)->nodeValue; $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','L',0,''); //VALOR TOTAL DOS SERVI�OS $x += $w; $w = 50; $texto = utf8_decode('VALOR TOTAL DOS SERVI�OS'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->ISSQNtot) ){ $texto = !empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeVa
lue) ? $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : ''; $texto = number_format($texto, 2, ",", "."); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //BASE DE C�LCULO DO ISSQN $x += $w; $w = 50; $texto = utf8_decode('BASE DE C�LCULO DO ISSQN'); $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->ISSQNtot) ){ $texto = !empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ? $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : ''; $texto = number_format($texto, 2, ",", "."); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); //VALOR TOTAL DO ISSQN $x += $w; $w = 50; $texto = utf8_decode('VALOR TOTAL DO ISSQN');
$aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if ( isset($this->ISSQNtot) ){ $texto = !empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ? $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : ''; $texto = number_format($texto, 2, ",", "."); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x,$y,$w,$h,strtoupper($texto),$aFont,'B','R',0,''); return ($y+$h); } //fim __issqnDANFE /** *__dadosAdicionaisDANFE * Coloca o grupo de ados adicionais da NFe. * @package NFePHP * @name __dadosAdicionaisDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @return number Posi��o vertical final */ private function __dadosAdicionaisDANFE($x,$y,$pag,$temObs){ $oldX = $x; //####################################################################
############## //DADOS ADICIONAIS $texto = "DADOS ADICIONAIS"; $texto = utf8_decode($texto); $w = 40; $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>'B'); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',0,''); //INFORMA��ES COMPLEMENTARES $texto = "INFORMA��ES COMPLEMENTARES"; $texto = utf8_decode($texto); $y += 3; $w = 140; $h = 50; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); if (isset($this->infAdic)){ $i = 0; $texto = ''; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item(0)->nodeValue; while (!empty($obsCont)){ $texto .= $this->infAdic->getElementsByTagName("obsCont")->item($i)->getAttribute("xCampo")." "; $texto .= $obsCont.chr(13).chr(10); $i += 1; $obsCont = $this->infAdic->getElementsByTagName("obsCont")->item($i)->nodeValue; } $texto .= !empty($this->infAdic->getElementsByTagName("infCpl")->item(0)->nodeValue) ? $this->infAdic->getElementsByTa
gName("infCpl")->item(0)->nodeValue : ''; $texto .= !empty($this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue) ? ' Inf. fisco: '.$this->infAdic->getElementsByTagName("infAdFisco")->item(0)->nodeValue : ''; $texto = str_replace(';',chr(13).chr(10), $texto); $texto = utf8_decode($texto); } else { $texto = ''; } $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y+2,$w-2,$h-3,$texto,$aFont,'T','L',0,'',FALSE,$h,0,&$temObs); //RESERVADO AO FISCO $texto = "RESERVADO AO FISCO"; $texto = utf8_decode($texto); $x += $w; $w = 60; $h = 50; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'B'); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'T','L',1,''); //inserir texto informando caso de conting�ncia //1 � Normal � emiss�o normal; //2 � Conting�ncia FS � emiss�o em conting�ncia com impress�o do DANFE em Formul�rio de Seguran�a; //3 � Conting�ncia SCAN � emiss�o em conting�ncia no Sistema de Conting�ncia do Ambiente Naciona
l � SCAN; //4 � Conting�ncia DPEC - emiss�o em conting�ncia com envio da Declara��o Pr�via de Emiss�o em Conting�ncia � DPEC; //5 � Conting�ncia FS-DA - emiss�o em conting�ncia com impress�o do DANFE em Formul�rio de Seguran�a para Impress�o de Documento Auxiliar de Documento Fiscal Eletr�nico (FS-DA). $tpEmis = $this->ide->getElementsByTagName("tpEmis")->item(0)->nodeValue; $texto = ''; switch($tpEmis){ case 2: $texto = 'CONTING�NCIA FS emiss�o em conting�ncia com impress�o do DANFE em Formul�rio de Seguran�a'; break; case 3: $texto = 'CONTING�NCIA SCAN'; break; case 4: $texto = 'CONTING�NCIA DPEC'; break; case 5: $texto = 'CONTING�NCIA FSDA emiss�o em conting�ncia com impress�o do DANFE em Formul�rio de Seguran�a para Impress�o de Documento Auxiliar de Documento Fiscal Eletr�nico (FS-DA)'; break; } $texto = utf8_decode($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y+3,$w-2,$h-3,$texto,$aFont,'T','L',0,'',FALSE); $y = $y
+ $h; $x -= 140; $texto = "DATA E HORA DA IMPRESS�O: ". date('d/m/Y H:i:s'); $texto = utf8_decode($texto); $w = 200; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>'I'); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',0,''); $texto = "NFePHP www.nfephp.org"; $texto = utf8_decode($texto); $w = 200; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','R',0,''); return $y+$h; } //fim __dadosAdicionaisDANFE /** * __canhotoDANFE * Monta o canho no final da DANFE * @package NFePHP * @name __canhotoDANFE * @version 1.1 * @param number $x Posi��o horizontal canto esquerdo * @param number $y Posi��o vertical canto superior * @return number Posi��o vertical final */ private function __canhotoDANFE($x,$y) { $oldX = $x; //################################################################################# //canhoto //identifica��o do sistema emissor //linha separadora do canhoto $w = 160; $y += 2; $h = 1
0; $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT); $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT); $texto = "RECEBEMOS DE "; $texto .= $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " "; $texto .= "OS PRODUTOS E/OU SERVI�OS CONSTANTES DA NOTA FISCAL ELETR�NICA INDICADA AO LADO. EMISS�O: "; $texto .= $this->__ymd2dmy($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ." "; $texto .= "VALOR TOTAL: R$ "; $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " "; $texto .= "DESTINAT�RIO: "; $texto .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - "; $texto .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", "; $texto .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - "; $texto .= $this->enderDest->getElementsByTagName("xBairro")
->item(0)->nodeValue . " "; $texto .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-"; $texto .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . ""; $texto = utf8_decode(strtoupper($texto)); $aFont = array('font'=>$this->fontePadrao,'size'=>7,'style'=>''); $this->__textBox($x,$y,$w,$h,$texto,$aFont,'C','L',1,'',FALSE); $x1 = $x + $w; $texto = "NF-e"; $aFont = array('font'=>$this->fontePadrao,'size'=>14,'style'=>'B'); $this->__textBox($x1,$y,40,18,$texto,$aFont,'T','C',0,''); $texto = "N�. " . $this->__format($numNF,"###.###.###") . " \n"; $texto .= "S�rie $serie"; $texto = utf8_decode($texto); $aFont = array('font'=>$this->fontePadrao,'size'=>10,'style'=>'B'); $this->__textBox($x1,$y,40,18,$texto,$aFont,'C','C',1,''); //DATA DO RECEBIMENTO $texto = "DATA DO RECEBIMENTO"; $y += $h; $w = 35; $aFont = array('font'=>$this->fontePadrao,'size'=>6,'style'=>''); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',1,''); //IDENTIFICA��O E ASSI
NATURA DO RECEBEDOR $x += $w; $w = 125; $texto = utf8_decode("IDENTIFICA��O E ASSINATURA DO RECEBEDOR"); $this->__textBox($x,$y,$w,8,$texto,$aFont,'T','L',1,''); $x -= 35; $y += 9; $this->__HdashedLine($x,$y,201,0.1,80); $y += 2; return $y; } //fim __canhotoDANFE /** * __format * Fun��o de formata��o de strings. * @package NFePHP * @name __format * @version 1.0 * @param string $campo String a ser formatada * @param string $mascara Regra de format��o da string (ex. ##.###.###/####-##) * @return string Retorna o campo formatado */ private function __format($campo='',$mascara=''){ //remove qualquer formata��o que ainda exista $sLimpo = ereg_replace("/[' '-./ t]/",'',$campo); // pega o tamanho da string e da mascara $tCampo = strlen($sLimpo); $tMask = strlen($mascara); if ( $tCampo > $tMask ) { $tMaior = $tCampo; } else { $tMaior = $tMask; } //contar o numero de cerquilhas da marcara $aMask = str_split($mascara); $z=0; $flag=FALSE; foreach ( $aMask as $letra ){ if ($letra
== '#'){ $z++; } } if ( $z > $tCampo ) { //o campo � menor que esperado $flag=TRUE; } //cria uma vari�vel grande o suficiente para conter os dados $sRetorno = ''; $sRetorno = str_pad($sRetorno, $tCampo+$tMask, " ",STR_PAD_LEFT); //pega o tamanho da string de retorno $tRetorno = strlen($sRetorno); //se houve entrada de dados if( $sLimpo != '' && $mascara !='' ) { //inicia com a posi��o do ultimo digito da mascara $x = $tMask; $y = $tCampo; $cI = 0; for ( $i = $tMaior-1; $i >= 0; $i-- ) { if ($cI < $z){ // e o digito da mascara � # trocar pelo digito do campo // se o inicio da string da mascara for atingido antes de terminar // o campo considerar # if ( $x > 0 ) { $digMask = $mascara[--$x]; } else { $digMask = '#'; } //se o fim do campo for atingido antes do fim da mascara //verificar se � ( se n�o for n�o use if ( $digMask=='#' ) { $cI++; if ( $y > 0 ) { $sRetorno[--$tRetorno] = $sLimpo[--$y]; } else { //$sRetorno[--$tRetorno] = ''; } } else { if ( $y > 0 ) { $sRetor
no[--$tRetorno] = $mascara[$x]; } else { if ($mascara[$x] =='('){ $sRetorno[--$tRetorno] = $mascara[$x]; } } $i++; } } } if (!$flag){ if ($mascara[0]!='#'){ $sRetorno = '(' . trim($sRetorno); } } return trim($sRetorno); } else { return ''; } } //fim __format /** *__textBox * Cria uma caixa de texto com ou sem bordas. Esta fun��o perimite o alinhamento horizontal * ou vertical do texto dentro da caixa. * Aten��o : Esta fun��o � dependente de outras classes de FPDF * * Ex. $this->__textBox(2,20,34,8,'Texto',array('fonte'=>$this->fontePadrao,'size'=>10,'style='B'),'C','L',FALSE,'http://www.nfephp.org') * * @package NFePHP * @name __textBox * @version 1.0 * @param number $x Posi��o horizontal da caixa, canto esquerdo superior * @param number $y Posi��o vertical da caixa, canto esquerdo superior * @param number $w Largura da caixa * @param number $h Altura da caixa * @param string $text Conte�do da caixa * @param array $aFont Matriz com as informa��es para formata��o do texto com
fonte, tamanho e estilo * @param string $vAlign Alinhamento vertical do texto, T-topo C-centro B-base * @param string $hAlign Alinhamento horizontal do texto, L-esquerda, C-centro, R-direita * @param boolean $border TRUE ou 1 desenha a borda, FALSE ou 0 Sem borda * @param string $link Insere um hiperlink * @return none */ private function __textBox($x,$y,$w,$h,$text='',$aFont=array('font'=>'Times','size'=>8,'style'=>''),$vAlign='T',$hAlign='L',$border=1,$link='',$force=TRUE,$hmax=0,$hini=0){ $oldY = $y; $temObs = FALSE; $resetou = FALSE; //desenhar a borda if ( $border ) { $this->pdf->RoundedRect($x,$y,$w,$h,0.8,'D'); } //estabelecer o fonte $this->pdf->SetFont($aFont['font'],$aFont['style'],$aFont['size']); //calcular o incremento $incY = $this->pdf->FontSize; //$aFont['size']/3;//$this->pdf->FontSize; if ( !$force ) { //verificar se o texto cabe no espa�o $n = $this->pdf->WordWrap($text,$w); } else { $n = 1; } //calcular a altura do conjunto de texto $altTe


xt = $incY * $n; //separar o texto em linhas $lines = explode("\n", $text); //verificar o alinhamento vertical If ( $vAlign == 'T' ) { //alinhado ao topo $y1 = $y+$incY; } If ( $vAlign == 'C' ) { //alinhado ao centro $y1 = $y + $incY + (($h-$altText)/2); } If ( $vAlign == 'B' ) { //alinhado a base $y1 = ($y + $h)-0.5; //- ($altText/2); } //para cada linha foreach( $lines as $line ) { //verificar o comprimento da frase $texto = trim($line); $comp = $this->pdf->GetStringWidth($texto); if ( $force ) { $newSize = $aFont['size']; while ( $comp > $w ) { //estabelecer novo fonte $this->pdf->SetFont($aFont['font'],$aFont['style'],--$newSize); $comp = $this->pdf->GetStringWidth($texto); } } //ajustar ao alinhamento horizontal if ( $hAlign == 'L' ) { $x1 = $x+1; } if ( $hAlign == 'C' ) { $x1 = $x + (($w - $comp)/2); } if ( $hAlign == 'R' ) { $x1 = $x + $w - ($comp+0.5); } //escrever o texto if ($hini >0){ if ($y1 > ($oldY+$hini)){ if (!$resetou){ $y1 = oldY; $resetou

= TRUE; } $this->pdf->Text($x1, $y1, $texto); } } else { $this->pdf->Text($x1, $y1, $texto); } //incrementar para escrever o proximo $y1 += $incY; if (($hmax > 0) && ($y1 > ($y+($hmax-1)))){ $temObs = TRUE; break; } } return ($y1-$y)-$incY; } // fim fun��o __textBox /** *__HdashedLine * Desenha uma linha horizontal tracejada com o FPDF * * @package NFePHP * @name __HdashedLine * @version 1.0 * @author Roberto L. Machado * @param number $x Posi��o horizontal inicial, em mm * @param number $y Posi��o vertical inicial, em mm * @param number $w Comprimento da linha, em mm * @param number $h Espessura da linha, em mm * @param number $n Numero de tra�os na se��o da linha com o comprimento $w * @return none */ private function __HdashedLine($x,$y,$w,$h,$n) { $this->pdf->SetLineWidth($h); $wDash=($w/$n)/2; // comprimento dos tra�os for( $i=$x; $i<=$x+$w; $i += $wDash+$wDash ) { for( $j=$i; $j<= ($i+$wDash); $j++ ) { if( $j <=
($x+$w-1) ) { $this->pdf->Line($j,$y,$j+1,$y); } } } } //fim fun��o __HdashedLine /** *__ymd2dmy * Converte datas no formato YMD (ex. 2009-11-02) para o formato brasileiro 02/11/2009) * * @package NFePHP * @name __ymd2dmy * @version 1.0 * @author Roberto L. Machado * @param string $data Par�metro extraido da NFe * @return string Formatada para apresneta��o da data no padr�o brasileiro */ private function __ymd2dmy($data) { if (!empty($data)) { $needle = "/"; if (strstr($data, "-")) { $needle = "-"; } $dt = explode($needle, $data); return "$dt[2]/$dt[1]/$dt[0]"; } } // fim da fun��o __ymd2dmy /** * __convertTime * Converte a imforma��o de data e tempo contida na NFe * @package NFePHP * @name __convertTime * @version 1.0 * @author Roberto L. Machado * @param string $DH Informa��o de data e tempo extraida da NFe * @return timestamp UNIX Para uso com a fun�ao date do php */ private function __convertTime($DH){ if ($DH){ $aDH = explode('T',$DH); $adDH = explode('-',$aDH[0]); $atDH
= explode(':',$aDH[1]); $timestampDH = mktime($atDH[0],$atDH[1],$atDH[2],$adDH[1],$adDH[2],$adDH[0]); return $timestampDH; } } //fim da fun��o __convertTime } //fim da classe ?>
>
>

DanfeNFePHP.class.php

FerreiraH.

unread,
Jul 18, 2010, 6:38:47 PM7/18/10
to nfe...@googlegroups.com
Ola daria para colocar o logo do lado esquerdo e as palavras do nome e endereço a direita já reduzi meu logo para 50X50 mas assim mesmo colide
Outro detalhe tem como anexar o arquivo estou recebendo em texto mas gostaria de receber em arquivo, da para fazer ?

Marcos

unread,
Jul 18, 2010, 9:43:11 PM7/18/10
to nfe...@googlegroups.com

Ola!

Sobre o logo nada sei, pq eu nao uso o logo. Deixei como estava, apenas
pus de volta o IF para ele nao aparecer se a imagem n�o existir.

Atendendo seu pedido, o arquivo segue agora zipado.

Duvidas, entre em contato.
Marcos

FerreiraH. wrote:
> Ola daria para colocar o logo do lado esquerdo e as palavras do nome e

> endere�o a direita j� reduzi meu logo para 50X50 mas assim mesmo colide


> Outro detalhe tem como anexar o arquivo estou recebendo em texto mas
> gostaria de receber em arquivo, da para fazer ?
>
> --
> Ferreira Helder
> B2Stok.net ERP Php5-Gtk2
> PhpGtkEditor
> PhpSDL
> PhpGladeTools
> Voce pode colaborar
>

> --
> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

DanfeNFePHP.class.php.zip

FerreiraH.

unread,
Jul 18, 2010, 10:05:53 PM7/18/10
to nfe...@googlegroups.com
Marcos Obrigado
Estou escapando aquelas as & < > ' "  com &amp; etc como o danfe faz ao encontrar estes caracteres escapados
Ao tentar gravar no banco de dados o XML esta dando erro porque o banco interpleta o ; como fim de linha
Como não coloquei o xml no banco não sei como ele faz qualdo sai do banco para ser impresso no danfe.

Voce satem alguma rotina ou exemplo para eu utilizar to me batendo estou utilizando assim

$sql.="UPDATE nota_xml SET xmlnome='$this->sfileNome',xml_estagio='criada',xml_status='criada',xml_doc= '". mysql_escape_string($data)."' , xml_file='".mysql_escape_string($data)."' where num_formulario='$this->nNF';";

mas da erro devido ao ponto e virgula

Em 18 de julho de 2010 22:43, Marcos <mar...@unitron.com.br> escreveu:

Ola!

Sobre o logo nada sei, pq eu nao uso o logo. Deixei como estava, apenas pus de volta o IF para ele nao aparecer se a imagem não existir.


Atendendo seu pedido, o arquivo segue agora zipado.

Duvidas, entre em contato.
Marcos

FerreiraH. wrote:
Ola daria para colocar o logo do lado esquerdo e as palavras do nome e endereço a direita já reduzi meu logo para 50X50 mas assim mesmo colide

Outro detalhe tem como anexar o arquivo estou recebendo em texto mas gostaria de receber em arquivo, da para fazer ?

--
Ferreira Helder
B2Stok.net ERP Php5-Gtk2
PhpGtkEditor
PhpSDL
PhpGladeTools
Voce pode colaborar

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

FerreiraH.

unread,
Jul 28, 2010, 10:51:16 PM7/28/10
to nfe...@googlegroups.com
Erro na classe Reabrindo esta discução

A classe antiga não sei qual versão do svn, emite um danfe com duas folhas quando temos 16 linhas
A Nova classe que esta no svn beta emite um danfe com 16 linhas colocando 16 linhas na primeira folha e as mesma 16 linhas na segunda folha
O site indicado pelo nosso Amigo Andre Morais  http://www.facilnfe.com.br/ que por sinal é muito util para quem precisa de uma copia de um danfe quando recebe um xml sem o danfe,  tambem imprime o danfe em duas folhas repetindo os itens

Quando corigirem me contem pois estou em produção e tive de enviar as duas folhas para o cliente.

Em 17 de julho de 2010 20:47, Paulo Gabriel <paulo...@gmail.com> escreveu:
Idéia que eu apoio.

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".
Para Postar: nfe...@googlegroups.com
Para Sair do Grupo: nfephp+un...@googlegroups.com
Link: http://groups.google.com.br/group/nfephp?hl=pt-BR
-------
FAQ: https://www.assembla.com/wiki/show/nfephp/FAQ
Como Participar: https://www.assembla.com/wiki/show/nfephp/Como_participar



--

Daniel Batista Lemes

unread,
Jul 28, 2010, 11:17:16 PM7/28/10
to nfe...@googlegroups.com
Não seria só imprimir duas vezes o danfe???

mar...@unitron.com.br

unread,
Jul 29, 2010, 7:02:47 AM7/29/10
to nfe...@googlegroups.com
voce pode mandar um exemplo do DANFE ?
Dai eu conserto.

Marcos

--- On Thu, 29/7/10, Daniel Batista Lemes <dle...@gmail.com> wrote:

> From: Daniel Batista Lemes <dle...@gmail.com>
> Subject: Re: [nfephp] Alterações DANFE

Paulo Gabriel

unread,
Jul 29, 2010, 8:07:13 AM7/29/10
to nfe...@googlegroups.com
Não Daniel,

O Ferreira se refere à uma nota onde a lista de produtos não cabe só na primeira página.

Então, o restante deve ser inserido em uma segunda página, diferente da primeira.

Acontece que recebemos excelentes contribuições (não estou sendo irônico), mas este detalhe passou.


É isso!

NFePHP - 1 ano!

Marcos

unread,
Jul 29, 2010, 8:15:11 AM7/29/10
to nfe...@googlegroups.com

Testei com 5 NFs minhas de 2 p�ginas e tal problema n�o ocorreu.

Por favor mande um exemplo, que eu me prontifico a consertar ainda hoje.

Marcos

On 29/07/2010 09:07, Paulo Gabriel wrote:
> N�o Daniel,
>
> O Ferreira se refere � uma nota onde a lista de produtos n�o cabe s� na
> primeira p�gina.
>
> Ent�o, o restante deve ser inserido em uma segunda p�gina, diferente da
> primeira.
>
> Acontece que recebemos excelentes contribui��es (n�o estou sendo
> ir�nico), mas este detalhe passou.
>
>
> � isso!
>
> NFePHP - 1 ano!
>
> --
> Voc� recebeu esta mensagem porque est� inscrito no Grupo "NFePHP".

FerreiraH.

unread,
Jul 29, 2010, 2:11:43 PM7/29/10
to nfe...@googlegroups.com
Pois é esta inconsistencia me apareceu com o transportadora me aguardando no balcão, mas as vezes, parece que as coizas acontece só com a gente hehehe

Em 29 de julho de 2010 09:15, Marcos <mar...@unitron.com.br> escreveu:

Testei com 5 NFs minhas de 2 páginas e tal problema não ocorreu.


Por favor mande um exemplo, que eu me prontifico a consertar ainda hoje.

Marcos


On 29/07/2010 09:07, Paulo Gabriel wrote:
Não Daniel,

O Ferreira se refere à uma nota onde a lista de produtos não cabe só na
primeira página.

Então, o restante deve ser inserido em uma segunda página, diferente da
primeira.

Acontece que recebemos excelentes contribuições (não estou sendo
irônico), mas este detalhe passou.


É isso!


NFePHP - 1 ano!

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".

Marcelo Telles

unread,
Aug 5, 2010, 10:16:28 AM8/5/10
to nfe...@googlegroups.com
Estou testando aqui a nova versao do DanfeNFePHP.class e tive alguns problemas.
com as funções WordWrap e RoundedRect e mais algumas extendi de uma
classe tcpdf que tinhas tais funções ....
a função ereg_replace tive que trocar por

$sLimpo = ereg_replace("/[' '-./ t]/",'',$campo);
$sLimpo = preg_replace("(/[' '-./ t]/)",'',$campo);

fiz uns ajustes mas não tive sucesso, no final saiu esta impressão em anexo

O o problema deve ser no fpdf? minha versão é antiga, tem como baixar
de uma so vez do svn?
ou precis baixar arquivo por arquivo?
alguem pode me madar o diretório do fpdf atual?

Estou testando a nova versão pois acho que ela vai resolver um
problema que percebi. Quando a descrição do item tem muitos caracteres
eu não estava quebrando a linha, mas pelo teste inicial a linha
continua nao quebrando.

Grato pela atenção


Marcelo Josué Telles
www.marcelo.kinghost.net

43100887223236000175550010000001170000001170.pdf

Marcelo Telles

unread,
Aug 5, 2010, 10:41:03 AM8/5/10
to nfe...@googlegroups.com
Descupe o apavoramento.
Usei o link que o Paulo disponibilizou, atualizei meu FPDF e deu tudo certo.
Mtuio grato.

Em 5 de agosto de 2010 11:16, Marcelo Telles
<marcelo...@gmail.com> escreveu:

--
Marcelo Josué Telles
Esc. Téc. Olímpio / Esc. Aplic. Feevale
Desenvolvimento AlphaBit
Msn: marce...@msn.com
Fone: 51 3595 2362
Cel: 51 9164 0596
www.marcelo.kinghost.net

FerreiraH.

unread,
Aug 5, 2010, 9:25:33 PM8/5/10
to nfe...@googlegroups.com
ereg_replace ( se tornou obsoleta no php5.3 )
tambem tive poblemas com um ubuntu 10.4 e tive de retornar ao ubuntu 9.10
a mensagem é deprecated fatal erro algo assim

--
Você recebeu esta mensagem porque está inscrito no Grupo "NFePHP".
Para Postar: nfe...@googlegroups.com
Para Sair do Grupo: nfephp+un...@googlegroups.com
Link: http://groups.google.com.br/group/nfephp?hl=pt-BR
-------
FAQ: https://www.assembla.com/wiki/show/nfephp/FAQ
Como Participar: https://www.assembla.com/wiki/show/nfephp/Como_participar
Reply all
Reply to author
Forward
0 new messages