public function __construct($docXML = '', $sOrientacao = '', $sPapel = '', $sPathLogo = '', $sDestino = 'I', $sDirPDF = '', $fonteDANFE = '', $mododebug = 2)
{
//verificacao temporária de segurança apenas para alertar se tentar instanciar
//a classe com 9 parâmetros, pois o "$exibirPIS" foi removido em 20/08/2014
// e parametrizado como atributo público para simplificar o construtor
if (func_num_args() == 9) {
throw new NfephpException("ATENCAO: o construtor da classe DanfeNFePHP nao possui mais 9 parametros");
}
if (is_numeric($mododebug)) {
$this->debugMode = $mododebug;
}
if ($mododebug == 1) {
//ativar modo debug
error_reporting(E_ALL);
ini_set('display_errors', 'On');
}
if ($mododebug == 0) {
//desativar modo debug
error_reporting(0);
ini_set('display_errors', 'Off');
}
$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;
}
//se for passado o xml
if (!empty($this->xml)) {
$this->dom = new DomDocumentNFePHP();
$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->entrega = $this->dom->getElementsByTagName("entrega")->item(0);
$this->retirada = $this->dom->getElementsByTagName("retirada")->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->reboque = $this->dom->getElementsByTagName("reboque")->item(0);
$this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0);
$this->compra = $this->dom->getElementsByTagName("compra")->item(0);
$this->tpEmis = $this->ide->getElementsByTagName("tpEmis")->item(0)->nodeValue;
$this->tpImp = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue;
$this->infProt = $this->dom->getElementsByTagName("infProt")->item(0);
//valida se o XML é uma NF-e modelo 55, pois não pode ser 65 (NFC-e)
if ($this->pSimpleGetValue($this->ide, "mod") != '55') {
throw new NfephpException("O xml do DANFE deve ser uma NF-e modelo 55");
}
}
}