Exemplo n.º 1
0
 /**
  * verifica
  * Verifica o status da SEFAZ com o webservice e retorna tags html com o resultado
  * @param string $config json do arquivo de configuração
  * @return string
  */
 public static function verifica($config = '')
 {
     $aRetorno = array();
     if (empty($config)) {
         return '';
     }
     self::$config = $config;
     if (is_file(APP_ROOT . '/base/status.json')) {
         $aRetorno = (array) json_decode(FilesFolders::readFile(APP_ROOT . '/base/status.json'));
     }
     $tstmp = DateTime::convertSefazTimeToTimestamp($aRetorno['dhRecbto']);
     $tsnow = time();
     $dif = $tsnow - $tstmp;
     //caso tenha passado mais de uma hora desde a ultima verificação
     if ($dif > 3600) {
         self::$nfe = new ToolsNFe($config);
         self::$certTS = self::$nfe->certExpireTimestamp;
         self::$nfe->sefazStatus('', '', $aRetorno);
         $retJson = json_encode($aRetorno);
         FilesFolders::saveFile(APP_ROOT . '/base', 'status.json', $retJson);
     }
     $tstmp = DateTime::convertSefazTimeToTimestamp($aRetorno['dhRecbto']);
     $dhora = date('d/m/Y H:i:s', $tstmp);
     $htmlStatus = "<p class=\"smallred\">OFF-LINE</p>\n<p class=\"smallred\">{$dhora}</p>";
     if ($aRetorno['cStat'] == '107') {
         $htmlStatus = "<p class=\"smallgreen\">SEFAZ On-Line</p>\n<p class=\"smallgreen\">{$dhora}</p>";
     }
     return $htmlStatus;
 }
Exemplo n.º 2
0
 public function __construct($configJson = '')
 {
     if ($configJson == '') {
         $configJson = Files\FilesFolders::readFile('../config/config.json');
     }
     $aConfig = (array) json_decode($configJson);
     $this->aMailConf = (array) $aConfig['aMailConf'];
 }
Exemplo n.º 3
0
 public function testWriteTest()
 {
     $htmlStandard = '<tr bgcolor="#FFFFCC">' . '<td>Test</td>' . '<td bgcolor="#00CC00">' . '<div align="center"> Permiss&atilde;o OK</div>' . '</td>' . '<td>O diret&oacute;rio deve ter permiss&atilde;o de escrita</td>' . '</tr>';
     $folderBase = dirname(dirname(dirname(__FILE__))) . '/fixtures/certs';
     $respHtml = '';
     $resp = FilesFolders::writeTest($folderBase, 'Test', $respHtml);
     $this->assertTrue($resp);
     $this->assertEquals($htmlStandard, $respHtml);
 }
Exemplo n.º 4
0
 /**
  * Executa a leitura do arquivo de configuração e
  * carrega o certificado
  *
  * @param string $config
  * @param bool   $ignore
  */
 protected function loadConfig($config = '', $ignore = false)
 {
     if (is_file($config)) {
         $config = FilesFolders::readFile($config);
     }
     $result = json_decode($config);
     if (json_last_error() === JSON_ERROR_NONE) {
         $this->objConfig = $result;
     }
     if (!is_object($this->objConfig)) {
         throw new InvalidArgumentException("Uma configuração valida deve ser passada!");
     }
     $this->pkcs = new Pkcs12($this->objConfig->pathCertsFiles, $this->objConfig->cnpj, '', '', '', $ignore);
     $this->pkcs->loadPfxFile($this->objConfig->pathCertsFiles . $this->objConfig->certPfxName, $this->objConfig->certPassword, true, $ignore, false);
 }
Exemplo n.º 5
0
 /**
  * identificacao
  * Identifica o documento
  * @param type $xml
  * @return string
  */
 public static function identificacao($xml = '', &$aResp = array())
 {
     if ($xml == '') {
         return '';
     } elseif (is_file($xml)) {
         $xml = FilesFolders::readFile($xml);
     }
     $dom = new Dom('1.0', 'utf-8');
     $dom->loadXMLString($xml);
     $key = '';
     $schId = (string) self::zSearchNode($dom, $key);
     if ($schId == '') {
         return '';
     }
     $chave = '';
     $tpAmb = '';
     $dhEmi = '';
     if ($schId == 'nfe' || $schId == 'cte' || $schId == 'mdfe') {
         switch ($schId) {
             case 'nfe':
                 $tag = 'infNFe';
                 break;
             case 'cte':
                 $tag = 'infCte';
                 break;
             case 'mdfe':
                 $tag = 'infMDFe';
                 break;
         }
         $chave = $dom->getChave($tag);
         $tpAmb = $dom->getNodeValue('tpAmb');
         $dhEmi = $dom->getNodeValue('dhEmi');
     }
     $aResp['Id'] = $schId;
     $aResp['tag'] = $key;
     $aResp['dom'] = $dom;
     $aResp['chave'] = $chave;
     $aResp['tpAmb'] = $tpAmb;
     $aResp['dhEmi'] = $dhEmi;
     return $schId;
 }
Exemplo n.º 6
0
 /**
  * zGravaFile
  * Grava os dados no diretorio das NFe
  * @param string $tpAmb ambiente
  * @param string $filename nome do arquivo
  * @param string $data dados a serem salvos
  * @param string $subFolder 
  * @param string $anomes 
  * @throws Exception\RuntimeException
  */
 protected function zGravaFile($tipo = '', $tpAmb = '2', $filename = '', $data = '', $subFolder = 'temporarias', $anomes = '')
 {
     if ($anomes == '') {
         $anomes = date('Ym');
     }
     $path = '';
     if ($tipo == 'nfe') {
         $path = $this->aConfig['pathNFeFiles'];
     } elseif ($tipo == 'cte') {
         $path = $this->aConfig['pathCTeFiles'];
     } elseif ($tipo == 'mdfe') {
         $path = $this->aConfig['pathMDFeFiles'];
     }
     $pathTemp = Files\FilesFolders::getFilePath($tpAmb, $path, $subFolder) . DIRECTORY_SEPARATOR . $anomes;
     if (!Files\FilesFolders::saveFile($pathTemp, $filename, $data)) {
         $msg = 'Falha na gravação no diretório. ' . $pathTemp;
         throw new Exception\RuntimeException($msg);
     }
 }
Exemplo n.º 7
0
 /**
  * zFolderMTest
  * @param string $path
  * @return array
  */
 protected static function zFolderMTest($path = '')
 {
     $aResp = array('status' => true, 'msg' => '');
     if ($path != '') {
         try {
             FilesFolders::createFolders($path);
         } catch (RuntimeException $e) {
             $aResp = array('status' => false, 'msg' => $e->getMessage());
         }
     }
     return $aResp;
 }
Exemplo n.º 8
0
<?php

/**
 * ATENÇÃO : Esse exemplo usa classe PROVISÓRIA que será removida assim que 
 * a nova classe DANFE estiver refatorada e a pasta EXTRAS será removida.
 */
error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once '../../bootstrap.php';
use NFePHP\Extras\Danfe;
use NFePHP\Common\Files\FilesFolders;
$chaveNotaFiscal = $_GET['chaveNotaFiscal'];
$logoLoja = $_GET['logoLoja'];
//var_dump($logoLoja);
//exit();
$xml = '../xml/' . $chaveNotaFiscal . '-nfe.xml';
$docxml = FilesFolders::readFile($xml);
$danfe = new Danfe($docxml, 'P', 'A4', '../../../../logos/' . $logoLoja, 'I', '');
$id = $danfe->montaDANFE();
$teste = $danfe->printDANFE($id . '.pdf', 'I');
Exemplo n.º 9
0
 /**
  * setTemplate
  * Carrega o arquivo html do template do email em um parametro da classe
  * @param type $pathFile
  */
 public function setTemplate($pathFile = '')
 {
     if (is_file($pathFile)) {
         $this->template = Files\FilesFolders::readFile($pathFile);
     }
 }
Exemplo n.º 10
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once '../../bootstrap.php';
use NFePHP\NFe\ToolsNFe;
use NFePHP\Extras\Danfce;
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 = 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);
$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
Exemplo n.º 11
0
 public function loadXMLFile($pathXmlFile = '')
 {
     $data = FilesFolders::readFile($pathXmlFile);
     $this->loadXMLString($data);
 }
Exemplo n.º 12
0
 /**
  * Grava as mensagens em disco
  *
  * @param string $data conteudo a ser gravado
  * @param string $filename
  * @param int $tpAmb
  * @param string $folder
  * @param string $subFolder
  * @throws RuntimeException
  */
 protected function gravaFile($data, $filename, $tpAmb = '2', $folder = '', $subFolder = '')
 {
     $anomes = date('Ym');
     $pathTemp = $folder . Files\FilesFolders::getAmbiente($tpAmb) . DIRECTORY_SEPARATOR . $subFolder . DIRECTORY_SEPARATOR . $anomes;
     if (!Files\FilesFolders::saveFile($pathTemp, $filename, $data)) {
         $msg = 'Falha na gravação no diretório. ' . $pathTemp;
         throw new RuntimeException($msg);
     }
 }
Exemplo n.º 13
0
$mailReplayToMail = '';
$mailReplayToName = '';
$mailImapHost = '';
$mailImapPort = '';
$mailImapSecurity = '';
$mailImapNocerts = '';
$mailImapBox = '';
$proxyIp = '';
$proxyPort = '';
$proxyUser = '';
$proxyPass = '';
$configfolder = PATH_NFEPHP . DIRECTORY_SEPARATOR . 'config';
$pathConfig = $configfolder . DIRECTORY_SEPARATOR . 'config.json';
$configureVer = '4.0';
if (is_file($pathConfig)) {
    $configJson = FilesFolders::readFile($pathConfig);
    $installConfig = json_decode($configJson);
    $tpAmb = isset($installConfig->tpAmb) ? $installConfig->tpAmb : '2';
    $pathXmlUrlFileNFe = isset($installConfig->pathXmlUrlFileNFe) ? $installConfig->pathXmlUrlFileNFe : '';
    $pathXmlUrlFileCTe = isset($installConfig->pathXmlUrlFileCTe) ? $installConfig->pathXmlUrlFileCTe : '';
    $pathXmlUrlFileMDFe = isset($installConfig->pathXmlUrlFileMDFe) ? $installConfig->pathXmlUrlFileMDFe : '';
    $pathXmlUrlFileCLe = isset($installConfig->pathXmlUrlFileCLe) ? $installConfig->pathXmlUrlFileCLe : '';
    $pathXmlUrlFileNFSe = isset($installConfig->pathXmlUrlFileNFSe) ? $installConfig->pathXmlUrlFileNFSe : '';
    $pathNFeFiles = isset($installConfig->pathNFeFiles) ? $installConfig->pathNFeFiles : '';
    $pathCTeFiles = isset($installConfig->pathCTeFiles) ? $installConfig->pathCTeFiles : '';
    $pathMDFeFiles = isset($installConfig->pathMDFeFiles) ? $installConfig->pathMDFeFiles : '';
    $pathCLeFiles = isset($installConfig->pathCLeFiles) ? $installConfig->pathCLeFiles : '';
    $pathNFSeFiles = isset($installConfig->pathNFSeFiles) ? $installConfig->pathNFSeFiles : '';
    $pathCertsFiles = isset($installConfig->pathCertsFiles) ? $installConfig->pathCertsFiles : '';
    $siteUrl = isset($installConfig->siteUrl) ? $installConfig->siteUrl : $siteUrl;
    $schemesNFe = isset($installConfig->schemesNFe) ? $installConfig->schemesNFe : '';
Exemplo n.º 14
0
 /**
  * verificaValidade
  * Verifica a validade de uma NFe recebida
  * @param string $pathXmlFile
  * @param array $aRetorno
  * @return boolean
  * @throws Exception\InvalidArgumentException
  */
 public function verificaValidade($pathXmlFile = '', &$aRetorno = array())
 {
     $aRetorno = array();
     if (!file_exists($pathXmlFile)) {
         $msg = "Arquivo não localizado!!";
         throw new Exception\InvalidArgumentException($msg);
     }
     //carrega a NFe
     $xml = Files\FilesFolders::readFile($pathXmlFile);
     $this->oCertificate->verifySignature($xml, 'infNFe');
     //obtem o chave da NFe
     $docnfe = new Dom();
     $docnfe->loadXMLFile($pathXmlFile);
     $tpAmb = $docnfe->getNodeValue('tpAmb');
     $chNFe = $docnfe->getChave('infNFe');
     $this->sefazConsultaChave($chNFe, $tpAmb, $aRetorno);
     if ($aRetorno['cStat'] != '100' && $aRetorno['cStat'] != '150') {
         return false;
     }
     return true;
 }
Exemplo n.º 15
0
 /**
  * zCancela
  * Edita a NFe recebida de terceiros indicando o cancelamento
  * @param string $pathFile
  */
 private static function zCancela($pathFile)
 {
     if (is_file($pathFile)) {
         //o arquivo foi localizado, então indicar o cancelamento
         //editando o xml da NFe e substituindo o cStat do protocolo por
         //135 ou 101
         $xml = FilesFolders::readFile($pathFile);
         $nfe = new \DOMDocument();
         $nfe->loadXML($xml);
         $infProt = $nfe->getElementsByTagName('infProt')->item(0);
         $infProt->getElementsByTagName('cStat')->item(0)->nodeValue = '101';
         $nfe->save($pathFile);
     }
 }
Exemplo n.º 16
0
include_once '../bootstrap.php';
use App\DFe;
use NFePHP\Common\Files\FilesFolders;
/**
 * Rotina para manifestar os resumos selecionados
 * 
 * @category   Application
 * @package    robmachado\teste
 * @copyright  Copyright (c) 2008-2015
 * @license    http://www.gnu.org/licenses/lesser.html LGPL v3
 * @author     Roberto L. Machado <linux.rlm at gmail dot com>
 * @link       http://github.com/robmachado/teste for the canonical source repository
 */
$lista = isset($_REQUEST['lista']) ? $_REQUEST['lista'] : array();
$aLista = explode(',', $lista);
$configJson = FilesFolders::readFile('../config/config.json');
$objConfig = json_decode($configJson);
//estabelece o ambiente
$ambiente = 'homologacao';
if ($objConfig->tpAmb == '1') {
    $ambiente = 'producao';
}
$caminho = 'recebidas' . DIRECTORY_SEPARATOR . 'resumo';
$path = $objConfig->pathNFeFiles . DIRECTORY_SEPARATOR . $ambiente . DIRECTORY_SEPARATOR . $caminho;
$dfe = new DFe('../config/config.json');
$aInv = array_flip($aLista);
foreach ($aLista as $res) {
    //a lista pode conter varios tipos de arquivos
    //se for uma chave de 44 digitos manifestar
    //caso não seja isso então é um nome de arquivo então remover apenas
    if (is_numeric($res)) {
Exemplo n.º 17
0
$mailProtocol = filter_input(INPUT_GET, 'mailProtocol', FILTER_SANITIZE_STRING);
$mailPort = filter_input(INPUT_GET, 'mailPort', FILTER_SANITIZE_NUMBER_INT);
$mailFromMail = filter_input(INPUT_GET, 'mailFromMail', FILTER_VALIDATE_EMAIL);
$mailFromName = filter_input(INPUT_GET, 'mailFromName', FILTER_SANITIZE_STRING);
$mailReplayToMail = filter_input(INPUT_GET, 'mailReplayToMail', FILTER_VALIDATE_EMAIL);
$mailReplayToName = filter_input(INPUT_GET, 'mailReplayToName', FILTER_SANITIZE_STRING);
$mailImapHost = filter_input(INPUT_GET, 'mailImapHost', FILTER_SANITIZE_URL);
$mailImapPort = filter_input(INPUT_GET, 'mailImapPort', FILTER_SANITIZE_NUMBER_INT);
$mailImapSecurity = filter_input(INPUT_GET, 'mailImapSecurity', FILTER_SANITIZE_STRING);
$mailImapNocerts = filter_input(INPUT_GET, 'mailImapNocerts');
$mailImapBox = filter_input(INPUT_GET, 'mailImapBox', FILTER_SANITIZE_STRING);
$proxyIp = filter_input(INPUT_GET, 'proxyIp', FILTER_SANITIZE_STRING);
$proxyPort = filter_input(INPUT_GET, 'proxyPort', FILTER_SANITIZE_NUMBER_INT);
$proxyUser = filter_input(INPUT_GET, 'proxyUser', FILTER_SANITIZE_STRING);
$proxyPass = filter_input(INPUT_GET, 'proxyPass', FILTER_SANITIZE_STRING);
$aDocFormat = array('format' => $format, 'paper' => $paper, 'southpaw' => $southpaw, 'pathLogoFile' => $pathLogoFile, 'logoPosition' => $logoPosition, 'font' => $font, 'printer' => $printer);
$aMailConf = array('mailAuth' => $mailAuth, 'mailFrom' => $mailFrom, 'mailSmtp' => $mailSmtp, 'mailUser' => $mailUser, 'mailPass' => $mailPass, 'mailProtocol' => $mailProtocol, 'mailPort' => $mailPort, 'mailFromMail' => $mailFromMail, 'mailFromName' => $mailFromName, 'mailReplayToMail' => $mailReplayToMail, 'mailReplayToName' => $mailReplayToName, 'mailImapHost' => $mailImapHost, 'mailImapPort' => $mailImapPort, 'mailImapSecurity' => $mailImapSecurity, 'mailImapNocerts' => $mailImapNocerts, 'mailImapBox' => $mailImapBox);
$aProxyConf = array('proxyIp' => $proxyIp, 'proxyPort' => $proxyPort, 'proxyUser' => $proxyUser, 'proxyPass' => $proxyPass);
$aConfig = array('atualizacao' => date('Y-m-d h:i:s'), 'tpAmb' => $tpAmb, 'pathXmlUrlFileNFe' => $pathXmlUrlFileNFe, 'pathXmlUrlFileCTe' => $pathXmlUrlFileCTe, 'pathXmlUrlFileMDFe' => $pathXmlUrlFileMDFe, 'pathXmlUrlFileCLe' => $pathXmlUrlFileCLe, 'pathXmlUrlFileNFSe' => $pathXmlUrlFileNFSe, 'pathNFeFiles' => $pathNFeFiles, 'pathCTeFiles' => $pathCTeFiles, 'pathMDFeFiles' => $pathMDFeFiles, 'pathCLeFiles' => $pathCLeFiles, 'pathNFSeFiles' => $pathNFSeFiles, 'pathCertsFiles' => $pathCertsFiles, 'siteUrl' => $siteUrl, 'schemesNFe' => $schemesNFe, 'schemesCTe' => $schemesCTe, 'schemesMDFe' => $schemesMDFe, 'schemesCLe' => $schemesCLe, 'schemesNFSe' => $schemesNFSe, 'razaosocial' => $razaosocial, 'siglaUF' => $siglaUF, 'cnpj' => $cnpj, 'tokenIBPT' => $tokenIBPT, 'tokenNFCe' => $tokenNFCe, 'tokenNFCeId' => $tokenNFCeId, 'certPfxName' => $certPfxName, 'certPassword' => $certPassword, 'certPhrase' => $certPhrase, 'aDocFormat' => $aDocFormat, 'aMailConf' => $aMailConf, 'aProxyConf' => $aProxyConf);
$content = json_encode($aConfig);
$msg = 'SUCESSO !! arquivo de configuração confg.json SALVO.';
if (!($resdefault = FilesFolders::saveFile($defaultconfigfolder, 'config.json', $content))) {
    $msg = "Falha ao salvar o config.json na pasta {$defaultconfigfolder} \n";
}
if ($configfolder != $defaultconfigfolder) {
    if (!($res = FilesFolders::saveFile($configfolder, 'config.json', $content))) {
        $msg = "Falha ao salvar o config.json na pasta {$configfolder} \n";
    }
}
$aResp = array('status' => $resdefault && $res, 'msg' => $msg);
print json_encode($aResp);
Exemplo n.º 18
0
 /**
  * @dataProvider ambientes
  */
 public function testDeveRetornarSempreAmbienteDeProducaoCasoNaoForInformadoUmParametroValido($ambientes)
 {
     $files = new FilesFolders();
     $this->assertEquals('producao', $files->getAmbiente($ambientes));
 }
Exemplo n.º 19
0
 /**
  *Método que faz o download da DANFE
  *
  * @name 	gerarDANFE
  * @access	public
  * @author	Roberson Faria
  * @param 	Numeric $customer_id
  * @param 	String $arquivo Caminho para o arquivo xml
  * @param   Char $tipoDownload Defini o tipo do download do arquivo "I" - abre o pdf no browser "D" - faz o download do PDF para a maquina do cliente.
  */
 public function printDanfe($arquivo, $tipoDownload = "I")
 {
     $dxml = base64_decode($arquivo);
     $logo = 'images/logo.jpg';
     if (strpos($arquivo, 'recebidas')) {
         $logo = '';
     }
     $docxml = FilesFolders::readFile($arquivo);
     $danfe = new Danfe($docxml, 'P', 'A4', $logo, $tipoDownload, '');
     $id = $danfe->montaDANFE();
     $danfe->printDANFE($id . '.pdf', $tipoDownload);
 }
Exemplo n.º 20
0
use NFePHP\Common\Files\FilesFolders;
use NFePHP\Common\Exception\InvalidArgumentException;
//carrega os dados de configuração
$configJson = FilesFolders::readFile('../config/config.json');
$objConfig = json_decode($configJson);
//estabelece o ambiente
$ambiente = 'homologacao';
if ($objConfig->tpAmb == '1') {
    $ambiente = 'producao';
}
//cria uma lista vazia
$aList = array();
$caminho = 'recebidas' . DIRECTORY_SEPARATOR . 'resumo';
$path = $objConfig->pathNFeFiles . DIRECTORY_SEPARATOR . $ambiente . DIRECTORY_SEPARATOR . $caminho;
try {
    $aList = FilesFolders::listDir($path, '*.xml', true);
} catch (InvalidArgumentException $exc) {
    $mensagem = $exc->getMessage();
}
$aDados = Dados::extraiResumo($aList);
$lista = '<form>';
$lista .= '<table width="75%"><thead><tr><th></th><th class=\\"border\\" data-sort=\\"int\\">NFe Número</th><th class=\\"border\\" data-sort=\\"string\\">Emitente</th><th class=\\"border\\" data-sort=\\"string\\">Data</th><th>Valor</th></tr></thead><tbody>';
$iCount = 0;
foreach ($aDados as $res) {
    $chkChave = "chk";
    $lista .= '<tr class=\\"dados\\">' . '<td><input type="checkbox" name="' . $chkChave . '" id="' . $chkChave . '" value="' . $res['chNFe'] . '" ></td>' . '<td class="center">' . substr($res['chNFe'], 25, 9) . '</td>' . '<td class="left">' . $res['xNome'] . '</td>' . '<td class="center">' . $res['dhEmi'] . '</td>' . '<td class="right">R$ ' . number_format($res['vNF'], 2, ',', '.') . '</td>' . '</tr>';
}
$lista .= '<tr><td colspan="4"><input type="button" value="Manifestar" onClick="manifestar();"></td></tr>';
$lista .= '</tbody></table></form>';
$html = "<!DOCTYPE html>\n<html>\n    <head>\n        <title>Resumos das Notas Fiscais</title>\n        <meta charset=\"UTF-8\">\n        <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n        <script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>\n        <script src=\"resources/stupidtable.js?dev\"></script>\n        <link rel=\"stylesheet\" type=\"text/css\" href=\"css/teste.css\">\n        <script>\n        \$(function() {\n            //Helper function para valores formatados em R\$\n            var valor_from_string = function(str) {\n                var newstr = str.replace(/(\\t*) */g, '');\n                newstr = newstr.replace(/[A-Z]/g, '');\n                newstr = newstr.replace(/[\$]/g, '');\n                newstr = newstr.replace(/\\./g, '');\n                newstr = newstr.replace(/[,]/g, '.');\n                var valor = parseInt(newstr)*100;\n                return valor;\n            }\n            var table = \$(\"table\").stupidtable({\n                \"valor\": function(a,b) {\n                    // Get these into int objects for comparison.\n                    aVal = valor_from_string(a);\n                    bVal = valor_from_string(b);\n                    return aVal - bVal;\n                }\n            });\n            table.on(\"beforetablesort\", function (event, data) {\n                // Apply a \"disabled\" look to the table while sorting.\n                // Using addClass for testing as it takes slightly longer to render.\n                \$(\"#msg\").text(\"Organizando a tabela ...\");\n                \$(\"table\").addClass(\"disabled\");\n            });\n            table.on(\"aftertablesort\", function (event, data) {\n                // Reset loading message.\n                \$(\"#msg\").html(\"&nbsp;\");\n                \$(\"table\").removeClass(\"disabled\");\n                var th = \$(this).find(\"th\");\n                th.find(\".arrow\").remove();\n                var dir = \$.fn.stupidtable.dir;\n                var arrow = data.direction === dir.ASC ? \"&uarr;\" : \"&darr;\";\n                th.eq(data.column).append('<span class=\"arrow\">' + arrow +'</span>');\n            });\n        });    \n        </script>\n        <script>\n        function OpenWindowWithPost(url, windowoption, name, params) {\n            var form = document.createElement(\"form\");\n            form.setAttribute(\"method\", \"post\");\n            form.setAttribute(\"action\", url);\n            form.setAttribute(\"target\", name);\n             for (var i in params) {\n                if (params.hasOwnProperty(i)) {\n                    var input = document.createElement('input');\n                    input.type = 'hidden';\n                    input.name = i;\n                    input.value = params[i];\n                    form.appendChild(input);\n                }\n            }\n            document.body.appendChild(form);\n            window.open(\"\", name, windowoption);\n            form.submit();\n            document.body.removeChild(form);\n        }\n        function manifestar() {\n            var url = 'manifestarmarcadas.php';\n            var name = 'page';\n            var lista = [];\n            var x = 0;\n            var specs = 'scrollbars=no,menubar=no,height=260,width=650,resizable=yes,toolbar=no,status=no';\n            var checkboxes = document.getElementsByName('chk');\n            for (var i= 0; i < checkboxes.length; i++) {\n                if (checkboxes[i].checked) {\n                    lista[x] = checkboxes[i].value;\n                    x++;\n                }\n            }\n            var param = {'lista' : lista};\n            OpenWindowWithPost(url, specs, name, param);\t\t\n        }\n        </script>\n    </head>\n    <body>\n    <div class=\"container\">\n        <center>\n        <h2>Resumos de Notas</h2>\n        <h3>Estas notas foram emitidas contra nós e podem ser maifestadas para permitir seu download</h3>\n        <h3>Selecione e manifeste a ciencia dessa operação.</h3>\n        {$lista}\n        </center>    \n    </div>\n    </body>\n</html>";
echo $html;
Exemplo n.º 21
0
 /**
  * gravaXML
  * grava o xml do documento fiscal na estrutura de pastas
  * em path indicar por exemplo /var/www/nfe ou /dados/cte ou /arquivo/mdfe
  * ou seja as pastas principais onde guardar os arquivos
  * Esse método itá colocar na subpastas [producao] ou [homologacao]
  * na subpasta [entradas] e na subpasta [ANOMES]
  *
  * @param  string $path
  * @return boolean
  */
 public function gravaXML($path = '')
 {
     //pode ser NFe, CTe, MDFe e pode ser homologação ou produção
     //essas informações estão dentro do xml
     if ($path == '') {
         return false;
     }
     if (!is_dir($path)) {
         return false;
     }
     if (substr($path, -1) == DIRECTORY_SEPARATOR) {
         $path = substr($path, 0, strlen($path) - 1);
     }
     $aResp = array();
     $aList = array('NFe' => 'nfe', 'CTe' => 'cte', 'MDFe' => 'mdfe');
     Identify::setListSchemesId($aList);
     $schem = Identify::identificacao($this->xml, $aResp);
     if ($aResp['chave'] == '') {
         return false;
     }
     $filename = $aResp['chave'] . '-' . $schem . '.xml';
     $dirBase = 'homologacao';
     if ($aResp['tpAmb'] == '1') {
         $dirBase = 'producao';
     }
     $aDh = explode('-', $aResp['dhEmi']);
     $anomes = date('Ym');
     if (count($aDh) > 1) {
         $anomes = $aDh[0] . $aDh[1];
     }
     $completePath = $path . DIRECTORY_SEPARATOR . $dirBase . DIRECTORY_SEPARATOR . 'entradas' . DIRECTORY_SEPARATOR . $anomes;
     $content = $this->xml;
     if (!FilesFolders::saveFile($completePath, $filename, $content)) {
         return false;
     }
     return true;
 }