Skip to content

Commit

Permalink
Refatoração da Classe Danfce.php seguindo os padrões do Manual DANFE …
Browse files Browse the repository at this point in the history
…NFC-e e QR CODE versão 3.4, inclusão de duas logo oficial padrão para NF-e e NFC-e, atualizado e melhorado as páginas que envolve a emissão da NFC-e.
  • Loading branch information
chinnonsantos committed May 18, 2016
1 parent b09da81 commit 2325309
Show file tree
Hide file tree
Showing 13 changed files with 438 additions and 381 deletions.
4 changes: 2 additions & 2 deletions config/nfe_ws3_mod55.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ AM Consulta de Cadastro não EXISTE
<NfeAutorizacao method="nfeAutorizacao" operation="NfeAutorizacao" version="3.10">https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeAutorizacao</NfeAutorizacao>
<NfeRetAutorizacao method="nfeRetAutorizacao" operation="NfeRetAutorizacao" version="3.10">https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeRetAutorizacao</NfeRetAutorizacao>
<CscNFCe method="admCscNFCe" operation="CscNFCe" version="1.00">https://homolog.sefaz.go.gov.br/nfe/services/v2/CscNFCe</CscNFCe>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://homolog.sefaz.go.gov.br/nfeweb/jsp/CConsultaCompletaNFEJSF.jsf</NfeConsultaQR>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://www.nfe.go.gov.br/pagina/ver/10275/consulta-de-testes</NfeConsultaQR>
<NfeConsultaDest method="nfeConsultaNFDest" operation="NfeConsultaDest" version="3.10"></NfeConsultaDest>
<NfeDownloadNF method="nfeDownloadNF" operation="NfeDownloadNF" version="3.10"></NfeDownloadNF>
</homologacao>
Expand All @@ -116,7 +116,7 @@ AM Consulta de Cadastro não EXISTE
<NfeAutorizacao method="nfeAutorizacao" operation="NfeAutorizacao" version="3.10">https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeAutorizacao</NfeAutorizacao>
<NfeRetAutorizacao method="nfeRetAutorizacao" operation="NfeRetAutorizacao" version="3.10">https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeRetAutorizacao</NfeRetAutorizacao>
<CscNFCe method="admCscNFCe" operation="CscNFCe" version="1.00">https://nfe.sefaz.go.gov.br/nfe/services/v2/CscNFCe</CscNFCe>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://nfe.sefaz.go.gov.br/nfeweb/jsp/CConsultaCompletaNFEJSF.jsf</NfeConsultaQR>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://www.nfe.go.gov.br/pagina/ver/10270/consulta-completa</NfeConsultaQR>
<NfeConsultaDest method="nfeConsultaNFDest" operation="NfeConsultaDest" version="3.10"></NfeConsultaDest>
<NfeDownloadNF method="nfeDownloadNF" operation="NfeDownloadNF" version="3.10"></NfeDownloadNF>
</producao>
Expand Down
4 changes: 2 additions & 2 deletions config/nfe_ws3_mod65.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ ATENÇÃO!!! Vários endereços destes webservices ainda não foram totalmente
<NfeAutorizacao method="nfeAutorizacao" operation="NfeAutorizacao" version="3.10">https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeAutorizacao</NfeAutorizacao>
<NfeRetAutorizacao method="nfeRetAutorizacao" operation="NfeRetAutorizacao" version="3.10">https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeRetAutorizacao</NfeRetAutorizacao>
<CscNFCe method="admCscNFCe" operation="CscNFCe" version="1.00">https://homolog.sefaz.go.gov.br/nfe/services/v2/CscNFCe</CscNFCe>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://homolog.sefaz.go.gov.br/nfeweb/jsp/CConsultaCompletaNFEJSF.jsf</NfeConsultaQR>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://www.nfe.go.gov.br/pagina/ver/10275/consulta-de-testes</NfeConsultaQR>
<NfeConsultaDest method="nfeConsultaNFDest" operation="NfeConsultaDest" version="3.10"></NfeConsultaDest>
<NfeDownloadNF method="nfeDownloadNF" operation="NfeDownloadNF" version="3.10"></NfeDownloadNF>
</homologacao>
Expand All @@ -173,7 +173,7 @@ ATENÇÃO!!! Vários endereços destes webservices ainda não foram totalmente
<NfeAutorizacao method="nfeAutorizacao" operation="NfeAutorizacao" version="3.10">https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeAutorizacao</NfeAutorizacao>
<NfeRetAutorizacao method="nfeRetAutorizacao" operation="NfeRetAutorizacao" version="3.10">https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeRetAutorizacao</NfeRetAutorizacao>
<CscNFCe method="admCscNFCe" operation="CscNFCe" version="1.00">https://nfe.sefaz.go.gov.br/nfe/services/v2/CscNFCe</CscNFCe>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://nfe.sefaz.go.gov.br/nfeweb/jsp/CConsultaCompletaNFEJSF.jsf</NfeConsultaQR>
<NfeConsultaQR method="QR-CODE" operation="NfeConsultaQR" version="100">http://www.nfe.go.gov.br/pagina/ver/10270/consulta-completa</NfeConsultaQR>
<NfeConsultaDest method="nfeConsultaNFDest" operation="NfeConsultaDest" version="3.10"></NfeConsultaDest>
<NfeDownloadNF method="nfeDownloadNF" operation="NfeDownloadNF" version="3.10"></NfeDownloadNF>
</producao>
Expand Down
12 changes: 6 additions & 6 deletions exemplos/NFe/4.00testaDanfce.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
use NFePHP\Common\Files\FilesFolders;

$nfe = new ToolsNFe('../../config/config.json');
//$nfe->aConfig['aDocFormat']->pathLogoFile // Logo em config

$saida = isset($_REQUEST['o']) ? $_REQUEST['o'] : 'pdf'; //pdf ou html

$ecoNFCe = '1'; //0=Sim (NFC-e Simplificada); 1=Não (NFC-e Completa)
$ecoNFCe = false; //false = Não (NFC-e Completa); true = Sim (NFC-e Simplificada)
$chave = '52160522234907000158650010000002001000002009';
$xmlProt = "D:/xampp/htdocs/GIT-nfephp-org/nfephp/xmls/NF-e/homologacao/enviadas/aprovadas/201605/{$chave}-protNFe.xml";
// Uso da nomeclatura '-danfce.pdf' para facilitar a diferenciação entre PDFs DANFE e DANFCE salvos na mesma pasta...
$pdfDanfe = "D:/xampp/htdocs/GIT-nfephp-org/nfephp/xmls/NF-e/homologacao/pdf/201605/{$chave}-danfce.pdf";

$docxml = FilesFolders::readFile($xmlProt);
$danfe = new Danfce($docxml, $nfe->aConfig['aDocFormat']->pathLogoFile, 2);
$id = $danfe->montaDANFE($ecoNFCe);
$salva = $danfe->printDANFE('pdf', $pdfDanfe, 'F'); //salva na pasta pdf
$id = $danfe->montaDANFE($ecoNFCe);
$abre = $danfe->printDANFE($saida, $pdfDanfe, 'I');
$danfce = new Danfce($docxml, '', 2);
$id = $danfce->montaDANFCE($ecoNFCe);
$salva = $danfce->printDANFCE('pdf', $pdfDanfe, 'F'); //Salva na pasta pdf
$abre = $danfce->printDANFCE($saida, $pdfDanfe, 'I'); //Abre na tela
15 changes: 5 additions & 10 deletions exemplos/NFe/4.00testaMakeNFe.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,16 +612,11 @@
//**************************************************************

// Calculo de carga tributária similar ao IBPT - Lei 12.741/12
$federal = $vII+$vIPI+$vIOF+$vPIS+$vCOFINS;
$estadual = $vICMS+$vST;
$municipal = $vISS;
$textoIBPT = "Valor Aprox. Tributos R$ ".number_format($federal+$estadual+$municipal,2,',','.')." - ";
$textoIBPT .= $federal>0?number_format($federal,2,',','.')." Federal":"";
$textoIBPT .= $federal>0?$estadual>0&&$municipal>0?", ":" e ":"";
$textoIBPT .= $estadual>0?number_format($estadual,2,',','.')." Estadual":"";
$textoIBPT .= $estadual>0&&$municipal>0?" e ":"";
$textoIBPT .= $municipal>0?number_format($municipal,2,',','.')." Municipal":"";
$textoIBPT .= ". ";
$federal = number_format($vII+$vIPI+$vIOF+$vPIS+$vCOFINS,2,',','.');
$estadual = number_format($vICMS+$vST,2,',','.');
$municipal = number_format($vISS,2,',','.');
$totalT = number_format($federal+$estadual+$municipal,2,',','.');
$textoIBPT = "Valor Aprox. Tributos R$ {$totalT} - {$federal} Federal, {$estadual} Estadual e {$municipal} Municipal.";

//Informações Adicionais
//$infAdFisco = "SAIDA COM SUSPENSAO DO IPI CONFORME ART 29 DA LEI 10.637";
Expand Down
20 changes: 9 additions & 11 deletions exemplos/NFe/4.00testaNFCeQrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,18 @@

//pagamento
$tPag = '01'; //Dinheiro
$vPag = '12.00';
$vPag = '2.00';
$rest = $nfe->tagpag($tPag, $vPag);
$tPag = '02'; //Cheque
$vPag = '10.00';
$rest = $nfe->tagpag($tPag, $vPag);

// Calculo de carga tributária similar ao IBPT - Lei 12.741/12
$federal = $vII+$vIPI+$vIOF+$vPIS+$vCOFINS;
$estadual = $vICMS+$vST;
$municipal = $vISS;
$textoIBPT = "Valor Aprox. Tributos R$ ".number_format($federal+$estadual+$municipal,2,',','.')." - ";
$textoIBPT .= $federal>0?number_format($federal,2,',','.')." Federal":"";
$textoIBPT .= $federal>0?$estadual>0&&$municipal>0?", ":" e ":"";
$textoIBPT .= $estadual>0?number_format($estadual,2,',','.')." Estadual":"";
$textoIBPT .= $estadual>0&&$municipal>0?" e ":"";
$textoIBPT .= $municipal>0?number_format($municipal,2,',','.')." Municipal":"";
$textoIBPT .= ". ";
$federal = number_format($vII+$vIPI+$vIOF+$vPIS+$vCOFINS,2,',','.');
$estadual = number_format($vICMS+$vST,2,',','.');
$municipal = number_format($vISS,2,',','.');
$totalT = number_format($federal+$estadual+$municipal,2,',','.');
$textoIBPT = "Valor Aprox. Tributos R$ {$totalT} - {$federal} Federal, {$estadual} Estadual e {$municipal} Municipal.";

//informações Adicionais
$infAdFisco = "";
Expand Down
Binary file added images/logo-nfce.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo-nfe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@
$format = 'P';
$paper = 'A4';
$southpaw = true;
$pathLogoFile = '';
$pathLogoFile = PATH_NFEPHP . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.jpg';
$pathLogoNFe = PATH_NFEPHP . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo-nfe.png';
$pathLogoNFCe = PATH_NFEPHP . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo-nfce.png';
$logoPosition = 'L';
$font = 'Times';
$printer = '';
Expand Down Expand Up @@ -160,6 +162,8 @@
$paper = isset($installConfig->aDocFormat->paper) ? $installConfig->aDocFormat->paper : 'A4';
$southpaw = isset($installConfig->aDocFormat->southpaw) ? $installConfig->aDocFormat->southpaw : true;
$pathLogoFile = isset($installConfig->aDocFormat->pathLogoFile) ? $installConfig->aDocFormat->pathLogoFile : '';
$pathLogoNFe = isset($installConfig->aDocFormat->pathLogoNFe) ? $installConfig->aDocFormat->pathLogoNFe : '';
$pathLogoNFCe = isset($installConfig->aDocFormat->pathLogoNFCe) ? $installConfig->aDocFormat->pathLogoNFCe : '';
$logoPosition = isset($installConfig->aDocFormat->logoPosition) ? $installConfig->aDocFormat->logoPosition : 'L';
$font = isset($installConfig->aDocFormat->font) ? $installConfig->aDocFormat->font : 'Times';
$printer = isset($installConfig->aDocFormat->printer) ? $installConfig->aDocFormat->printer : '';
Expand Down Expand Up @@ -532,14 +536,18 @@ function changeAlerts(key, flag, msg) {
<input type="text" id="font" name="font" size="10" value="<?php echo $font;?>" readonly /><br>
<span title="Normalmente não usado mas teria que complementar o script para permitir a impressão direta. Pois esse recurso depende do sistema operacional.">Impressora</span><br>
<input type="text" id="printer" name="printer" placeholder="Nome da Impressora" size="30" value="<?php echo $printer;?>" /><br>
<span title="Imagem com a logomarca, deverá ser um aquivo JPEG ou PNG">Logo</span><br>
<input type="text" id="pathLogoFile" name="pathLogoFile" placeholder="Path completo para o arquivo com o logo" value="<?php echo $pathLogoFile;?>" /><br>
<span title="Imagem com a logomarca, deverá ser um aquivo JPEG ou PNG">Logo (80x80px ou 160x50px jpg, gif ou png)</span><br>
<input type="text" id="pathLogoFile" name="pathLogoFile" placeholder="Path completo para o arquivo com o logo" value="<?php echo $pathLogoFile;?>" />
<input type="hidden" name="pathLogoNFe" value="<?php echo $pathLogoNFe;?>" readonly />
<input type="hidden" name="pathLogoNFCe" value="<?php echo $pathLogoNFCe;?>" readonly />
<br>
</div>
<div id="direita">
<h3>Para a impressão dos documentos auxiliares seja para NFe, CTe, MDFe ou CLe, está definido em documentação oficial o uso obrigatório de papel A4 e do tipo de letras "Times" (serifados), isso é fixo e não pode ser mudado.</h3>
<h3>O formato de impressão seja ele "Portraite" ou "Landscape" é definido também pelo campo &lt;tpImp&gt; do XML, portanto essa definição aqui estabelecida NÃO sobrepõe a especificação contida no XML, e nem é válida para qualquer documento auxiliar.</h3>
<h3>Para a impressão dos documentos auxiliares da NFCe as regras são diferentes tendo em vista que se trata de um substitudo do cupom fiscal. Nesses casos é usual havem impressoras termicas não-fiscais, especificas para a impressão desses cupons.</h3>
<h3>Dito isso, a impressão desses cupons (DANFCE) pode ser mais complexa pois algumas dessas impressoras para serem eficientes dependem do envio de comandos diretos no padrão ESC/POS ou similar (ex. Epson TM T20). Nesse momento ainda não temos na nossa API este recurso e portanto a DANFCE por enquato é gerada apenas em PDF.</h3>
<h3>A impressão de documentos auxiliares da NFC-e deve ser feita em impressoras comum (não fiscal) térmicas, laser ou deskjet de 80 colunas.</h3>
<h3>Por enquanto a API não envia os dados direto para impressora, e por tanto a DANFCE só é impressa em PDF ou HTML.</h3>
<h3>Caso não seja informado uma imagem para logo, será usado as imagens padrão para cada tipo de documento NF-e e NFC-e.</h3>
</div>
<div class="clear"> </div>

Expand Down
115 changes: 61 additions & 54 deletions install/nfephp.css
Original file line number Diff line number Diff line change
@@ -1,54 +1,61 @@
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
line-height: normal;
}

.clear { clear: both; }

label {
font-size: 10px;
font-style: italic;
line-height: normal;
}

span {
font-size: 10px;
font-style: italic;
line-height: normal;
}

input {
font-style: normal;
background-color: lightyellow;
}

input:required {
font-style: bold;
background-color: yellow;
}

select {
font-style: bold;
background-color: yellow;
}

#content {
width: 80%;
margin-left: auto;
margin-right: auto;
}


td {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
}

#direita { width: 50%; float: right; }
#esquerda { width: 50%; float: left; }

#tabs input {width: 95%;}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
line-height: normal;
}

.clear { clear: both; }

label {
font-size: 10px;
font-style: italic;
line-height: normal;
}
span {
font-size: 10px;
font-style: italic;
line-height: normal;
}

input {
font-style: normal;
background-color: lightyellow;
}

input:required {
font-style: bold;
background-color: yellow;
}

select {
font-style: bold;
background-color: yellow;
}

#content {
width: 80%;
margin-left: auto;
margin-right: auto;
}


td {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
}

#direita { width: 50%; float: right; }
#esquerda { width: 50%; float: left; }

#tabs input {width: 95%;}
.logoList {
float:left;
margin-right:10px;
text-align:center;
}
.logoList img {
border:none;
}
4 changes: 4 additions & 0 deletions install/saveconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
$paper = filter_input(INPUT_GET, 'paper', FILTER_SANITIZE_STRING);
$southpaw = filter_input(INPUT_GET, 'southpaw');
$pathLogoFile = filter_input(INPUT_GET, 'pathLogoFile', FILTER_SANITIZE_STRING);
$pathLogoNFe = filter_input(INPUT_GET, 'pathLogoNFe', FILTER_SANITIZE_STRING);
$pathLogoNFCe = filter_input(INPUT_GET, 'pathLogoNFCe', FILTER_SANITIZE_STRING);
$logoPosition = filter_input(INPUT_GET, 'logoPosition', FILTER_SANITIZE_STRING);
$font = filter_input(INPUT_GET, 'font', FILTER_SANITIZE_STRING);
$printer = filter_input(INPUT_GET, 'printer', FILTER_SANITIZE_STRING);
Expand Down Expand Up @@ -103,6 +105,8 @@
'paper' => $paper,
'southpaw' => $southpaw,
'pathLogoFile' => $pathLogoFile,
'pathLogoNFe' => $pathLogoNFe,
'pathLogoNFCe' => $pathLogoNFCe,
'logoPosition' => $logoPosition,
'font' => $font,
'printer' => $printer
Expand Down
18 changes: 18 additions & 0 deletions libs/Common/Base/BaseTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,4 +736,22 @@ protected function zGetSigla($cUF = '')
{
return array_search($cUF, $this->cUFlist);
}

/**
* zGetSigla
* @param string $cUF
* @param int $tpAmb
* @return string
*/
public function zGetUrlQR($cUF,$tpAmb)
{
$siglaUF = $this->zGetSigla($cUF);
$this->zLoadServico('nfe','NfeConsultaQR',$siglaUF,$tpAmb);
if ($this->urlService == '') {
$url = "http://www.sefaz.".strtolower($siglaUF).".gov.br/";
} else {
$url = $this->urlService;
}
return $url;
}
}
Loading

0 comments on commit 2325309

Please sign in to comment.