/** * Gerar HTML da Danfe. * * @return string * @throws \Exception */ public function getHTML() { ob_start(); try { $evento = XML::createByXml($this->nfeXml->getElementsByTagName('infEvento')->item(0)->C14N()); $retEvento = XML::createByXml($this->nfeXml->getElementsByTagName('infEvento')->item(1)->C14N()); $info = $this->nfeXml->getChaveInfo('infEvento', 'ID'); $logo = $this->getLogo(); $barcode = $this->getBarCode($evento); $style = $this->files->get(__DIR__ . '/Templates/pdf.css'); require __DIR__ . '/Templates/danfe.php'; return ob_get_clean(); } catch (\Exception $e) { ob_end_clean(); throw $e; } }
/** * Gerar HTML da Danfe. * * @return string * @throws \Exception */ public function getHTML() { ob_start(); try { $nfe = XML::createByXml($this->nfeXml->getElementsByTagName('infNFe')->item(0)->C14N()); $prot = XML::createByXml($this->nfeXml->getElementsByTagName('protNFe')->item(0)->C14N()); $logo = $this->getLogo(); $barcode = $this->getBarCode($nfe); $homolog = $this->getImageHomolog(); $style = $this->files->get(__DIR__ . '/Templates/pdf.css'); $style = str_replace('{{homolog}}', $homolog, $style); require __DIR__ . '/Templates/danfe.php'; return ob_get_clean(); } catch (\Exception $e) { ob_end_clean(); throw $e; } }
/** * Fazer requisição SOAP. * * @param MethodSefaz $method * @param $header * @param $body * @return DOMDocument * @throws \Exception */ protected function soap(MethodSefaz $method, $header, $body) { $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid(); try { // Criar diretorio temporario. $this->file->makeDirectory($dir); // Salvar certificados na pasta temp criada. $this->certificado->salvaChave($dir); $client = new Soap\CurlSoap($dir . '/pri.key', $dir . '/pub.key', $dir . '/cert.key'); $resp = $client->send($method->url, $method->getNamespace(), $header, $body, $method->method); $xml = XML::createByXml($resp); $this->file->deleteDirectory($dir); return $xml; } catch (\Exception $e) { $this->file->deleteDirectory($dir); throw $e; } }
/** * Retorna o primeiro child. * * @return XML */ public function first() { return XML::createByXml($this->elem->firstChild->C14N()); }