Completed
Pull Request — master (#75)
by Roberto
07:20
created

Danfce::pProdutosDANFE()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 154
Code Lines 136

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 136
nc 3
nop 3
dl 0
loc 154
ccs 0
cts 146
cp 0
crap 12
rs 8.2857
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\DA\NFe;
4
5
/**
6
 * Classe para a impressão em PDF do Documento Auxiliar de NFe Consumidor
7
 * NOTA: Esta classe não é a indicada para quem faz uso de impressoras térmicas ESCPOS
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @copyright 2009-2016 NFePHP
12
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
13
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
14
 * @author    Roberto Spadim <roberto at spadim dot com dot br>
15
 */
16
17
use Exception;
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Legacy\Common;
21
use Endroid\QrCode\QrCode;
22
use DateTime;
23
24
class Danfce extends Common
25
{
26
    protected $papel;
27
    protected $xml; // string XML NFe
28
    protected $logomarca=''; // path para logomarca em jpg
29
    protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####";
30
    protected $debugMode=0; //ativa ou desativa o modo de debug
31
    protected $tpImp; //ambiente
32
    protected $fontePadrao='Times';
33
    protected $nfeProc;
34
    protected $nfe;
35
    protected $infNFe;
36
    protected $ide;
37
    protected $enderDest;
38
    protected $ICMSTot;
39
    protected $imposto;
40
    protected $emit;
41
    protected $enderEmit;
42
    protected $qrCode;
43
    protected $det;
44
    protected $pag;
45
    protected $dest;
46
    protected $imgQRCode;
47
    protected $urlQR = '';
48
    protected $pdf;
49
    protected $margemInterna = 2;
50
    protected $hMaxLinha = 9;
51
    protected $hBoxLinha = 6;
52
    protected $hLinha = 3;
53
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
    /*
89
     * Fonte: http://nfce.encat.org/consumidor/consulte-sua-nota/
90
     * URL referente a pagina de consulta da NFCe pela chave de acesso
91
     * @var string
92
     */
93
    protected $urlConsulta = [
94
        '1' => [
95
            'AC' => 'www.sefaznet.ac.gov.br/nfce/consulta',
96
            'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm',
97
            'AP' => 'https://www.sefaz.ap.gov.br/sate/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261',
98
            'AM' => 'sistemas.sefaz.am.gov.br/nfceweb/formConsulta.do',
99
            'BA' => 'nfe.sefaz.ba.gov.br/servicos/nfce/default.aspx',
100
            'CE' => '',
101
            'DF' => 'http://dec.fazenda.df.gov.br/NFCE/',
102
            'ES' => 'http://app.sefaz.es.gov.br/ConsultaNFCe',
103
            'GO' => '',
104
            'MA' => 'http://www.nfce.sefaz.ma.gov.br/portal/consultaNFe.do?method=preFilterCupom&',
105
            'MT' => 'http://www.sefaz.mt.gov.br/nfce/consultanfce',
106
            'MS' => 'http://www.dfe.ms.gov.br/nfce',
107
            'MG' => '',
108
            'PA' => 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam',
109
            'PB' => 'www.receita.pb.gov.br/nfce',
110
            'PR' => 'http://www.fazenda.pr.gov.br',
111
            'PE' => '',
112
            'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb/consultarNFCe.jsf',
113
            'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta',
114
            'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx',
115
            'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx',
116
            'RO' => 'http://www.nfce.sefin.ro.gov.br',
117
            'RR' => 'https://www.sefaz.rr.gov.br/nfce/servlet/wp_consulta_nfce',
118
            'SC' => '',
119
            'SP' => 'https://www.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx',
120
            'SE' => 'http://www.nfce.se.gov.br/portal/portalNoticias.jsp',
121
            'TO' => ''
122
        ],
123
        '2' => [
124
            'AC' => 'http://hml.sefaznet.ac.gov.br/nfce/consulta',
125
            'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm',
126
            'AP' => 'https://www.sefaz.ap.gov.br/sate1/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261',
127
            'AM' => 'homnfce.sefaz.am.gov.br/nfceweb/formConsulta.do',
128
            'BA' => 'http://hnfe.sefaz.ba.gov.br/servicos/nfce/default.aspx',
129
            'CE' => 'http://nfceh.sefaz.ce.gov.br/pages/consultaNota.jsf',
130
            'DF' => 'http://dec.fazenda.df.gov.br/NFCE/',
131
            'ES' => 'http://homologacao.sefaz.es.gov.br/ConsultaNFCe',
132
            'GO' => '',
133
            'MA' => 'http://www.hom.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp',
134
            'MT' => 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce',
135
            'MS' => 'http://www.dfe.ms.gov.br/nfce',
136
            'MG' => '',
137
            'PA' => 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/consultanfce.seam',
138
            'PB' => '',
139
            'PR' => 'http://www.fazenda.pr.gov.br',
140
            'PE' => '',
141
            'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb-homologacao/consultarNFCe.jsf',
142
            'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta',
143
            'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx',
144
            'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx',
145
            'RO' => 'http://www.nfce.sefin.ro.gov.br',
146
            'RR' => 'http://200.174.88.103:8080/nfce/servlet/wp_consulta_nfce',
147
            'SC' => '',
148
            'SP' => 'https://www.homologacao.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx',
149
            'SE' => 'http://www.hom.nfe.se.gov.br/portal/portalNoticias.jsp',
150
            'TO' => ''
151
        ],
152
    ];
153
154
    /**
155
     * __contruct
156
     *
157
     * @param string $docXML
158
     * @param string $sPathLogo
159
     * @param string $mododebug
160
     * @param string $idToken
161
     * @param string $Token
0 ignored issues
show
Bug introduced by
There is no parameter named $Token. Was it maybe removed?

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 $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
162
     */
163
    public function __construct(
164
        $docXML = '',
165
        $sPathLogo = '',
166
        $mododebug = 0,
167
        // habilita os erros do sistema
168
        $idToken = '',
0 ignored issues
show
Unused Code introduced by
The parameter $idToken is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
169
        $emitToken = '',
0 ignored issues
show
Unused Code introduced by
The parameter $emitToken is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
170
        $urlQR = ''
0 ignored issues
show
Unused Code introduced by
The parameter $urlQR is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
171
    ) {
172
        if (is_numeric($mododebug)) {
173
            $this->debugMode = $mododebug;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mododebug can also be of type double or string. However, the property $debugMode is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
174
        }
175
        if ($this->debugMode) {
176
            //ativar modo debug
177
            error_reporting(E_ALL);
178
            ini_set('display_errors', 'On');
179
        } else {
180
            //desativar modo debug
181
            error_reporting(0);
182
            ini_set('display_errors', 'Off');
183
        }
184
        $this->xml = $docXML;
185
        $this->logomarca = $sPathLogo;
186
        if (empty($fonteDANFE)) {
0 ignored issues
show
Bug introduced by
The variable $fonteDANFE seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
187
            $this->fontePadrao = 'Times';
188
        } else {
189
            $this->fontePadrao = $fonteDANFE;
190
        }
191
        if (!empty($this->xml)) {
192
            $this->dom = new Dom();
0 ignored issues
show
Bug introduced by
The property dom does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
193
            $this->dom->loadXML($this->xml);
194
            $this->nfeProc    = $this->dom->getElementsByTagName("nfeProc")->item(0);
195
            $this->nfe        = $this->dom->getElementsByTagName("NFe")->item(0);
196
            $this->infNFe     = $this->dom->getElementsByTagName("infNFe")->item(0);
197
            $this->ide        = $this->dom->getElementsByTagName("ide")->item(0);
198
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
199
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
200
            $this->det        = $this->dom->getElementsByTagName("det");
201
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
202
            $this->pag        = $this->dom->getElementsByTagName("pag");
203
            $this->imposto    = $this->dom->getElementsByTagName("imposto")->item(0);
204
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
205
            $this->tpImp      = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue;
206
        }
207
        $this->qrCode = $this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue;
208
        if ($this->pSimpleGetValue($this->ide, "mod") != '65') {
209
            throw new nfephpException("O xml do DANFE deve ser uma NFC-e modelo 65");
210
        }
211
    }
212
    
213
    public function getPapel()
214
    {
215
        return $this->papel;
216
    }
217
    
218
    public function setPapel($aPap)
219
    {
220
        $this->papel = $aPap;
221
    }
222
    
223
    public function monta(
224
        $orientacao = 'P',
225
        $papel = '',
226
        $logoAlign = 'C',
227
        $classPdf = false,
228
        $depecNumReg = ''
229
    ) {
230
        $this->montaDANFE($orientacao, $papel, $logoAlign, $classPdf, $depecNumReg);
231
    }
232
    
233
    public function montaDANFE(
234
        $orientacao = 'P',
235
        $papel = '',
0 ignored issues
show
Unused Code introduced by
The parameter $papel is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
236
        $logoAlign = 'C',
237
        $classPdf = false,
238
        $depecNumReg = ''
239
    ) {
240
        $qtdItens = $this->det->length;
241
        $qtdPgto = $this->pag->length;
242
        $hMaxLinha = $this->hMaxLinha;
243
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
244
        $hLinha = $this->hLinha;
245
        $tamPapelVert = 160 +16+ (($qtdItens-1)*$hMaxLinha) + ($qtdPgto*$hLinha);
246
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
247
        if ($orientacao == '') {
248
            $orientacao = 'P';
249
        }
250
        $this->orientacao = $orientacao;
0 ignored issues
show
Bug introduced by
The property orientacao does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
251
        $this->papel = array(80,$tamPapelVert);
252
        $this->logoAlign = $logoAlign;
0 ignored issues
show
Bug introduced by
The property logoAlign does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
253
        //$this->situacao_externa = $situacaoExterna;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
254
        $this->numero_registro_dpec = $depecNumReg;
0 ignored issues
show
Bug introduced by
The property numero_registro_dpec does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
255
        //instancia a classe pdf
256
        if ($classPdf) {
257
            $this->pdf = $classPdf;
258
        } else {
259
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer,{"...nteger","1":"integer"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
260
        }
261
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
262
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
263
        //apenas para controle se necessário ser maior do que a margem superior
264
        $margSup = 2;
265
        $margEsq = 2;
266
        $margInf = 2;
267
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
268
        $xInic = $margEsq;
269
        $yInic = $margSup;
270
        $maxW = 80;
271
        $maxH = $tamPapelVert;
272
        //total inicial de paginas
273
        $totPag = 1;
0 ignored issues
show
Unused Code introduced by
$totPag is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
274
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
275
        $this->wPrint = $maxW-($margEsq*2);
0 ignored issues
show
Bug introduced by
The property wPrint does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
276
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
277
        //superior e inferior
278
        $this->hPrint = $maxH-$margSup-$margInf;
0 ignored issues
show
Bug introduced by
The property hPrint does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
279
        // estabelece contagem de paginas
280
        $this->pdf->aliasNbPages();
281
        $this->pdf->setMargins($margEsq, $margSup); // fixa as margens
282
        $this->pdf->setDrawColor(0, 0, 0);
283
        $this->pdf->setFillColor(255, 255, 255);
284
        $this->pdf->open(); // inicia o documento
285
        $this->pdf->addPage($this->orientacao, $this->papel); // adiciona a primeira página
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer,{"...nteger","1":"integer"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
286
        $this->pdf->setLineWidth(0.1); // define a largura da linha
287
        $this->pdf->setTextColor(0, 0, 0);
288
        $this->pTextBox(0, 0, $maxW, $maxH); // POR QUE PRECISO DESA LINHA?
289
        $hcabecalho = 27;//para cabeçalho (dados emitente mais logomarca)  (FIXO)
290
        $hcabecalhoSecundario = 10;//para cabeçalho secundário (cabeçalho sefaz) (FIXO)
291
        $hprodutos = $hLinha + ($qtdItens*$hMaxLinha) ;//box poduto
292
        $hTotal = 12; //box total (FIXO)
293
        $hpagamentos = $hLinha + ($qtdPgto*$hLinha);//para pagamentos
294
        $hmsgfiscal = 21;// para imposto (FIXO)
295
        if (!isset($this->dest)) {
296
            $hcliente = 6;// para cliente (FIXO)
297
        } else {
298
            $hcliente = 12;
299
        }// para cliente (FIXO)};
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
300
        $hQRCode = 50;// para qrcode (FIXO)
301
        $hCabecItens = 4;//cabeçalho dos itens
302
        
303
        $hUsado = $hCabecItens;
0 ignored issues
show
Unused Code introduced by
$hUsado is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
304
        $w2 = round($this->wPrint*0.31, 0);
0 ignored issues
show
Unused Code introduced by
$w2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
305
        $totPag = 1;
306
        $pag = 1;
307
        $x = $xInic;
308
        //COLOCA CABEÇALHO
309
        $y = $yInic;
310
        $y = $this->pCabecalhoDANFE($x, $y, $hcabecalho, $pag, $totPag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pCabecalhoDANFE($...becalho, $pag, $totPag) (which targets NFePHP\DA\NFe\Danfce::pCabecalhoDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
311
        //COLOCA CABEÇALHO SECUNDÁRIO
312
        $y = $hcabecalho;
313
        $y = $this->pCabecalhoSecundarioDANFE($x, $y, $hcabecalhoSecundario);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pCabecalhoSecunda... $hcabecalhoSecundario) (which targets NFePHP\DA\NFe\Danfce::pCabecalhoSecundarioDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
314
        //COLOCA PRODUTOS
315
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario;
316
        $y = $this->pProdutosDANFE($x, $y, $hprodutos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pProdutosDANFE($x, $y, $hprodutos) (which targets NFePHP\DA\NFe\Danfce::pProdutosDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
317
        //COLOCA TOTAL
318
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos;
319
        $y = $this->pTotalDANFE($x, $y, $hTotal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pTotalDANFE($x, $y, $hTotal) (which targets NFePHP\DA\NFe\Danfce::pTotalDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
320
        //COLOCA PAGAMENTOS
321
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal;
322
        $y = $this->pPagamentosDANFE($x, $y, $hpagamentos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pPagamentosDANFE($x, $y, $hpagamentos) (which targets NFePHP\DA\NFe\Danfce::pPagamentosDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
323
        //COLOCA MENSAGEM FISCAL
324
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal+ $hpagamentos;
325
        $y = $this->pFiscalDANFE($x, $y, $hmsgfiscal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pFiscalDANFE($x, $y, $hmsgfiscal) (which targets NFePHP\DA\NFe\Danfce::pFiscalDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
326
        //COLOCA CONSUMIDOR
327
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal + $hpagamentos + $hmsgfiscal;
328
        $y = $this->pConsumidorDANFE($x, $y, $hcliente);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pConsumidorDANFE($x, $y, $hcliente) (which targets NFePHP\DA\NFe\Danfce::pConsumidorDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
329
        //COLOCA QRCODE
330
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
331
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente;
332
        $y = $this->pQRDANFE($x, $y, $hQRCode);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pQRDANFE($x, $y, $hQRCode) (which targets NFePHP\DA\NFe\Danfce::pQRDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
333
        //retorna o ID na NFe
334
        if ($classPdf!==false) {
335
            $aR = [
336
             'id'=>str_replace('NFe', '', $this->infNFe->getAttribute("Id")),
337
             'classe_PDF'=>$this->pdf
338
            ];
339
            return $aR;
340
        } else {
341
            return str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
342
        }
343
    }
344
    
345
    protected function pCabecalhoDANFE($x = 0, $y = 0, $h = 0, $pag = '1', $totPag = '1')
0 ignored issues
show
Unused Code introduced by
The parameter $x is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $pag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $totPag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
346
    {
347
        $emitRazao  = $this->pSimpleGetValue($this->emit, "xNome");
348
        $emitCnpj   = $this->pSimpleGetValue($this->emit, "CNPJ");
349
        $emitCnpj   = $this->pFormat($emitCnpj, "##.###.###/####-##");
350
        $emitIE     = $this->pSimpleGetValue($this->emit, "IE");
351
        $emitIM     = $this->pSimpleGetValue($this->emit, "IM");
352
        $emitFone = $this->pSimpleGetValue($this->enderEmit, "fone");
353
        $foneLen = strlen($emitFone);
354
        if ($foneLen>0) {
355
            $ddd = substr($emitFone, 0, 2);
356
            $fone1 = substr($emitFone, -8);
357
            $digito9 = ' ';
358
            if ($foneLen == 11) {
359
                $digito9 = substr($emitFone, 2, 1);
360
            }
361
            $emitFone = ' - ('.$ddd.') '.$digito9. ' ' . substr($fone1, 0, 4) . '-' . substr($fone1, -4);
362
        } else {
363
            $emitFone = '';
364
        }
365
        $emitLgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
366
        $emitNro = $this->pSimpleGetValue($this->enderEmit, "nro");
367
        $emitCpl = $this->pSimpleGetValue($this->enderEmit, "xCpl", "");
368
        $emitBairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
369
        $emitCEP = $this->pFormat($this->pSimpleGetValue($this->enderEmit, "CEP"), "#####-###");
370
        $emitMun = $this->pSimpleGetValue($this->enderEmit, "xMun");
371
        $emitUF = $this->pSimpleGetValue($this->enderEmit, "UF");
372
        // CONFIGURAÇÃO DE POSIÇÃO
373
        $margemInterna = $this->margemInterna;
374
        $maxW = $this->wPrint;
375
        $h = $h-($margemInterna);
376
        //COLOCA LOGOMARCA
377
        if (is_file($this->logomarca)) {
378
            $xImg = $margemInterna;
379
            $yImg = $margemInterna + 1;
380
            $this->pdf->Image($this->logomarca, $xImg, $yImg, 30, 22.5);
381
            $xRs = ($maxW*0.4) + $margemInterna;
382
            $wRs = ($maxW*0.6);
383
            $alignEmit = 'L';
384
        } else {
385
            $xRs = $margemInterna;
386
            $wRs = ($maxW*1);
387
            $alignEmit = 'L';
388
        }
389
        //COLOCA RAZÃO SOCIAL
390
        $texto = $emitRazao;
391
        $texto = $texto . "\nCNPJ:" . $emitCnpj;
392
        $texto = $texto . "\nIE:" . $emitIE;
393
        if (!empty($emitIM)) {
394
            $texto = $texto . " - IM:" . $emitIM;
395
        }
396
        $texto = $texto . "\n" . $emitLgr . "," . $emitNro . " " . $emitCpl . "," . $emitBairro
397
                . ". CEP:" . $emitCEP . ". " . $emitMun . "-" . $emitUF . $emitFone;
398
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
399
        $this->pTextBox($xRs, $y, $wRs, $h, $texto, $aFont, 'C', $alignEmit, 0, '', false);
400
    }
401
    
402
    protected function pCabecalhoSecundarioDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
403
    {
404
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
405
        $maxW = $this->wPrint;
406
        $w = ($maxW*1);
407
        $hBox1 = 7;
408
        $texto = "DANFE NFC-e\nDocumento Auxiliar da Nota Fiscal de Consumidor Eletrônica";
409
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
410
        $this->pTextBox($x, $y, $w, $hBox1, $texto, $aFont, 'C', 'C', 0, '', false);
411
        $hBox2 = 4;
412
        $yBox2 = $y + $hBox1;
413
        $texto = "\nNFC-e não permite aproveitamento de crédito de ICMS";
414
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
415
        $this->pTextBox($x, $yBox2, $w, $hBox2, $texto, $aFont, 'C', 'C', 0, '', false);
416
    }
417
    
418
    protected function pProdutosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
419
    {
420
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
421
        $maxW = $this->wPrint;
422
        $qtdItens = $this->det->length;
423
        $w = ($maxW*1);
424
        $hLinha = $this->hLinha;
425
        $aFontCabProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
426
        $wBoxCod = $w*0.17;
427
        $texto = "CÓDIGO";
428
        $this->pTextBox($x, $y, $wBoxCod, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
429
        $wBoxDescricao = $w*0.43;
430
        $xBoxDescricao = $wBoxCod + $x;
431
        $texto = "DESCRICÃO";
432
        $this->pTextBox(
433
            $xBoxDescricao,
434
            $y,
435
            $wBoxDescricao,
436
            $hLinha,
437
            $texto,
438
            $aFontCabProdutos,
439
            'T',
440
            'L',
441
            0,
442
            '',
443
            false
444
        );
445
        $wBoxQt = $w*0.08;
446
        $xBoxQt = $wBoxDescricao + $xBoxDescricao;
447
        $texto = "QT";
448
        $this->pTextBox($xBoxQt, $y, $wBoxQt, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
449
        $wBoxUn = $w*0.06;
450
        $xBoxUn = $wBoxQt + $xBoxQt;
451
        $texto = "UN";
452
        $this->pTextBox($xBoxUn, $y, $wBoxUn, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
453
        $wBoxVl = $w*0.13;
454
        $xBoxVl = $wBoxUn + $xBoxUn;
455
        $texto = "VALOR";
456
        $this->pTextBox($xBoxVl, $y, $wBoxVl, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
457
        $wBoxTotal = $w*0.13;
458
        $xBoxTotal = $wBoxVl + $xBoxVl;
459
        $texto = "TOTAL";
460
        $this->pTextBox($xBoxTotal, $y, $wBoxTotal, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
461
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
462
        $hMaxLinha = $this->hMaxLinha;
463
        $cont = 0;
464
        $aFontProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
465
        if ($qtdItens > 0) {
466
            foreach ($this->det as $detI) {
467
                $thisItem   = $detI;
468
                $prod       = $thisItem->getElementsByTagName("prod")->item(0);
469
                $nitem      = $thisItem->getAttribute("nItem");
0 ignored issues
show
Unused Code introduced by
$nitem is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
470
                $cProd      = $this->pSimpleGetValue($prod, "cProd");
471
                $xProd      = $this->pSimpleGetValue($prod, "xProd");
472
                $qCom       = number_format($this->pSimpleGetValue($prod, "qCom"), 2, ",", ".");
473
                $uCom       = $this->pSimpleGetValue($prod, "uCom");
474
                $vUnCom     = number_format($this->pSimpleGetValue($prod, "vUnCom"), 2, ",", ".");
475
                $vProd      = number_format($this->pSimpleGetValue($prod, "vProd"), 2, ",", ".");
476
                //COLOCA PRODUTO
477
                $yBoxProd = $y + $hLinha + ($cont*$hMaxLinha);
478
                //COLOCA PRODUTO CÓDIGO
479
                $wBoxCod = $w*0.17;
480
                $texto = $cProd;
481
                $this->pTextBox($x, $yBoxProd, $wBoxCod, $hMaxLinha, $texto, $aFontProdutos, 'C', 'C', 0, '', false);
482
                //COLOCA PRODUTO DESCRIÇÃO
483
                $wBoxDescricao = $w*0.43;
484
                $xBoxDescricao = $wBoxCod + $x;
485
                $texto = $xProd;
486
                $this->pTextBox(
487
                    $xBoxDescricao,
488
                    $yBoxProd,
489
                    $wBoxDescricao,
490
                    $hMaxLinha,
491
                    $texto,
492
                    $aFontProdutos,
493
                    'C',
494
                    'L',
495
                    0,
496
                    '',
497
                    false
498
                );
499
                //COLOCA PRODUTO QUANTIDADE
500
                $wBoxQt = $w*0.08;
501
                $xBoxQt = $wBoxDescricao + $xBoxDescricao;
502
                $texto = $qCom;
503
                $this->pTextBox(
504
                    $xBoxQt,
505
                    $yBoxProd,
506
                    $wBoxQt,
507
                    $hMaxLinha,
508
                    $texto,
509
                    $aFontProdutos,
510
                    'C',
511
                    'C',
512
                    0,
513
                    '',
514
                    false
515
                );
516
                //COLOCA PRODUTO UNIDADE
517
                $wBoxUn = $w*0.06;
518
                $xBoxUn = $wBoxQt + $xBoxQt;
519
                $texto = $uCom;
520
                $this->pTextBox(
521
                    $xBoxUn,
522
                    $yBoxProd,
523
                    $wBoxUn,
524
                    $hMaxLinha,
525
                    $texto,
526
                    $aFontProdutos,
527
                    'C',
528
                    'C',
529
                    0,
530
                    '',
531
                    false
532
                );
533
                //COLOCA PRODUTO VL UNITÁRIO
534
                $wBoxVl = $w*0.13;
535
                $xBoxVl = $wBoxUn + $xBoxUn;
536
                $texto = $vUnCom;
537
                $this->pTextBox(
538
                    $xBoxVl,
539
                    $yBoxProd,
540
                    $wBoxVl,
541
                    $hMaxLinha,
542
                    $texto,
543
                    $aFontProdutos,
544
                    'C',
545
                    'R',
546
                    0,
547
                    '',
548
                    false
549
                );
550
                //COLOCA PRODUTO VL TOTAL
551
                $wBoxTotal = $w*0.13;
552
                $xBoxTotal = $wBoxVl + $xBoxVl;
553
                $texto = $vProd;
554
                $this->pTextBox(
555
                    $xBoxTotal,
556
                    $yBoxProd,
557
                    $wBoxTotal,
558
                    $hMaxLinha,
559
                    $texto,
560
                    $aFontProdutos,
561
                    'C',
562
                    'R',
563
                    0,
564
                    '',
565
                    false
566
                );
567
                
568
                $cont++;
569
            }
570
        }
571
    }
572
    
573
    protected function pTotalDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
574
    {
575
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
576
        $maxW = $this->wPrint;
577
        $hLinha = 3;
578
        $wColEsq = ($maxW*0.7);
579
        $wColDir = ($maxW*0.3);
580
        $xValor = $x + $wColEsq;
581
        $qtdItens = $this->det->length;
582
        $vProd = $this->pSimpleGetValue($this->ICMSTot, "vProd");
583
        $vNF = $this->pSimpleGetValue($this->ICMSTot, "vNF");
584
        $vDesc  = $this->pSimpleGetValue($this->ICMSTot, "vDesc");
585
        $vTotTrib = $this->pSimpleGetValue($this->ICMSTot, "vTotTrib");
586
        $texto = "Qtd. Total de Itens";
587
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
588
        $this->pTextBox($x, $y, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
589
        $texto = $qtdItens;
590
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
591
        $this->pTextBox($xValor, $y, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
592
        $yTotal = $y + ($hLinha);
593
        $texto = "Total de Produtos";
594
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
595
        $this->pTextBox($x, $yTotal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
596
        $texto = "R$ " . number_format($vProd, 2, ",", ".");
597
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
598
        $this->pTextBox($xValor, $yTotal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
599
        $yDesconto = $y + ($hLinha*2);
600
        $texto = "Descontos";
601
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
602
        $this->pTextBox($x, $yDesconto, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
603
        $texto = "R$ " . $vDesc;
604
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
605
        $this->pTextBox($xValor, $yDesconto, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
606
        $yTotalFinal = $y + ($hLinha*3);
607
        $texto = "Total";
608
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
609
        $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
610
        $texto = "R$ " . $vNF;
611
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
612
        $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
613
        $yTotalFinal = $y + ($hLinha*4);
614
        $texto = "Informação dos Tributos Totais Incidentes";
615
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
616
        $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
617
        $texto = "R$ " . $vTotTrib;
618
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
619
        $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
620
    }
621
    
622
    protected function pPagamentosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
623
    {
624
        $y += 4;
625
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
626
        $maxW = $this->wPrint;
627
        $qtdPgto = $this->pag->length;
628
        $w = ($maxW*1);
629
        $hLinha = $this->hLinha;
630
        $wColEsq = ($maxW*0.7);
631
        $wColDir = ($maxW*0.3);
0 ignored issues
show
Unused Code introduced by
$wColDir is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
632
        $xValor = $x + $wColEsq;
0 ignored issues
show
Unused Code introduced by
$xValor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
633
        $aFontPgto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
634
        $wBoxEsq = $w*0.7;
635
        $texto = "FORMA DE PAGAMENTO";
636
        $this->pTextBox($x, $y, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
637
        $wBoxDir = $w*0.3;
638
        $xBoxDescricao = $x + $wBoxEsq;
639
        $texto = "VALOR PAGO";
640
        $this->pTextBox($xBoxDescricao, $y, $wBoxDir, $hLinha, $texto, $aFontPgto, 'T', 'R', 0, '', false);
641
        $cont = 0;
642
        if ($qtdPgto > 0) {
643
            foreach ($this->pag as $pagI) {
644
                $tPag = $this->pSimpleGetValue($pagI, "tPag");
645
                $tPagNome = $this->tipoPag($tPag);
646
                $tPnome = $tPagNome;
0 ignored issues
show
Unused Code introduced by
$tPnome is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
647
                $vPag = number_format($this->pSimpleGetValue($pagI, "vPag"), 2, ",", ".");
648
                $card = $pagI->getElementsByTagName("card")->item(0);
649
                $cardCNPJ = '';
0 ignored issues
show
Unused Code introduced by
$cardCNPJ is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
650
                $tBand = '';
0 ignored issues
show
Unused Code introduced by
$tBand is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
651
                $tBandNome = '';
0 ignored issues
show
Unused Code introduced by
$tBandNome is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
652
                if (isset($card)) {
653
                    $cardCNPJ = $this->pSimpleGetValue($card, "CNPJ");
0 ignored issues
show
Unused Code introduced by
$cardCNPJ is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
654
                    $tBand    = $this->pSimpleGetValue($card, "tBand");
655
                    $cAut = $this->pSimpleGetValue($card, "cAut");
0 ignored issues
show
Unused Code introduced by
$cAut is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
656
                    $tBandNome = self::getCardName($tBand);
0 ignored issues
show
Unused Code introduced by
$tBandNome is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
657
                }
658
                //COLOCA PRODUTO
659
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
660
                //COLOCA PRODUTO CÓDIGO
661
                $texto = $tPagNome;
662
                $this->pTextBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
663
                //COLOCA PRODUTO DESCRIÇÃO
664
                $xBoxDescricao = $wBoxEsq + $x;
665
                $texto = "R$ " . $vPag;
666
                $this->pTextBox(
667
                    $xBoxDescricao,
668
                    $yBoxProd,
669
                    $wBoxDir,
670
                    $hLinha,
671
                    $texto,
672
                    $aFontPgto,
673
                    'C',
674
                    'R',
675
                    0,
676
                    '',
677
                    false
678
                );
679
                $cont++;
680
            }
681
        }
682
    }
683
    
684
    protected function pFiscalDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
685
    {
686
        $y += 4;
687
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
688
        $maxW = $this->wPrint;
689
        $w = ($maxW*1);
690
        $hLinha = $this->hLinha;
691
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
692
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
693
        $digVal = $this->pSimpleGetValue($this->nfe, "DigestValue");
0 ignored issues
show
Unused Code introduced by
$digVal is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
694
        $chNFe = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
695
        $tpAmb = $this->pSimpleGetValue($this->ide, 'tpAmb');
696
        $cUF = $this->pSimpleGetValue($this->ide, 'cUF');
697
        $nNF = $this->pSimpleGetValue($this->ide, 'nNF');
698
        $serieNF = str_pad($this->pSimpleGetValue($this->ide, "serie"), 3, "0", STR_PAD_LEFT);
699
        $dhEmi = $this->pSimpleGetValue($this->ide, "dhEmi");
700
        $urlChave = $this->urlConsulta[$tpAmb][$this->UFSigla[$cUF]];
701
        $texto = "ÁREA DE MENSAGEM FISCAL";
702
        $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
703
        $yTex1 = $y + ($hLinha*1);
704
        $hTex1 = $hLinha*2;
705
        $texto = "Número " . $nNF . " Série " . $serieNF . " " .$dhEmi . " - Via Consumidor";
706
        $this->pTextBox($x, $yTex1, $w, $hTex1, $texto, $aFontTex, 'C', 'C', 0, '', false);
707
        $yTex2 = $y + ($hLinha*3);
708
        $hTex2 = $hLinha*2;
709
        $texto = "Consulte pela Chave de Acesso em " . $urlChave;
710
        $this->pTextBox($x, $yTex2, $w, $hTex2, $texto, $aFontTex, 'C', 'C', 0, '', false);
711
        $texto = "CHAVE DE ACESSO";
712
        $yTit2 = $y + ($hLinha*5);
713
        $this->pTextBox($x, $yTit2, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
714
        $yTex3 = $y + ($hLinha*6);
715
        $texto = $chNFe;
716
        $this->pTextBox($x, $yTex3, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
717
    }
718
    
719
    protected function pConsumidorDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
720
    {
721
        $y += 4;
722
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
723
        $maxW = $this->wPrint;
724
        $w = ($maxW*1);
725
        $hLinha = $this->hLinha;
726
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
727
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
728
        $texto = "CONSUMIDOR";
729
        $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
730
        if (isset($this->dest)) {
731
            $considEstrangeiro = !empty($this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue)
732
                    ? $this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue
733
                    : '';
734
            $consCPF = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
735
                    ? $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue
736
                    : '';
737
            $consCNPJ = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)
738
                    ? $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue
739
                    : '';
740
            $cDest = $consCPF.$consCNPJ.$considEstrangeiro; //documentos do consumidor
0 ignored issues
show
Unused Code introduced by
$cDest is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
741
            $enderDest = $this->dest->getElementsByTagName("enderDest")->item(0);
742
            $consNome = $this->pSimpleGetValue($this->dest, "xNome");
743
            $consLgr = $this->pSimpleGetValue($enderDest, "xLgr");
744
            $consNro = $this->pSimpleGetValue($enderDest, "nro");
745
            $consCpl = $this->pSimpleGetValue($enderDest, "xCpl", " - ");
746
            $consBairro = $this->pSimpleGetValue($enderDest, "xBairro");
747
            $consCEP = $this->pFormat($this->pSimpleGetValue($enderDest, "CEP"));
748
            $consMun = $this->pSimpleGetValue($enderDest, "xMun");
749
            $consUF = $this->pSimpleGetValue($enderDest, "UF");
750
            $considEstrangeiro = $this->pSimpleGetValue($this->dest, "idEstrangeiro");
751
            $consCPF = $this->pSimpleGetValue($this->dest, "CPF");
752
            $consCNPJ = $this->pSimpleGetValue($this->dest, "CNPJ");
753
            $consDoc = "";
754
            if (!empty($consCNPJ)) {
755
                $consDoc = "CNPJ: $consCNPJ";
756
            } elseif (!empty($consCPF)) {
757
                $consDoc = "CPF: $consCPF";
758
            } elseif (!empty($considEstrangeiro)) {
759
                $consDoc = "id: $considEstrangeiro";
760
            }
761
            $consEnd = "";
762
            if (!empty($consLgr)) {
763
                $consEnd = $consLgr
764
                    . ","
765
                    . $consNro
766
                    . " "
767
                    . $consCpl
768
                    . ","
769
                    . $consBairro
770
                    . ". CEP:"
771
                    . $consCEP
772
                    . ". "
773
                    . $consMun
774
                    . "-"
775
                    . $consUF;
776
            }
777
            $yTex1 = $y + $hLinha;
778
            $texto = $consNome;
779
            if (!empty($consDoc)) {
780
                $texto .= " - ". $consDoc . "\n" . $consEnd;
781
                $this->pTextBox($x, $yTex1, $w, $hLinha*3, $texto, $aFontTex, 'C', 'C', 0, '', false);
782
            }
783
        } else {
784
            $yTex1 = $y + $hLinha;
785
            $texto = "Consumidor não identificado";
786
            $this->pTextBox($x, $yTex1, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
787
        }
788
    }
789
    
790
    protected function pQRDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
791
    {
792
        $y += 4;
793
        $margemInterna = $this->margemInterna;
794
        $maxW = $this->wPrint;
795
        $w = ($maxW*1);
796
        $hLinha = $this->hLinha;
0 ignored issues
show
Unused Code introduced by
$hLinha is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
797
        $hBoxLinha = $this->hBoxLinha;
798
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
0 ignored issues
show
Unused Code introduced by
$aFontTit is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
799
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
800
        $dhRecbto = '';
801
        $nProt = '';
802
        if (isset($this->nfeProc)) {
803
            $nProt = $this->pSimpleGetValue($this->nfeProc, "nProt");
804
            $dhRecbto  = $this->pSimpleGetValue($this->nfeProc, "dhRecbto");
805
        }
806
        $qrcode = new QRcode($this->qrCode, 'M');
0 ignored issues
show
Unused Code introduced by
The call to QrCode::__construct() has too many arguments starting with 'M'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
807
        $wQr = 50;
808
        $hQr = 50;
809
        $yQr = ($y+$margemInterna);
810
        $xQr = ($w/2) - ($wQr/2);
811
        // prepare a base64 encoded "data url"
812
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode->writeString());
813
        $info = getimagesize($pic);
0 ignored issues
show
Unused Code introduced by
$info is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
814
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
815
        $dt = new DateTime($dhRecbto);
816
        $yQr = ($yQr+$hQr+$margemInterna);
817
        $this->pTextBox($x, $yQr, $w, $hBoxLinha, "Protocolo de Autorização: " . $nProt . "\n"
818
            . $dt->format('d/m/Y H:i:s'), $aFontTex, 'C', 'C', 0, '', false);
819
    }
820
   
821
    /**
822
     * printDANFE
823
     * Esta função envia a DANFE em PDF criada para o dispositivo informado.
824
     * O destino da impressão pode ser :
825
     * I-browser
826
     * D-browser com download
827
     * F-salva em um arquivo local com o nome informado
828
     * S-retorna o documento como uma string e o nome é ignorado.
829
     * Para enviar o pdf diretamente para uma impressora indique o
830
     * nome da impressora e o destino deve ser 'S'.
831
     *
832
     * @param  string $nome    Path completo com o nome do arquivo pdf
833
     * @param  string $destino Direção do envio do PDF
834
     * @param  string $printer Identificação da impressora no sistema
835
     * @return string Caso o destino seja S o pdf é retornado como uma string
836
     * @todo   Rotina de impressão direta do arquivo pdf criado
837
     */
838
    public function printDANFE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
839
    {
840
        $arq = $this->pdf->Output($nome, $destino);
841
        if ($destino == 'S') {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
842
            //aqui pode entrar a rotina de impressão direta
843
        }
844
        return $arq;
845
    }
846
847
    /**
848
     * Dados brutos do PDF
849
     * @return string
850
     */
851
    public function render()
852
    {
853
        return $this->pdf->getPdf();
854
    }
855
    
856
    /**
857
     * str2Hex
858
     * Converte string para haxadecimal ASCII
859
     *
860
     * @param  string $str
861
     * @return string
862
     */
863
    protected static function str2Hex($str)
864
    {
865
        if ($str == '') {
866
            return '';
867
        }
868
        $hex = "";
869
        $iCount = 0;
870
        do {
871
            $hex .= sprintf("%02x", ord($str{$iCount}));
872
            $iCount++;
873
        } while ($iCount < strlen($str));
874
        return $hex;
875
    }//fim str2Hex
876
    
877
    protected static function getCardName($tBand)
878
    {
879
        switch ($tBand) {
880
            case '01':
881
                $tBandNome = 'VISA';
882
                break;
883
            case '02':
884
                $tBandNome = 'MASTERCARD';
885
                break;
886
            case '03':
887
                $tBandNome = 'AMERICAM EXPRESS';
888
                break;
889
            case '04':
890
                $tBandNome = 'SOROCRED';
891
                break;
892
            case '99':
893
                $tBandNome = 'OUTROS';
894
        }
895
        return $tBandNome;
0 ignored issues
show
Bug introduced by
The variable $tBandNome does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
896
    }
897
    
898
    protected function tipoPag($tPag)
899
    {
900
        switch ($tPag) {
901
            case '01':
902
                $tPagNome = 'Dinheiro';
903
                break;
904
            case '02':
905
                $tPagNome = 'Cheque';
906
                break;
907
            case '03':
908
                $tPagNome = 'Cartão de Crédito';
909
                break;
910
            case '04':
911
                $tPagNome = 'Cartão de Débito';
912
                break;
913
            case '05':
914
                $tPagNome = 'Crédito Loja';
915
                break;
916
            case '10':
917
                $tPagNome = 'Vale Alimentação';
918
                break;
919
            case '11':
920
                $tPagNome = 'Vale Refeição';
921
                break;
922
            case '12':
923
                $tPagNome = 'Vale Presente';
924
                break;
925
            case '13':
926
                $tPagNome = 'Vale Combustível';
927
                break;
928
            case '99':
929
                $tPagNome = 'Outros';
930
        }
931
        return $tPagNome;
0 ignored issues
show
Bug introduced by
The variable $tPagNome does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
932
    }
933
    
934
    /**
935
     * hex2Str
936
     * Converte hexadecimal ASCII para string
937
     *
938
     * @param  string $str
939
     * @return string
940
     */
941
    protected static function hex2Str($str)
942
    {
943
        if ($str == '') {
944
            return '';
945
        }
946
        $bin = "";
947
        $iCount = 0;
948
        do {
949
            $bin .= chr(hexdec($str{$iCount}.$str{($iCount + 1)}));
950
            $iCount += 2;
951
        } while ($iCount < strlen($str));
952
        return $bin;
953
    }
954
    
955
    protected function makeQRCode(
956
        $chNFe,
957
        $url,
958
        $tpAmb,
959
        $cDest = '',
960
        $dhEmi = '',
961
        $vNF = '',
962
        $vICMS = '',
963
        $digVal = '',
964
        $idToken = '000001',
965
        $token = ''
966
    ) {
967
        $nVersao = '100';
968
        $dhHex = self::str2Hex($dhEmi);
969
        $digHex = self::str2Hex($digVal);
970
        $seq = '';
971
        $seq .= 'chNFe=' . $chNFe;
972
        $seq .= '&nVersao=' . $nVersao;
973
        $seq .= '&tpAmb=' . $tpAmb;
974
        if ($cDest != '') {
975
            $seq .= '&cDest=' . $cDest;
976
        }
977
        $seq .= '&dhEmi=' . strtolower($dhHex);
978
        $seq .= '&vNF=' . $vNF;
979
        $seq .= '&vICMS=' . $vICMS;
980
        $seq .= '&digVal=' . strtolower($digHex);
981
        $seq .= '&cIdToken=' . $idToken;
982
        //o hash code é calculado com o Token incluso
983
        $hash = sha1($seq.$token);
984
        $seq .= '&cHashQRCode='. strtoupper($hash);
985
        if (strpos($url, '?') === false) {
986
            $seq = $url.'?'.$seq;
987
        } else {
988
            $seq = $url.''.$seq;
989
        }
990
        return $seq;
991
    }
992
}
993