Completed
Pull Request — master (#289)
by
unknown
03:16
created

Danfe::pLocalRetiradaDANFE()   F

Complexity

Conditions 12
Paths 768

Size

Total Lines 140

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 156

Importance

Changes 0
Metric Value
cc 12
nc 768
nop 2
dl 0
loc 140
ccs 0
cts 128
cp 0
crap 156
rs 2.4977
c 0
b 0
f 0

How to fix   Long Method    Complexity   

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
use InvalidArgumentException;
6
use NFePHP\DA\Legacy\Dom;
7
use NFePHP\DA\Legacy\Pdf;
8
use NFePHP\DA\Legacy\Common;
9
10
class Danfe extends Common
11
{
12
13
    /**
14
     * alinhamento padrão do logo (C-Center)
15
     *
16
     * @var string
17
     */
18
    protected $logoAlign = 'C';
19
    /**
20
     * Posição
21
     * @var float
22
     */
23
    protected $yDados = 0;
24
    /**
25
     * Numero DPEC
26
     *
27
     * @var string
28
     */
29
    protected $numero_registro_dpec = '';
30
     /**
31
     * Parâmetro para exibir ou ocultar os valores do PIS/COFINS.
32
     * @var boolean
33
     */
34
    protected $qCanhoto = 1;
35
    /**
36
     * Define a exbição dos valores de PIS e Cofins
37
     * @var bool
38
     */
39
    protected $exibirPIS = true;
40
    /**
41
     * Parâmetro para exibir ou ocultar os valores do ICMS Interestadual e Valor Total dos Impostos.
42
     * @var boolean
43
     */
44
    protected $exibirIcmsInterestadual = true;
45
    /**
46
     * Parâmetro para exibir ou ocultar o texto sobre valor aproximado dos tributos.
47
     * @var boolean
48
     */
49
    protected $exibirValorTributos = true;
50
    /**
51
     * Parâmetro para exibir ou ocultar o texto adicional sobre a forma de pagamento
52
     * e as informações de fatura/duplicata.
53
     * @var boolean
54
     */
55
    protected $exibirTextoFatura = false;
56
    /**
57
     * Parâmetro do controle se deve concatenar automaticamente informações complementares
58
     * na descrição do produto, como por exemplo, informações sobre impostos.
59
     * @var boolean
60
     */
61
    protected $descProdInfoComplemento = true;
62
    /**
63
     * Parâmetro do controle se deve gerar quebras de linha com "\n" a partir de ";" na descrição do produto.
64
     * @var boolean
65
     */
66
    protected $descProdQuebraLinha = true;
67
    /**
68
     * objeto fpdf()
69
     * @var \NFePHP\DA\Legacy\Pdf
70
     */
71
    protected $pdf;
72
    /**
73
     * XML NFe
74
     * @var string
75
     */
76
    protected $xml;
77
    /**
78
     * path para logomarca em jpg
79
     * @var string
80
     */
81
    protected $logomarca = '';
82
    /**
83
     * mesagens de erro
84
     * @var string
85
     */
86
    protected $errMsg = '';
87
    /**
88
     * status de erro true um erro ocorreu false sem erros
89
     * @var boolean
90
     */
91
    protected $errStatus = false;
92
    /**
93
     * orientação da DANFE
94
     * P-Retrato ou L-Paisagem
95
     * @var string
96
     */
97
    protected $orientacao = 'P';
98
    /**
99
     * formato do papel
100
     * @var string
101
     */
102
    protected $papel = 'A4';
103
    /**
104
     * Nome da Fonte para gerar o DANFE
105
     * @var string
106
     */
107
    protected $fontePadrao = 'Times';
108
    /**
109
     * Texto adicional da DANFE
110
     * @var string
111
     */
112
    protected $textoAdic = '';
113
    /**
114
     * Largura
115
     * @var float
116
     */
117
    protected $wAdic = 0;
118
    /**
119
     * largura imprimivel, em milímetros
120
     * @var float
121
     */
122
    protected $wPrint;
123
    /**
124
     * Comprimento (altura) imprimivel, em milímetros
125
     * @var float
126
     */
127
    protected $hPrint;
128
    /**
129
     * Altura maxima
130
     * @var float
131
     */
132
    protected $maxH;
133
    /**
134
     * Largura maxima
135
     * @var float
136
     */
137
    protected $maxW;
138
    /**
139
     * largura do canhoto (25mm) apenas para a formatação paisagem
140
     * @var float
141
     */
142
    protected $wCanhoto = 25;
143
    /**
144
     * Formato chave
145
     * @var string
146
     */
147
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
148
    /**
149
     * quantidade de itens já processados na montagem do DANFE
150
     * @var integer
151
     */
152
    protected $qtdeItensProc;
153
    /**
154
     * Dom Document
155
     * @var \NFePHP\DA\Legacy\Dom
156
     */
157
    protected $dom;
158
    /**
159
     * Node
160
     * @var \DOMNode
161
     */
162
    protected $infNFe;
163
    /**
164
     * Node
165
     * @var \DOMNode
166
     */
167
    protected $ide;
168
    /**
169
     * Node
170
     * @var \DOMNode
171
     */
172
    protected $entrega;
173
    /**
174
     * Node
175
     * @var \DOMNode
176
     */
177
    protected $retirada;
178
    /**
179
     * Node
180
     * @var \DOMNode
181
     */
182
    protected $emit;
183
    /**
184
     * Node
185
     * @var \DOMNode
186
     */
187
    protected $dest;
188
    /**
189
     * Node
190
     * @var \DOMNode
191
     */
192
    protected $enderEmit;
193
    /**
194
     * Node
195
     * @var \DOMNode
196
     */
197
    protected $enderDest;
198
    /**
199
     * Node
200
     * @var \DOMNode
201
     */
202
    protected $det;
203
    /**
204
     * Node
205
     * @var \DOMNode
206
     */
207
    protected $cobr;
208
    /**
209
     * Node
210
     * @var \DOMNode
211
     */
212
    protected $dup;
213
    /**
214
     * Node
215
     * @var \DOMNode
216
     */
217
    protected $ICMSTot;
218
    /**
219
     * Node
220
     * @var \DOMNode
221
     */
222
    protected $ISSQNtot;
223
    /**
224
     * Node
225
     * @var \DOMNode
226
     */
227
    protected $transp;
228
    /**
229
     * Node
230
     * @var \DOMNode
231
     */
232
    protected $transporta;
233
    /**
234
     * Node
235
     * @var \DOMNode
236
     */
237
    protected $veicTransp;
238
    /**
239
     * Node reboque
240
     * @var \DOMNode
241
     */
242
    protected $reboque;
243
    /**
244
     * Node infAdic
245
     * @var \DOMNode
246
     */
247
    protected $infAdic;
248
    /**
249
     * Tipo de emissão
250
     * @var integer
251
     */
252
    protected $tpEmis;
253
    /**
254
     * Node infProt
255
     * @var \DOMNode
256
     */
257
    protected $infProt;
258
    /**
259
     * 1-Retrato/ 2-Paisagem
260
     * @var integer
261
     */
262
    protected $tpImp;
263
    /**
264
     * Node compra
265
     * @var \DOMNode
266
     */
267
    protected $compra;
268
    /**
269
     * ativa ou desativa o modo de debug
270
     * @var integer
271
     */
272
    protected $debugmode = false;
273
    /**
274
     * Creditos para integrador
275
     * @var string
276
     */
277
    protected $creditos = '';
278
279
    /**
280
     * __construct
281
     *
282
     * @name  __construct
283
     * @param string  $xml Conteúdo XML da NF-e (com ou sem a tag nfeProc)
284
     */
285
    public function __construct($xml)
286
    {
287
        $this->debugMode();
288
        $this->loadDoc($xml);
289
    }
290
    
291
    /**
292
     * Ativa ou desativa o modo debug
293
     * @param bool $activate
294
     * @return bool
295
     */
296
    public function debugMode($activate = null)
297
    {
298
        if (isset($activate) && is_bool($activate)) {
299
            $this->debugmode = $activate;
0 ignored issues
show
Documentation Bug introduced by
The property $debugmode was declared of type integer, but $activate is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
300
        }
301
        if ($this->debugmode) {
302
            //ativar modo debug
303
            error_reporting(E_ALL);
304
            ini_set('display_errors', 'On');
305
        } else {
306
            //desativar modo debug
307
            error_reporting(0);
308
            ini_set('display_errors', 'Off');
309
        }
310
        return $this->debugmode;
311
    }
312
313
    /**
314
     * Add the credits to the integrator in the footer message
315
     * @param string $message
316
     */
317
    public function creditsIntegratorFooter($message = '')
318
    {
319
        $this->creditos = trim($message);
320
    }
321
    
322
    /**
323
     * Dados brutos do PDF
324
     * @return string
325
     */
326
    public function render()
327
    {
328
        if (empty($this->pdf)) {
329
            $this->monta();
330
        }
331
        return $this->pdf->getPdf();
332
    }
333
334
    /**
335
     * monta
336
     * Monta a DANFE conforme as informações fornecidas para a classe durante sua
337
     * construção. Constroi DANFEs com até 3 páginas podendo conter até 56 itens.
338
     * A definição de margens e posições iniciais para a impressão são estabelecidas
339
     * pelo conteúdo da funçao e podem ser modificados.
340
     *
341
     * @param  string $orientacao (Opcional) Estabelece a orientação da impressão
342
     *  (ex. P-retrato), se nada for fornecido será usado o padrão da NFe
343
     * @param  string $papel      (Opcional) Estabelece o tamanho do papel (ex. A4)
344
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
345
     */
346
    public function monta(
347
        $logo = '',
348
        $orientacao = '',
349
        $papel = 'A4',
350
        $logoAlign = 'C',
351
        $depecNumReg = '',
352
        $margSup = 2,
353
        $margEsq = 2,
354
        $margInf = 2
355
    ) {
356
        $this->pdf = '';
0 ignored issues
show
Documentation Bug introduced by
It seems like '' of type string is incompatible with the declared type object<NFePHP\DA\Legacy\Pdf> of property $pdf.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
357
        $this->logomarca = $logo;
358
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
359
        if ($orientacao == '') {
360
            if ($this->tpImp == '2') {
361
                $orientacao = 'L';
362
            } else {
363
                $orientacao = 'P';
364
            }
365
        }
366
        $this->orientacao = $orientacao;
367
        $this->papel = $papel;
368
        $this->logoAlign = $logoAlign;
369
        $this->numero_registro_dpec = $depecNumReg;
370
        //instancia a classe pdf
371
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
372
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
373
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
374
        //apenas para controle se necessário ser maior do que a margem superior
375
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
376
        $xInic = $margEsq;
377
        if ($this->orientacao == 'P') {
378
            if ($papel == 'A4') {
379
                $this->maxW = 210;
0 ignored issues
show
Documentation Bug introduced by
The property $maxW was declared of type double, but 210 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
380
                $this->maxH = 297;
0 ignored issues
show
Documentation Bug introduced by
The property $maxH was declared of type double, but 297 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
381
            }
382
        } else {
383
            if ($papel == 'A4') {
384
                $this->maxW = 297;
0 ignored issues
show
Documentation Bug introduced by
The property $maxW was declared of type double, but 297 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
385
                $this->maxH = 210;
0 ignored issues
show
Documentation Bug introduced by
The property $maxH was declared of type double, but 210 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
386
                $xInic = $margEsq+10;
387
                //se paisagem multiplica a largura do canhoto pela quantidade de canhotos
388
                //$this->wCanhoto *= $this->qCanhoto;
389
            }
390
        }
391
        //total inicial de paginas
392
        $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...
393
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
394
        $this->wPrint = $this->maxW-($margEsq * 2);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->maxW - $margEsq * 2 can also be of type integer. However, the property $wPrint is declared as type double. 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...
395
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
396
        //superior e inferior
397
        $this->hPrint = $this->maxH-$margSup-$margInf;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->maxH - $margSup - $margInf can also be of type integer. However, the property $hPrint is declared as type double. 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...
398
        // estabelece contagem de paginas
399
        $this->pdf->aliasNbPages();
400
        // fixa as margens
401
        $this->pdf->setMargins($margEsq, $margSup);
402
        $this->pdf->setDrawColor(0, 0, 0);
403
        $this->pdf->setFillColor(255, 255, 255);
404
        // inicia o documento
405
        $this->pdf->open();
406
        // adiciona a primeira página
407
        $this->pdf->addPage($this->orientacao, $this->papel);
408
        $this->pdf->setLineWidth(0.1);
409
        $this->pdf->settextcolor(0, 0, 0);
410
411
        //##################################################################
412
        // CALCULO DO NUMERO DE PAGINAS A SEREM IMPRESSAS
413
        //##################################################################
414
        //Verificando quantas linhas serão usadas para impressão das duplicatas
415
        $linhasDup = 0;
416
        $qtdPag = 0;
417
        if (isset($this->dup) && $this->dup->length > 0) {
418
            $qtdPag = $this->dup->length;
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
419
        } elseif (isset($this->detPag) && $this->detPag->length > 0) {
0 ignored issues
show
Bug introduced by
The property detPag 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...
420
            $qtdPag = $this->detPag->length;
421
        }
422
        if (($qtdPag > 0) && ($qtdPag <= 7)) {
423
            $linhasDup = 1;
424
        } elseif (($qtdPag > 7) && ($qtdPag <= 14)) {
425
            $linhasDup = 2;
426
        } elseif (($qtdPag > 14) && ($qtdPag <= 21)) {
427
            $linhasDup = 3;
428
        } elseif ($qtdPag > 21) {
429
            // chinnonsantos 11/05/2016: Limite máximo de impressão de duplicatas na NFe,
430
            // só vai ser exibito as 21 primeiras duplicatas (parcelas de pagamento),
431
            // se não oculpa espaço d+, cada linha comporta até 7 duplicatas.
432
            $linhasDup = 3;
433
        }
434
        //verifica se será impressa a linha dos serviços ISSQN
435
        $linhaISSQN = 0;
436
        if ((isset($this->ISSQNtot)) && ($this->getTagValue($this->ISSQNtot, 'vServ') > 0)) {
437
            $linhaISSQN = 1;
438
        }
439
        //calcular a altura necessária para os dados adicionais
440
        if ($this->orientacao == 'P') {
441
            $this->wAdic = round($this->wPrint*0.66, 0);
442
        } else {
443
            $this->wAdic = round(($this->wPrint-$this->wCanhoto)*0.5, 0);
444
        }
445
        $fontProduto = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
446
        $this->textoAdic = '';
447
        if (isset($this->retirada)) {
448
            $txRetCNPJ = $this->getTagValue($this->retirada, "CNPJ");
449
            $txRetxLgr = $this->getTagValue($this->retirada, "xLgr");
450
            $txRetnro = $this->getTagValue($this->retirada, "nro");
451
            $txRetxCpl = $this->getTagValue($this->retirada, "xCpl", " - ");
452
            $txRetxBairro = $this->getTagValue($this->retirada, "xBairro");
453
            $txRetxMun = $this->getTagValue($this->retirada, "xMun");
454
            $txRetUF = $this->getTagValue($this->retirada, "UF");
455
            $this->textoAdic .= "LOCAL DE RETIRADA : ".
456
                    $txRetCNPJ.
457
                    '-' .
458
                    $txRetxLgr .
459
                    ', ' .
460
                    $txRetnro .
461
                    ' ' .
462
                    $txRetxCpl .
463
                    ' - ' .
464
                    $txRetxBairro .
465
                    ' ' .
466
                    $txRetxMun .
467
                    ' - ' .
468
                    $txRetUF .
469
                    "\r\n";
470
        }
471
        //dados do local de entrega da mercadoria
472
        if (isset($this->entrega)) {
473
            $txRetCNPJ = $this->getTagValue($this->entrega, "CNPJ");
474
            $txRetxLgr = $this->getTagValue($this->entrega, "xLgr");
475
            $txRetnro = $this->getTagValue($this->entrega, "nro");
476
            $txRetxCpl = $this->getTagValue($this->entrega, "xCpl", " - ");
477
            $txRetxBairro = $this->getTagValue($this->entrega, "xBairro");
478
            $txRetxMun = $this->getTagValue($this->entrega, "xMun");
479
            $txRetUF = $this->getTagValue($this->entrega, "UF");
480
            if ($this->textoAdic != '') {
481
                $this->textoAdic .= ". \r\n";
482
            }
483
            $this->textoAdic .= "LOCAL DE ENTREGA : ".$txRetCNPJ.'-'.$txRetxLgr.', '.$txRetnro.' '.$txRetxCpl.
484
               ' - '.$txRetxBairro.' '.$txRetxMun.' - '.$txRetUF."\r\n";
485
        }
486
        //informações adicionais
487
        $this->textoAdic .= $this->geraInformacoesDasNotasReferenciadas();
488
        if (isset($this->infAdic)) {
489
            $i = 0;
490
            if ($this->textoAdic != '') {
491
                $this->textoAdic .= ". \r\n";
492
            }
493
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infCpl"))
494
            ? 'Inf. Contribuinte: ' . $this->anfaveaDANFE($this->getTagValue($this->infAdic, "infCpl"))
495
            : '';
496
            $infPedido = $this->geraInformacoesDaTagCompra();
497
            if ($infPedido != "") {
498
                $this->textoAdic .= $infPedido;
499
            }
500
            $this->textoAdic .= $this->getTagValue($this->dest, "email", ' Email do Destinatário: ');
501
            $this->textoAdic .= ! empty($this->getTagValue($this->infAdic, "infAdFisco"))
502
            ? "\r\n Inf. fisco: " . $this->getTagValue($this->infAdic, "infAdFisco")
503
            : '';
504
            $obsCont = $this->infAdic->getElementsByTagName("obsCont");
505
            if (isset($obsCont)) {
506
                foreach ($obsCont as $obs) {
507
                    $campo =  $obsCont->item($i)->getAttribute("xCampo");
508
                    $xTexto = ! empty($obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue)
509
                    ? $obsCont->item($i)->getElementsByTagName("xTexto")->item(0)->nodeValue
510
                    : '';
511
                    $this->textoAdic .= "\r\n" . $campo . ':  ' . trim($xTexto);
512
                    $i++;
513
                }
514
            }
515
        }
516
        //INCLUSO pela NT 2013.003 Lei da Transparência
517
        //verificar se a informação sobre o valor aproximado dos tributos
518
        //já se encontra no campo de informações adicionais
519
        if ($this->exibirValorTributos) {
520
            $flagVTT = strpos(strtolower(trim($this->textoAdic)), 'valor');
521
            $flagVTT = $flagVTT || strpos(strtolower(trim($this->textoAdic)), 'vl');
522
            $flagVTT = $flagVTT && strpos(strtolower(trim($this->textoAdic)), 'aprox');
523
            $flagVTT = $flagVTT && (strpos(strtolower(trim($this->textoAdic)), 'trib') ||
524
                    strpos(strtolower(trim($this->textoAdic)), 'imp'));
525
            $vTotTrib = $this->getTagValue($this->ICMSTot, 'vTotTrib');
526
            if ($vTotTrib != '' && !$flagVTT) {
527
                $this->textoAdic .= "\n Valor Aproximado dos Tributos : R$ "
528
                    . number_format($vTotTrib, 2, ",", ".");
529
            }
530
        }
531
        //fim da alteração NT 2013.003 Lei da Transparência
532
        $this->textoAdic = str_replace(";", "\n", $this->textoAdic);
533
        $alinhas = explode("\n", $this->textoAdic);
534
        $numlinhasdados = 0;
535
        foreach ($alinhas as $linha) {
536
            $numlinhasdados += $this->pdf->getNumLines($linha, $this->wAdic, $fontProduto);
537
        }
538
        $hdadosadic = round(($numlinhasdados+3) * $this->pdf->fontSize, 0);
539
        if ($hdadosadic < 10) {
540
            $hdadosadic = 10;
541
        }
542
        //altura disponivel para os campos da DANFE
543
        $hcabecalho = 47;//para cabeçalho
544
        $hdestinatario = 25;//para destinatario
545
        $hduplicatas = 12;//para cada grupo de 7 duplicatas
546
        if (isset($this->entrega)) {
547
            $hlocalentrega = 25;
548
        } else {
549
            $hlocalentrega = 0;
550
        }
551
        if (isset($this->retirada)) {
552
            $hlocalretirada = 25;
553
        } else {
554
            $hlocalretirada = 0;
555
        }
556
        $himposto = 18;// para imposto
557
        $htransporte = 25;// para transporte
558
        $hissqn = 11;// para issqn
559
        $hfooter = 5;// para rodape
560
        $hCabecItens = 4;//cabeçalho dos itens
561
        //alturas disponiveis para os dados
562
        $hDispo1 = $this->hPrint - 10 - ($hcabecalho +
563
            $hdestinatario + $hlocalentrega + $hlocalretirada +
564
            ($linhasDup * $hduplicatas) + $himposto + $htransporte +
565
            ($linhaISSQN * $hissqn) + $hdadosadic + $hfooter + $hCabecItens +
566
            $this->sizeExtraTextoFatura());
567
        if ($this->orientacao == 'P') {
568
            $hDispo1 -= 24 * $this->qCanhoto;//para canhoto
569
            $w = $this->wPrint;
570
        } else {
571
            $hcanhoto = $this->hPrint;//para canhoto
0 ignored issues
show
Unused Code introduced by
$hcanhoto 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...
572
            $w = $this->wPrint - $this->wCanhoto;
573
        }
574
        $hDispo2 = $this->hPrint - 10 - ($hcabecalho + $hfooter + $hCabecItens)-4;
575
        //Contagem da altura ocupada para impressão dos itens
576
        $fontProduto = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
577
        $numlinhas = 0;
0 ignored issues
show
Unused Code introduced by
$numlinhas 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...
578
        $hUsado = $hCabecItens;
579
        $w2 = round($w*0.28, 0);
580
        $hDispo = $hDispo1;
581
        $totPag = 1;
582
        $i = 0;
583
        while ($i < $this->det->length) {
584
            $texto = $this->descricaoProduto($this->det->item($i));
585
            $numlinhas = $this->pdf->getNumLines($texto, $w2, $fontProduto);
586
            $hUsado += round(($numlinhas * $this->pdf->fontSize) + ($numlinhas * 0.5), 2);
587
            if ($hUsado > $hDispo) {
588
                $totPag++;
589
                $hDispo = $hDispo2;
590
                $hUsado = $hCabecItens;
591
                // Remove canhoto para páginas secundárias em modo paisagem ('L')
592
                $w2 = round($this->wPrint*0.28, 0);
593
                $i--; // decrementa para readicionar o item que não coube nessa pagina na outra.
594
            }
595
            $i++;
596
        } //fim da soma das areas de itens usadas
597
        $qtdeItens = $i; //controle da quantidade de itens no DANFE
598
        //montagem da primeira página
599
        $pag = 1;
600
        
601
        $x = $margEsq;
602
        $y = $margSup;
603
        //coloca o(s) canhoto(s) da NFe
604
        if ($this->orientacao == 'P') {
605
            $y = $this->canhoto($margEsq, $margSup);
606
        } else {
607
            $this->canhoto($margEsq, $margSup);
608
            $x = 25;
609
        }
610
        //$x = $xInic;
611
        //$y = $yInic;
612
        
613
        //coloca o cabeçalho
614
        $y = $this->header($x, $y, $pag, $totPag);
615
        //coloca os dados do destinatário
616
        $y = $this->destinatarioDANFE($x, $y+1);
617
        
618
        //coloca os dados do local de retirada
619
        if (isset($this->retirada)) {
620
            $y = $this->pLocalRetiradaDANFE($x, $y+1);
621
        }
622
        //coloca os dados do local de entrega
623
        if (isset($this->entrega)) {
624
            $y = $this->pLocalEntregaDANFE($x, $y+1);
625
        }
626
        
627
        //Verifica as formas de pagamento da nota fiscal
628
        $formaPag = [];
629
        if (isset($this->detPag) && $this->detPag->length > 0) {
630
            foreach ($this->detPag as $k => $d) {
631
                $fPag = !empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
632
                ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
633
                : '0';
634
                $formaPag[$fPag] = $fPag;
635
            }
636
        }
637
        //caso tenha boleto imprimir fatura
638
        if ($this->dup->length > 0) {
639
            $y = $this->fatura($x, $y+1);
640
        } else {
641
            //Se somente tiver a forma de pagamento sem pagamento ou outros não imprimir nada
642
            if (count($formaPag)=='1' && (isset($formaPag[90]) || isset($formaPag[99]))) {
643
                $y = $y;
0 ignored issues
show
Bug introduced by
Why assign $y to itself?

This checks looks for cases where a variable has been assigned to itself.

This assignement can be removed without consequences.

Loading history...
644
            } else {
645
                //caso tenha mais de uma forma de pagamento ou seja diferente de boleto exibe a
646
                //forma de pagamento e o valor
647
                $y = $this->pagamento($x, $y+1);
648
            }
649
        }
650
        //coloca os dados dos impostos e totais da NFe
651
        $y = $this->imposto($x, $y+1);
652
        //coloca os dados do trasnporte
653
        $y = $this->transporte($x, $y+1);
654
        //itens da DANFE
655
        $nInicial = 0;
656
657
        $y = $this->itens($x, $y+1, $nInicial, $hDispo1, $pag, $totPag, $hCabecItens);
658
659
        //coloca os dados do ISSQN
660
        if ($linhaISSQN == 1) {
661
            $y = $this->issqn($x, $y+4);
662
        } else {
663
            $y += 4;
664
        }
665
        //coloca os dados adicionais da NFe
666
        $y = $this->dadosAdicionais($x, $y, $hdadosadic);
0 ignored issues
show
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...
667
        //coloca o rodapé da página
668
        if ($this->orientacao == 'P') {
669
            $this->rodape($xInic);
670
        } else {
671
            $this->rodape($xInic);
672
        }
673
674
        //loop para páginas seguintes
675
        for ($n = 2; $n <= $totPag; $n++) {
676
            // fixa as margens
677
            $this->pdf->setMargins($margEsq, $margSup);
678
            //adiciona nova página
679
            $this->pdf->addPage($this->orientacao, $this->papel);
680
            //ajusta espessura das linhas
681
            $this->pdf->setLineWidth(0.1);
682
            //seta a cor do texto para petro
683
            $this->pdf->settextcolor(0, 0, 0);
684
            // posição inicial do relatorio
685
            $x = $margEsq;
686
            $y = $margSup;
687
            //coloca o cabeçalho na página adicional
688
            $y = $this->header($x, $y, $n, $totPag);
689
            //coloca os itens na página adicional
690
            $y = $this->itens($x, $y+1, $nInicial, $hDispo2, $n, $totPag, $hCabecItens);
0 ignored issues
show
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...
691
            //coloca o rodapé da página
692
            if ($this->orientacao == 'P') {
693
                $this->rodape($margEsq);
694
            } else {
695
                $this->rodape($margEsq);
696
            }
697
            //se estiver na última página e ainda restar itens para inserir, adiciona mais uma página
698
            if ($n == $totPag && $this->qtdeItensProc < $qtdeItens) {
699
                $totPag++;
700
            }
701
        }
702
    }
703
704
    /**
705
     * anfavea
706
     * Função para transformar o campo cdata do padrão ANFAVEA para
707
     * texto imprimível
708
     *
709
     * @param  string $cdata campo CDATA
710
     * @return string conteúdo do campo CDATA como string
711
     */
712
    protected function anfaveaDANFE($cdata = '')
713
    {
714
        if ($cdata == '') {
715
            return '';
716
        }
717
        //remove qualquer texto antes ou depois da tag CDATA
718
        $cdata = str_replace('<![CDATA[', '<CDATA>', $cdata);
719
        $cdata = str_replace(']]>', '</CDATA>', $cdata);
720
        $cdata = preg_replace('/\s\s+/', ' ', $cdata);
721
        $cdata = str_replace("> <", "><", $cdata);
722
        $len = strlen($cdata);
723
        $startPos = strpos($cdata, '<');
724
        if ($startPos === false) {
725
            return $cdata;
726
        }
727
        for ($x=$len; $x>0; $x--) {
728
            if (substr($cdata, $x, 1) == '>') {
729
                $endPos = $x;
730
                break;
731
            }
732
        }
733
        if ($startPos > 0) {
734
            $parte1 = substr($cdata, 0, $startPos);
735
        } else {
736
            $parte1 = '';
737
        }
738
        $parte2 = substr($cdata, $startPos, $endPos-$startPos+1);
0 ignored issues
show
Bug introduced by
The variable $endPos 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...
739
        if ($endPos < $len) {
740
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
741
        } else {
742
            $parte3 = '';
743
        }
744
        $texto = trim($parte1).' '.trim($parte3);
745
        if (strpos($parte2, '<CDATA>') === false) {
746
            $cdata = '<CDATA>'.$parte2.'</CDATA>';
747
        } else {
748
            $cdata = $parte2;
749
        }
750
        //Retira a tag <FONTE IBPT> (caso existir) pois não é uma estrutura válida XML
751
        $cdata = str_replace('<FONTE IBPT>', '', $cdata);
752
        //carrega o xml CDATA em um objeto DOM
753
        $dom = new Dom();
754
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
755
        //$xml = $dom->saveXML();
756
        //grupo CDATA infADprod
757
        $id = $dom->getElementsByTagName('id')->item(0);
758
        $div = $dom->getElementsByTagName('div')->item(0);
759
        $entg = $dom->getElementsByTagName('entg')->item(0);
760
        $dest = $dom->getElementsByTagName('dest')->item(0);
761
        $ctl = $dom->getElementsByTagName('ctl')->item(0);
762
        $ref = $dom->getElementsByTagName('ref')->item(0);
763
        if (isset($id)) {
764
            if ($id->hasAttributes()) {
765
                foreach ($id->attributes as $attr) {
766
                    $name = $attr->nodeName;
767
                    $value = $attr->nodeValue;
768
                    $texto .= " $name : $value";
769
                }
770
            }
771
        }
772
        if (isset($div)) {
773
            if ($div->hasAttributes()) {
774
                foreach ($div->attributes as $attr) {
775
                    $name = $attr->nodeName;
776
                    $value = $attr->nodeValue;
777
                    $texto .= " $name : $value";
778
                }
779
            }
780
        }
781
        if (isset($entg)) {
782
            if ($entg->hasAttributes()) {
783
                foreach ($entg->attributes as $attr) {
784
                    $name = $attr->nodeName;
785
                    $value = $attr->nodeValue;
786
                    $texto .= " $name : $value";
787
                }
788
            }
789
        }
790
        if (isset($dest)) {
791
            if ($dest->hasAttributes()) {
792
                foreach ($dest->attributes as $attr) {
793
                    $name = $attr->nodeName;
794
                    $value = $attr->nodeValue;
795
                    $texto .= " $name : $value";
796
                }
797
            }
798
        }
799
        if (isset($ctl)) {
800
            if ($ctl->hasAttributes()) {
801
                foreach ($ctl->attributes as $attr) {
802
                    $name = $attr->nodeName;
803
                    $value = $attr->nodeValue;
804
                    $texto .= " $name : $value";
805
                }
806
            }
807
        }
808
        if (isset($ref)) {
809
            if ($ref->hasAttributes()) {
810
                foreach ($ref->attributes as $attr) {
811
                    $name = $attr->nodeName;
812
                    $value = $attr->nodeValue;
813
                    $texto .= " $name : $value";
814
                }
815
            }
816
        }
817
        //grupo CADATA infCpl
818
        $t = $dom->getElementsByTagName('transmissor')->item(0);
819
        $r = $dom->getElementsByTagName('receptor')->item(0);
820
        $versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
821
            'Versao:'.$dom->getElementsByTagName('versao')->item(0)->nodeValue.' ' : '';
822
        $especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
823
            'Especie:'.$dom->getElementsByTagName('especieNF')->item(0)->nodeValue.' ' : '';
824
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
825
            'Entrega:'.$dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue.' ' : '';
826
        $dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
827
            'dca:'.$dom->getElementsByTagName('dca')->item(0)->nodeValue.' ' : '';
828
        $texto .= "".$versao.$especieNF.$fabEntrega.$dca;
829
        if (isset($t)) {
830
            if ($t->hasAttributes()) {
831
                $texto .= " Transmissor ";
832
                foreach ($t->attributes as $attr) {
833
                    $name = $attr->nodeName;
834
                    $value = $attr->nodeValue;
835
                    $texto .= " $name : $value";
836
                }
837
            }
838
        }
839
        if (isset($r)) {
840
            if ($r->hasAttributes()) {
841
                $texto .= " Receptor ";
842
                foreach ($r->attributes as $attr) {
843
                    $name = $attr->nodeName;
844
                    $value = $attr->nodeValue;
845
                    $texto .= " $name : $value";
846
                }
847
            }
848
        }
849
        return $texto;
850
    }
851
852
    /**
853
     * Verifica o status da NFe
854
     *
855
     * @return array
856
     */
857
    protected function statusNFe()
858
    {
859
        if (!isset($this->nfeProc)) {
860
            return ['status' => false, 'message' => 'NFe NÃO PROTOCOLADA'];
861
        }
862
        if ($this->getTagValue($this->ide, "tpAmb") == '2') {
863
            return ['status' => false, 'message' => 'NFe EMITIDA EM HOMOLOGAÇÃO'];
864
        }
865
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
0 ignored issues
show
Bug introduced by
The property nfeProc 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...
866
        if ($cStat == '101'
867
            || $cStat == '151'
868
            || $cStat == '135'
869
            || $cStat == '155'
870
        ) {
871
            return ['status' => false, 'message' => 'NFe CANCELADA'];
872
        }
873
        
874
        if ($cStat == '110' ||
875
               $cStat == '301' ||
876
               $cStat == '302'
877
               
878
        ) {
879
            return ['status' => false, 'message' => 'NFe DENEGADA'];
880
        }
881
        return ['status' => true, 'message' => ''];
882
    }
883
884
    protected function notaDPEC()
885
    {
886
        return $this->numero_registro_dpec != '';
887
    }
888
889
    /**
890
     *header
891
     * Monta o cabelhalho da DANFE (retrato e paisagem)
892
     *
893
     * @param  number $x      Posição horizontal inicial, canto esquerdo
894
     * @param  number $y      Posição vertical inicial, canto superior
895
     * @param  number $pag    Número da Página
896
     * @param  number $totPag Total de páginas
897
     * @return number Posição vertical final
898
     */
899
    protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
900
    {
901
        $oldX = $x;
902
        $oldY = $y;
903
        if ($this->orientacao == 'P') {
904
              $maxW = $this->wPrint;
905
        } else {
906
            if ($pag == 1) { // primeira página
907
                $maxW = $this->wPrint - $this->wCanhoto;
908
            } else { // páginas seguintes
909
                $maxW = $this->wPrint;
910
            }
911
        }
912
        //####################################################################################
913
        //coluna esquerda identificação do emitente
914
        $w = round($maxW*0.41, 0);
915
        if ($this->orientacao == 'P') {
916
            $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I'];
917
        } else {
918
            $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
919
        }
920
        $w1 = $w;
921
        $h=32;
922
        $oldY += $h;
923
        $this->pdf->textBox($x, $y, $w, $h);
924
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
925
        $this->pdf->textBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, '');
926
        //estabelecer o alinhamento
927
        //pode ser left L, center C, right R, full logo L
928
        //se for left separar 1/3 da largura para o tamanho da imagem
929
        //os outros 2/3 serão usados para os dados do emitente
930
        //se for center separar 1/2 da altura para o logo e 1/2 para os dados
931
        //se for right separa 2/3 para os dados e o terço seguinte para o logo
932
        //se não houver logo centraliza dos dados do emitente
933
        // coloca o logo
934
        if (!empty($this->logomarca)) {
935
            $logoInfo = getimagesize($this->logomarca);
936
            $type = strtolower(explode('/', $logoInfo['mime'])[1]);
937
            if ($type == 'png') {
938
                $this->logomarca = $this->imagePNGtoJPG($this->logomarca);
939
                $type == 'jpg';
940
            }
941
            //largura da imagem em mm
942
            $logoWmm = ($logoInfo[0]/72)*25.4;
943
            //altura da imagem em mm
944
            $logoHmm = ($logoInfo[1]/72)*25.4;
945
            if ($this->logoAlign=='L') {
946
                $nImgW = round($w/3, 0);
947
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
948
                $xImg = $x+1;
949
                $yImg = round(($h-$nImgH)/2, 0)+$y;
950
                //estabelecer posições do texto
951
                $x1 = round($xImg + $nImgW +1, 0);
952
                $y1 = round($h/3+$y, 0);
953
                $tw = round(2*$w/3, 0);
954
            } elseif ($this->logoAlign=='C') {
955
                $nImgH = round($h/3, 0);
956
                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
957
                $xImg = round(($w-$nImgW)/2+$x, 0);
958
                $yImg = $y+3;
959
                $x1 = $x;
960
                $y1 = round($yImg + $nImgH + 1, 0);
961
                $tw = $w;
962
            } elseif ($this->logoAlign=='R') {
963
                $nImgW = round($w/3, 0);
964
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
965
                $xImg = round($x+($w-(1+$nImgW)), 0);
966
                $yImg = round(($h-$nImgH)/2, 0)+$y;
967
                $x1 = $x;
968
                $y1 = round($h/3+$y, 0);
969
                $tw = round(2*$w/3, 0);
970
            } elseif ($this->logoAlign=='F') {
971
                $nImgH = round($h-5, 0);
972
                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
973
                $xImg = round(($w-$nImgW)/2+$x, 0);
974
                $yImg = $y+3;
975
                $x1 = $x;
976
                $y1 = round($yImg + $nImgH + 1, 0);
977
                $tw = $w;
978
            }
979
            $type = (substr($this->logomarca, 0, 7) === 'data://') ? 'jpg' : null;
980
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, $type);
0 ignored issues
show
Bug introduced by
The variable $xImg 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...
Bug introduced by
The variable $yImg 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...
Bug introduced by
The variable $nImgW 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...
Bug introduced by
The variable $nImgH 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...
981
        } else {
982
            $x1 = $x;
983
            $y1 = round($h/3+$y, 0);
984
            $tw = $w;
985
        }
986
        // monta as informações apenas se diferente de full logo
987
        if ($this->logoAlign !== 'F') {
988
            //Nome emitente
989
            $aFont = ['font'=>$this->fontePadrao, 'size'=>12, 'style'=>'B'];
990
            $texto = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue;
991
            $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 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...
Bug introduced by
The variable $y1 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...
Bug introduced by
The variable $tw 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...
992
            //endereço
993
            $y1 = $y1+5;
994
            $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
995
            $fone = ! empty($this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue)
996
            ? $this->enderEmit->getElementsByTagName("fone")->item(0)->nodeValue
997
            : '';
998
            $lgr = $this->getTagValue($this->enderEmit, "xLgr");
999
            $nro = $this->getTagValue($this->enderEmit, "nro");
1000
            $cpl = $this->getTagValue($this->enderEmit, "xCpl", " - ");
1001
            $bairro = $this->getTagValue($this->enderEmit, "xBairro");
1002
            $CEP = $this->getTagValue($this->enderEmit, "CEP");
1003
            $CEP = $this->formatField($CEP, "#####-###");
1004
            $mun = $this->getTagValue($this->enderEmit, "xMun");
1005
            $UF = $this->getTagValue($this->enderEmit, "UF");
1006
            $texto = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - "
1007
                . $CEP . "\n" . $mun . " - " . $UF . " "
1008
                . "Fone/Fax: " . $fone;
1009
            $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
1010
        }
1011
1012
        //####################################################################################
1013
        //coluna central Danfe
1014
        $x += $w;
1015
        $w=round($maxW * 0.17, 0);//35;
1016
        $w2 = $w;
1017
        $h = 32;
1018
        $this->pdf->textBox($x, $y, $w, $h);
1019
  
1020
        $texto = "DANFE";
1021
        $aFont = ['font'=>$this->fontePadrao, 'size'=>14, 'style'=>'B'];
1022
        $this->pdf->textBox($x, $y+1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
1023
        $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
1024
        $texto = 'Documento Auxiliar da Nota Fiscal Eletrônica';
1025
        $h = 20;
1026
        $this->pdf->textBox($x, $y+6, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
1027
1028
        $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
1029
        $texto = '0 - ENTRADA';
1030
        $y1 = $y + 14;
1031
        $h = 8;
1032
        $this->pdf->textBox($x+2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1033
        $texto = '1 - SAÍDA';
1034
        $y1 = $y + 17;
1035
        $this->pdf->textBox($x+2, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1036
        //tipo de nF
1037
        $aFont = ['font'=>$this->fontePadrao, 'size'=>12, 'style'=>'B'];
1038
        $y1 = $y + 13;
1039
        $h = 7;
1040
        $texto = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
1041
        $this->pdf->textBox($x+27, $y1, 5, $h, $texto, $aFont, 'C', 'C', 1, '');
1042
        //numero da NF
1043
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1044
        $y1 = $y + 20;
1045
        $numNF = str_pad(
1046
            $this->ide->getElementsByTagName('nNF')->item(0)->nodeValue,
1047
            9,
1048
            "0",
1049
            STR_PAD_LEFT
1050
        );
1051
        $numNF = $this->formatField($numNF, "###.###.###");
1052
        $texto = "Nº. " . $numNF;
1053
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1054
        //Série
1055
        $y1 = $y + 23;
1056
        $serie = str_pad(
1057
            $this->ide->getElementsByTagName('serie')->item(0)->nodeValue,
1058
            3,
1059
            "0",
1060
            STR_PAD_LEFT
1061
        );
1062
        $texto = "Série " . $serie;
1063
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1064
        //numero paginas
1065
        $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I'];
1066
        $y1 = $y + 26;
1067
        $texto = "Folha " . $pag . "/" . $totPag;
1068
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1069
1070
        //####################################################################################
1071
        //coluna codigo de barras
1072
        $x += $w;
1073
        $w = ($maxW-$w1-$w2);//85;
1074
        $w3 = $w;
1075
        $h = 32;
1076
        $this->pdf->textBox($x, $y, $w, $h);
1077
        $this->pdf->setFillColor(0, 0, 0);
1078
        $chave_acesso = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
1079
        $bW = 75;
1080
        $bH = 12;
1081
        //codigo de barras
1082
        $this->pdf->code128($x+(($w-$bW)/2), $y+2, $chave_acesso, $bW, $bH);
1083
        //linhas divisorias
1084
        $this->pdf->line($x, $y+4+$bH, $x+$w, $y+4+$bH);
1085
        $this->pdf->line($x, $y+12+$bH, $x+$w, $y+12+$bH);
1086
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1087
        $y1 = $y+4+$bH;
1088
        $h = 7;
1089
        $texto = 'CHAVE DE ACESSO';
1090
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1091
        $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
1092
        $y1 = $y+8+$bH;
1093
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
1094
        $this->pdf->textBox($x+2, $y1, $w-2, $h, $texto, $aFont, 'T', 'C', 0, '');
1095
        $y1 = $y+12+$bH;
1096
        $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
1097
        $chaveContingencia="";
1098
        if ($this->notaDpec()) {
1099
            $cabecalhoProtoAutorizacao = 'NÚMERO DE REGISTRO DPEC';
1100
        } else {
1101
            $cabecalhoProtoAutorizacao = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
1102
        }
1103
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && !$this->notaDpec()) {
1104
            $cabecalhoProtoAutorizacao = "DADOS DA NF-E";
1105
            $chaveContingencia = $this->geraChaveAdicionalDeContingencia();
1106
            $this->pdf->setFillColor(0, 0, 0);
1107
            //codigo de barras
1108
            $this->pdf->code128($x+11, $y1+1, $chaveContingencia, $bW*.9, $bH/2);
1109
        } else {
1110
            $texto = 'Consulta de autenticidade no portal nacional da NF-e';
1111
            $this->pdf->textBox($x+2, $y1, $w-2, $h, $texto, $aFont, 'T', 'C', 0, '');
1112
            $y1 = $y+16+$bH;
1113
            $texto = 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora';
1114
            $this->pdf->textBox(
1115
                $x+2,
1116
                $y1,
1117
                $w-2,
1118
                $h,
1119
                $texto,
1120
                $aFont,
1121
                'T',
1122
                'C',
1123
                0,
1124
                'http://www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora'
1125
            );
1126
        }
1127
1128
        //####################################################################################
1129
        //Dados da NF do cabeçalho
1130
        //natureza da operação
1131
        $texto = 'NATUREZA DA OPERAÇÃO';
1132
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1133
        $w = $w1+$w2;
1134
        $y = $oldY;
1135
        $oldY += $h;
1136
        $x = $oldX;
1137
        $h = 7;
1138
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1139
        $texto = $this->ide->getElementsByTagName("natOp")->item(0)->nodeValue;
1140
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1141
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1142
        $x += $w;
1143
        $w = $w3;
1144
        //PROTOCOLO DE AUTORIZAÇÃO DE USO ou DADOS da NF-E
1145
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1146
        $this->pdf->textBox($x, $y, $w, $h, $cabecalhoProtoAutorizacao, $aFont, 'T', 'L', 1, '');
1147
        // algumas NFe podem estar sem o protocolo de uso portanto sua existencia deve ser
1148
        // testada antes de tentar obter a informação.
1149
        // NOTA : DANFE sem protocolo deve existir somente no caso de contingência !!!
1150
        // Além disso, existem várias NFes em contingência que eu recebo com protocolo de autorização.
1151
        // Na minha opinião, deveríamos mostra-lo, mas o  manual  da NFe v4.01 diz outra coisa...
1152
        if (($this->tpEmis == 2 || $this->tpEmis == 5) && !$this->notaDpec()) {
1153
            $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
1154
            $texto = $this->formatField(
1155
                $chaveContingencia,
1156
                "#### #### #### #### #### #### #### #### ####"
1157
            );
1158
            $cStat = '';
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1159
        } else {
1160
            $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1161
            if ($this->notaDpec()) {
1162
                $texto = $this->numero_registro_dpec;
1163
                $cStat = '';
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1164
            } else {
1165
                if (isset($this->nfeProc)) {
1166
                    $texto = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue)
1167
                    ? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue
1168
                    : '';
1169
                    $tsHora = $this->toTimestamp(
1170
                        $this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
1171
                    );
1172
                    if ($texto != '') {
1173
                        $texto .= "  -  " . date('d/m/Y H:i:s', $tsHora);
1174
                    }
1175
                    $cStat = $this->nfeProc->getElementsByTagName("cStat")->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1176
                } else {
1177
                    $texto = '';
1178
                    $cStat = '';
0 ignored issues
show
Unused Code introduced by
$cStat 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...
1179
                }
1180
            }
1181
        }
1182
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1183
        //####################################################################################
1184
        //INSCRIÇÃO ESTADUAL
1185
        $w = round($maxW * 0.333, 0);
1186
        $y += $h;
1187
        $oldY += $h;
1188
        $x = $oldX;
1189
        $texto = 'INSCRIÇÃO ESTADUAL';
1190
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1191
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1192
        $texto = $this->getTagValue($this->emit, "IE");
1193
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1194
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1195
        //INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.
1196
        $x += $w;
1197
        $texto = 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.';
1198
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1199
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1200
        $texto = ! empty($this->emit->getElementsByTagName("IEST")->item(0)->nodeValue)
1201
        ? $this->emit->getElementsByTagName("IEST")->item(0)->nodeValue
1202
        : '';
1203
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1204
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1205
        //CNPJ
1206
        $x += $w;
1207
        $w = ($maxW-(2*$w));
1208
        $texto = 'CNPJ / CPF';
1209
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1210
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1211
        //Pegando valor do CPF/CNPJ
1212
        if (! empty($this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1213
            $texto = $this->formatField(
1214
                $this->emit->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1215
                "###.###.###/####-##"
1216
            );
1217
        } else {
1218
            $texto = ! empty($this->emit->getElementsByTagName("CPF")->item(0)->nodeValue)
1219
            ? $this->formatField(
1220
                $this->emit->getElementsByTagName("CPF")->item(0)->nodeValue,
1221
                "###.###.###-##"
1222
            )
1223
            : '';
1224
        }
1225
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1226
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1227
1228
        //####################################################################################
1229
        //Indicação de NF Homologação, cancelamento e falta de protocolo
1230
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
0 ignored issues
show
Unused Code introduced by
$tpAmb 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...
1231
        //indicar cancelamento
1232
        $resp = $this->statusNFe();
1233
        if (!$resp['status']) {
1234
            $x = 10;
1235
            $y = $this->hPrint-130;
1236
            $h = 25;
1237
            $w = $maxW-(2*$x);
1238
            $this->pdf->settextcolor(90, 90, 90);
1239
            $texto = $resp['message'];
1240
            $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1241
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1242
            $y += $h;
1243
            $h = 5;
1244
            $w = $maxW-(2*$x);
1245
            if (isset($this->infProt) && $resp['status']) {
1246
                $xMotivo = $this->infProt->getElementsByTagName("xMotivo")->item(0)->nodeValue;
1247
            } else {
1248
                $xMotivo = '';
1249
            }
1250
            $texto = "SEM VALOR FISCAL\n".$xMotivo;
1251
            $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1252
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1253
            $this->pdf->settextcolor(0, 0, 0);
1254
        }
1255
        
1256
        /*
1257
        if ($this->pNotaCancelada()) {
1258
            //101 Cancelamento
1259
            $x = 10;
1260
            $y = $this->hPrint-130;
1261
            $h = 25;
1262
            $w = $maxW-(2*$x);
1263
            $this->pdf->SetTextColor(90, 90, 90);
1264
            $texto = "NFe CANCELADA";
1265
            $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1266
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1267
            $this->pdf->SetTextColor(0, 0, 0);
1268
        }*/
1269
1270
        if ($this->notaDpec() || $this->tpEmis == 4) {
1271
            //DPEC
1272
            $x = 10;
1273
            $y = $this->hPrint-130;
1274
            $h = 25;
1275
            $w = $maxW-(2*$x);
1276
            $this->pdf->SetTextColor(200, 200, 200);
1277
            $texto = "DANFE impresso em contingência -\n".
1278
                     "DPEC regularmente recebido pela Receita\n".
1279
                     "Federal do Brasil";
1280
            $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1281
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1282
            $this->pdf->SetTextColor(0, 0, 0);
1283
        }
1284
        /*
1285
        if ($this->pNotaDenegada()) {
1286
            //110 301 302 Denegada
1287
            $x = 10;
1288
            $y = $this->hPrint-130;
1289
            $h = 25;
1290
            $w = $maxW-(2*$x);
1291
            $this->pdf->SetTextColor(90, 90, 90);
1292
            $texto = "NFe USO DENEGADO";
1293
            $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1294
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1295
            $y += $h;
1296
            $h = 5;
1297
            $w = $maxW-(2*$x);
1298
            if (isset($this->infProt)) {
1299
                $xMotivo = $this->infProt->getElementsByTagName("xMotivo")->item(0)->nodeValue;
1300
            } else {
1301
                $xMotivo = '';
1302
            }
1303
            $texto = "SEM VALOR FISCAL\n".$xMotivo;
1304
            $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1305
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1306
            $this->pdf->SetTextColor(0, 0, 0);
1307
        }
1308
         *
1309
         */
1310
        //indicar sem valor
1311
        /*
1312
        if ($tpAmb != 1) {
1313
            $x = 10;
1314
            if ($this->orientacao == 'P') {
1315
                $y = round($this->hPrint*2/3, 0);
1316
            } else {
1317
                $y = round($this->hPrint/2, 0);
1318
            }
1319
            $h = 5;
1320
            $w = $maxW-(2*$x);
1321
            $this->pdf->SetTextColor(90, 90, 90);
1322
            $texto = "SEM VALOR FISCAL";
1323
            $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1324
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1325
            $aFont = ['font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B'];
1326
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1327
            $this->pdf->textBox($x, $y+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1328
            $this->pdf->SetTextColor(0, 0, 0);
1329
        } else {
1330
            $x = 10;
1331
            if ($this->orientacao == 'P') {
1332
                $y = round($this->hPrint*2/3, 0);
1333
            } else {
1334
                $y = round($this->hPrint/2, 0);
1335
            }//fim orientacao
1336
            $h = 5;
1337
            $w = $maxW-(2*$x);
1338
            $this->pdf->SetTextColor(90, 90, 90);
1339
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1340
            if (($this->tpEmis == 2 || $this->tpEmis == 5) && !$this->notaDpec()) {
1341
                //Contingência
1342
                $texto = "DANFE Emitido em Contingência";
1343
                $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1344
                $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1345
                $aFont = ['font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B'];
1346
                $texto = "devido à problemas técnicos";
1347
                $this->pdf->textBox($x, $y+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1348
            } else {
1349
                if (!isset($this->nfeProc)) {
1350
                    if (!$this->notaDpec()) {
1351
                        $texto = "SEM VALOR FISCAL";
1352
                        $aFont = ['font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B'];
1353
                        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1354
                    }
1355
                    $aFont = ['font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B'];
1356
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1357
                    if (!$this->notaDpec()) {
1358
                        $this->pdf->textBox($x, $y+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1359
                    } else {
1360
                        $this->pdf->textBox($x, $y+25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1361
                    }
1362
                }//fim nefProc
1363
            }//fim tpEmis
1364
            $this->pdf->SetTextColor(0, 0, 0);
1365
        }
1366
         *
1367
         */
1368
        return $oldY;
1369
    } //fim header
1370
1371
    /**
1372
     * destinatarioDANFE
1373
     * Monta o campo com os dados do destinatário na DANFE. (retrato e paisagem)
1374
     *
1375
     * @name   destinatarioDANFE
1376
     * @param  number $x Posição horizontal canto esquerdo
1377
     * @param  number $y Posição vertical canto superior
1378
     * @return number Posição vertical final
1379
     */
1380
    protected function destinatarioDANFE($x = 0, $y = 0)
1381
    {
1382
        //####################################################################################
1383
        //DESTINATÁRIO / REMETENTE
1384
        $oldX = $x;
1385
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
1386
        if ($this->orientacao == 'P') {
1387
            $maxW = $this->wPrint;
1388
        } else {
1389
            $maxW = $this->wPrint - $this->wCanhoto;
1390
        }
1391
        $w = $maxW;
1392
        $h = 7;
1393
        $texto = 'DESTINATÁRIO / REMETENTE';
1394
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
1395
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1396
        //NOME / RAZÃO SOCIAL
1397
        $w = round($maxW*0.61, 0);
1398
        $w1 = $w;
1399
        $y += 3;
1400
        $texto = 'NOME / RAZÃO SOCIAL';
1401
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1402
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1403
        $texto = $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue;
1404
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1405
        if ($this->orientacao == 'P') {
1406
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
1407
        } else {
1408
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, '');
1409
        }
1410
        //CNPJ / CPF
1411
        $x += $w;
1412
        $w = round($maxW*0.23, 0);
1413
        $w2 = $w;
1414
        $texto = 'CNPJ / CPF';
1415
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1416
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1417
        //Pegando valor do CPF/CNPJ
1418
        if (! empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1419
            $texto = $this->formatField(
1420
                $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1421
                "###.###.###/####-##"
1422
            );
1423
        } else {
1424
            $texto = ! empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
1425
            ? $this->formatField(
1426
                $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue,
1427
                "###.###.###-##"
1428
            )
1429
            : '';
1430
        }
1431
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1432
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1433
        //DATA DA EMISSÃO
1434
        $x += $w;
1435
        $w = $maxW-($w1+$w2);
1436
        $wx = $w;
1437
        $texto = 'DATA DA EMISSÃO';
1438
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1439
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1440
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue)
1441
        ? $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue
1442
        : '';
1443
        if ($dEmi == '') {
1444
            $dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue)
1445
            ? $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue
1446
            : '';
1447
            $aDemi = explode('T', $dEmi);
1448
            $dEmi = $aDemi[0];
1449
        }
1450
        $texto = $this->ymdTodmy($dEmi);
1451
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1452
        if ($this->orientacao == 'P') {
1453
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1454
        } else {
1455
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, '');
1456
        }
1457
        //ENDEREÇO
1458
        $w = round($maxW*0.47, 0);
1459
        $w1 = $w;
1460
        $y += $h;
1461
        $x = $oldX;
1462
        $texto = 'ENDEREÇO';
1463
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1464
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1465
        $texto = $this->dest->getElementsByTagName("xLgr")->item(0)->nodeValue;
1466
        $texto .= ', ' . $this->dest->getElementsByTagName("nro")->item(0)->nodeValue;
1467
        $texto .= $this->getTagValue($this->dest, "xCpl", " - ");
1468
1469
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1470
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true);
1471
        //BAIRRO / DISTRITO
1472
        $x += $w;
1473
        $w = round($maxW*0.21, 0);
1474
        $w2 = $w;
1475
        $texto = 'BAIRRO / DISTRITO';
1476
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1477
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1478
        $texto = $this->dest->getElementsByTagName("xBairro")->item(0)->nodeValue;
1479
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1480
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1481
        //CEP
1482
        $x += $w;
1483
        $w = $maxW-$w1-$w2-$wx;
1484
        $w2 = $w;
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...
1485
        $texto = 'CEP';
1486
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1487
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1488
        $texto = ! empty($this->dest->getElementsByTagName("CEP")->item(0)->nodeValue)
1489
        ? $this->dest->getElementsByTagName("CEP")->item(0)->nodeValue
1490
        : '';
1491
        $texto = $this->formatField($texto, "#####-###");
1492
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1493
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1494
        //DATA DA SAÍDA
1495
        $x += $w;
1496
        $w = $wx;
1497
        $texto = 'DATA DA SAÍDA/ENTRADA';
1498
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1499
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1500
        $dSaiEnt = ! empty($this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue)
1501
            ? $this->ide->getElementsByTagName("dSaiEnt")->item(0)->nodeValue
1502
            : '';
1503
        if ($dSaiEnt == '') {
1504
            $dSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1505
                ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1506
                : '';
1507
            $aDsaient = explode('T', $dSaiEnt);
1508
            $dSaiEnt = $aDsaient[0];
1509
        }
1510
        $texto = $this->ymdTodmy($dSaiEnt);
1511
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1512
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1513
        //MUNICÍPIO
1514
        $w = $w1;
1515
        $y += $h;
1516
        $x = $oldX;
1517
        $texto = 'MUNICÍPIO';
1518
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1519
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1520
        $texto = $this->dest->getElementsByTagName("xMun")->item(0)->nodeValue;
1521
        if (strtoupper(trim($texto)) == "EXTERIOR"
1522
            && $this->dest->getElementsByTagName("xPais")->length > 0
1523
        ) {
1524
            $texto .= " - " .  $this->dest->getElementsByTagName("xPais")->item(0)->nodeValue;
1525
        }
1526
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1527
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
1528
        //UF
1529
        $x += $w;
1530
        $w = 8;
1531
        $texto = 'UF';
1532
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1533
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1534
        $texto = $this->dest->getElementsByTagName("UF")->item(0)->nodeValue;
1535
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1536
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1537
        //FONE / FAX
1538
        $x += $w;
1539
        $w = round(($maxW -$w1-$wx-8)/2, 0);
1540
        $w3 = $w;
1541
        $texto = 'FONE / FAX';
1542
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1543
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1544
        $texto = ! empty($this->dest->getElementsByTagName("fone")->item(0)->nodeValue)
1545
        ? $this->dest->getElementsByTagName("fone")->item(0)->nodeValue
1546
        : '';
1547
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1548
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1549
        //INSCRIÇÃO ESTADUAL
1550
        $x += $w;
1551
        $w = $maxW -$w1-$wx-8-$w3;
1552
        $texto = 'INSCRIÇÃO ESTADUAL';
1553
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1554
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1555
        $IE = $this->dest->getElementsByTagName("IE");
1556
        $texto = ($IE && $IE->length > 0) ? $IE->item(0)->nodeValue : '';
1557
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1558
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1559
        //HORA DA SAÍDA
1560
        $x += $w;
1561
        $w = $wx;
1562
        $texto = 'HORA DA SAÍDA/ENTRADA';
1563
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
1564
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1565
        $hSaiEnt = ! empty($this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue)
1566
        ? $this->ide->getElementsByTagName("hSaiEnt")->item(0)->nodeValue
1567
        : '';
1568
        if ($hSaiEnt == '') {
1569
            $dhSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
1570
            ? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
1571
            : '';
1572
            $tsDhSaiEnt = $this->toTimestamp($dhSaiEnt);
1573
            if ($tsDhSaiEnt != '') {
1574
                $hSaiEnt = date('H:i:s', $tsDhSaiEnt);
1575
            }
1576
        }
1577
        $texto = $hSaiEnt;
1578
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
1579
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
1580
        return ($y + $h);
1581
    } //fim da função destinatarioDANFE
1582
1583
    /**
1584
     * localEntregaDANFE
1585
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1586
     *
1587
     * @name   localEntregaDANFE
1588
     * @param  number $x Posição horizontal canto esquerdo
1589
     * @param  number $y Posição vertical canto superior
1590
     * @return number Posição vertical final
1591
     */
1592
    protected function pLocalEntregaDANFE($x = 0, $y = 0)
1593
    {
1594
        //####################################################################################
1595
        //LOCAL DE ENTREGA
1596
        $oldX = $x;
1597
        if ($this->orientacao == 'P') {
1598
            $maxW = $this->wPrint;
1599
        } else {
1600
            $maxW = $this->wPrint - $this->wCanhoto;
1601
        }
1602
        $w = $maxW;
1603
        $h = 7;
1604
        $texto = 'INFORMAÇÕES DO LOCAL DE ENTREGA';
1605
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
1606
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1607
        //NOME / RAZÃO SOCIAL
1608
        $w = round($maxW*0.61, 0);
1609
        $w1 = $w;
1610
        $y += 3;
1611
        $texto = 'NOME / RAZÃO SOCIAL';
1612
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1613
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1614
        $texto = '';
1615
        if ($this->entrega->getElementsByTagName("xNome")->item(0)) {
1616
            $texto = $this->entrega->getElementsByTagName("xNome")->item(0)->nodeValue;
1617
        }
1618
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1619
        if ($this->orientacao == 'P') {
1620
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1621
        } else {
1622
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1623
        }
1624
        //CNPJ / CPF
1625
        $x += $w;
1626
        $w = round($maxW*0.23, 0);
1627
        $w2 = $w;
1628
        $texto = 'CNPJ / CPF';
1629
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1630
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1631
        //Pegando valor do CPF/CNPJ
1632
        if (! empty($this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1633
            $texto = $this->pFormat(
0 ignored issues
show
Bug introduced by
The method pFormat() does not seem to exist on object<NFePHP\DA\NFe\Danfe>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1634
                $this->entrega->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1635
                "###.###.###/####-##"
1636
            );
1637
        } else {
1638
            $texto = ! empty($this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1639
                    $this->pFormat(
0 ignored issues
show
Bug introduced by
The method pFormat() does not seem to exist on object<NFePHP\DA\NFe\Danfe>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1640
                        $this->entrega->getElementsByTagName("CPF")->item(0)->nodeValue,
1641
                        "###.###.###-##"
1642
                    ) : '';
1643
        }
1644
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1645
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1646
        //INSCRIÇÃO ESTADUAL
1647
        $x += $w;
1648
        $w = $maxW-($w1+$w2);
1649
        $wx = $w;
1650
        $texto = 'INSCRIÇÃO ESTADUAL';
1651
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1652
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1653
        $texto = '';
1654
        if ($this->entrega->getElementsByTagName("IE")->item(0)) {
1655
            $texto = $this->entrega->getElementsByTagName("IE")->item(0)->nodeValue;
1656
        }
1657
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1658
        if ($this->orientacao == 'P') {
1659
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1660
        } else {
1661
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1662
        }
1663
        //ENDEREÇO
1664
        $w = round($maxW*0.355, 0) + $wx;
1665
        $w1 = $w;
1666
        $y += $h;
1667
        $x = $oldX;
1668
        $texto = 'ENDEREÇO';
1669
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1670
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1671
        $texto = $this->entrega->getElementsByTagName("xLgr")->item(0)->nodeValue;
1672
        $texto .= ', ' . $this->entrega->getElementsByTagName("nro")->item(0)->nodeValue;
1673
        $texto .= $this->getTagValue($this->entrega, "xCpl", " - ");
1674
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1675
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true);
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1676
        //BAIRRO / DISTRITO
1677
        $x += $w;
1678
        $w = round($maxW*0.335, 0);
1679
        $w2 = $w;
1680
        $texto = 'BAIRRO / DISTRITO';
1681
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1682
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1683
        $texto = $this->entrega->getElementsByTagName("xBairro")->item(0)->nodeValue;
1684
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1685
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1686
        //CEP
1687
        $x += $w;
1688
        $w = $maxW-($w1+$w2);
1689
        $texto = 'CEP';
1690
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1691
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1692
        $texto = ! empty($this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1693
                $this->entrega->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1694
        $texto = $this->pFormat($texto, "#####-###");
0 ignored issues
show
Bug introduced by
The method pFormat() does not seem to exist on object<NFePHP\DA\NFe\Danfe>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1695
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1696
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1697
        //MUNICÍPIO
1698
        $w = round($maxW*0.805, 0);
1699
        $w1 = $w;
1700
        $y += $h;
1701
        $x = $oldX;
1702
        $texto = 'MUNICÍPIO';
1703
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1704
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1705
        $texto = $this->entrega->getElementsByTagName("xMun")->item(0)->nodeValue;
1706
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->entrega->getElementsByTagName("xPais")->length > 0) {
1707
            $texto .= " - " .  $this->entrega->getElementsByTagName("xPais")->item(0)->nodeValue;
1708
        }
1709
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1710
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1711
        //UF
1712
        $x += $w;
1713
        $w = 8;
1714
        $texto = 'UF';
1715
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1716
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1717
        $texto = $this->entrega->getElementsByTagName("UF")->item(0)->nodeValue;
1718
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1719
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1720
        //FONE / FAX
1721
        $x += $w;
1722
        $w = $maxW-$w-$w1;
1723
        $texto = 'FONE / FAX';
1724
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1725
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1726
        $texto = ! empty($this->entrega->getElementsByTagName("fone")->item(0)->nodeValue) ?
1727
                $this->entrega->getElementsByTagName("fone")->item(0)->nodeValue : '';
1728
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1729
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1730
        return ($y + $h);
1731
    } //fim da função localEntregaDANFE
1732
    
1733
    /**
1734
     * localretiradaDANFE
1735
     * Monta o campo com os dados do local de entrega na DANFE. (retrato e paisagem)
1736
     *
1737
     * @name   localretiradaDANFE
1738
     * @param  number $x Posição horizontal canto esquerdo
1739
     * @param  number $y Posição vertical canto superior
1740
     * @return number Posição vertical final
1741
     */
1742
    protected function pLocalRetiradaDANFE($x = 0, $y = 0)
1743
    {
1744
        //####################################################################################
1745
        //LOCAL DE RETIRADA
1746
        $oldX = $x;
1747
        if ($this->orientacao == 'P') {
1748
            $maxW = $this->wPrint;
1749
        } else {
1750
            $maxW = $this->wPrint - $this->wCanhoto;
1751
        }
1752
        $w = $maxW;
1753
        $h = 7;
1754
        $texto = 'INFORMAÇÕES DO LOCAL DE RETIRADA';
1755
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
1756
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1757
        //NOME / RAZÃO SOCIAL
1758
        $w = round($maxW*0.61, 0);
1759
        $w1 = $w;
1760
        $y += 3;
1761
        $texto = 'NOME / RAZÃO SOCIAL';
1762
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1763
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1764
        $texto = '';
1765
        if ($this->retirada->getElementsByTagName("xNome")->item(0)) {
1766
            $texto = $this->retirada->getElementsByTagName("xNome")->item(0)->nodeValue;
1767
        }
1768
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1769
        if ($this->orientacao == 'P') {
1770
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1771
        } else {
1772
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1773
        }
1774
        //CNPJ / CPF
1775
        $x += $w;
1776
        $w = round($maxW*0.23, 0);
1777
        $w2 = $w;
1778
        $texto = 'CNPJ / CPF';
1779
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1780
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1781
        //Pegando valor do CPF/CNPJ
1782
        if (! empty($this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue)) {
1783
            $texto = $this->pFormat(
0 ignored issues
show
Bug introduced by
The method pFormat() does not seem to exist on object<NFePHP\DA\NFe\Danfe>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1784
                $this->retirada->getElementsByTagName("CNPJ")->item(0)->nodeValue,
1785
                "###.###.###/####-##"
1786
            );
1787
        } else {
1788
            $texto = ! empty($this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue) ?
1789
                    $this->pFormat(
0 ignored issues
show
Bug introduced by
The method pFormat() does not seem to exist on object<NFePHP\DA\NFe\Danfe>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1790
                        $this->retirada->getElementsByTagName("CPF")->item(0)->nodeValue,
1791
                        "###.###.###-##"
1792
                    ) : '';
1793
        }
1794
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1795
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1796
        //INSCRIÇÃO ESTADUAL
1797
        $x += $w;
1798
        $w = $maxW-($w1+$w2);
1799
        $wx = $w;
1800
        $texto = 'INSCRIÇÃO ESTADUAL';
1801
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1802
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1803
        $texto = '';
1804
        if ($this->retirada->getElementsByTagName("IE")->item(0)) {
1805
            $texto = $this->retirada->getElementsByTagName("IE")->item(0)->nodeValue;
1806
        }
1807
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1808
        if ($this->orientacao == 'P') {
1809
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1810
        } else {
1811
            $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1812
        }
1813
        //ENDEREÇO
1814
        $w = round($maxW*0.355, 0) + $wx;
1815
        $w1 = $w;
1816
        $y += $h;
1817
        $x = $oldX;
1818
        $texto = 'ENDEREÇO';
1819
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1820
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1821
        $texto = $this->retirada->getElementsByTagName("xLgr")->item(0)->nodeValue;
1822
        $texto .= ', ' . $this->retirada->getElementsByTagName("nro")->item(0)->nodeValue;
1823
        $texto .= $this->getTagValue($this->retirada, "xCpl", " - ");
1824
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1825
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '', true);
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1826
        //BAIRRO / DISTRITO
1827
        $x += $w;
1828
        $w = round($maxW*0.335, 0);
1829
        $w2 = $w;
1830
        $texto = 'BAIRRO / DISTRITO';
1831
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1832
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1833
        $texto = $this->retirada->getElementsByTagName("xBairro")->item(0)->nodeValue;
1834
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1835
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1836
        //CEP
1837
        $x += $w;
1838
        $w = $maxW-($w1+$w2);
1839
        $texto = 'CEP';
1840
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1841
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1842
        $texto = ! empty($this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue) ?
1843
                $this->retirada->getElementsByTagName("CEP")->item(0)->nodeValue : '';
1844
        $texto = $this->pFormat($texto, "#####-###");
0 ignored issues
show
Bug introduced by
The method pFormat() does not seem to exist on object<NFePHP\DA\NFe\Danfe>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1845
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1846
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1847
        //MUNICÍPIO
1848
        $w = round($maxW*0.805, 0);
1849
        $w1 = $w;
1850
        $y += $h;
1851
        $x = $oldX;
1852
        $texto = 'MUNICÍPIO';
1853
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1854
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1855
        $texto = $this->retirada->getElementsByTagName("xMun")->item(0)->nodeValue;
1856
        if (strtoupper(trim($texto)) == "EXTERIOR" && $this->retirada->getElementsByTagName("xPais")->length > 0) {
1857
            $texto .= " - " .  $this->retirada->getElementsByTagName("xPais")->item(0)->nodeValue;
1858
        }
1859
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1860
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1861
        //UF
1862
        $x += $w;
1863
        $w = 8;
1864
        $texto = 'UF';
1865
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1866
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1867
        $texto = $this->retirada->getElementsByTagName("UF")->item(0)->nodeValue;
1868
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1869
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1870
        //FONE / FAX
1871
        $x += $w;
1872
        $w = $maxW-$w-$w1;
1873
        $texto = 'FONE / FAX';
1874
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'');
1875
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1876
        $texto = ! empty($this->retirada->getElementsByTagName("fone")->item(0)->nodeValue) ?
1877
                $this->retirada->getElementsByTagName("fone")->item(0)->nodeValue : '';
1878
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B');
1879
        $this->pdf->textBo($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method textBo() does not exist on NFePHP\DA\Legacy\Pdf. Did you maybe mean drawTextBox()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1880
        return ($y + $h);
1881
    } //fim da função localRetiradaDANFE
1882
    
1883
     /**
1884
     * getTextoFatura
1885
     * Gera a String do Texto da Fatura
1886
      *
1887
     * @name   getTextoFatura
1888
     * @return uma String com o texto ou "";
1889
     */
1890
    protected function getTextoFatura()
1891
    {
1892
        if (isset($this->cobr)) {
1893
            $fat = $this->cobr->getElementsByTagName("fat")->item(0);
1894
            if (isset($fat)) {
1895
                if (!empty($this->getTagValue($this->ide, "indPag"))) {
1896
                    $textoIndPag = "";
1897
                    $indPag = $this->getTagValue($this->ide, "indPag");
1898
                    if ($indPag === "0") {
1899
                        $textoIndPag = "Pagamento à Vista - ";
1900
                    } elseif ($indPag === "1") {
1901
                        $textoIndPag = "Pagamento à Prazo - ";
1902
                    }
1903
                    $nFat = $this->getTagValue($fat, "nFat", "Fatura: ");
1904
                    $vOrig = $this->getTagValue($fat, "vOrig", " Valor Original: ");
1905
                    $vDesc = $this->getTagValue($fat, "vDesc", " Desconto: ");
1906
                    $vLiq = $this->getTagValue($fat, "vLiq", " Valor Líquido: ");
1907
                    $texto = $textoIndPag . $nFat . $vOrig . $vDesc . $vLiq;
1908
                    return $texto;
1909
                } else {
1910
                    $pag = $this->dom->getElementsByTagName("pag");
1911
                    if ($tPag = $this->getTagValue($pag->item(0), "tPag")) {
1912
                        return $this->tipoPag($tPag);
1913
                    }
1914
                }
1915
            }
1916
        }
1917
        return "";
1918
    }
1919
1920
     /**
1921
     * sizeExtraTextoFatura
1922
     * Calcula o espaço ocupado pelo texto da fatura. Este espaço só é utilizado quando não houver duplicata.
1923
      *
1924
     * @name   sizeExtraTextoFatura
1925
     * @return integer
1926
     */
1927
    protected function sizeExtraTextoFatura()
1928
    {
1929
        $textoFatura = $this->getTextoFatura();
1930
        //verificar se existem duplicatas
1931
        if ($this->dup->length == 0 && $textoFatura !== "") {
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1932
            return 10;
1933
        }
1934
        return 0;
1935
    }
1936
1937
    /**
1938
     * fatura
1939
     * Monta o campo de duplicatas da DANFE (retrato e paisagem)
1940
     *
1941
     * @name   fatura
1942
     * @param  number $x Posição horizontal canto esquerdo
1943
     * @param  number $y Posição vertical canto superior
1944
     * @return number Posição vertical final
1945
     */
1946
    protected function fatura($x, $y)
1947
    {
1948
        $linha = 1;
1949
        $h = 8+3;
0 ignored issues
show
Unused Code introduced by
$h 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...
1950
        $oldx = $x;
1951
        $textoFatura = $this->getTextoFatura();
1952
        //verificar se existem duplicatas
1953
        if ($this->dup->length > 0 || $textoFatura !== "") {
1954
            //#####################################################################
1955
            //FATURA / DUPLICATA
1956
            $texto = "FATURA / DUPLICATA";
1957
            if ($this->orientacao == 'P') {
1958
                $w = $this->wPrint;
1959
            } else {
1960
                $w = 271;
1961
            }
1962
            $h = 8;
1963
            $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
1964
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1965
            $y += 3;
1966
            $dups = "";
0 ignored issues
show
Unused Code introduced by
$dups 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...
1967
            $dupcont = 0;
1968
            $nFat = $this->dup->length;
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1969
            if ($nFat > 7) {
1970
                $myH = 6;
1971
                $myW = $this->wPrint;
1972
                if ($this->orientacao == 'L') {
1973
                    $myW -= $this->wCanhoto;
1974
                }
1975
                $aFont = ['font' => $this->fontePadrao, 'size' => 9, 'style' => ''];
1976
                $texto = "Existem mais de 7 duplicatas registradas, portanto não "
1977
                    . "serão exibidas, confira diretamente pelo XML.";
1978
                $this->pdf->textBox($x, $y, $myW, $myH, $texto, $aFont, 'C', 'C', 1, '');
1979
                return ($y + $h - 3);
1980
            }
1981
            if ($textoFatura !== "" && $this->exibirTextoFatura) {
1982
                $myH=6;
1983
                $myW = $this->wPrint;
1984
                if ($this->orientacao == 'L') {
1985
                    $myW -= $this->wCanhoto;
1986
                }
1987
                $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
1988
                $this->pdf->textBox($x, $y, $myW, $myH, $textoFatura, $aFont, 'C', 'L', 1, '');
1989
                $y+=$myH+1;
1990
            }
1991
            if ($this->orientacao == 'P') {
1992
                $w = round($this->wPrint/7.018, 0)-1;
1993
            } else {
1994
                $w = 28;
1995
            }
1996
            $increm = 1;
1997
            foreach ($this->dup as $k => $d) {
0 ignored issues
show
Bug introduced by
The expression $this->dup of type object<DOMNode> is not traversable.
Loading history...
1998
                $nDup = ! empty($this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue)
1999
                ? $this->dup->item($k)->getElementsByTagName('nDup')->item(0)->nodeValue
2000
                : '';
2001
                $dDup = ! empty($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
2002
                ? $this->ymdTodmy($this->dup->item($k)->getElementsByTagName('dVenc')->item(0)->nodeValue)
2003
                : '';
2004
                $vDup = ! empty($this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue)
2005
                ? 'R$ ' . number_format(
2006
                    $this->dup->item($k)->getElementsByTagName('vDup')->item(0)->nodeValue,
2007
                    2,
2008
                    ",",
2009
                    "."
2010
                )
2011
                : '';
2012
                $h = 8;
2013
                $texto = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
2014
                if ($nDup!='0' && $nDup!='') {
2015
                    $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2016
                    $this->pdf->textBox($x, $y, $w, $h, 'Num.', $aFont, 'T', 'L', 1, '');
2017
                    $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2018
                    $this->pdf->textBox($x, $y, $w, $h, $nDup, $aFont, 'T', 'R', 0, '');
2019
                } else {
2020
                    $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2021
                    $this->pdf->textBox($x, $y, $w, $h, ($dupcont+1)."", $aFont, 'T', 'L', 1, '');
2022
                }
2023
                $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2024
                $this->pdf->textBox($x, $y, $w, $h, 'Venc.', $aFont, 'C', 'L', 0, '');
2025
                $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2026
                $this->pdf->textBox($x, $y, $w, $h, $dDup, $aFont, 'C', 'R', 0, '');
2027
                $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2028
                $this->pdf->textBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, '');
2029
                $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2030
                $this->pdf->textBox($x, $y, $w, $h, $vDup, $aFont, 'B', 'R', 0, '');
2031
                $x += $w+$increm;
2032
                $dupcont += 1;
2033
                if ($this->orientacao == 'P') {
2034
                    $maxDupCont = 6;
2035
                } else {
2036
                    $maxDupCont = 8;
2037
                }
2038
                if ($dupcont > $maxDupCont) {
2039
                    $y += 9;
2040
                    $x = $oldx;
2041
                    $dupcont = 0;
2042
                    $linha += 1;
2043
                }
2044
                if ($linha == 5) {
2045
                    $linha = 4;
2046
                    break;
2047
                }
2048
            }
2049
            if ($dupcont == 0) {
2050
                $y -= 9;
2051
                $linha--;
2052
            }
2053
            return ($y+$h);
2054
        } else {
2055
            $linha = 0;
0 ignored issues
show
Unused Code introduced by
$linha 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...
2056
            return ($y-2);
2057
        }
2058
    }
2059
2060
    /**
2061
     * pagamento
2062
     * Monta o campo de pagamentos da DANFE (retrato e paisagem) (foi baseada na fatura)
2063
     *
2064
     * @name   pagamento
2065
     * @param  number $x Posição horizontal canto esquerdo
2066
     * @param  number $y Posição vertical canto superior
2067
     * @return number Posição vertical final
2068
     */
2069
    protected function pagamento($x, $y)
2070
    {
2071
        $linha = 1;
2072
        $h = 8+3;
0 ignored issues
show
Unused Code introduced by
$h 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...
2073
        $oldx = $x;
2074
        //verificar se existem cobranças definidas
2075
        if (isset($this->detPag) && $this->detPag->length > 0) {
2076
            //#####################################################################
2077
            //Tipo de pagamento
2078
            $texto = "PAGAMENTO";
2079
            if ($this->orientacao == 'P') {
2080
                $w = $this->wPrint;
2081
            } else {
2082
                $w = 271;
2083
            }
2084
            $h = 8;
2085
            $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2086
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2087
            $y += 3;
2088
            $dups = "";
0 ignored issues
show
Unused Code introduced by
$dups 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...
2089
            $dupcont = 0;
2090
            if ($this->orientacao == 'P') {
2091
                $w = round($this->wPrint/7.018, 0)-1;
2092
            } else {
2093
                $w = 28;
2094
            }
2095
            if ($this->orientacao == 'P') {
2096
                $maxDupCont = 6;
2097
            } else {
2098
                $maxDupCont = 8;
2099
            }
2100
            $increm = 1;
2101
            $formaPagamento = ['01'=>'Dinheiro','02'=>'Cheque','03'=>'Cartão de Crédito',
2102
                                    '04'=>'Cartão de Débito','05'=>'Crédito Loja','10'=>'Vale Alimentação',
2103
                                    '11'=>'Vale Refeição','12'=>'Vale Presente','13'=>'Vale Combustível',
2104
                                    '14'=>'Duplicata Mercantil','15'=>'Boleto','90'=>'Sem pagamento','99'=>'Outros'];
2105
            $bandeira = ['01'=>'Visa','02'=>'Mastercard','03'=>'American','04'=>'Sorocred','05'=>'Diners',
0 ignored issues
show
Unused Code introduced by
$bandeira 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...
2106
                              '06'=>'Elo','07'=>'Hipercard','08'=>'Aura','09'=>'Cabal','99'=>'Outros'];
2107
            foreach ($this->detPag as $k => $d) {
2108
                $fPag = !empty($this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue)
2109
                ? $this->detPag->item($k)->getElementsByTagName('tPag')->item(0)->nodeValue
2110
                : '0';
2111
                $vPag = ! empty($this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue)
2112
                ? 'R$ ' . number_format(
2113
                    $this->detPag->item($k)->getElementsByTagName('vPag')->item(0)->nodeValue,
2114
                    2,
2115
                    ",",
2116
                    "."
2117
                )
2118
                : '';
2119
                $h = 6;
2120
                $texto = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
2121
                if (isset($formaPagamento[$fPag])) {
2122
                    /*Exibir Item sem pagamento ou outros?*/
2123
                    if ($fPag=='90' || $fPag=='99') {
2124
                        continue;
2125
                    }
2126
                    $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2127
                    $this->pdf->textBox($x, $y, $w, $h, 'Forma', $aFont, 'T', 'L', 1, '');
2128
                    $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2129
                    $this->pdf->textBox($x, $y, $w, $h, $formaPagamento[$fPag], $aFont, 'T', 'R', 0, '');
2130
                } else {
2131
                    $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
2132
                    $this->pdf->textBox($x, $y, $w, $h, "Forma ".$fPag." não encontrado", $aFont, 'T', 'L', 1, '');
2133
                }
2134
                $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2135
                $this->pdf->textBox($x, $y, $w, $h, 'Valor', $aFont, 'B', 'L', 0, '');
2136
                $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2137
                $this->pdf->textBox($x, $y, $w, $h, $vPag, $aFont, 'B', 'R', 0, '');
2138
                $x += $w+$increm;
2139
                $dupcont += 1;
2140
2141
                if ($dupcont>$maxDupCont) {
2142
                    $y += 9;
2143
                    $x = $oldx;
2144
                    $dupcont = 0;
2145
                    $linha += 1;
2146
                }
2147
                if ($linha == 5) {
2148
                    $linha = 4;
2149
                    break;
2150
                }
2151
            }
2152
            if ($dupcont == 0) {
2153
                $y -= 9;
2154
                $linha--;
2155
            }
2156
            return ($y+$h);
2157
        } else {
2158
            $linha = 0;
0 ignored issues
show
Unused Code introduced by
$linha 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...
2159
            return ($y-2);
2160
        }
2161
    } //fim da função pagamento
2162
    
2163
    /**
2164
     * impostoHelper
2165
     * Auxilia a montagem dos campos de impostos e totais da DANFE
2166
     *
2167
     * @name   impostoHelper
2168
     * @param  float $x Posição horizontal canto esquerdo
2169
     * @param  float $y Posição vertical canto superior
2170
     * @param  float $w Largura do campo
2171
     * @param  float $h Altura do campo
2172
     * @param  float $h Título do campo
2173
     * @param  float $h Valor do imposto
2174
     * @return float Sugestão do $x do próximo imposto
2175
     */
2176
    protected function impostoHelper($x, $y, $w, $h, $titulo, $campoImposto)
2177
    {
2178
        $valorImposto = '0, 00';
2179
        $the_field = $this->ICMSTot->getElementsByTagName($campoImposto)->item(0);
2180
        if (isset($the_field)) {
2181
            $the_value = $the_field->nodeValue;
2182
            if (!empty($the_value)) {
2183
                $valorImposto = number_format($the_value, 2, ",", ".");
2184
            }
2185
        }
2186
2187
        $fontTitulo = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2188
        $fontValor = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2189
        $this->pdf->textBox($x, $y, $w, $h, $titulo, $fontTitulo, 'T', 'L', 1, '');
2190
        $this->pdf->textBox($x, $y, $w, $h, $valorImposto, $fontValor, 'B', 'R', 0, '');
2191
2192
        $next_x = $x + $w;
2193
        return $next_x;
2194
    }
2195
2196
    /**
2197
     * imposto
2198
     * Monta o campo de impostos e totais da DANFE (retrato e paisagem)
2199
     *
2200
     * @param  number $x Posição horizontal canto esquerdo
2201
     * @param  number $y Posição vertical canto superior
2202
     * @return number Posição vertical final
2203
     */
2204
    protected function imposto($x, $y)
2205
    {
2206
        $x_inicial = $x;
2207
        //#####################################################################
2208
2209
2210
        $campos_por_linha = 9;
2211
        if (!$this->exibirPIS) {
2212
            $campos_por_linha--;
2213
        }
2214
        if (!$this->exibirIcmsInterestadual) {
2215
            $campos_por_linha -= 2;
2216
        }
2217
2218
        if ($this->orientacao == 'P') {
2219
            $maxW = $this->wPrint;
2220
            $title_size = 31;
2221
        } else {
2222
            $maxW = $this->wPrint - $this->wCanhoto;
2223
            $title_size = 40;
2224
        }
2225
        $w = $maxW / $campos_por_linha;
2226
2227
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2228
        $texto = "CÁLCULO DO IMPOSTO";
2229
        $this->pdf->textBox($x, $y, $title_size, 8, $texto, $aFont, 'T', 'L', 0, '');
2230
        $y += 3;
2231
        $h = 7;
2232
2233
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. DO ICMS", "vBC");
2234
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS", "vICMS");
2235
        $x = $this->impostoHelper($x, $y, $w, $h, "BASE DE CÁLC. ICMS S.T.", "vBCST");
2236
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO ICMS SUBST.", "vST");
2237
        $x = $this->impostoHelper($x, $y, $w, $h, "V. IMP. IMPORTAÇÃO", "vII");
2238
2239
        if ($this->exibirIcmsInterestadual) {
2240
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF REMET.", "vICMSUFRemet");
2241
            $x = $this->impostoHelper($x, $y, $w, $h, "V. FCP UF DEST.", "vFCPUFDest");
2242
        }
2243
2244
        if ($this->exibirPIS) {
2245
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO PIS", "vPIS");
2246
        }
2247
2248
        $x = $this->impostoHelper($x, $y, $w, $h, "V. TOTAL PRODUTOS", "vProd");
0 ignored issues
show
Unused Code introduced by
$x 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...
2249
2250
        //
2251
2252
        $y += $h;
2253
        $x = $x_inicial;
2254
2255
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO FRETE", "vFrete");
2256
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DO SEGURO", "vSeg");
2257
        $x = $this->impostoHelper($x, $y, $w, $h, "DESCONTO", "vDesc");
2258
        $x = $this->impostoHelper($x, $y, $w, $h, "OUTRAS DESPESAS", "vOutro");
2259
        $x = $this->impostoHelper($x, $y, $w, $h, "VALOR TOTAL IPI", "vIPI");
2260
2261
        if ($this->exibirIcmsInterestadual) {
2262
            $x = $this->impostoHelper($x, $y, $w, $h, "V. ICMS UF DEST.", "vICMSUFDest");
2263
            $x = $this->impostoHelper($x, $y, $w, $h, "V. TOT. TRIB.", "vTotTrib");
2264
        }
2265
2266
        if ($this->exibirPIS) {
2267
            $x = $this->impostoHelper($x, $y, $w, $h, "VALOR DA COFINS", "vCOFINS");
2268
        }
2269
        $x = $this->impostoHelper($x, $y, $w, $h, "V. TOTAL DA NOTA", "vNF");
0 ignored issues
show
Unused Code introduced by
$x 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...
2270
2271
        return ($y+$h);
2272
    } //fim imposto
2273
2274
    /**
2275
     * transporte
2276
     * Monta o campo de transportes da DANFE (retrato e paisagem)
2277
     *
2278
     * @name   transporte
2279
     * @param  float $x Posição horizontal canto esquerdo
2280
     * @param  float $y Posição vertical canto superior
2281
     * @return float Posição vertical final
2282
     */
2283
    protected function transporte($x, $y)
2284
    {
2285
        $oldX = $x;
2286
        if ($this->orientacao == 'P') {
2287
            $maxW = $this->wPrint;
2288
        } else {
2289
            $maxW = $this->wPrint - $this->wCanhoto;
2290
        }
2291
        //#####################################################################
2292
        //TRANSPORTADOR / VOLUMES TRANSPORTADOS
2293
        $texto = "TRANSPORTADOR / VOLUMES TRANSPORTADOS";
2294
        $w = $maxW;
2295
        $h = 7;
2296
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2297
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2298
        //NOME / RAZÃO SOCIAL
2299
        $w1 = $maxW*0.29;
2300
        $y += 3;
2301
        $texto = 'NOME / RAZÃO SOCIAL';
2302
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2303
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
2304
        if (isset($this->transporta)) {
2305
            $texto = ! empty($this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue)
2306
            ? $this->transporta->getElementsByTagName("xNome")->item(0)->nodeValue
2307
            : '';
2308
        } else {
2309
            $texto = '';
2310
        }
2311
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2312
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, '');
2313
        //FRETE POR CONTA
2314
        $x += $w1;
2315
        $w2 = $maxW*0.15;
2316
        $texto = 'FRETE';
2317
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2318
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2319
        $tipoFrete = ! empty($this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue)
2320
        ? $this->transp->getElementsByTagName("modFrete")->item(0)->nodeValue
2321
        : '0';
2322
        switch ($tipoFrete) {
2323
            case 0:
2324
                $texto = "0-Por conta do Rem";
2325
                break;
2326
            case 1:
2327
                $texto = "1-Por conta do Dest";
2328
                break;
2329
            case 2:
2330
                $texto = "2-Por conta de Terceiros";
2331
                break;
2332
            case 3:
2333
                $texto = "3-Próprio por conta do Rem";
2334
                break;
2335
            case 4:
2336
                $texto = "4-Próprio por conta do Dest";
2337
                break;
2338
            case 9:
2339
                $texto = "9-Sem Transporte";
2340
                break;
2341
        }
2342
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2343
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 1, '');
2344
        //CÓDIGO ANTT
2345
        $x += $w2;
2346
        $texto = 'CÓDIGO ANTT';
2347
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2348
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2349
        if (isset($this->veicTransp)) {
2350
            $texto = ! empty($this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue)
2351
            ? $this->veicTransp->getElementsByTagName("RNTC")->item(0)->nodeValue
2352
            : '';
2353
        } else {
2354
            $texto = '';
2355
        }
2356
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2357
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2358
        //PLACA DO VEÍC
2359
        $x += $w2;
2360
        $texto = 'PLACA DO VEÍCULO';
2361
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2362
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2363
        if (isset($this->veicTransp)) {
2364
            $texto = ! empty($this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue)
2365
            ? $this->veicTransp->getElementsByTagName("placa")->item(0)->nodeValue
2366
            : '';
2367
        } elseif (isset($this->reboque)) {
2368
            $texto = ! empty($this->reboque->getElementsByTagName("placa")->item(0)->nodeValue)
2369
            ? $this->reboque->getElementsByTagName("placa")->item(0)->nodeValue
2370
            : '';
2371
        } else {
2372
            $texto = '';
2373
        }
2374
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2375
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2376
        //UF
2377
        $x += $w2;
2378
        $w3 = round($maxW*0.04, 0);
2379
        $texto = 'UF';
2380
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2381
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
2382
        if (isset($this->veicTransp)) {
2383
            $texto = ! empty($this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue)
2384
            ? $this->veicTransp->getElementsByTagName("UF")->item(0)->nodeValue
2385
            : '';
2386
        } elseif (isset($this->reboque)) {
2387
            $texto = ! empty($this->reboque->getElementsByTagName("UF")->item(0)->nodeValue)
2388
            ? $this->reboque->getElementsByTagName("UF")->item(0)->nodeValue
2389
            : '';
2390
        } else {
2391
            $texto = '';
2392
        }
2393
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2394
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, '');
2395
        //CNPJ / CPF
2396
        $x += $w3;
2397
        $w = $maxW-($w1+3*$w2+$w3);
2398
        $texto = 'CNPJ / CPF';
2399
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2400
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2401
        if (isset($this->transporta)) {
2402
            $texto = ! empty($this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue)
2403
            ? $this->formatField(
2404
                $this->transporta->getElementsByTagName("CNPJ")->item(0)->nodeValue,
2405
                "##.###.###/####-##"
2406
            )
2407
            : '';
2408
            if ($texto == '') {
2409
                $texto = ! empty($this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue)
2410
                ? $this->formatField(
2411
                    $this->transporta->getElementsByTagName("CPF")->item(0)->nodeValue,
2412
                    "###.###.###-##"
2413
                )
2414
                : '';
2415
            }
2416
        } else {
2417
            $texto = '';
2418
        }
2419
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2420
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
2421
        //#####################################################################
2422
        //ENDEREÇO
2423
        $y += $h;
2424
        $x = $oldX;
2425
        $h = 7;
2426
        $w1 = $maxW*0.44;
2427
        $texto = 'ENDEREÇO';
2428
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2429
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
2430
        if (isset($this->transporta)) {
2431
            $texto = ! empty($this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue)
2432
                ? $this->transporta->getElementsByTagName("xEnder")->item(0)->nodeValue
2433
                : '';
2434
        } else {
2435
            $texto = '';
2436
        }
2437
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2438
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'L', 0, '');
2439
        //MUNICÍPIO
2440
        $x += $w1;
2441
        $w2 = round($maxW*0.30, 0);
2442
        $texto = 'MUNICÍPIO';
2443
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2444
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2445
        if (isset($this->transporta)) {
2446
            $texto = ! empty($this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue)
2447
                ? $this->transporta->getElementsByTagName("xMun")->item(0)->nodeValue
2448
                : '';
2449
        } else {
2450
            $texto = '';
2451
        }
2452
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2453
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2454
        //UF
2455
        $x += $w2;
2456
        $w3 = round($maxW*0.04, 0);
2457
        $texto = 'UF';
2458
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2459
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
2460
        if (isset($this->transporta)) {
2461
            $texto = ! empty($this->transporta->getElementsByTagName("UF")->item(0)->nodeValue)
2462
                ? $this->transporta->getElementsByTagName("UF")->item(0)->nodeValue
2463
                : '';
2464
        } else {
2465
            $texto = '';
2466
        }
2467
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2468
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'C', 0, '');
2469
        //INSCRIÇÃO ESTADUAL
2470
        $x += $w3;
2471
        $w = $maxW-($w1+$w2+$w3);
2472
        $texto = 'INSCRIÇÃO ESTADUAL';
2473
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2474
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2475
        $texto = '';
2476
        if (isset($this->transporta)) {
2477
            if (! empty($this->transporta->getElementsByTagName("IE")->item(0)->nodeValue)) {
2478
                $texto = $this->transporta->getElementsByTagName("IE")->item(0)->nodeValue;
2479
            }
2480
        }
2481
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2482
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'C', 0, '');
2483
        //Tratar Multiplos volumes
2484
        $volumes = $this->transp->getElementsByTagName('vol');
2485
        $quantidade = 0;
2486
        $especie = '';
2487
        $marca = '';
2488
        $numero = '';
2489
        $texto = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
2490
        $pesoBruto=0;
2491
        $pesoLiquido=0;
2492
        foreach ($volumes as $volume) {
2493
            $quantidade += ! empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue) ?
2494
                    $volume->getElementsByTagName("qVol")->item(0)->nodeValue : 0;
2495
            $pesoBruto += ! empty($volume->getElementsByTagName("pesoB")->item(0)->nodeValue) ?
2496
                    $volume->getElementsByTagName("pesoB")->item(0)->nodeValue : 0;
2497
            $pesoLiquido += ! empty($volume->getElementsByTagName("pesoL")->item(0)->nodeValue) ?
2498
                    $volume->getElementsByTagName("pesoL")->item(0)->nodeValue : 0;
2499
            $texto = ! empty($this->transp->getElementsByTagName("esp")->item(0)->nodeValue) ?
2500
                    $this->transp->getElementsByTagName("esp")->item(0)->nodeValue : '';
2501
            if ($texto != $especie && $especie != '') {
2502
                //tem várias especies
2503
                $especie = 'VARIAS';
2504
            } else {
2505
                $especie = $texto;
2506
            }
2507
            $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue)
2508
                ? $this->transp->getElementsByTagName("marca")->item(0)->nodeValue
2509
                : '';
2510
            if ($texto != $marca && $marca != '') {
2511
                //tem várias especies
2512
                $marca = 'VARIAS';
2513
            } else {
2514
                $marca = $texto;
2515
            }
2516
            $texto = ! empty($this->transp->getElementsByTagName("nVol")->item(0)->nodeValue)
2517
                ? $this->transp->getElementsByTagName("nVol")->item(0)->nodeValue
2518
                : '';
2519
            if ($texto != $numero && $numero != '') {
2520
                //tem várias especies
2521
                $numero = 'VARIOS';
2522
            } else {
2523
                $numero = $texto;
2524
            }
2525
        }
2526
2527
        //#####################################################################
2528
        //QUANTIDADE
2529
        $y += $h;
2530
        $x = $oldX;
2531
        $h = 7;
2532
        $w1 = round($maxW*0.10, 0);
2533
        $texto = 'QUANTIDADE';
2534
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2535
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'L', 1, '');
2536
        if (!empty($quantidade)) {
2537
            $texto = $quantidade;
2538
            $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2539
            $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'B', 'C', 0, '');
2540
        }
2541
        //ESPÉCIE
2542
        $x += $w1;
2543
        $w2 = round($maxW*0.17, 0);
2544
        $texto = 'ESPÉCIE';
2545
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2546
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2547
        $texto = $especie;
2548
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2549
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2550
        //MARCA
2551
        $x += $w2;
2552
        $texto = 'MARCA';
2553
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2554
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2555
        $texto = ! empty($this->transp->getElementsByTagName("marca")->item(0)->nodeValue) ?
2556
                $this->transp->getElementsByTagName("marca")->item(0)->nodeValue : '';
2557
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2558
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2559
        //NUMERAÇÃO
2560
        $x += $w2;
2561
        $texto = 'NUMERAÇÃO';
2562
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2563
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'T', 'L', 1, '');
2564
        $texto = $numero;
2565
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2566
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'B', 'C', 0, '');
2567
        //PESO BRUTO
2568
        $x += $w2;
2569
        $w3 = round($maxW*0.20, 0);
2570
        $texto = 'PESO BRUTO';
2571
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2572
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'L', 1, '');
2573
        if (is_numeric($pesoBruto) && $pesoBruto > 0) {
2574
            $texto = number_format($pesoBruto, 3, ",", ".");
2575
        } else {
2576
            $texto = '';
2577
        }
2578
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2579
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'B', 'R', 0, '');
2580
        //PESO LÍQUIDO
2581
        $x += $w3;
2582
        $w = $maxW -($w1+3*$w2+$w3);
2583
        $texto = 'PESO LÍQUIDO';
2584
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2585
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
2586
        if (is_numeric($pesoLiquido) && $pesoLiquido > 0) {
2587
            $texto = number_format($pesoLiquido, 3, ",", ".");
2588
        } else {
2589
            $texto = '';
2590
        }
2591
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
2592
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
2593
        return ($y+$h);
2594
    } //fim transporte
2595
2596
2597
2598
    protected function descricaoProdutoHelper($origem, $campo, $formato)
2599
    {
2600
        $valor_original = $origem->getElementsByTagName($campo)->item(0);
2601
        if (!isset($valor_original)) {
2602
            return "";
2603
        }
2604
        $valor_original = $valor_original->nodeValue;
2605
        $valor = ! empty($valor_original) ? number_format($valor_original, 2, ",", ".") : '';
2606
2607
        if ($valor != "") {
2608
            return sprintf($formato, $valor);
2609
        }
2610
        return "";
2611
    }
2612
2613
    /**
2614
     * descricaoProduto
2615
     * Monta a string de descrição de cada Produto
2616
     *
2617
     * @name   descricaoProduto
2618
     * @param  DOMNode itemProd
2619
     * @return string descricao do produto
2620
     */
2621
    protected function descricaoProduto($itemProd)
2622
    {
2623
        $prod = $itemProd->getElementsByTagName('prod')->item(0);
2624
        $ICMS = $itemProd->getElementsByTagName("ICMS")->item(0);
2625
        $ICMSUFDest = $itemProd->getElementsByTagName("ICMSUFDest")->item(0);
2626
        $impostos = '';
2627
2628
        if (!empty($ICMS)) {
2629
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCP", " BcFcp=%s");
2630
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCP", " pFcp=%s%%");
2631
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCP", " vFcp=%s");
2632
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pRedBC", " pRedBC=%s%%");
2633
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pMVAST", " IVA/MVA=%s%%");
2634
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pICMSST", " pIcmsSt=%s%%");
2635
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCST", " BcIcmsSt=%s");
2636
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSST", " vIcmsSt=%s");
2637
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCFCPST", " BcFcpSt=%s");
2638
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pFCPST", " pFcpSt=%s%%");
2639
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vFCPST", " vFcpSt=%s");
2640
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vBCSTRet", " vBcStRet=%s");
2641
            $impostos .= $this->descricaoProdutoHelper($ICMS, "pST", " pSt=%s");
2642
            $impostos .= $this->descricaoProdutoHelper($ICMS, "vICMSSTRet", " vIcmsStRet=%s");
2643
        }
2644
        if (!empty($ICMSUFDest)) {
2645
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pFCPUFDest", " pFCPUFDest=%s%%");
2646
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSUFDest", " pICMSUFDest=%s%%");
2647
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "pICMSInterPart", " pICMSInterPart=%s%%");
2648
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vFCPUFDest", " vFCPUFDest=%s");
2649
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFDest", " vICMSUFDest=%s");
2650
            $impostos .= $this->descricaoProdutoHelper($ICMSUFDest, "vICMSUFRemet", " vICMSUFRemet=%s");
2651
        }
2652
        $infAdProd = ! empty($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue)
2653
        ? substr(
2654
            $this->anfaveaDANFE($itemProd->getElementsByTagName('infAdProd')->item(0)->nodeValue),
2655
            0,
2656
            500
2657
        )
2658
        : '';
2659
        if (! empty($infAdProd)) {
2660
            $infAdProd = trim($infAdProd);
2661
            $infAdProd .= ' ';
2662
        }
2663
        $loteTxt ='';
2664
        $rastro = $prod->getElementsByTagName("med");
0 ignored issues
show
Unused Code introduced by
$rastro 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...
2665
        if (!empty($prod->getElementsByTagName("rastro"))) {
2666
            $rastro = $prod->getElementsByTagName("rastro");
2667
            $i = 0;
2668
            while ($i < $rastro->length) {
2669
                $loteTxt .= $this->getTagValue($rastro->item($i), 'nLote', ' Lote: ');
2670
                $loteTxt .= $this->getTagValue($rastro->item($i), 'qLote', ' Quant: ');
2671
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dFab', ' Fab: ');
2672
                $loteTxt .= $this->getTagDate($rastro->item($i), 'dVal', ' Val: ');
2673
                $loteTxt .= $this->getTagValue($rastro->item($i), 'vPMC', ' PMC: ');
2674
                $i++;
2675
            }
2676
            if ($loteTxt != '') {
2677
                $loteTxt.= ' ';
2678
            }
2679
        }
2680
        //NT2013.006 FCI
2681
        $nFCI = (! empty($itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue)) ?
2682
                ' FCI:'.$itemProd->getElementsByTagName('nFCI')->item(0)->nodeValue : '';
2683
        $tmp_ad=$infAdProd . ($this->descProdInfoComplemento ? $loteTxt . $impostos . $nFCI : '');
2684
        $texto = $prod->getElementsByTagName("xProd")->item(0)->nodeValue
2685
            . (strlen($tmp_ad)!=0?"\n    ".$tmp_ad:'');
2686
        //decodifica os caracteres html no xml
2687
        $texto = html_entity_decode($texto);
2688
        if ($this->descProdQuebraLinha) {
2689
            $texto = str_replace(";", "\n", $texto);
2690
        }
2691
        return $texto;
2692
    }
2693
2694
    /**
2695
     * itens
2696
     * Monta o campo de itens da DANFE (retrato e paisagem)
2697
     *
2698
     * @name   itens
2699
     * @param  float $x       Posição horizontal canto esquerdo
2700
     * @param  float $y       Posição vertical canto superior
2701
     * @param  float $nInicio Número do item inicial
2702
     * @param  float $max     Número do item final
0 ignored issues
show
Bug introduced by
There is no parameter named $max. 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...
2703
     * @param  float $hmax    Altura máxima do campo de itens em mm
2704
     * @return float Posição vertical final
2705
     */
2706
    protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabecItens = 7)
2707
    {
2708
        $oldX = $x;
2709
        $oldY = $y;
2710
        $totItens = $this->det->length;
0 ignored issues
show
Bug introduced by
The property length does not seem to exist in DOMNode.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
2711
        //#####################################################################
2712
        //DADOS DOS PRODUTOS / SERVIÇOS
2713
        $texto = "DADOS DOS PRODUTOS / SERVIÇOS ";
2714
        if ($this->orientacao == 'P') {
2715
            $w = $this->wPrint;
2716
        } else {
2717
            if ($nInicio < 2) { // primeira página
2718
                $w = $this->wPrint - $this->wCanhoto;
2719
            } else { // páginas seguintes
2720
                $w = $this->wPrint;
2721
            }
2722
        }
2723
        $h = 4;
2724
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
2725
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2726
        $y += 3;
2727
        //desenha a caixa dos dados dos itens da NF
2728
        $hmax += 1;
2729
        $texto = '';
0 ignored issues
show
Unused Code introduced by
$texto 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...
2730
        $this->pdf->textBox($x, $y, $w, $hmax);
2731
        //##################################################################################
2732
        // cabecalho LOOP COM OS DADOS DOS PRODUTOS
2733
        //CÓDIGO PRODUTO
2734
        $texto = "CÓDIGO PRODUTO";
2735
        $w1 = round($w*0.09, 0);
2736
        $h = 4;
2737
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2738
        $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2739
        $this->pdf->line($x+$w1, $y, $x+$w1, $y+$hmax);
2740
        //DESCRIÇÃO DO PRODUTO / SERVIÇO
2741
        $x += $w1;
2742
        $w2 = round($w*0.28, 0);
2743
        $texto = 'DESCRIÇÃO DO PRODUTO / SERVIÇO';
2744
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2745
        $this->pdf->textBox($x, $y, $w2, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2746
        $this->pdf->line($x+$w2, $y, $x+$w2, $y+$hmax);
2747
        //NCM/SH
2748
        $x += $w2;
2749
        $w3 = round($w*0.06, 0);
2750
        $texto = 'NCM/SH';
2751
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2752
        $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2753
        $this->pdf->line($x+$w3, $y, $x+$w3, $y+$hmax);
2754
        //O/CST ou O/CSOSN
2755
        $x += $w3;
2756
        $w4 = round($w*0.05, 0);
2757
        $texto = 'O/CSOSN';//Regime do Simples CRT = 1 ou CRT = 2
2758
        if ($this->getTagValue($this->emit, 'CRT') == '3') {
2759
             $texto = 'O/CST';//Regime Normal
2760
        }
2761
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2762
        $this->pdf->textBox($x, $y, $w4, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2763
        $this->pdf->line($x+$w4, $y, $x+$w4, $y+$hmax);
2764
        //CFOP
2765
        $x += $w4;
2766
        $w5 = round($w*0.04, 0);
2767
        $texto = 'CFOP';
2768
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2769
        $this->pdf->textBox($x, $y, $w5, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2770
        $this->pdf->line($x+$w5, $y, $x+$w5, $y+$hmax);
2771
        //UN
2772
        $x += $w5;
2773
        $w6 = round($w*0.03, 0);
2774
        $texto = 'UN';
2775
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2776
        $this->pdf->textBox($x, $y, $w6, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2777
        $this->pdf->line($x+$w6, $y, $x+$w6, $y+$hmax);
2778
        //QUANT
2779
        $x += $w6;
2780
        $w7 = round($w*0.07, 0);
2781
        $texto = 'QUANT';
2782
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2783
        $this->pdf->textBox($x, $y, $w7, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2784
        $this->pdf->line($x+$w7, $y, $x+$w7, $y+$hmax);
2785
        //VALOR UNIT
2786
        $x += $w7;
2787
        $w8 = round($w*0.06, 0);
2788
        $texto = 'VALOR UNIT';
2789
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2790
        $this->pdf->textBox($x, $y, $w8, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2791
        $this->pdf->line($x+$w8, $y, $x+$w8, $y+$hmax);
2792
        //VALOR TOTAL
2793
        $x += $w8;
2794
        $w9 = round($w*0.06, 0);
2795
        $texto = 'VALOR TOTAL';
2796
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2797
        $this->pdf->textBox($x, $y, $w9, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2798
        $this->pdf->line($x+$w9, $y, $x+$w9, $y+$hmax);
2799
        //B.CÁLC ICMS
2800
        $x += $w9;
2801
        $w10 = round($w*0.06, 0);
2802
        $texto = 'B.CÁLC ICMS';
2803
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2804
        $this->pdf->textBox($x, $y, $w10, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2805
        $this->pdf->line($x+$w10, $y, $x+$w10, $y+$hmax);
2806
        //VALOR ICMS
2807
        $x += $w10;
2808
        $w11 = round($w*0.06, 0);
2809
        $texto = 'VALOR ICMS';
2810
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2811
        $this->pdf->textBox($x, $y, $w11, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2812
        $this->pdf->line($x+$w11, $y, $x+$w11, $y+$hmax);
2813
        //VALOR IPI
2814
        $x += $w11;
2815
        $w12 = round($w*0.05, 0);
2816
        $texto = 'VALOR IPI';
2817
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2818
        $this->pdf->textBox($x, $y, $w12, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2819
        $this->pdf->line($x+$w12, $y, $x+$w12, $y+$hmax);
2820
        //ALÍQ. ICMS
2821
        $x += $w12;
2822
        $w13 = round($w*0.035, 0);
2823
        $texto = 'ALÍQ. ICMS';
2824
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
2825
        $this->pdf->textBox($x, $y, $w13, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2826
        $this->pdf->line($x+$w13, $y, $x+$w13, $y+$hmax);
2827
        //ALÍQ. IPI
2828
        $x += $w13;
2829
        $w14 = $w-($w1+$w2+$w3+$w4+$w5+$w6+$w7+$w8+$w9+$w10+$w11+$w12+$w13);
2830
        $texto = 'ALÍQ. IPI';
2831
        $this->pdf->textBox($x, $y, $w14, $h, $texto, $aFont, 'C', 'C', 0, '', false);
2832
        $this->pdf->line($oldX, $y+$h+1, $oldX + $w, $y+$h+1);
2833
        $y += 5;
2834
        //##################################################################################
2835
        // LOOP COM OS DADOS DOS PRODUTOS
2836
        $i = 0;
2837
        $hUsado = $hCabecItens;
2838
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
2839
        foreach ($this->det as $d) {
0 ignored issues
show
Bug introduced by
The expression $this->det of type object<DOMNode> is not traversable.
Loading history...
2840
            if ($i >= $nInicio) {
2841
                $thisItem = $this->det->item($i);
2842
                //carrega as tags do item
2843
                $prod = $thisItem->getElementsByTagName("prod")->item(0);
2844
                $imposto = $this->det->item($i)->getElementsByTagName("imposto")->item(0);
2845
                $ICMS = $imposto->getElementsByTagName("ICMS")->item(0);
2846
                $IPI  = $imposto->getElementsByTagName("IPI")->item(0);
2847
                $textoProduto = trim($this->descricaoProduto($thisItem));
2848
2849
                $linhaDescr = $this->pdf->getNumLines($textoProduto, $w2, $aFont);
2850
                $h = round(($linhaDescr * $this->pdf->fontSize)+ ($linhaDescr * 0.5), 2);
2851
                $hUsado += $h;
2852
2853
                $diffH = $hmax - $hUsado;
2854
2855
                if ($pag != $totpag) {
2856
                    if (1 > $diffH && $i < $totItens) {
2857
                        //ultrapassa a capacidade para uma única página
2858
                        //o restante dos dados serão usados nas proximas paginas
2859
                        $nInicio = $i;
2860
                        break;
2861
                    }
2862
                }
2863
                $y_linha=$y+$h;
2864
                // linha entre itens
2865
                $this->pdf->dashedHLine($oldX, $y_linha, $w, 0.1, 120);
2866
                //corrige o x
2867
                $x=$oldX;
2868
                //codigo do produto
2869
                $texto = $prod->getElementsByTagName("cProd")->item(0)->nodeValue;
2870
                $this->pdf->textBox($x, $y, $w1, $h, $texto, $aFont, 'T', 'C', 0, '');
2871
                $x += $w1;
2872
                //DESCRIÇÃO
2873
                if ($this->orientacao == 'P') {
2874
                    $this->pdf->textBox($x, $y, $w2, $h, $textoProduto, $aFont, 'T', 'L', 0, '', false);
2875
                } else {
2876
                    $this->pdf->textBox($x, $y, $w2, $h, $textoProduto, $aFont, 'T', 'L', 0, '', false);
2877
                }
2878
                $x += $w2;
2879
                //NCM
2880
                $texto = ! empty($prod->getElementsByTagName("NCM")->item(0)->nodeValue) ?
2881
                        $prod->getElementsByTagName("NCM")->item(0)->nodeValue : '';
2882
                $this->pdf->textBox($x, $y, $w3, $h, $texto, $aFont, 'T', 'C', 0, '');
2883
                $x += $w3;
2884
                //CST
2885
                if (isset($ICMS)) {
2886
                    $origem =  $this->getTagValue($ICMS, "orig");
2887
                    $cst =  $this->getTagValue($ICMS, "CST");
2888
                    $csosn =  $this->getTagValue($ICMS, "CSOSN");
2889
                    $texto = $origem.$cst.$csosn;
2890
                    $this->pdf->textBox($x, $y, $w4, $h, $texto, $aFont, 'T', 'C', 0, '');
2891
                }
2892
                //CFOP
2893
                $x += $w4;
2894
                $texto = $prod->getElementsByTagName("CFOP")->item(0)->nodeValue;
2895
                $this->pdf->textBox($x, $y, $w5, $h, $texto, $aFont, 'T', 'C', 0, '');
2896
                //Unidade
2897
                $x += $w5;
2898
                $texto = $prod->getElementsByTagName("uCom")->item(0)->nodeValue;
2899
                $this->pdf->textBox($x, $y, $w6, $h, $texto, $aFont, 'T', 'C', 0, '');
2900
                $x += $w6;
2901
                if ($this->orientacao == 'P') {
2902
                    $alinhamento = 'R';
2903
                } else {
2904
                    $alinhamento = 'R';
2905
                }
2906
                // QTDADE
2907
                $texto = number_format($prod->getElementsByTagName("qCom")->item(0)->nodeValue, 4, ",", ".");
2908
                $this->pdf->textBox($x, $y, $w7, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
2909
                $x += $w7;
2910
                // Valor Unitário
2911
                $texto = number_format($prod->getElementsByTagName("vUnCom")->item(0)->nodeValue, 4, ",", ".");
2912
                $this->pdf->textBox($x, $y, $w8, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
2913
                $x += $w8;
2914
                // Valor do Produto
2915
                $texto = "";
2916
                if (is_numeric($prod->getElementsByTagName("vProd")->item(0)->nodeValue)) {
2917
                    $texto = number_format($prod->getElementsByTagName("vProd")->item(0)->nodeValue, 2, ",", ".");
2918
                }
2919
                $this->pdf->textBox($x, $y, $w9, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
2920
                //Valor da Base de calculo
2921
                $x += $w9;
2922
                if (isset($ICMS)) {
2923
                    $texto = ! empty($ICMS->getElementsByTagName("vBC")->item(0)->nodeValue)
2924
                    ? number_format(
2925
                        $ICMS->getElementsByTagName("vBC")->item(0)->nodeValue,
2926
                        2,
2927
                        ",",
2928
                        "."
2929
                    )
2930
                    : '0, 00';
2931
                    $this->pdf->textBox($x, $y, $w10, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
2932
                }
2933
                //Valor do ICMS
2934
                $x += $w10;
2935
                if (isset($ICMS)) {
2936
                    $texto = ! empty($ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue)
2937
                    ? number_format(
2938
                        $ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue,
2939
                        2,
2940
                        ",",
2941
                        "."
2942
                    )
2943
                    : '0, 00';
2944
                    $this->pdf->textBox($x, $y, $w11, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
2945
                }
2946
                //Valor do IPI
2947
                $x += $w11;
2948
                if (isset($IPI)) {
2949
                    $texto = ! empty($IPI->getElementsByTagName("vIPI")->item(0)->nodeValue)
2950
                    ? number_format(
2951
                        $IPI->getElementsByTagName("vIPI")->item(0)->nodeValue,
2952
                        2,
2953
                        ",",
2954
                        "."
2955
                    )
2956
                    :'';
2957
                } else {
2958
                    $texto = '';
2959
                }
2960
                $this->pdf->textBox($x, $y, $w12, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
2961
                // %ICMS
2962
                $x += $w12;
2963
                if (isset($ICMS)) {
2964
                    $texto = ! empty($ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue)
2965
                    ? number_format(
2966
                        $ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue,
2967
                        2,
2968
                        ",",
2969
                        "."
2970
                    )
2971
                    : '0, 00';
2972
                    $this->pdf->textBox($x, $y, $w13, $h, $texto, $aFont, 'T', 'C', 0, '');
2973
                }
2974
                //%IPI
2975
                $x += $w13;
2976
                if (isset($IPI)) {
2977
                    $texto = ! empty($IPI->getElementsByTagName("pIPI")->item(0)->nodeValue)
2978
                    ? number_format(
2979
                        $IPI->getElementsByTagName("pIPI")->item(0)->nodeValue,
2980
                        2,
2981
                        ",",
2982
                        "."
2983
                    )
2984
                    : '';
2985
                } else {
2986
                    $texto = '';
2987
                }
2988
                $this->pdf->textBox($x, $y, $w14, $h, $texto, $aFont, 'T', 'C', 0, '');
2989
2990
2991
                // Dados do Veiculo Somente para veiculo 0 Km
2992
                $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
2993
                // Tag somente é gerada para veiculo 0k, e só é permitido um veiculo por NF-e por conta do detran
2994
                // Verifica se a Tag existe
2995
                if (!empty($veicProd)) {
2996
                    $this->dadosItenVeiculoDANFE($oldX, $y, $nInicio, $h, $prod);
2997
                }
2998
2999
3000
                $y += $h;
3001
                $i++;
3002
                //incrementa o controle dos itens processados.
3003
                $this->qtdeItensProc++;
3004
            } else {
3005
                $i++;
3006
            }
3007
        }
3008
        return $oldY+$hmax;
3009
    }
3010
3011
3012
    /**
3013
     * dadosItenVeiculoDANFE
3014
     * Coloca os dados do veiculo abaixo do item da NFe. (retrato e paisagem)
3015
     *
3016
     * @param float  $x    Posição horizontal
3017
     *                     canto esquerdo
3018
     * @param float  $y    Posição vertical
3019
     *                     canto superior
3020
     * @param        $nInicio
3021
     * @param float  $h    altura do campo
3022
     * @param object $prod Contendo todos os dados do item
3023
     */
3024
3025
    protected function dadosItenVeiculoDANFE($x, $y, &$nInicio, $h, $prod)
3026
    {
3027
        $oldX = $x;
3028
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY 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...
3029
3030
        if ($this->orientacao == 'P') {
3031
            $w = $this->wPrint;
3032
        } else {
3033
            if ($nInicio < 2) { // primeira página
3034
                $w = $this->wPrint - $this->wCanhoto;
3035
            } else { // páginas seguintes
3036
                $w = $this->wPrint;
3037
            }
3038
        }
3039
3040
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
3041
3042
        $w1 = round($w*0.09, 0);
3043
3044
        // Tabela Renavam Combustivel
3045
        $renavamCombustivel = [
3046
            1=>'ALCOOL',
3047
            2=>'GASOLINA',
3048
            3=>'DIESEL',
3049
            4=>'GASOGENIO',
3050
            5=>'GAS METANO',
3051
            6=>'ELETRICO/FONTE INTERNA',
3052
            7=>'ELETRICO/FONTE EXTERNA',
3053
            8=>'GASOL/GAS NATURAL COMBUSTIVEL',
3054
            9=>'ALCOOL/GAS NATURAL COMBUSTIVEL',
3055
            10=>'DIESEL/GAS NATURAL COMBUSTIVEL',
3056
            11=>'VIDE/CAMPO/OBSERVACAO',
3057
            12=>'ALCOOL/GAS NATURAL VEICULAR',
3058
            13=>'GASOLINA/GAS NATURAL VEICULAR',
3059
            14=>'DIESEL/GAS NATURAL VEICULAR',
3060
            15=>'GAS NATURAL VEICULAR',
3061
            16=>'ALCOOL/GASOLINA',
3062
            17=>'GASOLINA/ALCOOL/GAS NATURAL',
3063
            18=>'GASOLINA/ELETRICO'
3064
        ];
3065
3066
        $renavamEspecie = [
3067
            1=>'PASSAGEIRO',
3068
            2=>'CARGA',
3069
            3=>'MISTO',
3070
            4=>'CORRIDA',
3071
            5=>'TRACAO',
3072
            6=>'ESPECIAL',
3073
            7=>'COLECAO'
3074
        ];
3075
3076
        $renavamTiposVeiculos = [
3077
            1=>'BICICLETA',
3078
            2=>'CICLOMOTOR',
3079
            3=>'MOTONETA',
3080
            4=>'MOTOCICLETA',
3081
            5=>'TRICICLO',
3082
            6=>'AUTOMOVEL',
3083
            7=>'MICROONIBUS',
3084
            8=>'ONIBUS',
3085
            9=>'BONDE',
3086
            10=>'REBOQUE',
3087
            11=>'SEMI-REBOQUE',
3088
            12=>'CHARRETE',
3089
            13=>'CAMIONETA',
3090
            14=>'CAMINHAO',
3091
            15=>'CARROCA',
3092
            16=>'CARRO DE MAO',
3093
            17=>'CAMINHAO TRATOR',
3094
            18=>'TRATOR DE RODAS',
3095
            19=>'TRATOR DE ESTEIRAS',
3096
            20=>'TRATOR MISTO',
3097
            21=>'QUADRICICLO',
3098
            22=>'CHASSI/PLATAFORMA',
3099
            23=>'CAMINHONETE',
3100
            24=>'SIDE-CAR',
3101
            25=>'UTILITARIO',
3102
            26=>'MOTOR-CASA'
3103
        ];
3104
3105
        $renavamTipoPintura = [
0 ignored issues
show
Unused Code introduced by
$renavamTipoPintura 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...
3106
            'F'=>'FOSCA',
3107
            'S'=>'SÓLIDA',
3108
            'P'=>'PEROLIZADA',
3109
            'M'=>'METALICA',
3110
        ];
3111
3112
        $veicProd = $prod->getElementsByTagName("veicProd")->item(0);
3113
3114
        $veiculoChassi = $veicProd->getElementsByTagName("chassi")->item(0)->nodeValue;
3115
        $veiculoCor = $veicProd->getElementsByTagName("xCor")->item(0)->nodeValue;
3116
        $veiculoCilindrada = $veicProd->getElementsByTagName("cilin")->item(0)->nodeValue;
3117
        $veiculoCmkg = $veicProd->getElementsByTagName("CMT")->item(0)->nodeValue;
3118
        $veiculoTipo = $veicProd->getElementsByTagName("tpVeic")->item(0)->nodeValue;
3119
3120
        $veiculoMotor = $veicProd->getElementsByTagName("nMotor")->item(0)->nodeValue;
3121
        $veiculoRenavam = $veicProd->getElementsByTagName("cMod")->item(0)->nodeValue;
3122
        $veiculoHp = $veicProd->getElementsByTagName("pot")->item(0)->nodeValue;
3123
        $veiculoPlaca = ''; //$veiculo->getElementsByTagName("CMT")->item(0)->nodeValue;
3124
        $veiculoTipoPintura = $veicProd->getElementsByTagName("tpPint")->item(0)->nodeValue;
3125
        $veiculoMarcaModelo = $prod->getElementsByTagName("xProd")->item(0)->nodeValue;
3126
        $veiculoEspecie = $veicProd->getElementsByTagName("espVeic")->item(0)->nodeValue;
3127
        $veiculoCombustivel = $veicProd->getElementsByTagName("tpComb")->item(0)->nodeValue;
3128
        $veiculoSerial = $veicProd->getElementsByTagName("nSerie")->item(0)->nodeValue;
3129
        $veiculoFabricacao = $veicProd->getElementsByTagName("anoFab")->item(0)->nodeValue;
3130
        $veiculoModelo = $veicProd->getElementsByTagName("anoMod")->item(0)->nodeValue;
3131
        $veiculoDistancia = $veicProd->getElementsByTagName("dist")->item(0)->nodeValue;
3132
3133
        $x = $oldX;
3134
3135
        $yVeic = $y + $h;
3136
        $texto = 'Chassi: ............: ' . $veiculoChassi;
3137
        $this->pdf->textBox($x, $yVeic, $w1+40, $h, $texto, $aFont, 'T', 'L', 0, '');
3138
        $yVeic += $h;
3139
        $texto = 'Cor...................: ' . $veiculoCor;
3140
        $this->pdf->textBox($x, $yVeic, $w1+40, $h, $texto, $aFont, 'T', 'L', 0, '');
3141
        $yVeic += $h;
3142
        $texto = 'Cilindrada........: ' . $veiculoCilindrada;
3143
        $this->pdf->textBox($x, $yVeic, $w1+40, $h, $texto, $aFont, 'T', 'L', 0, '');
3144
        $yVeic += $h;
3145
        $texto = 'Cmkg...............: ' . $veiculoCmkg;
3146
        $this->pdf->textBox($x, $yVeic, $w1+40, $h, $texto, $aFont, 'T', 'L', 0, '');
3147
        $yVeic += $h;
3148
        $texto = 'Tipo.................: ' . ($renavamTiposVeiculos[intval($veiculoTipo)] ?? $veiculoTipo);
3149
         $this->pdf->textBox($x, $yVeic, $w1+40, $h, $texto, $aFont, 'T', 'L', 0, '');
3150
        $yVeic = $y + $h;
3151
        $xVeic = $x + 65;
3152
        $texto = 'Nº Motor: .........: ' . $veiculoMotor;
3153
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3154
        $yVeic += $h;
3155
        $texto = 'Renavam...........: ' . $veiculoRenavam;
3156
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3157
        $yVeic += $h;
3158
        $texto = 'HP.....................: ' . $veiculoHp;
3159
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3160
        $yVeic += $h;
3161
        $texto = 'Placa.................: ' . $veiculoPlaca;
3162
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3163
        $yVeic += $h;
3164
        $texto = 'Tipo Pintura......: ' . ($renavamEspecie[intval($veiculoTipoPintura)] ?? $veiculoTipoPintura);
3165
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3166
        $yVeic = $y + $h;
3167
        $xVeic = $xVeic + 55;
3168
        $texto = 'Marca / Modelo.....: ' . $veiculoMarcaModelo;
3169
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3170
        $yVeic += $h;
3171
        $texto = 'Especie..................: ' . ($renavamEspecie[intval($veiculoEspecie)] ?? $veiculoEspecie);
3172
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3173
        $yVeic += $h;
3174
        $texto = 'Combustivel..........: ' . ($renavamCombustivel[intval($veiculoCombustivel)] ?? $veiculoCombustivel);
3175
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3176
        $yVeic += $h;
3177
        $texto = 'Serial.....................: ' . $veiculoSerial;
3178
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3179
        $yVeic += $h;
3180
        $texto = 'Ano Fab/Mod........: '. $veiculoFabricacao . '/' . $veiculoModelo;
3181
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3182
        $yVeic += $h;
3183
        $texto = 'Distancia Entre Eixos(mm)..: '. $veiculoDistancia;
3184
        $this->pdf->textBox($xVeic, $yVeic, $w1+50, $h, $texto, $aFont, 'T', 'L', 0, '');
3185
    }
3186
3187
    /**
3188
     * issqn
3189
     * Monta o campo de serviços do DANFE
3190
     *
3191
     * @name   issqn (retrato e paisagem)
3192
     * @param  float $x Posição horizontal canto esquerdo
3193
     * @param  float $y Posição vertical canto superior
3194
     * @return float Posição vertical final
3195
     */
3196
    protected function issqn($x, $y)
3197
    {
3198
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
3199
        //#####################################################################
3200
        //CÁLCULO DO ISSQN
3201
        $texto = "CÁLCULO DO ISSQN";
3202
        $w = $this->wPrint;
3203
        $h = 7;
3204
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
3205
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3206
        //INSCRIÇÃO MUNICIPAL
3207
        $y += 3;
3208
        $w = round($this->wPrint*0.23, 0);
3209
        $texto = 'INSCRIÇÃO MUNICIPAL';
3210
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
3211
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
3212
        //inscrição municipal
3213
        $texto = ! empty($this->emit->getElementsByTagName("IM")->item(0)->nodeValue) ?
3214
                $this->emit->getElementsByTagName("IM")->item(0)->nodeValue : '';
3215
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
3216
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'L', 0, '');
3217
        //VALOR TOTAL DOS SERVIÇOS
3218
        $x += $w;
3219
        $texto = 'VALOR TOTAL DOS SERVIÇOS';
3220
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
3221
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
3222
        if (isset($this->ISSQNtot)) {
3223
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
3224
                    $this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : '';
3225
            $texto = number_format($texto, 2, ",", ".");
3226
        } else {
3227
            $texto = '';
3228
        }
3229
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
3230
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
3231
        //BASE DE CÁLCULO DO ISSQN
3232
        $x += $w;
3233
        $texto = 'BASE DE CÁLCULO DO ISSQN';
3234
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
3235
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
3236
        if (isset($this->ISSQNtot)) {
3237
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue) ?
3238
                    $this->ISSQNtot->getElementsByTagName("vBC")->item(0)->nodeValue : '';
3239
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3240
        } else {
3241
            $texto = '';
3242
        }
3243
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
3244
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
3245
        //VALOR TOTAL DO ISSQN
3246
        $x += $w;
3247
        if ($this->orientacao == 'P') {
3248
            $w = $this->wPrint - (3 * $w);
3249
        } else {
3250
            $w = $this->wPrint - (3 * $w)-$this->wCanhoto;
3251
        }
3252
        $texto = 'VALOR TOTAL DO ISSQN';
3253
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
3254
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
3255
        if (isset($this->ISSQNtot)) {
3256
            $texto = ! empty($this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue) ?
3257
                    $this->ISSQNtot->getElementsByTagName("vISS")->item(0)->nodeValue : '';
3258
            $texto = ! empty($texto) ? number_format($texto, 2, ",", ".") : '';
3259
        } else {
3260
            $texto = '';
3261
        }
3262
        $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
3263
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'B', 'R', 0, '');
3264
        return ($y+$h+1);
3265
    }
3266
3267
    /**
3268
     *dadosAdicionais
3269
     * Coloca o grupo de dados adicionais da NFe. (retrato e paisagem)
3270
     *
3271
     * @name   dadosAdicionais
3272
     * @param  float $x Posição horizontal canto esquerdo
3273
     * @param  float $y Posição vertical canto superior
3274
     * @param  float $h altura do campo
3275
     * @return float Posição vertical final (eixo Y)
3276
     */
3277
    protected function dadosAdicionais($x, $y, $h)
3278
    {
3279
        //##################################################################################
3280
        //DADOS ADICIONAIS
3281
        $texto = "DADOS ADICIONAIS";
3282
        if ($this->orientacao == 'P') {
3283
              $w = $this->wPrint;
3284
        } else {
3285
              $w = $this->wPrint-$this->wCanhoto;
3286
        }
3287
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
3288
        $this->pdf->textBox($x, $y, $w, 8, $texto, $aFont, 'T', 'L', 0, '');
3289
        //INFORMAÇÕES COMPLEMENTARES
3290
        $texto = "INFORMAÇÕES COMPLEMENTARES";
3291
        $y += 3;
3292
        $w = $this->wAdic;
3293
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>'B'];
3294
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
3295
        //o texto com os dados adicionais foi obtido na função montaDANFE
3296
        //e carregado em uma propriedade privada da classe
3297
        //$this->wAdic com a largura do campo
3298
        //$this->textoAdic com o texto completo do campo
3299
        $y += 1;
3300
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
3301
        $this->pdf->textBox($x, $y+2, $w-2, $h-3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3302
        //RESERVADO AO FISCO
3303
        $texto = "RESERVADO AO FISCO";
3304
        $x += $w;
3305
        $y -= 1;
3306
        if ($this->orientacao == 'P') {
3307
            $w = $this->wPrint-$w;
3308
        } else {
3309
            $w = $this->wPrint-$w-$this->wCanhoto;
3310
        }
3311
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>'B'];
3312
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
3313
        //inserir texto informando caso de contingência
3314
        // 1 - Normal - emissão normal;
3315
        // 2 - Contingência FS - emissão em contingência com impressão do DANFE em Formulário de Segurança;
3316
        // 3 - Contingência SCAN - emissão em contingência no Sistema de Contingência do Ambiente Nacional;
3317
        // 4 - Contingência DPEC - emissão em contingência com envio da Declaração
3318
        //     Prévia de Emissão em Contingência;
3319
        // 5 - Contingência FS-DA - emissão em contingência com impressão do DANFE em Formulário de
3320
        //     Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA);
3321
        // 6 - Contingência SVC-AN
3322
        // 7 - Contingência SVC-RS
3323
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3324
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3325
        $texto = '';
3326
        switch ($this->tpEmis) {
3327
            case 2:
3328
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3329
                break;
3330
            case 3:
3331
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3332
                break;
3333
            case 4:
3334
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3335
                break;
3336
            case 5:
3337
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3338
                break;
3339
            case 6:
3340
                $texto = 'CONTINGÊNCIA SVC-AN' . $dhCont . $xJust;
3341
                break;
3342
            case 7:
3343
                $texto = 'CONTINGÊNCIA SVC-RS' . $dhCont . $xJust;
3344
                break;
3345
        }
3346
        $y += 2;
3347
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
3348
        $this->pdf->textBox($x, $y, $w-2, $h-3, $texto, $aFont, 'T', 'L', 0, '', false);
3349
        return $y+$h;
3350
    }
3351
3352
    /**
3353
     * rodape
3354
     * Monta o rodapé no final da DANFE com a data/hora de impressão e informações
3355
     * sobre a API NfePHP
3356
     *
3357
     * @param  float $x  Posição horizontal canto esquerdo
3358
     *
3359
     * @return void
3360
     */
3361
    protected function rodape($x)
3362
    {
3363
        
3364
        $y = $this->maxH - 4;
3365
        if ($this->orientacao == 'P') {
3366
              $w = $this->wPrint;
3367
        } else {
3368
              $w = $this->wPrint-$this->wCanhoto;
3369
              $x = $this->wCanhoto;
3370
        }
3371
        $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I'];
3372
        $texto = "Impresso em ". date('d/m/Y') . " as " . date('H:i:s')
3373
            . '  ' . $this->creditos;
3374
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'L', false);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a integer.

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...
3375
        $texto = "Powered by NFePHP®";
3376
        $this->pdf->textBox($x, $y, $w, 0, $texto, $aFont, 'T', 'R', false, '');
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a integer.

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...
3377
    }
3378
3379
    /**
3380
     * pCcanhotoDANFE
3381
     * Monta o canhoto da DANFE (retrato e paisagem)
3382
     *
3383
     * @name   canhotoDANFE
3384
     * @param  number $x Posição horizontal canto esquerdo
3385
     * @param  number $y Posição vertical canto superior
3386
     * @return number Posição vertical final
3387
     *
3388
     * TODO 21/07/14 fmertins: quando orientação L-paisagem, o canhoto está sendo gerado incorretamente
3389
     */
3390
    protected function canhoto($x, $y)
3391
    {
3392
        $oldX = $x;
3393
        $oldY = $y;
3394
        //#################################################################################
3395
        //canhoto
3396
        //identificação do tipo de nf entrada ou saida
3397
        $tpNF = $this->ide->getElementsByTagName('tpNF')->item(0)->nodeValue;
3398
        if ($tpNF == '0') {
3399
            //NFe de Entrada
3400
            $emitente = '';
3401
            $emitente .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3402
            $emitente .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3403
            $emitente .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " - ";
3404
            $emitente .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3405
            $emitente .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3406
            $emitente .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3407
            $emitente .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . "";
3408
            $destinatario = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3409
        } else {
3410
            //NFe de Saída
3411
            $emitente = $this->emit->getElementsByTagName("xNome")->item(0)->nodeValue . " ";
3412
            $destinatario = '';
3413
            $destinatario .= $this->dest->getElementsByTagName("xNome")->item(0)->nodeValue . " - ";
3414
            $destinatario .= $this->enderDest->getElementsByTagName("xLgr")->item(0)->nodeValue . ", ";
3415
            $destinatario .= $this->enderDest->getElementsByTagName("nro")->item(0)->nodeValue . " ";
3416
            $destinatario .= $this->getTagValue($this->enderDest, "xCpl", " - ", " ");
3417
            $destinatario .= $this->enderDest->getElementsByTagName("xBairro")->item(0)->nodeValue . " ";
3418
            $destinatario .= $this->enderDest->getElementsByTagName("xMun")->item(0)->nodeValue . "-";
3419
            $destinatario .= $this->enderDest->getElementsByTagName("UF")->item(0)->nodeValue . " ";
3420
        }
3421
        //identificação do sistema emissor
3422
        //linha separadora do canhoto
3423
        if ($this->orientacao == 'P') {
3424
            $w = round($this->wPrint * 0.81, 0);
3425
        } else {
3426
            //linha separadora do canhoto - 238
3427
            //posicao altura
3428
            $y = $this->wPrint-85;
3429
            //altura
3430
            $w = $this->wPrint-85-24;
3431
        }
3432
        $h = 10;
3433
        //desenha caixa
3434
        $texto = '';
3435
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
3436
        $aFontSmall = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
3437
        if ($this->orientacao == 'P') {
3438
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false);
3439
        } else {
3440
            $this->pdf->textBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'L', 1, '', false);
3441
        }
3442
        $numNF = str_pad($this->ide->getElementsByTagName('nNF')->item(0)->nodeValue, 9, "0", STR_PAD_LEFT);
3443
        $serie = str_pad($this->ide->getElementsByTagName('serie')->item(0)->nodeValue, 3, "0", STR_PAD_LEFT);
3444
        $texto = "RECEBEMOS DE ";
3445
        $texto .= $emitente;
3446
        $texto .= " OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA ";
3447
        if ($this->orientacao == 'P') {
3448
            $texto .= "ABAIXO";
3449
        } else {
3450
            $texto .= "AO LADO";
3451
        }
3452
        $texto .= ". EMISSÃO: ";
3453
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3454
                $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3455
        if ($dEmi == '') {
3456
            $dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3457
                    $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3458
            $aDemi = explode('T', $dEmi);
3459
            $dEmi = $aDemi[0];
3460
        }
3461
        $texto .= $this->ymdTodmy($dEmi) ." ";
3462
        $texto .= "VALOR TOTAL: R$ ";
3463
        $texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " ";
3464
        $texto .= "DESTINATÁRIO: ";
3465
        $texto .= $destinatario;
3466
        if ($this->orientacao == 'P') {
3467
            $this->pdf->textBox($x, $y, $w-1, $h, $texto, $aFont, 'C', 'L', 0, '', false);
3468
            $x1 = $x + $w;
3469
            $w1 = $this->wPrint - $w;
3470
            $texto = "NF-e";
3471
            $aFont = ['font'=>$this->fontePadrao, 'size'=>14, 'style'=>'B'];
3472
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'T', 'C', 0, '');
3473
            $texto = "Nº. " . $this->formatField($numNF, "###.###.###") . " \n";
3474
            $texto .= "Série $serie";
3475
            $aFont = ['font'=>$this->fontePadrao, 'size'=>10, 'style'=>'B'];
3476
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'C', 'C', 1, '');
3477
            //DATA DE RECEBIMENTO
3478
            $texto = "DATA DE RECEBIMENTO";
3479
            $y += $h;
3480
            $w2 = round($this->wPrint*0.17, 0); //35;
3481
            $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
3482
            $this->pdf->textBox($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
3483
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3484
            $x += $w2;
3485
            $w3 = $w-$w2;
3486
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3487
            $this->pdf->textBox($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
3488
            $x = $oldX;
3489
            $y += 9;
3490
            $this->pdf->dashedHLine($x, $y, $this->wPrint, 0.1, 80);
3491
            $y += 2;
3492
            return $y;
3493
        } else {
3494
            $x--;
3495
            $x = $this->pdf->textBox90($x, $y, $w-1, $h, $texto, $aFontSmall, 'C', 'L', 0, '', false);
0 ignored issues
show
Unused Code introduced by
$x 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...
3496
            //NUMERO DA NOTA FISCAL LOGO NFE
3497
            $w1 = 18;
3498
            $x1 = $oldX;
3499
            $y = $oldY;
3500
            $texto = "NF-e";
3501
            $aFont = ['font'=>$this->fontePadrao, 'size'=>14, 'style'=>'B'];
3502
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'T', 'C', 0, '');
3503
            $texto = "Nº.\n" . $this->formatField($numNF, "###.###.###") . " \n";
3504
            $texto .= "Série $serie";
3505
            $aFont = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
3506
            $this->pdf->textBox($x1, $y, $w1, 18, $texto, $aFont, 'C', 'C', 1, '');
3507
            //DATA DO RECEBIMENTO
3508
            $texto = "DATA DO RECEBIMENTO";
3509
            $y = $this->wPrint-85;
3510
            $x = 12;
3511
            $w2 = round($this->wPrint*0.17, 0); //35;
3512
            $aFont = ['font'=>$this->fontePadrao, 'size'=>6, 'style'=>''];
3513
            $this->pdf->textBox90($x, $y, $w2, 8, $texto, $aFont, 'T', 'L', 1, '');
3514
            //IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR
3515
            $y -= $w2;
3516
            $w3 = $w-$w2;
3517
            $texto = "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR";
3518
            $aFont = ['font'=>$this->fontePadrao, 'size'=>5.7, 'style'=>''];
3519
            $x = $this->pdf->textBox90($x, $y, $w3, 8, $texto, $aFont, 'T', 'L', 1, '');
3520
            $this->pdf->dashedVLine(22, $oldY, 0.1, $this->wPrint, 69);
3521
            return $x;
3522
        }
3523
    }
3524
3525
    /**
3526
     * geraInformacoesDaTagCompra
3527
     * Devolve uma string contendo informação sobre as tag <compra><xNEmp>, <xPed> e <xCont> ou string vazia.
3528
     * Aviso: Esta função não leva em consideração dados na tag xPed do item.
3529
     *
3530
     * @name   pGeraInformacoesDaTagCompra
3531
     * @return string com as informacoes dos pedidos.
3532
     */
3533
    protected function geraInformacoesDaTagCompra()
3534
    {
3535
        $saida = "";
3536
        if (isset($this->compra)) {
3537
            if (! empty($this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue)) {
3538
                $saida .= " Nota de Empenho: " . $this->compra->getElementsByTagName("xNEmp")->item(0)->nodeValue;
3539
            }
3540
            if (! empty($this->compra->getElementsByTagName("xPed")->item(0)->nodeValue)) {
3541
                $saida .= " Pedido: " . $this->compra->getElementsByTagName("xPed")->item(0)->nodeValue;
3542
            }
3543
            if (! empty($this->compra->getElementsByTagName("xCont")->item(0)->nodeValue)) {
3544
                $saida .= " Contrato: " . $this->compra->getElementsByTagName("xCont")->item(0)->nodeValue;
3545
            }
3546
        }
3547
        return $saida;
3548
    }
3549
3550
    /**
3551
     * geraChaveAdicionalDeContingencia
3552
     *
3553
     * @name   geraChaveAdicionalDeContingencia
3554
     * @return string chave
3555
     */
3556
    protected function geraChaveAdicionalDeContingencia()
3557
    {
3558
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
3559
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
3560
        $forma  = "%02d%d%s%014d%01d%01d%02d";
3561
        $cUF    = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
3562
        $CNPJ   = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3563
        $CNPJ   = substr($CNPJ, -14);
3564
        $vNF    = $this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue * 100;
3565
        $vICMS  = $this->ICMSTot->getElementsByTagName("vICMS")->item(0)->nodeValue;
3566
        if ($vICMS > 0) {
3567
            $vICMS = 1;
3568
        }
3569
        $icmss  = $this->ICMSTot->getElementsByTagName("vBC")->item(0)->nodeValue;
3570
        if ($icmss > 0) {
3571
            $icmss = 1;
3572
        }
3573
        $dEmi = ! empty($this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue) ?
3574
                $this->ide->getElementsByTagName("dEmi")->item(0)->nodeValue : '';
3575
        if ($dEmi == '') {
3576
            $dEmi = ! empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
3577
                    $this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue : '';
3578
            $aDemi = explode('T', $dEmi);
3579
            $dEmi = $aDemi[0];
3580
        }
3581
        $dd  = $dEmi;
3582
        $rpos = strrpos($dd, '-');
3583
        $dd  = substr($dd, $rpos +1);
3584
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vNF, $vICMS, $icmss, $dd);
3585
        $chave = $chave . $this->modulo11($chave);
3586
        return $chave;
3587
    }
3588
3589
    /**
3590
     *  geraInformacoesDasNotasReferenciadas
3591
     * Devolve uma string contendo informação sobre as notas referenciadas. Suporta N notas, eletrônicas ou não
3592
     * Exemplo: NFe Ref.: série: 01 número: 01 emit: 11.111.111/0001-01
3593
     * em 10/2010 [0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000]
3594
     *
3595
     * @return string Informacoes a serem adicionadas no rodapé sobre notas referenciadas.
3596
     */
3597
    protected function geraInformacoesDasNotasReferenciadas()
3598
    {
3599
        $formaNfeRef = "\r\nNFe Ref.: série:%d número:%d emit:%s em %s [%s]";
3600
        $formaCTeRef = "\r\nCTe Ref.: série:%d número:%d emit:%s em %s [%s]";
3601
        $formaNfRef = "\r\nNF  Ref.: série:%d numero:%d emit:%s em %s modelo: %d";
3602
        $formaECFRef = "\r\nECF Ref.: modelo: %s ECF:%d COO:%d";
3603
        $formaNfpRef = "\r\nNFP Ref.: série:%d número:%d emit:%s em %s modelo: %d IE:%s";
3604
        $saida='';
3605
        $nfRefs = $this->ide->getElementsByTagName('NFref');
3606
        if (0 === $nfRefs->length) {
3607
            return $saida;
3608
        }
3609
        if ($nfRefs->length > 2) {
3610
            return 'Existem mais de 2 NF/NFe/ECF/NFP/CTe referenciadas, não serão exibidas na DANFE.';
3611
        }
3612
        foreach ($nfRefs as $nfRef) {
3613
            if (empty($nfRef)) {
3614
                continue;
3615
            }
3616
            $refNFe = $nfRef->getElementsByTagName('refNFe');
3617
            foreach ($refNFe as $chave_acessoRef) {
3618
                $chave_acesso = $chave_acessoRef->nodeValue;
3619
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3620
                $data = substr($chave_acesso, 4, 2)."/20".substr($chave_acesso, 2, 2);
3621
                $cnpj = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3622
                $serie  = substr($chave_acesso, 22, 3);
3623
                $numero = substr($chave_acesso, 25, 9);
3624
                $saida .= sprintf($formaNfeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3625
            }
3626
            $refNF = $nfRef->getElementsByTagName('refNF');
3627
            foreach ($refNF as $umaRefNFe) {
3628
                $data = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3629
                $cnpj = $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue;
3630
                $mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3631
                $serie = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3632
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3633
                $data = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3634
                $cnpj = $this->formatField($cnpj, "##.###.###/####-##");
3635
                $saida .= sprintf($formaNfRef, $serie, $numero, $cnpj, $data, $mod);
3636
            }
3637
            $refCTe = $nfRef->getElementsByTagName('refCTe');
3638
            foreach ($refCTe as $chave_acessoRef) {
3639
                $chave_acesso = $chave_acessoRef->nodeValue;
3640
                $chave_acessoF = $this->formatField($chave_acesso, $this->formatoChave);
3641
                $data = substr($chave_acesso, 4, 2)."/20".substr($chave_acesso, 2, 2);
3642
                $cnpj = $this->formatField(substr($chave_acesso, 6, 14), "##.###.###/####-##");
3643
                $serie  = substr($chave_acesso, 22, 3);
3644
                $numero = substr($chave_acesso, 25, 9);
3645
                $saida .= sprintf($formaCTeRef, $serie, $numero, $cnpj, $data, $chave_acessoF);
3646
            }
3647
            $refECF = $nfRef->getElementsByTagName('refECF');
3648
            foreach ($refECF as $umaRefNFe) {
3649
                $mod    = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3650
                $nECF   = $umaRefNFe->getElementsByTagName('nECF')->item(0)->nodeValue;
3651
                $nCOO   = $umaRefNFe->getElementsByTagName('nCOO')->item(0)->nodeValue;
3652
                $saida .= sprintf($formaECFRef, $mod, $nECF, $nCOO);
3653
            }
3654
            $refNFP = $nfRef->getElementsByTagName('refNFP');
3655
            foreach ($refNFP as $umaRefNFe) {
3656
                $data = $umaRefNFe->getElementsByTagName('AAMM')->item(0)->nodeValue;
3657
                $cnpj = ! empty($umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue) ?
3658
                    $umaRefNFe->getElementsByTagName('CNPJ')->item(0)->nodeValue :
3659
                    '';
3660
                $cpf = ! empty($umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue) ?
3661
                        $umaRefNFe->getElementsByTagName('CPF')->item(0)->nodeValue : '';
3662
                $mod = $umaRefNFe->getElementsByTagName('mod')->item(0)->nodeValue;
3663
                $serie = $umaRefNFe->getElementsByTagName('serie')->item(0)->nodeValue;
3664
                $numero = $umaRefNFe->getElementsByTagName('nNF')->item(0)->nodeValue;
3665
                $ie = $umaRefNFe->getElementsByTagName('IE')->item(0)->nodeValue;
3666
                $data = substr($data, 2, 2) . "/20" . substr($data, 0, 2);
3667
                if ($cnpj == '') {
3668
                    $cpf_cnpj = $this->formatField($cpf, "###.###.###-##");
3669
                } else {
3670
                    $cpf_cnpj = $this->formatField($cnpj, "##.###.###/####-##");
3671
                }
3672
                $saida .= sprintf($formaNfpRef, $serie, $numero, $cpf_cnpj, $data, $mod, $ie);
3673
            }
3674
        }
3675
        return $saida;
3676
    }
3677
    
3678
    private function loadDoc($xml)
3679
    {
3680
        $this->xml = $xml;
3681
        if (!empty($xml)) {
3682
            $this->dom = new Dom();
3683
            $this->dom->loadXML($this->xml);
3684
            if (empty($this->dom->getElementsByTagName("infNFe")->item(0))) {
3685
                throw new \Exception('Isso não é um NFe.');
3686
            }
3687
            $this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0);
3688
            $this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0);
3689
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
3690
            if ($this->getTagValue($this->ide, "mod") != '55') {
3691
                throw new \Exception("O xml deve ser NF-e modelo 55.");
3692
            }
3693
            $this->entrega = $this->dom->getElementsByTagName("entrega")->item(0);
3694
            $this->retirada = $this->dom->getElementsByTagName("retirada")->item(0);
3695
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
3696
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
3697
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
3698
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
3699
            $this->det = $this->dom->getElementsByTagName("det");
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->dom->getElementsByTagName('det') of type object<DOMNodeList> is incompatible with the declared type object<DOMNode> of property $det.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3700
            $this->cobr = $this->dom->getElementsByTagName("cobr")->item(0);
3701
            $this->dup = $this->dom->getElementsByTagName('dup');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->dom->getElementsByTagName('dup') of type object<DOMNodeList> is incompatible with the declared type object<DOMNode> of property $dup.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
3702
            $this->ICMSTot = $this->dom->getElementsByTagName("ICMSTot")->item(0);
3703
            $this->ISSQNtot = $this->dom->getElementsByTagName("ISSQNtot")->item(0);
3704
            $this->transp = $this->dom->getElementsByTagName("transp")->item(0);
3705
            $this->transporta = $this->dom->getElementsByTagName("transporta")->item(0);
3706
            $this->veicTransp = $this->dom->getElementsByTagName("veicTransp")->item(0);
3707
            $this->detPag = $this->dom->getElementsByTagName("detPag");
3708
            $this->reboque = $this->dom->getElementsByTagName("reboque")->item(0);
3709
            $this->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0);
3710
            $this->compra = $this->dom->getElementsByTagName("compra")->item(0);
3711
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
0 ignored issues
show
Documentation Bug introduced by
The property $tpEmis was declared of type integer, but $this->getTagValue($this->ide, 'tpEmis') is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
3712
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
0 ignored issues
show
Documentation Bug introduced by
The property $tpImp was declared of type integer, but $this->getTagValue($this->ide, 'tpImp') is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
3713
            $this->infProt = $this->dom->getElementsByTagName("infProt")->item(0);
3714
        }
3715
    }
3716
    
3717
    private function imagePNGtoJPG($original)
3718
    {
3719
        $image = imagecreatefrompng($original);
3720
        ob_start();
3721
        imagejpeg($image, null, 100);
3722
        imagedestroy($image);
3723
        $stringdata = ob_get_contents(); // read from buffer
3724
        ob_end_clean();
3725
        return 'data://text/plain;base64,'.base64_encode($stringdata);
3726
    }
3727
}
3728