Complex classes like Danfce often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Danfce, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 23 | class Danfce extends Common |
||
| 24 | { |
||
| 25 | protected $papel; |
||
| 26 | protected $xml; // string XML NFe |
||
| 27 | protected $logomarca=''; // path para logomarca em jpg |
||
| 28 | protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####"; |
||
| 29 | protected $debugMode=0; //ativa ou desativa o modo de debug |
||
| 30 | protected $tpImp; //ambiente |
||
| 31 | protected $fontePadrao='Times'; |
||
| 32 | protected $nfeProc; |
||
| 33 | protected $nfe; |
||
| 34 | protected $infNFe; |
||
| 35 | protected $ide; |
||
| 36 | protected $enderDest; |
||
| 37 | protected $ICMSTot; |
||
| 38 | protected $imposto; |
||
| 39 | protected $emit; |
||
| 40 | protected $enderEmit; |
||
| 41 | protected $qrCode; |
||
| 42 | protected $det; |
||
| 43 | protected $infAdic; |
||
| 44 | protected $textoAdic; |
||
| 45 | protected $pag; |
||
| 46 | protected $dest; |
||
| 47 | protected $imgQRCode; |
||
| 48 | protected $urlQR = ''; |
||
| 49 | protected $pdf; |
||
| 50 | protected $margemInterna = 2; |
||
| 51 | protected $hMaxLinha = 9; |
||
| 52 | protected $hBoxLinha = 6; |
||
| 53 | protected $hLinha = 3; |
||
| 54 | /* |
||
| 55 | * Retorna a sigla da UF |
||
| 56 | * @var string |
||
| 57 | */ |
||
| 58 | protected $UFSigla = [ |
||
| 59 | '12' => 'AC', |
||
| 60 | '27' => 'AL', |
||
| 61 | '13' => 'AM', |
||
| 62 | '16' => 'AP', |
||
| 63 | '29' => 'BA', |
||
| 64 | '23' => 'CE', |
||
| 65 | '53' => 'DF', |
||
| 66 | '32' => 'ES', |
||
| 67 | '52' => 'GO', |
||
| 68 | '31' => 'MG', |
||
| 69 | '50' => 'MS', |
||
| 70 | '51' => 'MT', |
||
| 71 | '21' => 'MA', |
||
| 72 | '15' => 'PA', |
||
| 73 | '25' => 'PB', |
||
| 74 | '26' => 'PE', |
||
| 75 | '22' => 'PI', |
||
| 76 | '41' => 'PR', |
||
| 77 | '33' => 'RJ', |
||
| 78 | '11' => 'RO', |
||
| 79 | '24' => 'RN', |
||
| 80 | '14' => 'RR', |
||
| 81 | '43' => 'RS', |
||
| 82 | '42' => 'SC', |
||
| 83 | '28' => 'SE', |
||
| 84 | '35' => 'SP', |
||
| 85 | '17' => 'TO' |
||
| 86 | ]; |
||
| 87 | /* |
||
| 88 | * Fonte: http://nfce.encat.org/consumidor/consulte-sua-nota/ |
||
| 89 | * URL referente a pagina de consulta da NFCe pela chave de acesso |
||
| 90 | * @var string |
||
| 91 | */ |
||
| 92 | protected $urlConsulta = [ |
||
| 93 | '1' => [ |
||
| 94 | 'AC' => 'www.sefaznet.ac.gov.br/nfce/consulta', |
||
| 95 | 'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm', |
||
| 96 | 'AP' => 'https://www.sefaz.ap.gov.br/sate/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261', |
||
| 97 | 'AM' => 'sistemas.sefaz.am.gov.br/nfceweb/formConsulta.do', |
||
| 98 | 'BA' => 'nfe.sefaz.ba.gov.br/servicos/nfce/default.aspx', |
||
| 99 | 'CE' => '', |
||
| 100 | 'DF' => 'http://dec.fazenda.df.gov.br/NFCE/', |
||
| 101 | 'ES' => 'http://app.sefaz.es.gov.br/ConsultaNFCe', |
||
| 102 | 'GO' => '', |
||
| 103 | 'MA' => 'http://www.nfce.sefaz.ma.gov.br/portal/consultaNFe.do?method=preFilterCupom&', |
||
| 104 | 'MT' => 'http://www.sefaz.mt.gov.br/nfce/consultanfce', |
||
| 105 | 'MS' => 'http://www.dfe.ms.gov.br/nfce', |
||
| 106 | 'MG' => '', |
||
| 107 | 'PA' => 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam', |
||
| 108 | 'PB' => 'www.receita.pb.gov.br/nfce', |
||
| 109 | 'PR' => 'http://www.fazenda.pr.gov.br', |
||
| 110 | 'PE' => '', |
||
| 111 | 'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb/consultarNFCe.jsf', |
||
| 112 | 'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta', |
||
| 113 | 'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx', |
||
| 114 | 'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx', |
||
| 115 | 'RO' => 'http://www.nfce.sefin.ro.gov.br', |
||
| 116 | 'RR' => 'https://www.sefaz.rr.gov.br/nfce/servlet/wp_consulta_nfce', |
||
| 117 | 'SC' => '', |
||
| 118 | 'SP' => 'https://www.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx', |
||
| 119 | 'SE' => 'http://www.nfce.se.gov.br/portal/portalNoticias.jsp', |
||
| 120 | 'TO' => '' |
||
| 121 | ], |
||
| 122 | '2' => [ |
||
| 123 | 'AC' => 'http://hml.sefaznet.ac.gov.br/nfce/consulta', |
||
| 124 | 'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm', |
||
| 125 | 'AP' => 'https://www.sefaz.ap.gov.br/sate1/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261', |
||
| 126 | 'AM' => 'homnfce.sefaz.am.gov.br/nfceweb/formConsulta.do', |
||
| 127 | 'BA' => 'http://hnfe.sefaz.ba.gov.br/servicos/nfce/default.aspx', |
||
| 128 | 'CE' => 'http://nfceh.sefaz.ce.gov.br/pages/consultaNota.jsf', |
||
| 129 | 'DF' => 'http://dec.fazenda.df.gov.br/NFCE/', |
||
| 130 | 'ES' => 'http://homologacao.sefaz.es.gov.br/ConsultaNFCe', |
||
| 131 | 'GO' => '', |
||
| 132 | 'MA' => 'http://www.hom.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp', |
||
| 133 | 'MT' => 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce', |
||
| 134 | 'MS' => 'http://www.dfe.ms.gov.br/nfce', |
||
| 135 | 'MG' => '', |
||
| 136 | 'PA' => 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/consultanfce.seam', |
||
| 137 | 'PB' => '', |
||
| 138 | 'PR' => 'http://www.fazenda.pr.gov.br', |
||
| 139 | 'PE' => '', |
||
| 140 | 'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb-homologacao/consultarNFCe.jsf', |
||
| 141 | 'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta', |
||
| 142 | 'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx', |
||
| 143 | 'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx', |
||
| 144 | 'RO' => 'http://www.nfce.sefin.ro.gov.br', |
||
| 145 | 'RR' => 'http://200.174.88.103:8080/nfce/servlet/wp_consulta_nfce', |
||
| 146 | 'SC' => '', |
||
| 147 | 'SP' => 'https://www.homologacao.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx', |
||
| 148 | 'SE' => 'http://www.hom.nfe.se.gov.br/portal/portalNoticias.jsp', |
||
| 149 | 'TO' => '' |
||
| 150 | ], |
||
| 151 | ]; |
||
| 152 | /** |
||
| 153 | * __contruct |
||
| 154 | * |
||
| 155 | * @param string $docXML |
||
| 156 | * @param string $sPathLogo |
||
| 157 | * @param string $mododebug |
||
| 158 | * @param string $idToken |
||
| 159 | * @param string $Token |
||
|
|
|||
| 160 | */ |
||
| 161 | public function __construct( |
||
| 162 | $docXML = '', |
||
| 163 | $sPathLogo = '', |
||
| 164 | $mododebug = 0, |
||
| 165 | // habilita os erros do sistema |
||
| 166 | $idToken = '', |
||
| 167 | $emitToken = '', |
||
| 168 | $urlQR = '' |
||
| 169 | ) { |
||
| 170 | if (is_numeric($mododebug)) { |
||
| 171 | $this->debugMode = $mododebug; |
||
| 172 | } |
||
| 173 | if ($this->debugMode) { |
||
| 174 | //ativar modo debug |
||
| 175 | error_reporting(E_ALL); |
||
| 176 | ini_set('display_errors', 'On'); |
||
| 177 | } else { |
||
| 178 | //desativar modo debug |
||
| 179 | error_reporting(0); |
||
| 180 | ini_set('display_errors', 'Off'); |
||
| 181 | } |
||
| 182 | $this->xml = $docXML; |
||
| 183 | $this->logomarca = $sPathLogo; |
||
| 184 | if (empty($fonteDANFE)) { |
||
| 185 | $this->fontePadrao = 'Times'; |
||
| 186 | } else { |
||
| 187 | $this->fontePadrao = $fonteDANFE; |
||
| 188 | } |
||
| 189 | if (!empty($this->xml)) { |
||
| 190 | $this->dom = new Dom(); |
||
| 191 | $this->dom->loadXML($this->xml); |
||
| 192 | $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0); |
||
| 193 | $this->nfe = $this->dom->getElementsByTagName("NFe")->item(0); |
||
| 194 | $this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0); |
||
| 195 | $this->ide = $this->dom->getElementsByTagName("ide")->item(0); |
||
| 196 | $this->emit = $this->dom->getElementsByTagName("emit")->item(0); |
||
| 197 | $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0); |
||
| 198 | $this->det = $this->dom->getElementsByTagName("det"); |
||
| 199 | $this->dest = $this->dom->getElementsByTagName("dest")->item(0); |
||
| 200 | $this->imposto = $this->dom->getElementsByTagName("imposto")->item(0); |
||
| 201 | $this->ICMSTot = $this->dom->getElementsByTagName("ICMSTot")->item(0); |
||
| 202 | $this->tpImp = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue; |
||
| 203 | $this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0); |
||
| 204 | |||
| 205 | //se for o layout 4.0 busca pelas tags de detalhe do pagamento |
||
| 206 | //senao, busca pelas tags de pagamento principal |
||
| 207 | if ($this->infNFe->getAttribute("versao") == "4.00") { |
||
| 208 | $this->pag = $this->dom->getElementsByTagName("detPag"); |
||
| 209 | } else { |
||
| 210 | $this->pag = $this->dom->getElementsByTagName("pag"); |
||
| 211 | } |
||
| 212 | } |
||
| 213 | $this->qrCode = $this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue; |
||
| 214 | if ($this->pSimpleGetValue($this->ide, "mod") != '65') { |
||
| 215 | throw new nfephpException("O xml do DANFE deve ser uma NFC-e modelo 65"); |
||
| 216 | } |
||
| 217 | } |
||
| 218 | |||
| 219 | public function getPapel() |
||
| 220 | { |
||
| 221 | return $this->papel; |
||
| 222 | } |
||
| 223 | |||
| 224 | public function setPapel($aPap) |
||
| 225 | { |
||
| 226 | $this->papel = $aPap; |
||
| 227 | } |
||
| 228 | |||
| 229 | public function monta( |
||
| 230 | $orientacao = 'P', |
||
| 231 | $papel = '', |
||
| 232 | $logoAlign = 'C', |
||
| 233 | $classPdf = false, |
||
| 234 | $depecNumReg = '' |
||
| 235 | ) { |
||
| 236 | $this->montaDANFE($orientacao, $papel, $logoAlign, $classPdf, $depecNumReg); |
||
| 237 | } |
||
| 238 | |||
| 239 | public function montaDANFE( |
||
| 240 | $orientacao = 'P', |
||
| 241 | $papel = '', |
||
| 242 | $logoAlign = 'C', |
||
| 243 | $classPdf = false, |
||
| 244 | $depecNumReg = '' |
||
| 245 | ) { |
||
| 246 | $qtdItens = $this->det->length; |
||
| 247 | $qtdPgto = $this->pag->length; |
||
| 248 | $hMaxLinha = $this->hMaxLinha; |
||
| 249 | $hBoxLinha = $this->hBoxLinha; |
||
| 250 | $hLinha = $this->hLinha; |
||
| 251 | $tamPapelVert = 160 + 16 + (($qtdItens - 1) * $hMaxLinha) + ($qtdPgto * $hLinha); |
||
| 252 | // verifica se existe informações adicionais |
||
| 253 | $this->textoAdic = ''; |
||
| 254 | if (isset($this->infAdic)) { |
||
| 255 | $this->textoAdic .= !empty($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue) ? |
||
| 256 | 'Inf. Contribuinte: '. |
||
| 257 | trim($this->pAnfavea($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue)) : ''; |
||
| 258 | if (!empty($this->textoAdic)) { |
||
| 259 | $tempPDF = new Pdf(); // cria uma instancia temporaria da class pdf |
||
| 260 | $tempPDF->SetFont('Times', '', '8'); // seta a font do PDF |
||
| 261 | $linhasCount = $tempPDF->WordWrap($this->textoAdic, 76); |
||
| 262 | //seta a quantidade de linhas que o texto vai ocupar |
||
| 263 | //e deixa uma folga para a margem bottom |
||
| 264 | $tamPapelVert += $linhasCount + ceil(2.9 * $linhasCount); |
||
| 265 | } |
||
| 266 | } |
||
| 267 | //se a orientação estiver em branco utilizar o padrão estabelecido na NF |
||
| 268 | if ($orientacao == '') { |
||
| 269 | $orientacao = 'P'; |
||
| 270 | } |
||
| 271 | $this->orientacao = $orientacao; |
||
| 272 | $this->papel = array(80,$tamPapelVert); |
||
| 273 | $this->logoAlign = $logoAlign; |
||
| 274 | //$this->situacao_externa = $situacaoExterna; |
||
| 275 | $this->numero_registro_dpec = $depecNumReg; |
||
| 276 | //instancia a classe pdf |
||
| 277 | if ($classPdf) { |
||
| 278 | $this->pdf = $classPdf; |
||
| 279 | } else { |
||
| 280 | $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
||
| 281 | } |
||
| 282 | //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à |
||
| 283 | //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui |
||
| 284 | //apenas para controle se necessário ser maior do que a margem superior |
||
| 285 | $margSup = 2; |
||
| 286 | $margEsq = 2; |
||
| 287 | $margInf = 2; |
||
| 288 | // posição inicial do conteúdo, a partir do canto superior esquerdo da página |
||
| 289 | $xInic = $margEsq; |
||
| 290 | $yInic = $margSup; |
||
| 291 | $maxW = 80; |
||
| 292 | $maxH = $tamPapelVert; |
||
| 293 | //total inicial de paginas |
||
| 294 | $totPag = 1; |
||
| 295 | //largura imprimivel em mm: largura da folha menos as margens esq/direita |
||
| 296 | $this->wPrint = $maxW-($margEsq*2); |
||
| 297 | //comprimento (altura) imprimivel em mm: altura da folha menos as margens |
||
| 298 | //superior e inferior |
||
| 299 | $this->hPrint = $maxH-$margSup-$margInf; |
||
| 300 | // estabelece contagem de paginas |
||
| 301 | $this->pdf->aliasNbPages(); |
||
| 302 | $this->pdf->setMargins($margEsq, $margSup); // fixa as margens |
||
| 303 | $this->pdf->setDrawColor(0, 0, 0); |
||
| 304 | $this->pdf->setFillColor(255, 255, 255); |
||
| 305 | $this->pdf->open(); // inicia o documento |
||
| 306 | $this->pdf->addPage($this->orientacao, $this->papel); // adiciona a primeira página |
||
| 307 | $this->pdf->setLineWidth(0.1); // define a largura da linha |
||
| 308 | $this->pdf->setTextColor(0, 0, 0); |
||
| 309 | $this->pTextBox(0, 0, $maxW, $maxH); // POR QUE PRECISO DESA LINHA? |
||
| 310 | $hcabecalho = 27;//para cabeçalho (dados emitente mais logomarca) (FIXO) |
||
| 311 | $hcabecalhoSecundario = 10;//para cabeçalho secundário (cabeçalho sefaz) (FIXO) |
||
| 312 | $hprodutos = $hLinha + ($qtdItens*$hMaxLinha) ;//box poduto |
||
| 313 | $hTotal = 12; //box total (FIXO) |
||
| 314 | $hpagamentos = $hLinha + ($qtdPgto*$hLinha);//para pagamentos |
||
| 315 | $hmsgfiscal = 21;// para imposto (FIXO) |
||
| 316 | if (!isset($this->dest)) { |
||
| 317 | $hcliente = 6;// para cliente (FIXO) |
||
| 318 | } else { |
||
| 319 | $hcliente = 12; |
||
| 320 | }// para cliente (FIXO)}; |
||
| 321 | $hQRCode = 50;// para qrcode (FIXO) |
||
| 322 | $hCabecItens = 4;//cabeçalho dos itens |
||
| 323 | |||
| 324 | $hUsado = $hCabecItens; |
||
| 325 | $w2 = round($this->wPrint*0.31, 0); |
||
| 326 | $totPag = 1; |
||
| 327 | $pag = 1; |
||
| 328 | $x = $xInic; |
||
| 329 | //COLOCA CABEÇALHO |
||
| 330 | $y = $yInic; |
||
| 331 | $y = $this->pCabecalhoDANFE($x, $y, $hcabecalho, $pag, $totPag); |
||
| 332 | //COLOCA CABEÇALHO SECUNDÁRIO |
||
| 333 | $y = $hcabecalho; |
||
| 334 | $y = $this->pCabecalhoSecundarioDANFE($x, $y, $hcabecalhoSecundario); |
||
| 335 | //COLOCA PRODUTOS |
||
| 336 | $y = $xInic + $hcabecalho + $hcabecalhoSecundario; |
||
| 337 | $y = $this->pProdutosDANFE($x, $y, $hprodutos); |
||
| 338 | //COLOCA TOTAL |
||
| 339 | $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos; |
||
| 340 | $y = $this->pTotalDANFE($x, $y, $hTotal); |
||
| 341 | //COLOCA PAGAMENTOS |
||
| 342 | $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal; |
||
| 343 | $y = $this->pPagamentosDANFE($x, $y, $hpagamentos); |
||
| 344 | //COLOCA MENSAGEM FISCAL |
||
| 345 | $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal+ $hpagamentos; |
||
| 346 | $y = $this->pFiscalDANFE($x, $y, $hmsgfiscal); |
||
| 347 | //COLOCA CONSUMIDOR |
||
| 348 | $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal + $hpagamentos + $hmsgfiscal; |
||
| 349 | $y = $this->pConsumidorDANFE($x, $y, $hcliente); |
||
| 350 | //COLOCA QRCODE |
||
| 351 | $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos |
||
| 352 | + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente; |
||
| 353 | $y = $this->pQRDANFE($x, $y, $hQRCode); |
||
| 354 | |||
| 355 | //adiciona as informações opcionais |
||
| 356 | if (!empty($this->textoAdic)) { |
||
| 357 | $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos |
||
| 358 | + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente + $hQRCode; |
||
| 359 | $hInfAdic = 0; |
||
| 360 | $y = $this->pInfAdic($x, $y, $hInfAdic); |
||
| 361 | } |
||
| 362 | |||
| 363 | //retorna o ID na NFe |
||
| 364 | if ($classPdf!==false) { |
||
| 365 | $aR = [ |
||
| 366 | 'id'=>str_replace('NFe', '', $this->infNFe->getAttribute("Id")), |
||
| 367 | 'classe_PDF'=>$this->pdf |
||
| 368 | ]; |
||
| 369 | return $aR; |
||
| 370 | } else { |
||
| 371 | return str_replace('NFe', '', $this->infNFe->getAttribute("Id")); |
||
| 372 | } |
||
| 373 | } |
||
| 374 | |||
| 375 | protected function pCabecalhoDANFE($x = 0, $y = 0, $h = 0, $pag = '1', $totPag = '1') |
||
| 376 | { |
||
| 377 | $emitRazao = $this->pSimpleGetValue($this->emit, "xNome"); |
||
| 378 | $emitCnpj = $this->pSimpleGetValue($this->emit, "CNPJ"); |
||
| 379 | $emitCnpj = $this->pFormat($emitCnpj, "##.###.###/####-##"); |
||
| 380 | $emitIE = $this->pSimpleGetValue($this->emit, "IE"); |
||
| 381 | $emitIM = $this->pSimpleGetValue($this->emit, "IM"); |
||
| 382 | $emitFone = $this->pSimpleGetValue($this->enderEmit, "fone"); |
||
| 383 | $foneLen = strlen($emitFone); |
||
| 384 | if ($foneLen>0) { |
||
| 385 | $ddd = substr($emitFone, 0, 2); |
||
| 386 | $fone1 = substr($emitFone, -8); |
||
| 387 | $digito9 = ' '; |
||
| 388 | if ($foneLen == 11) { |
||
| 389 | $digito9 = substr($emitFone, 2, 1); |
||
| 390 | } |
||
| 391 | $emitFone = ' - ('.$ddd.') '.$digito9. ' ' . substr($fone1, 0, 4) . '-' . substr($fone1, -4); |
||
| 392 | } else { |
||
| 393 | $emitFone = ''; |
||
| 394 | } |
||
| 395 | $emitLgr = $this->pSimpleGetValue($this->enderEmit, "xLgr"); |
||
| 396 | $emitNro = $this->pSimpleGetValue($this->enderEmit, "nro"); |
||
| 397 | $emitCpl = $this->pSimpleGetValue($this->enderEmit, "xCpl", ""); |
||
| 398 | $emitBairro = $this->pSimpleGetValue($this->enderEmit, "xBairro"); |
||
| 399 | $emitCEP = $this->pFormat($this->pSimpleGetValue($this->enderEmit, "CEP"), "#####-###"); |
||
| 400 | $emitMun = $this->pSimpleGetValue($this->enderEmit, "xMun"); |
||
| 401 | $emitUF = $this->pSimpleGetValue($this->enderEmit, "UF"); |
||
| 402 | // CONFIGURAÇÃO DE POSIÇÃO |
||
| 403 | $margemInterna = $this->margemInterna; |
||
| 404 | $maxW = $this->wPrint; |
||
| 405 | $h = $h-($margemInterna); |
||
| 406 | //COLOCA LOGOMARCA |
||
| 407 | if (is_file($this->logomarca)) { |
||
| 408 | $xImg = $margemInterna; |
||
| 409 | $yImg = $margemInterna + 1; |
||
| 410 | $this->pdf->Image($this->logomarca, $xImg, $yImg, 30, 22.5); |
||
| 411 | $xRs = ($maxW*0.4) + $margemInterna; |
||
| 412 | $wRs = ($maxW*0.6); |
||
| 413 | $alignEmit = 'L'; |
||
| 414 | } else { |
||
| 415 | $xRs = $margemInterna; |
||
| 416 | $wRs = ($maxW*1); |
||
| 417 | $alignEmit = 'L'; |
||
| 418 | } |
||
| 419 | //COLOCA RAZÃO SOCIAL |
||
| 420 | $texto = $emitRazao; |
||
| 421 | $texto = $texto . "\nCNPJ:" . $emitCnpj; |
||
| 422 | $texto = $texto . "\nIE:" . $emitIE; |
||
| 423 | if (!empty($emitIM)) { |
||
| 424 | $texto = $texto . " - IM:" . $emitIM; |
||
| 425 | } |
||
| 426 | $texto = $texto . "\n" . $emitLgr . "," . $emitNro . " " . $emitCpl . "," . $emitBairro |
||
| 427 | . ". CEP:" . $emitCEP . ". " . $emitMun . "-" . $emitUF . $emitFone; |
||
| 428 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>''); |
||
| 429 | $this->pTextBox($xRs, $y, $wRs, $h, $texto, $aFont, 'C', $alignEmit, 0, '', false); |
||
| 430 | } |
||
| 431 | |||
| 432 | protected function pCabecalhoSecundarioDANFE($x = 0, $y = 0, $h = 0) |
||
| 433 | { |
||
| 434 | $margemInterna = $this->margemInterna; |
||
| 435 | $maxW = $this->wPrint; |
||
| 436 | $w = ($maxW*1); |
||
| 437 | $hBox1 = 7; |
||
| 438 | $texto = "DANFE NFC-e\nDocumento Auxiliar da Nota Fiscal de Consumidor Eletrônica"; |
||
| 439 | $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'); |
||
| 440 | $this->pTextBox($x, $y, $w, $hBox1, $texto, $aFont, 'C', 'C', 0, '', false); |
||
| 441 | $hBox2 = 4; |
||
| 442 | $yBox2 = $y + $hBox1; |
||
| 443 | $texto = "\nNFC-e não permite aproveitamento de crédito de ICMS"; |
||
| 444 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>''); |
||
| 445 | $this->pTextBox($x, $yBox2, $w, $hBox2, $texto, $aFont, 'C', 'C', 0, '', false); |
||
| 446 | } |
||
| 447 | |||
| 448 | protected function pProdutosDANFE($x = 0, $y = 0, $h = 0) |
||
| 449 | { |
||
| 450 | $margemInterna = $this->margemInterna; |
||
| 451 | $maxW = $this->wPrint; |
||
| 452 | $qtdItens = $this->det->length; |
||
| 453 | $w = ($maxW*1); |
||
| 454 | $hLinha = $this->hLinha; |
||
| 455 | $aFontCabProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 456 | $wBoxCod = $w*0.17; |
||
| 457 | $texto = "CÓDIGO"; |
||
| 458 | $this->pTextBox($x, $y, $wBoxCod, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false); |
||
| 459 | $wBoxDescricao = $w*0.43; |
||
| 460 | $xBoxDescricao = $wBoxCod + $x; |
||
| 461 | $texto = "DESCRICÃO"; |
||
| 462 | $this->pTextBox( |
||
| 463 | $xBoxDescricao, |
||
| 464 | $y, |
||
| 465 | $wBoxDescricao, |
||
| 466 | $hLinha, |
||
| 467 | $texto, |
||
| 468 | $aFontCabProdutos, |
||
| 469 | 'T', |
||
| 470 | 'L', |
||
| 471 | 0, |
||
| 472 | '', |
||
| 473 | false |
||
| 474 | ); |
||
| 475 | $wBoxQt = $w*0.08; |
||
| 476 | $xBoxQt = $wBoxDescricao + $xBoxDescricao; |
||
| 477 | $texto = "QT"; |
||
| 478 | $this->pTextBox($xBoxQt, $y, $wBoxQt, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false); |
||
| 479 | $wBoxUn = $w*0.06; |
||
| 480 | $xBoxUn = $wBoxQt + $xBoxQt; |
||
| 481 | $texto = "UN"; |
||
| 482 | $this->pTextBox($xBoxUn, $y, $wBoxUn, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false); |
||
| 483 | $wBoxVl = $w*0.13; |
||
| 484 | $xBoxVl = $wBoxUn + $xBoxUn; |
||
| 485 | $texto = "VALOR"; |
||
| 486 | $this->pTextBox($xBoxVl, $y, $wBoxVl, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false); |
||
| 487 | $wBoxTotal = $w*0.13; |
||
| 488 | $xBoxTotal = $wBoxVl + $xBoxVl; |
||
| 489 | $texto = "TOTAL"; |
||
| 490 | $this->pTextBox($xBoxTotal, $y, $wBoxTotal, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false); |
||
| 491 | $hBoxLinha = $this->hBoxLinha; |
||
| 492 | $hMaxLinha = $this->hMaxLinha; |
||
| 493 | $cont = 0; |
||
| 494 | $aFontProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>''); |
||
| 495 | if ($qtdItens > 0) { |
||
| 496 | foreach ($this->det as $detI) { |
||
| 497 | $thisItem = $detI; |
||
| 498 | $prod = $thisItem->getElementsByTagName("prod")->item(0); |
||
| 499 | $nitem = $thisItem->getAttribute("nItem"); |
||
| 500 | $cProd = $this->pSimpleGetValue($prod, "cProd"); |
||
| 501 | $xProd = $this->pSimpleGetValue($prod, "xProd"); |
||
| 502 | $qCom = number_format($this->pSimpleGetValue($prod, "qCom"), 2, ",", "."); |
||
| 503 | $uCom = $this->pSimpleGetValue($prod, "uCom"); |
||
| 504 | $vUnCom = number_format($this->pSimpleGetValue($prod, "vUnCom"), 2, ",", "."); |
||
| 505 | $vProd = number_format($this->pSimpleGetValue($prod, "vProd"), 2, ",", "."); |
||
| 506 | //COLOCA PRODUTO |
||
| 507 | $yBoxProd = $y + $hLinha + ($cont*$hMaxLinha); |
||
| 508 | //COLOCA PRODUTO CÓDIGO |
||
| 509 | $wBoxCod = $w*0.17; |
||
| 510 | $texto = $cProd; |
||
| 511 | $this->pTextBox($x, $yBoxProd, $wBoxCod, $hMaxLinha, $texto, $aFontProdutos, 'C', 'C', 0, '', false); |
||
| 512 | //COLOCA PRODUTO DESCRIÇÃO |
||
| 513 | $wBoxDescricao = $w*0.43; |
||
| 514 | $xBoxDescricao = $wBoxCod + $x; |
||
| 515 | $texto = $xProd; |
||
| 516 | $this->pTextBox( |
||
| 517 | $xBoxDescricao, |
||
| 518 | $yBoxProd, |
||
| 519 | $wBoxDescricao, |
||
| 520 | $hMaxLinha, |
||
| 521 | $texto, |
||
| 522 | $aFontProdutos, |
||
| 523 | 'C', |
||
| 524 | 'L', |
||
| 525 | 0, |
||
| 526 | '', |
||
| 527 | false |
||
| 528 | ); |
||
| 529 | //COLOCA PRODUTO QUANTIDADE |
||
| 530 | $wBoxQt = $w*0.08; |
||
| 531 | $xBoxQt = $wBoxDescricao + $xBoxDescricao; |
||
| 532 | $texto = $qCom; |
||
| 533 | $this->pTextBox( |
||
| 534 | $xBoxQt, |
||
| 535 | $yBoxProd, |
||
| 536 | $wBoxQt, |
||
| 537 | $hMaxLinha, |
||
| 538 | $texto, |
||
| 539 | $aFontProdutos, |
||
| 540 | 'C', |
||
| 541 | 'C', |
||
| 542 | 0, |
||
| 543 | '', |
||
| 544 | false |
||
| 545 | ); |
||
| 546 | //COLOCA PRODUTO UNIDADE |
||
| 547 | $wBoxUn = $w*0.06; |
||
| 548 | $xBoxUn = $wBoxQt + $xBoxQt; |
||
| 549 | $texto = $uCom; |
||
| 550 | $this->pTextBox( |
||
| 551 | $xBoxUn, |
||
| 552 | $yBoxProd, |
||
| 553 | $wBoxUn, |
||
| 554 | $hMaxLinha, |
||
| 555 | $texto, |
||
| 556 | $aFontProdutos, |
||
| 557 | 'C', |
||
| 558 | 'C', |
||
| 559 | 0, |
||
| 560 | '', |
||
| 561 | false |
||
| 562 | ); |
||
| 563 | //COLOCA PRODUTO VL UNITÁRIO |
||
| 564 | $wBoxVl = $w*0.13; |
||
| 565 | $xBoxVl = $wBoxUn + $xBoxUn; |
||
| 566 | $texto = $vUnCom; |
||
| 567 | $this->pTextBox( |
||
| 568 | $xBoxVl, |
||
| 569 | $yBoxProd, |
||
| 570 | $wBoxVl, |
||
| 571 | $hMaxLinha, |
||
| 572 | $texto, |
||
| 573 | $aFontProdutos, |
||
| 574 | 'C', |
||
| 575 | 'R', |
||
| 576 | 0, |
||
| 577 | '', |
||
| 578 | false |
||
| 579 | ); |
||
| 580 | //COLOCA PRODUTO VL TOTAL |
||
| 581 | $wBoxTotal = $w*0.13; |
||
| 582 | $xBoxTotal = $wBoxVl + $xBoxVl; |
||
| 583 | $texto = $vProd; |
||
| 584 | $this->pTextBox( |
||
| 585 | $xBoxTotal, |
||
| 586 | $yBoxProd, |
||
| 587 | $wBoxTotal, |
||
| 588 | $hMaxLinha, |
||
| 589 | $texto, |
||
| 590 | $aFontProdutos, |
||
| 591 | 'C', |
||
| 592 | 'R', |
||
| 593 | 0, |
||
| 594 | '', |
||
| 595 | false |
||
| 596 | ); |
||
| 597 | |||
| 598 | $cont++; |
||
| 599 | } |
||
| 600 | } |
||
| 601 | } |
||
| 602 | |||
| 603 | protected function pTotalDANFE($x = 0, $y = 0, $h = 0) |
||
| 604 | { |
||
| 605 | $margemInterna = $this->margemInterna; |
||
| 606 | $maxW = $this->wPrint; |
||
| 607 | $hLinha = 3; |
||
| 608 | $wColEsq = ($maxW*0.7); |
||
| 609 | $wColDir = ($maxW*0.3); |
||
| 610 | $xValor = $x + $wColEsq; |
||
| 611 | $qtdItens = $this->det->length; |
||
| 612 | $vProd = $this->pSimpleGetValue($this->ICMSTot, "vProd"); |
||
| 613 | $vNF = $this->pSimpleGetValue($this->ICMSTot, "vNF"); |
||
| 614 | $vDesc = $this->pSimpleGetValue($this->ICMSTot, "vDesc"); |
||
| 615 | $vFrete = $this->pSimpleGetValue($this->ICMSTot, "vFrete"); |
||
| 616 | $vTotTrib = $this->pSimpleGetValue($this->ICMSTot, "vTotTrib"); |
||
| 617 | $texto = "Qtd. Total de Itens"; |
||
| 618 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 619 | $this->pTextBox($x, $y, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false); |
||
| 620 | $texto = $qtdItens; |
||
| 621 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 622 | $this->pTextBox($xValor, $y, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false); |
||
| 623 | $yTotal = $y + ($hLinha); |
||
| 624 | $texto = "Total de Produtos"; |
||
| 625 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 626 | $this->pTextBox($x, $yTotal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false); |
||
| 627 | $texto = "R$ " . number_format($vProd, 2, ",", "."); |
||
| 628 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 629 | $this->pTextBox($xValor, $yTotal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false); |
||
| 630 | $yDesconto = $y + ($hLinha*2); |
||
| 631 | $texto = "Descontos"; |
||
| 632 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 633 | $this->pTextBox($x, $yDesconto, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false); |
||
| 634 | $texto = "R$ " . $vDesc; |
||
| 635 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 636 | $this->pTextBox($xValor, $yDesconto, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false); |
||
| 637 | $yFrete= $y + ($hLinha*3); |
||
| 638 | $texto = "Frete"; |
||
| 639 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 640 | $this->pTextBox($x, $yFrete, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false); |
||
| 641 | $texto = "R$ " . $vFrete; |
||
| 642 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 643 | $this->pTextBox($xValor, $yFrete, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false); |
||
| 644 | $yTotalFinal = $y + ($hLinha*4); |
||
| 645 | $texto = "Total"; |
||
| 646 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 647 | $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false); |
||
| 648 | $texto = "R$ " . $vNF; |
||
| 649 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 650 | $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false); |
||
| 651 | $yTotalFinal = $y + ($hLinha*5); |
||
| 652 | $texto = "Informação dos Tributos Totais Incidentes"; |
||
| 653 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>''); |
||
| 654 | $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false); |
||
| 655 | $texto = "R$ " . $vTotTrib; |
||
| 656 | $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'); |
||
| 657 | $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false); |
||
| 658 | } |
||
| 659 | |||
| 660 | protected function pPagamentosDANFE($x = 0, $y = 0, $h = 0) |
||
| 721 | |||
| 722 | protected function pFiscalDANFE($x = 0, $y = 0, $h = 0) |
||
| 723 | { |
||
| 724 | $y += 6; |
||
| 725 | $margemInterna = $this->margemInterna; |
||
| 726 | $maxW = $this->wPrint; |
||
| 727 | $w = ($maxW*1); |
||
| 728 | $hLinha = $this->hLinha; |
||
| 729 | $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'); |
||
| 730 | $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>''); |
||
| 773 | |||
| 774 | protected function pConsumidorDANFE($x = 0, $y = 0, $h = 0) |
||
| 844 | |||
| 845 | protected function pQRDANFE($x = 0, $y = 0, $h = 0) |
||
| 884 | |||
| 885 | protected function pInfAdic($x = 0, $y = 0, $h = 0) |
||
| 906 | |||
| 907 | /** |
||
| 908 | * printDANFE |
||
| 909 | * Esta função envia a DANFE em PDF criada para o dispositivo informado. |
||
| 910 | * O destino da impressão pode ser : |
||
| 911 | * I-browser |
||
| 912 | * D-browser com download |
||
| 913 | * F-salva em um arquivo local com o nome informado |
||
| 914 | * S-retorna o documento como uma string e o nome é ignorado. |
||
| 915 | * Para enviar o pdf diretamente para uma impressora indique o |
||
| 916 | * nome da impressora e o destino deve ser 'S'. |
||
| 917 | * |
||
| 918 | * @param string $nome Path completo com o nome do arquivo pdf |
||
| 919 | * @param string $destino Direção do envio do PDF |
||
| 920 | * @param string $printer Identificação da impressora no sistema |
||
| 921 | * @return string Caso o destino seja S o pdf é retornado como uma string |
||
| 922 | * @todo Rotina de impressão direta do arquivo pdf criado |
||
| 923 | */ |
||
| 924 | public function printDANFE($nome = '', $destino = 'I', $printer = '') |
||
| 932 | /** |
||
| 933 | * Dados brutos do PDF |
||
| 934 | * @return string |
||
| 935 | */ |
||
| 936 | public function render() |
||
| 940 | |||
| 941 | /** |
||
| 942 | * anfavea |
||
| 943 | * Função para transformar o campo cdata do padrão ANFAVEA para |
||
| 944 | * texto imprimível |
||
| 945 | * |
||
| 946 | * @param string $cdata campo CDATA |
||
| 947 | * @return string conteúdo do campo CDATA como string |
||
| 948 | */ |
||
| 949 | protected function pAnfavea($cdata = '') |
||
| 1086 | |||
| 1087 | /** |
||
| 1088 | * str2Hex |
||
| 1089 | * Converte string para haxadecimal ASCII |
||
| 1090 | * |
||
| 1091 | * @param string $str |
||
| 1092 | * @return string |
||
| 1093 | */ |
||
| 1094 | protected static function str2Hex($str) |
||
| 1107 | |||
| 1108 | protected static function getCardName($tBand) |
||
| 1128 | |||
| 1129 | /** |
||
| 1130 | * hex2Str |
||
| 1131 | * Converte hexadecimal ASCII para string |
||
| 1132 | * |
||
| 1133 | * @param string $str |
||
| 1134 | * @return string |
||
| 1135 | */ |
||
| 1136 | protected static function hex2Str($str) |
||
| 1149 | |||
| 1150 | protected function makeQRCode( |
||
| 1187 | |||
| 1188 | protected function pNotaCancelada() |
||
| 1199 | |||
| 1200 | protected function pNotaDenegada() |
||
| 1212 | } |
||
| 1213 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.