1 | <?php |
||
36 | class NFCe extends Nota |
||
37 | { |
||
38 | |||
39 | const QRCODE_VERSAO = '100'; |
||
40 | |||
41 | private $consulta_url; |
||
42 | |||
43 | 7 | public function __construct($nfce = array()) |
|
49 | |||
50 | 4 | public function getConsultaURL($normalize = false) |
|
57 | |||
58 | 7 | public function setConsultaURL($consulta_url) |
|
63 | |||
64 | 2 | public function toArray() |
|
70 | |||
71 | 7 | public function fromArray($nfce = array()) |
|
72 | { |
||
73 | 7 | if ($nfce instanceof NFCe) { |
|
74 | 2 | $nfce = $nfce->toArray(); |
|
75 | 7 | } elseif (!is_array($nfce)) { |
|
76 | 2 | return $this; |
|
77 | } |
||
78 | 7 | parent::fromArray($nfce); |
|
79 | 7 | if (isset($nfce['consulta_url'])) { |
|
80 | $this->setConsultaURL($nfce['consulta_url']); |
||
81 | } else { |
||
82 | 7 | $this->setConsultaURL(null); |
|
83 | } |
||
84 | 7 | return $this; |
|
85 | } |
||
86 | |||
87 | 3 | private function gerarQRCodeInfo(&$dom) |
|
88 | { |
||
89 | 3 | $config = SEFAZ::getInstance()->getConfiguracao(); |
|
90 | 3 | $totais = $this->getTotais(); |
|
91 | 3 | $digest = $dom->getElementsByTagName('DigestValue')->item(0); |
|
92 | // if($this->getEmissao() == self::EMISSAO_NORMAL) |
||
93 | 3 | $dig_val = $digest->nodeValue; |
|
94 | // else |
||
95 | // $dig_val = base64_encode(sha1($dom->saveXML(), true)); |
||
96 | $params = array( |
||
97 | 3 | 'chNFe' => $this->getID(), |
|
98 | 3 | 'nVersao' => self::QRCODE_VERSAO, |
|
99 | 3 | 'tpAmb' => $this->getAmbiente(true), |
|
100 | 3 | 'cDest' => null, |
|
101 | 3 | 'dhEmi' => Util::toHex($this->getDataEmissao(true)), |
|
102 | 3 | 'vNF' => Util::toCurrency($totais['nota']), |
|
103 | 3 | 'vICMS' => Util::toCurrency($totais[Imposto::GRUPO_ICMS]), |
|
104 | 3 | 'digVal' => Util::toHex($dig_val), |
|
105 | 3 | 'cIdToken' => Util::padDigit($config->getToken(), 6), |
|
106 | 'cHashQRCode' => null |
||
107 | 3 | ); |
|
108 | 3 | if (!is_null($this->getDestinatario())) { |
|
109 | 3 | $params['cDest'] = $this->getDestinatario()->getID(true); |
|
110 | 3 | } else { |
|
111 | unset($params['cDest']); |
||
112 | } |
||
113 | 3 | $_params = $params; |
|
114 | 3 | unset($_params['cHashQRCode']); |
|
115 | 3 | $query = http_build_query($_params); |
|
116 | 3 | $params['cHashQRCode'] = sha1($query.$config->getCSC()); |
|
117 | 3 | return $params; |
|
118 | } |
||
119 | |||
120 | 3 | private function checkQRCode(&$dom) |
|
134 | |||
135 | 3 | private function getNodeSuplementar(&$dom) |
|
145 | |||
146 | 3 | public function loadNode($element, $name = null) |
|
160 | |||
161 | /** |
||
162 | * Assina e adiciona informações suplementares da nota |
||
163 | */ |
||
164 | 3 | public function assinar($dom = null) |
|
172 | } |
||
173 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.