Inheritance: extends NFePHP\Common\Base\BaseTools
Ejemplo n.º 1
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aResposta = array();
$siglaUF = $nfe->aConfig['siglaUF'];
$tpAmb = '2';
$cnpj = $nfe->aConfig['cnpj'];
// Consulta por CNPJ ou IE ou CPF
$iest = '';
$cpf = '';
$retorno = $nfe->sefazCadastro($siglaUF, $tpAmb, $cnpj, $iest, $cpf, $aResposta);
echo '<br><br><pre>';
echo htmlspecialchars($nfe->soapDebug);
echo '</pre><br><pre>';
print_r($aResposta);
echo "</pre><br>";
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$ultNSU = 0;
// se estiver como zero irá retornar os dados dos ultimos 15 dias até o limite de 50 registros
// se for diferente de zero irá retornar a partir desse numero os dados dos
// últimos 15 dias até o limite de 50 registros
$numNSU = 0;
// se estiver como zero irá usar o ultNSU
// se for diferente de zero não importa o que está contido em ultNSU será retornado apenas
// os dados deste NSU em particular
$tpAmb = '1';
// esses dados somente existirão em ambiente de produção pois em ambiente de testes
// não existem dados de eventos, nem de NFe emitidas para o seu CNPJ
$cnpj = '';
// deixando vazio irá pegar o CNPJ default do config
// se for colocado um CNPJ tenha certeza que o certificado está autorizado a
// baixar os dados desse CNPJ pois se não estiver autorizado haverá uma
// mensagem de erro da SEFAZ
//array que irá conter os dados de retorno da SEFAZ
$aResposta = array();
//essa rotina deve rá ser repetida a cada hora até que o maxNSU retornado esteja contido no NSU da mensagem
//se estiver já foram baixadas todas as referencias a NFe, CTe e outros eventos da NFe e não a mais nada a buscar
//outro detalhe é que não adianta tentar buscar dados muito antigos o sistema irá informar que
//nada foi encontrado, porque a SEFAZ não mantêm os NSU em base de dados por muito tempo, em
//geral são mantidos apenas os dados dos últimos 15 dias.
Ejemplo n.º 3
0
$servidor = 'localhost';
$usuario = 'root';
$senha = '';
$banco = 'fit4';
// Conecta-se ao banco de dados MySQL
$mysqli = new mysqli($servidor, $usuario, $senha, $banco);
// Caso algo tenha dado errado, exibe uma mensagem de erro
if (mysqli_connect_errno()) {
    trigger_error(mysqli_connect_error());
}
ini_set('display_errors', 'On');
include_once 'nfe/bootstrap.php';
use NFePHP\NFe\ToolsNFe;
if (isset($_POST['password']) && $_POST['password'] == "senha") {
    //Se estiver setada e correta a senha de upload
    $nfe = new ToolsNFe('C:/xampp/htdocs/cristiano/fit4/nfe/config.json');
    $nfe->setModelo('55');
    ############################################################# TRANSMISSÃO NFE ##########################################################
    if (isset($_POST['function']) && $_POST['function'] == "transmissao") {
        //SE FOR TRANSMISSÃO DE NOTA FISCAL
        $uploaddir = 'C:\\xampp\\htdocs\\cristiano\\fit4\\nfe\\enviadas';
        //Instancia variavel com o destino do arquivo
        if (!is_dir($uploaddir)) {
            //Se não existe
            mkdir($uploaddir);
            //Cria o destino
        }
        $uploadfile = $uploaddir . "\\" . basename($_FILES['xml']['name']);
        //Contrói o namespace completo do file
        if (move_uploaded_file($_FILES['xml']['tmp_name'], $uploadfile)) {
            //Se conclui o upload
Ejemplo n.º 4
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aResposta = array();
$tpAmb = '2';
$recibo = '521000011732162';
$retorno = $nfe->sefazConsultaRecibo($recibo, $tpAmb, $aResposta);
echo '<br><br><pre>';
echo htmlspecialchars($nfe->soapDebug);
echo '</pre><br><br><pre>';
print_r($aResposta);
echo "</pre><br>";
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$aResposta = array();
$pathNFefile = '/var/www/nfe/homologacao/assinadas/35150158716523000119550010000000071000000076-nfe.xml';
$pathProtfile = '/var/www/nfe/homologacao/temporarias/201501/35150158716523000119550010000000071000000076-retConsSitNFe.xml';
$saveFile = true;
$retorno = $nfe->addProtocolo($pathNFefile, $pathProtfile, $saveFile);
echo '<br><br><PRE>';
echo htmlspecialchars($retorno);
echo '</PRE><BR>';
echo "<br>";
Ejemplo n.º 6
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\MakeNFe;
use NFePHP\NFe\ToolsNFe;
$nfe = new MakeNFe();
$nfeTools = new ToolsNFe('../../config/config.json');
//Dados da NFCe - infNFe
$cUF = '52';
$cNF = '00000200';
$natOp = 'Venda ao consumidor';
$indPag = '0';
$mod = '65';
$serie = '1';
$nNF = '200';
$dhEmi = date("Y-m-d\\TH:i:sP");
//Formato: “AAAA-MM-DDThh:mm:ssTZD” (UTC - Universal Coordinated Time).
$dhSaiEnt = '';
//Não informar este campo para a NFC-e.
$tpNF = '1';
$idDest = '1';
$cMunFG = '5208707';
$tpImp = '4';
$tpEmis = '1';
//normal
$tpAmb = '2';
//homolocação
$finNFe = '1';
$indFinal = '1';
Ejemplo n.º 7
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$aResposta = array();
$pathNFefile = '/var/www/nfe/homologacao/enviadas/aprovadas/201501/35150158716523000119550010000000071000000076-protNFe.xml';
$pathProtfile = '/var/www/nfe/homologacao/temporarias/201501/35150158716523000119550010000000071000000076-CancNFe-retEnvEvento.xml';
$saveFile = true;
$retorno = $nfe->addCancelamento($pathNFefile, $pathProtfile, $saveFile);
echo '<br><br><PRE>';
echo htmlspecialchars($retorno);
echo '</PRE><BR>';
echo "<br>";
Ejemplo n.º 8
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('65');
/* Operações de administração CSC (indOp):

01 – Consulta
02 – Solicitação
03 – Revogação

*/
$indOp = '1';
$tpAmb = '2';
$raizCNPJ = '';
// Deixe vazio para utilizar o CNPJ do Certificado
$idCsc = '';
$codigoCsc = '';
$saveXml = true;
// Salva o resultado em XML na pasta csc
$aResposta = array();
$xml = $nfe->sefazManutencaoCsc($indOp, $tpAmb, $raizCNPJ, $idCsc, $codigoCsc, $saveXml, $aResposta);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR><PRE>';
print_r($aResposta);
echo "</PRE><br>";
Ejemplo n.º 9
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$aResposta = array();
$pathNFefile = '';
$pathB2Bfile = '';
$tagB2B = '';
$retorno = $nfe->addB2B($pathNFefile, $pathB2Bfile, $tagB2B);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
//210200 – Confirmação da Operação
//210210 – Ciência da Operação
//210220 – Desconhecimento da Operação
//210240 – Operação não Realizada ===> é obritatoria uma justificativa para esse caso
$chave = '35150158716523000119550010000000071000000076';
$tpAmb = '2';
$xJust = '';
$tpEvento = '210210';
//ciencia da operação
$aResposta = array();
$xml = $nfe->sefazManifesta($chave, $tpAmb, $xJust = '', $tpEvento = '', $aResposta);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
Ejemplo n.º 11
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$chave = '52160500067985000172550010000000101000000100';
// $filename = "/var/www/nfe/homologacao/entradas/{$chave}-nfe.xml"; // Ambiente Linux
$filename = "D:/xampp/htdocs/GIT-nfephp-org/nfephp/xmls/NF-e/homologacao/entradas/{$chave}-nfe.xml";
// Ambiente Windows
$xml = file_get_contents($filename);
$xml = $nfe->assina($xml);
// $filename = "/var/www/nfe/homologacao/assinadas/{$chave}-nfe.xml"; // Ambiente Linux
$filename = "D:/xampp/htdocs/GIT-nfephp-org/nfephp/xmls/NF-e/homologacao/assinadas/{$chave}-nfe.xml";
// Ambiente Windows
file_put_contents($filename, $xml);
chmod($filename, 0777);
echo $chave;
Ejemplo n.º 12
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aResposta = array();
$chave = '35150158716523000119550010000000071000000076';
$nProt = '135150000408219';
$tpAmb = '2';
$xJust = 'Teste de cancelamento em ambiente de homologação';
$retorno = $nfe->sefazCancela($chave, $tpAmb, $xJust, $nProt, $aResposta);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
Ejemplo n.º 13
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aResposta = array();
$chNFe = '35150258716523000119550010000000091000000090';
$tpAmb = '2';
$xCorrecao = 'Teste de carta de correcao em ambiente homologacao';
$nSeqEvento = 1;
$retorno = $nfe->sefazCCe($chNFe, $tpAmb, $xCorrecao, $nSeqEvento, $aResposta);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
Ejemplo n.º 14
0
 /**
  * Metodo para envio da manifestacao para a SEFAZ
  *
  * @name	setManifesto
  * @access	public
  * @author	Roberson Faria
  * @param 	Numeric $customer_id
  * @param 	Numeric $chNFe
  * @param 	Numeric $operacao
  * @param 	String $justificativa
  * @return	Json $respostaSefaz
  */
 public function setManifesto($customer_id, $chNFe, $operacao, $xJust = "")
 {
     $customer = Customer::find($customer_id)->toArray();
     $nfe = new ToolsNFe($this->setConfig($customer));
     $xml = $nfe->sefazManifesta($chNFe, $this->dadosConfig["tpAmb"], $xJust = '', $tpEvento = '', $aResposta);
     return $aResposta;
 }
Ejemplo n.º 15
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$chave = '52160500067985000172550010000000101000000100';
$tpAmb = '2';
// $xml = "/var/www/nfe/homologacao/assinadas/{$chave}-nfe.xml"; // Ambiente Linux
$xml = "D:/xampp/htdocs/GIT-nfephp-org/nfephp/xmls/NF-e/homologacao/assinadas/{$chave}-nfe.xml";
// Ambiente Windows
if (!$nfe->validarXml($xml) || sizeof($nfeTools->errors)) {
    echo "<h3>Eita !?! Tem bicho na linha .... </h3>";
    foreach ($nfe->errors as $erro) {
        if (is_array($erro)) {
            foreach ($erro as $err) {
                echo "{$err} <br>";
            }
        } else {
            echo "{$erro} <br>";
        }
    }
    exit;
}
echo "NFe Valida !";
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\MakeNFe;
use NFePHP\NFe\ToolsNFe;
$tools = new ToolsNFe('../../config/config.json');
$nfe = new MakeNFe();
$cUF = '35';
$ano = '15';
$mes = '10';
$cnpj = '58716523000119';
$mod = '65';
$serie = '1';
$nNF = '175';
$tpEmis = '2';
$cNF = '00000175';
$versao = '3.10';
$natOp = 'Venda ao consumidor';
$indPag = '0';
$dhEmi = str_replace(' ', 'T', date('Y-m-d H:i:sP'));
$dhSaiEnt = str_replace(' ', 'T', date('Y-m-d H:i:sP'));
$tpNF = '1';
$idDest = '1';
$cMunFG = '4314902';
$tpImp = '4';
$tpAmb = '2';
$finNFe = '1';
$indFinal = '1';
$indPres = '1';
Ejemplo n.º 17
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aResposta = array();
$chave = '35150258716523000119550010000000091000000090';
$tpAmb = '2';
$aXml = file_get_contents("/var/www/nfe/homologacao/assinadas/{$chave}-nfe.xml");
$idLote = '';
$indSinc = '0';
$flagZip = false;
$retorno = $nfe->sefazEnviaLote($aXml, $tpAmb, $idLote, $aResposta, $indSinc, $flagZip);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aResposta = array();
$pathXmlFile = '/var/www/nfephpdev/exemplos/xml/35150258716523000119550000000344861511504837-nfe.xml';
if (!$nfe->verificaValidade($pathXmlFile, $aResposta)) {
    echo "<h1>NFe INVÁLIDA!!</h1>";
} else {
    echo "<h1>NFe valida.</h1>";
}
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
Ejemplo n.º 19
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$chNFe = '35150458716523000119550010000000131000000139';
$tpAmb = '2';
$cnpj = '58716523000119';
$aResposta = array();
$resp = $nfe->sefazDownload($chNFe, $tpAmb, $cnpj, $aResposta);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aResposta = array();
$nSerie = 1;
$nIni = 8;
$nFin = 8;
$xJust = 'teste de inutilização de notas fiscais em homologacao';
$tpAmb = '2';
$xml = $nfe->sefazInutiliza($nSerie, $nIni, $nFin, $xJust, $tpAmb, $aResposta);
echo '<br><br><PRE>';
echo htmlspecialchars($nfe->soapDebug);
echo '</PRE><BR>';
print_r($aResposta);
echo "<br>";
Ejemplo n.º 21
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$ncm = '22030000';
$exTarif = '0';
$siglaUF = 'GO';
$resp = $nfe->getImpostosIBPT($ncm, $exTarif, $siglaUF);
print_r($resp);
Ejemplo n.º 22
0
 /**
  * o objetivo desta função é ler o XML e gerar o DANFE NFC-e com auxilio de conversão HTML-PDF
  * @param boolean $ecoNFCe false = Não (NFC-e Completa); true = Sim (NFC-e Simplificada)
  * @return string
  */
 public function montaDANFCE($ecoNFCe = true)
 {
     $toolsNFe = new ToolsNFe('../../config/config.json');
     //DADOS DA NF
     $dhRecbto = $nProt = '';
     if (isset($this->nfeProc)) {
         $nProt = $this->pSimpleGetValue($this->nfeProc, "nProt");
         $dhRecbto = $this->pSimpleGetValue($this->nfeProc, "dhRecbto");
     }
     $digVal = $this->pSimpleGetValue($this->nfe, "DigestValue");
     $chNFe = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
     $chNFe = $this->pFormat($chNFe, "#### #### #### #### #### #### #### #### #### #### ####");
     $tpAmb = $this->pSimpleGetValue($this->ide, 'tpAmb');
     $tpEmis = $this->pSimpleGetValue($this->ide, 'tpEmis');
     $cUF = $this->pSimpleGetValue($this->ide, 'cUF');
     $nNF = $this->pSimpleGetValue($this->ide, 'nNF');
     $serieNF = str_pad($this->pSimpleGetValue($this->ide, "serie"), 3, "0", STR_PAD_LEFT);
     $dhEmi = $this->pSimpleGetValue($this->ide, "dhEmi");
     $vTotTrib = $this->pSimpleGetValue($this->ICMSTot, "vTotTrib");
     $vICMS = $this->pSimpleGetValue($this->ICMSTot, "vICMS");
     $vProd = $this->pSimpleGetValue($this->ICMSTot, "vProd");
     $vDesc = $this->pSimpleGetValue($this->ICMSTot, "vDesc");
     $vOutro = $this->pSimpleGetValue($this->ICMSTot, "vOutro");
     $vNF = $this->pSimpleGetValue($this->ICMSTot, "vNF");
     $qtdItens = $this->det->length;
     if ($this->urlQR == '') {
         //Busca no XML a URL da Consulta
         $urlQR = $toolsNFe->zGetUrlQR($cUF, $tpAmb);
     } else {
         $urlQR = $this->urlQR;
     }
     //DADOS DO EMITENTE
     if (empty($this->logomarca)) {
         $image = $toolsNFe->aConfig['aDocFormat']->pathLogoNFCe;
         $imageData = base64_encode(file_get_contents($image));
         $this->logomarca = "data: " . mime_content_type($image) . ";base64,{$imageData}";
     }
     $emitRazao = $this->pSimpleGetValue($this->emit, "xNome");
     $emitCnpj = $this->pSimpleGetValue($this->emit, "CNPJ");
     $emitCnpj = $this->pFormat($emitCnpj, "##.###.###/####-##");
     $emitIE = $this->pSimpleGetValue($this->emit, "IE");
     $emitFone = $this->pSimpleGetValue($this->enderEmit, "fone");
     $foneLen = strlen($emitFone);
     if ($foneLen > 0) {
         $fone2 = substr($emitFone, 0, $foneLen - 4);
         $fone1 = substr($emitFone, 0, $foneLen - 8);
         $emitFone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($emitFone, -4);
     } else {
         $emitFone = '';
     }
     $emitLgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
     $emitNro = $this->pSimpleGetValue($this->enderEmit, "nro");
     $emitCpl = $this->pSimpleGetValue($this->enderEmit, "xCpl");
     $emitBairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
     $emitCEP = $this->pFormat($this->pSimpleGetValue($this->enderEmit, "CEP"), "#####-###");
     $emitMun = $this->pSimpleGetValue($this->enderEmit, "xMun");
     $emitUF = $this->pSimpleGetValue($this->enderEmit, "UF");
     //necessário para QRCode
     $cDest = '';
     if (isset($this->dest)) {
         $considEstrangeiro = !empty($this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue) ? $this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue : '';
         $consCPF = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue) ? $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue : '';
         $consCNPJ = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue) ? $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue : '';
         $cDest = $consCPF . $consCNPJ . $considEstrangeiro;
         //documentos do consumidor
     }
     //DADOS PARA QRCODE
     if (!empty($this->qrCode)) {
         $this->imgQRCode = self::imgQR($this->qrCode);
     } else {
         $this->imgQRCode = self::makeQRCode($chNFe, $urlQR, $tpAmb, $cDest, $dhEmi, $vNF, $vICMS, $digVal, $this->idToken, $this->emitToken);
     }
     //FORMATAÇÃO DOS CAMPOS
     $numNF = "Número " . $this->pFormat($nNF, "###.###.###");
     $tsHora = $this->pConvertTime($dhEmi);
     if ($dhRecbto == '') {
         $dhRecbto = $dhEmi;
     }
     $tsProt = $this->pConvertTime($dhRecbto);
     //$valorProdutos = number_format($vProd, 2, ",", ".");
     //$valorTotal = number_format($vNF, 2, ",", ".");
     /* 
      * Leiaute de Impressão DANFE NFC-e em acordo com 
      * Manual Padrões Técnicos do DANFE-NFC-e e QR Code
      * Versão 3.4
      * Outubro 2015
      * Refatorado por: Chinnon Santos - 05/2016
      */
     $this->html = "";
     $this->html .= "<html>\n";
     $this->html .= "<head>\n";
     $this->html .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
     $this->html .= $this->css;
     $this->html .= "</head>\n";
     $this->html .= "<body>\n";
     // ***                                                    ***//
     // *** Via Única ou Via do Consumidor em Modo Contigência ***//
     // ***                                                    ***//
     // -- Divisão I - Informações do Cabeçalho
     $this->html .= "<table width=\"100%\">\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td><img src=\"{$this->logomarca}\" width=\"82\" ></td>\n";
     $this->html .= "<td colspan=\"2\">" . htmlspecialchars($emitRazao) . "<br>CNPJ:{$emitCnpj} I.E.:{$emitIE}<br>" . htmlspecialchars($emitLgr . ", nº" . $emitNro) . "<br>" . htmlspecialchars($emitCpl) . "<br>" . htmlspecialchars($emitBairro . ", " . $emitMun . ", " . $emitUF) . "<br>CEP: {$emitCEP} {$emitFone}</td>\n";
     $this->html .= "</tr>\n";
     $this->html .= "</table>\n";
     // -- Divisão II – Identificação do DANFE NFC-e
     $this->html .= "<table width=\"100%\">\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td colspan=\"3\" class=\"tCenter\"><strong>" . htmlspecialchars("DANFE NFC-e - DOCUMENTO AUXILIAR DA NOTA FISCAL DE CONSUMIDOR ELETRÔNICA") . "</strong></td>\n";
     $this->html .= "</tr>\n";
     $this->html .= "</table>\n";
     // -- Divisão III – Informações de detalhes de produtos/serviços
     if (!$ecoNFCe) {
         $this->html .= self::itens($this->det);
     }
     // -- Divisão IV – Informações de Totais do DANFE NFC-e
     $this->html .= "<table width=\"100%\">\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td class=\"tLeft\">Qtde. Total de Itens</td>\n";
     $this->html .= "<td class=\"tRight\">{$qtdItens}</td>\n";
     $this->html .= "</tr>\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td class=\"tLeft\">" . htmlspecialchars('Valor Total R$') . "</td>\n";
     $this->html .= "<td class=\"tRight\">" . number_format($vProd, 2, ',', '.') . "</td>\n";
     $this->html .= "</tr>\n";
     $this->html .= "<tr>\n";
     // Acréscimos (frete, seguro e outras despesas)/Desconto R$ (Exibe somente se houver!)
     $hasAD = false;
     if ($vDesc != '0.00') {
         $this->html .= "<tr>\n";
         $this->html .= "<td class=\"tLeft\">" . htmlspecialchars('Desconto R$') . "</td>\n";
         $this->html .= "<td class=\"tRight\">-" . number_format($vDesc, 2, ',', '.') . "</td>\n";
         $this->html .= "</tr>\n";
         $this->html .= "<tr>\n";
         $hasAD = true;
     }
     if ($vOutro != '0.00') {
         $this->html .= "<tr>\n";
         $this->html .= "<td class=\"tLeft\">" . htmlspecialchars('Acréscimos R$') . "</td>\n";
         $this->html .= "<td class=\"tRight\">" . number_format($vOutro, 2, ',', '.') . "</td>\n";
         $this->html .= "</tr>\n";
         $this->html .= "<tr>\n";
         $hasAD = true;
     }
     // (Total Itens - Descontos + Acréscimos) deve ser impresso apenas se existir acréscimo ou desconto
     if ($hasAD) {
         $this->html .= "<tr>\n";
         $this->html .= "<td class=\"tLeft\">" . htmlspecialchars('Valor a Pagar R$') . "</td>\n";
         $this->html .= "<td class=\"tRight\">" . number_format($vOutro, 2, ',', '.') . "</td>\n";
         $this->html .= "</tr>\n";
     }
     // Formas de Pagamentos
     $this->html .= "<tr>\n";
     $this->html .= "<th class=\"tLeft\">FORMA DE PAGAMENTO</th>\n";
     $this->html .= "<th class=\"tRight\">VALOR PAGO</th>\n";
     $this->html .= "</tr>\n";
     $this->html .= self::pagamento($this->pag);
     $this->html .= "</table>\n";
     // -- Divisão V – Área de Mensagem Fiscal
     $this->html .= "<table width=\"100%\">\n";
     if ($tpEmis != 1) {
         $this->html .= "<tr>\n";
         $this->html .= "<td colspan=\"3\"><strong>" . htmlspecialchars("EMITIDA EM CONTINGÊNCIA") . "</strong></td>\n";
         $this->html .= "</tr>\n";
     } elseif ($tpAmb == 2) {
         $this->html .= "<tr>\n";
         $this->html .= "<td colspan=\"3\"><strong>" . htmlspecialchars("EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO – SEM VALOR FISCAL") . "<strong></td>\n";
         $this->html .= "</tr>\n";
     } elseif (!empty($this->infAdFisco)) {
         $this->html .= "<tr>\n";
         $this->html .= "<td colspan=\"3\"><strong>" . htmlspecialchars("INFORMAÇÕES ADICIONAIS DE INTERESSE DO FISCO") . "<strong></td>\n";
         $this->html .= "<td colspan=\"3\">{$this->infAdFisco}</td>\n" . ($this->html .= "</tr>\n");
     }
     $this->html .= "</table>\n";
     // -- Divisão VI – Informações de Identificação da NFC-e e do Protocolo de Autorização
     $this->html .= "<table width=\"100%\">\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td colspan=\"3\">" . htmlspecialchars($numNF);
     $this->html .= " " . htmlspecialchars('Série: ') . "{$serieNF}";
     if ($tpEmis == 1) {
         $this->html .= " " . htmlspecialchars('Emissão: ') . date('d/m/y H:i:s', $tsHora) . "</td>\n";
     } else {
         $this->html .= " " . htmlspecialchars('Emissão: ') . date('d/m/y H:i:s', $tsHora);
         $this->html .= "<br><strong>Via do Consumidor</strong></td>\n";
     }
     $this->html .= "</tr>\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td colspan=\"3\">Consulte pela Chave de Acesso em <a href=\"{$urlQR}\">{$urlQR}</a></td>\n";
     $this->html .= "</tr>\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td colspan=\"3\">Chave de Acesso<br>{$chNFe}</td>\n";
     $this->html .= "</tr>\n";
     if ($tpEmis == 1) {
         $this->html .= "<tr>\n";
         $this->html .= "<td colspan=\"3\">Protocolo de autorização: {$nProt} - " . date('d/m/y H:i:s', $tsProt) . "</td>\n";
         $this->html .= "</tr>\n";
     }
     $this->html .= "</table>\n";
     // -- Divisão VII – Informações sobre o Consumidor
     $this->html .= self::consumidor($this->dest);
     // -- Divisão VIII – Informações da Consulta via QR Code
     $this->html .= "<table width=\"100%\">\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td colspan=\"3\"><img src=\"{$this->imgQRCode}\" ></td>\n";
     $this->html .= "</tr>\n";
     $this->html .= "</table>\n";
     // -- Divisão IX – Mensagem de Interesse do Contribuinte
     $this->html .= "<table width=\"100%\" class=\"noBorder\">\n";
     $this->html .= "<tr>\n";
     $this->html .= "<td colspan=\"3\" class=\"menor tCenter\"><strong>{$this->infCpl}</strong></td>\n";
     $this->html .= "</tr>\n";
     $this->html .= "</table>\n";
     // ***                                            ***//
     // *** Via do Estabelecimento em Modo Contigência ***//
     // ***                                            ***//
     if ($tpEmis != 1) {
         $html2via = str_replace('Via do Consumidor', 'Via do Estabelecimento', $this->html);
         $this->html .= "<br><hr><br>\n";
         $this->html .= $html2via;
     }
     $this->html .= "</body>\n</html>\n";
     return $chNFe;
 }
Ejemplo n.º 23
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
//NOTA: o envio de email com o DANFE somente funciona para modelo 55
//      o modelo 65 nunca requer o envio do DANFCE por email
use NFePHP\NFe\ToolsNFe;
$xml = __DIR__ . '/../xml/35150300822602000124550010009923461099234656-nfe.xml';
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$aMails = ['*****@*****.**'];
//se for um array vazio a classe Mail irá pegar os emails do xml
$templateFile = '';
//se vaizio usará o template padrão da mensagem
$comPdf = true;
try {
    $nfe->enviaMail($xml, $aMails, $templateFile, $comPdf);
} catch (NFePHP\Common\Exception\RuntimeException $e) {
    echo $e->getMessage();
}
Ejemplo n.º 24
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
//$nfe->ativaContingencia('GO','Contingência Ativada pela SEFAZ GO desde 08/10/2010 18:00:00','');
//$nfe->desativaContingencia();
$nfe->setModelo('55');
$aResposta = array();
$siglaUF = 'GO';
$tpAmb = '2';
$retorno = $nfe->sefazStatus($siglaUF, $tpAmb, $aResposta);
echo '<br><br><pre>';
echo htmlspecialchars($nfe->soapDebug);
echo '</pre><br><br><pre>';
print_r($aResposta);
echo "</pre><br>";
Ejemplo n.º 25
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$chave = '52160500067985000172550010000000101000000100';
$tpAmb = '2';
$aResposta = array();
$xml = $nfe->sefazConsultaChave($chave, $tpAmb, $aResposta);
echo '<br><br><pre>';
echo htmlspecialchars($nfe->soapDebug);
echo '</pre><br><pre>';
print_r($aResposta);
echo "<pre><br>";
Ejemplo n.º 26
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
$nfe = new ToolsNFe('../../config/config.json');
$nfe->setModelo('55');
$chave = '35150458716523000119550010000000131000000139';
$tpAmb = '2';
$xml = "/var/www/nfe/homologacao/assinadas/{$chave}-nfe.xml";
if (!$nfe->validarXml($xml)) {
    echo "Eita !?! Tem bicho na linha .... <br>";
    foreach ($nfe->errors as $erro) {
        echo "{$erro} <br>";
    }
    exit;
}
echo "NFe Valida !";