diff --git a/composer.json b/composer.json index 04d44f66..a688d032 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "php": ">= 7.4", "ext-dom": "*", "ext-gd": "*", + "ext-mbstring": "*", "tecnickcom/tc-lib-barcode": "^1", "nfephp-org/sped-common": "^5.1.0" }, diff --git a/examples/nfe/danfesimples.php b/examples/nfe/danfesimples.php index 3a1faba4..3e560125 100644 --- a/examples/nfe/danfesimples.php +++ b/examples/nfe/danfesimples.php @@ -10,6 +10,7 @@ try { $danfe = new DanfeSimples($xml); $danfe->debugMode(false); + $pdf = $danfe->render(); header('Content-Type: application/pdf'); echo $pdf; diff --git a/src/CTe/Daevento.php b/src/CTe/Daevento.php index c830ffc5..eec966df 100644 --- a/src/CTe/Daevento.php +++ b/src/CTe/Daevento.php @@ -117,8 +117,7 @@ protected function loadDoc($xml) */ protected function monta( $logo = '' - ) - { + ) { if (!empty($logo)) { $this->logomarca = $this->adjustImage($logo); } @@ -189,8 +188,7 @@ private function header( $x, $y, $pag - ) - { + ) { $oldX = $x; $oldY = $y; $maxW = $this->wPrint; diff --git a/src/Legacy/Pdf.php b/src/Legacy/Pdf.php index 04eaeeca..e1ae8e0b 100644 --- a/src/Legacy/Pdf.php +++ b/src/Legacy/Pdf.php @@ -806,7 +806,7 @@ public function dashedHLine($x, $y, $w, $h, $n) */ public function dashedVLine($x, $y, $w, $yfinal, $n) { - $this->setDrawColor(150,150,150); + $this->setDrawColor(150, 150, 150); $this->setLineWidth($w); if ($y > $yfinal) { $aux = $yfinal; @@ -1124,8 +1124,8 @@ public function textBox90( * @param string $text * @return string */ - private function convertToIso($text) { + private function convertToIso($text) + { return mb_convert_encoding($text, 'ISO-8859-1', ['UTF-8', 'windows-1252']); } - } diff --git a/src/NFe/Danfe.php b/src/NFe/Danfe.php index 3d2e75e8..f1ae8bed 100644 --- a/src/NFe/Danfe.php +++ b/src/NFe/Danfe.php @@ -414,7 +414,7 @@ protected function calculoEspacoVericalDadosAdicionais() $this->textoAdic .= $infPedido; } // EXIBE EMAIL DO DESTINATÁRIO - if($this->exibirEmailDestinatario){ + if ($this->exibirEmailDestinatario) { $this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: '); } @@ -2245,7 +2245,7 @@ protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto) if (isset($the_field_aux)) { $value2 = $the_field_aux->nodeValue; } - } else if ($campoImposto == 'vST') { // soma junto ao ICMS ST o FCP ST + } elseif ($campoImposto == 'vST') { // soma junto ao ICMS ST o FCP ST $the_field_aux = $this->ICMSTot->getElementsByTagName('vFCPST')->item(0); if (isset($the_field_aux)) { $value2 = $the_field_aux->nodeValue; diff --git a/src/NFe/DanfeSimples.php b/src/NFe/DanfeSimples.php index 8288f2e5..12d98a04 100644 --- a/src/NFe/DanfeSimples.php +++ b/src/NFe/DanfeSimples.php @@ -193,7 +193,6 @@ public function __construct($xml, $orientacao = 'P') $this->loadDoc($xml); $this->orientacao = $orientacao; } - private function loadDoc($xml) { $this->xml = $xml; @@ -263,7 +262,9 @@ protected function monta($logo = null) $pesoB = 0.000; $totalVolumes = 0; - if( isset($this->nfeArray['NFe']['infNFe']['transp']) && isset($this->nfeArray['NFe']['infNFe']['transp']['vol']) ) { + if (isset($this->nfeArray['NFe']['infNFe']['transp']) + && isset($this->nfeArray['NFe']['infNFe']['transp']['vol']) + ) { // Normalizar o array de volumes quando tem apenas 1 volumes if (!isset($this->nfeArray['NFe']['infNFe']['transp']['vol'][0])) { $this->nfeArray['NFe']['infNFe']['transp']['vol'] = [ @@ -300,7 +301,7 @@ protected function monta($logo = null) 'C', 1 ); - } + } // LINHA 2 $dataEmissao = date('d/m/Y', strtotime("{$this->nfeArray['NFe']['infNFe']['ide']['dhEmi']}")); @@ -392,11 +393,13 @@ protected function monta($logo = null) ? $this->nfeArray['NFe']['infNFe']['emit']['CNPJ'] :$this->nfeArray['NFe']['infNFe']['emit']['CPF']); $this->pdf->cell(($c1 * 2), $pequeno ? 4 : 5, "CNPJ/CPF {$cpfCnpj}", 1, 0, 'C', 1); - + $this->pdf->cell( ($c1 * 2), $pequeno ? 4 : 5, - isset($this->nfeArray['NFe']['infNFe']['emit']['IE']) ? "RG/IE {$this->nfeArray['NFe']['infNFe']['emit']['IE']}" : "RG/IE: Nenhum", + isset($this->nfeArray['NFe']['infNFe']['emit']['IE']) + ? "RG/IE {$this->nfeArray['NFe']['infNFe']['emit']['IE']}" + : "RG/IE: Nenhum", 1, 1, 'C', @@ -431,11 +434,13 @@ protected function monta($logo = null) ? $this->nfeArray['NFe']['infNFe']['dest']['CNPJ'] :$this->nfeArray['NFe']['infNFe']['dest']['CPF']); $this->pdf->cell(($c1 * 2), $pequeno ? 4 : 5, "CNPJ/CPF {$cpfCnpj}", 1, 0, 'C', 1); - + $this->pdf->cell( ($c1 * 2), $pequeno ? 4 : 5, - isset($this->nfeArray['NFe']['infNFe']['dest']['IE']) ? "RG/IE {$this->nfeArray['NFe']['infNFe']['dest']['IE']}" : "RG/IE: Nenhum", + isset($this->nfeArray['NFe']['infNFe']['dest']['IE']) + ? "RG/IE {$this->nfeArray['NFe']['infNFe']['dest']['IE']}" + : "RG/IE: Nenhum", 1, 1, 'C', @@ -453,7 +458,9 @@ protected function monta($logo = null) } $enderecoLinha2 .= "{$this->nfeArray['NFe']['infNFe']['entrega']['xMun']}" . " / {$this->nfeArray['NFe']['infNFe']['entrega']['UF']}" - . (isset($this->nfeArray['NFe']['infNFe']['entrega']['CEP']) ? " - CEP {$this->nfeArray['NFe']['infNFe']['entrega']['CEP']}" : null); + . (isset($this->nfeArray['NFe']['infNFe']['entrega']['CEP']) + ? " - CEP {$this->nfeArray['NFe']['infNFe']['entrega']['CEP']}" + : null); } else { $enderecoLinha1 = "{$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['xLgr']}"; if (!empty($this->nfeArray['NFe']['infNFe']['dest']['enderDest']['nro'])) { @@ -465,7 +472,9 @@ protected function monta($logo = null) } $enderecoLinha2 .= "{$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['xMun']}" . " / {$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['UF']}" - . (isset($this->nfeArray['NFe']['infNFe']['entrega']['CEP']) ? " - CEP {$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['CEP']}" : null); + . (isset($this->nfeArray['NFe']['infNFe']['entrega']['CEP']) + ? " - CEP {$this->nfeArray['NFe']['infNFe']['dest']['enderDest']['CEP']}" + : null); } $this->pdf->setFont('Arial', '', $pequeno ? 9 : 10); @@ -540,8 +549,8 @@ protected function monta($logo = null) } } - private function convertToIso($text) { + private function convertToIso($text) + { return mb_convert_encoding($text, 'ISO-8859-1', ['UTF-8', 'windows-1252']); } - } diff --git a/src/NFe/Traits/TraitBlocoV.php b/src/NFe/Traits/TraitBlocoV.php index 81dcc5e2..f7a166d3 100644 --- a/src/NFe/Traits/TraitBlocoV.php +++ b/src/NFe/Traits/TraitBlocoV.php @@ -61,7 +61,6 @@ protected function blocoV($y) $texto = !empty($this->vTroco) ? number_format((float) $this->vTroco, 2, ',', '.') : '0,00'; $y1 = $this->pdf->textBox($this->margem, $z, $this->wPrint, 3, $texto, $aFont, 'T', 'R', false, '', false); - $this->pdf->dashedHLine($this->margem, $this->bloco5H+$y, $this->wPrint, 0.1, 30); return $this->bloco5H + $y; } @@ -86,7 +85,7 @@ protected function pagType($type) 90 => 'Sem pagamento', 99 => 'Outros', ]; - return $lista[$type]; + return mb_strtoupper($lista[$type]); } protected function calculateHeightPag()