Passed
Push — master ( 380f19...ba17a5 )
by Roberto
04:44 queued 45s
created

DacteV3::__construct()   F

Complexity

Conditions 12
Paths 252

Size

Total Lines 160
Code Lines 115

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 156

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 12
eloc 115
c 4
b 0
f 0
nc 252
nop 11
dl 0
loc 160
ccs 0
cts 124
cp 0
crap 156
rs 3.7956

How to fix   Long Method    Complexity    Many Parameters   

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:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Exception;
19
use NFePHP\DA\Legacy\Dom;
20
use NFePHP\DA\Legacy\Pdf;
21
use NFePHP\DA\Legacy\Common;
22
23
class DacteV3 extends Common
24
{
25
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
26
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
27
    const SIT_DPEC = 3;
28
29
    protected $logoAlign = 'C';
30
    protected $yDados = 0;
31
    protected $situacao_externa = 0;
32
    protected $numero_registro_dpec = '';
33
    protected $pdf;
34
    protected $xml;
35
    protected $logomarca = '';
36
    protected $errMsg = '';
37
    protected $errStatus = false;
38
    protected $orientacao = 'P';
39
    protected $papel = 'A4';
40
    protected $destino = 'I';
41
    protected $pdfDir = '';
42
    protected $fontePadrao = 'Times';
43
    protected $version = '1.3.0';
44
    protected $wPrint;
45
    protected $hPrint;
46
    protected $dom;
47
    protected $infCte;
48
    protected $infCteComp;
49
    protected $chaveCTeRef;
50
    protected $tpCTe;
51
    protected $ide;
52
    protected $emit;
53
    protected $enderEmit;
54
    protected $rem;
55
    protected $enderReme;
56
    protected $dest;
57
    protected $enderDest;
58
    protected $exped;
59
    protected $enderExped;
60
    protected $receb;
61
    protected $enderReceb;
62
    protected $infCarga;
63
    protected $infQ;
64
    protected $seg;
65
    protected $modal;
66
    protected $rodo;
67
    protected $moto;
68
    protected $veic;
69
    protected $ferrov;
70
    protected $Comp;
71
    protected $infNF;
72
    protected $infNFe;
73
    protected $compl;
74
    protected $ICMS;
75
    protected $ICMSSN;
76
    protected $ICMSOutraUF;
77
    protected $imp;
78
    protected $toma4;
79
    protected $toma03;
80
    protected $tpEmis;
81
    protected $tpImp;
82
    protected $tpAmb;
83
    protected $vPrest;
84
    protected $wAdic = 150;
85
    protected $textoAdic = '';
86
    protected $debugMode = 2;
87
    protected $formatPadrao;
88
    protected $formatNegrito;
89
    protected $aquav;
90
    protected $preVisualizar;
91
    protected $flagDocOrigContinuacao;
92
    protected $arrayNFe = array();
93
    protected $siteDesenvolvedor;
94
    protected $nomeDesenvolvedor;
95
    protected $totPag;
96
    protected $idDocAntEle = [];
97
98
    /**
99
     * __construct
100
     *
101
     * @param string $docXML Arquivo XML da CTe
102
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
103
     * @param string $sPapel Tamanho do papel (Ex. A4)
104
     * @param string $sPathLogo Caminho para o arquivo do logo
105
     * @param string $sDestino Estabelece a direção do envio do documento PDF
106
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
107
     * @param string $fonteDACTE Nome da fonte a ser utilizada
108
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
109
     * @param string $preVisualizar 0-Não 1-Sim
110
     */
111
    public function __construct(
112
        $docXML = '',
113
        $sOrientacao = '',
114
        $sPapel = '',
115
        $sPathLogo = '',
116
        $sDestino = 'I',
117
        $sDirPDF = '',
118
        $fonteDACTE = '',
119
        $mododebug = 2,
120
        $preVisualizar = false,
121
        $nomeDesenvolvedor = 'Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org',
122
        $siteDesenvolvedor = 'http://www.nfephp.org'
123
    ) {
124
    
125
        if (is_numeric($mododebug)) {
126
            $this->debugMode = $mododebug;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mododebug can also be of type double or string. However, the property $debugMode is declared as type integer. Maybe add an additional type check?

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

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

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

class Id
{
    public $id;

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

}

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

$account_id = false;

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

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
127
        }
128
        if ($mododebug == 1) {
129
            //ativar modo debug
130
            error_reporting(E_ALL);
131
            ini_set('display_errors', 'On');
132
        } elseif ($mododebug == 0) {
133
            //desativar modo debug
134
            error_reporting(0);
135
            ini_set('display_errors', 'Off');
136
        }
137
        $this->orientacao = $sOrientacao;
138
        $this->papel = $sPapel;
139
        $this->pdf = '';
140
        $this->xml = $docXML;
141
        $this->logomarca = $sPathLogo;
142
        $this->destino = $sDestino;
143
        $this->pdfDir = $sDirPDF;
144
        $this->preVisualizar = $preVisualizar;
145
        $this->siteDesenvolvedor = $siteDesenvolvedor;
146
        $this->nomeDesenvolvedor = $nomeDesenvolvedor;
147
        // verifica se foi passa a fonte a ser usada
148
        if (!empty($fonteDACTE)) {
149
            $this->fontePadrao = $fonteDACTE;
150
        }
151
        $this->formatPadrao = array(
152
            'font' => $this->fontePadrao,
153
            'size' => 6,
154
            'style' => '');
155
        $this->formatNegrito = array(
156
            'font' => $this->fontePadrao,
157
            'size' => 7,
158
            'style' => 'B');
159
        //se for passado o xml
160
        if (!empty($this->xml)) {
161
            $this->dom = new Dom();
162
            $this->dom->loadXML($this->xml);
163
            $this->cteProc = $this->dom->getElementsByTagName("cteProc")->item(0);
0 ignored issues
show
Bug introduced by
The property cteProc 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...
164
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
165
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
166
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
167
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
168
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
169
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
170
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
171
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
172
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
173
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
174
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
175
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
176
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
177
            $this->infQ = $this->dom->getElementsByTagName("infQ");
178
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
179
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
180
            $this->lota = $this->pSimpleGetValue($this->rodo, "lota");
0 ignored issues
show
Bug introduced by
The property lota 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...
181
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
182
            $this->veic = $this->dom->getElementsByTagName("veic");
183
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
184
            // adicionar outros modais
185
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
186
            $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chave");
187
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
188
            $this->Comp = $this->dom->getElementsByTagName("Comp");
189
            $this->infNF = $this->dom->getElementsByTagName("infNF");
190
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
191
            $this->infOutros = $this->dom->getElementsByTagName("infOutros");
0 ignored issues
show
Bug introduced by
The property infOutros 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...
192
            $this->compl = $this->dom->getElementsByTagName("compl");
193
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
194
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
195
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
196
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
197
198
            $vTrib = $this->pSimpleGetValue($this->imp, "vTotTrib");
199
            if (!is_numeric($vTrib)) {
200
                $vTrib = 0;
201
            }
202
            $textoAdic = number_format($vTrib, 2, ",", ".");
203
204
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
205
                    .$textoAdic;
206
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
207
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
208
            //Tag tomador é identificado por toma03 na versão 2.00
209
            if ($this->infCte->getAttribute("versao")=="2.00") {
210
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
211
            }
212
            //modal aquaviário
213
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
214
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
215
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
216
            switch ($tomador) {
217
                case '0':
218
                    $this->toma = $this->rem;
0 ignored issues
show
Bug introduced by
The property toma 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...
219
                    $this->enderToma = $this->enderReme;
0 ignored issues
show
Bug introduced by
The property enderToma 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...
220
                    break;
221
                case '1':
222
                    $this->toma = $this->exped;
223
                    $this->enderToma = $this->enderExped;
224
                    break;
225
                case '2':
226
                    $this->toma = $this->receb;
227
                    $this->enderToma = $this->enderReceb;
228
                    break;
229
                case '3':
230
                    $this->toma = $this->dest;
231
                    $this->enderToma = $this->enderDest;
232
                    break;
233
                default:
234
                    $this->toma = $this->toma4;
235
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
236
                    break;
237
            }
238
            /*$seguro = $this->pSimpleGetValue($this->seg, "respSeg");
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
239
            switch ($seguro) {
240
                case '0':
241
                    $this->respSeg = 'Remetente';
242
                    break;
243
                case '1':
244
                    $this->respSeg = 'Expedidor';
245
                    break;
246
                case '2':
247
                    $this->respSeg = 'Recebedor';
248
                    break;
249
                case '3':
250
                    $this->respSeg = 'Destinatário';
251
                    break;
252
                case '4':
253
                    $this->respSeg = 'Emitente';
254
                    break;
255
                case '5':
256
                    $this->respSeg = 'Tomador';
257
                    break;
258
                default:
259
                    $this->respSeg = '';
260
                    break;
261
            }*/
262
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
263
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
264
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
265
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
266
            $this->protCTe = $this->dom->getElementsByTagName("protCTe")->item(0);
0 ignored issues
show
Bug introduced by
The property protCTe 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...
267
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
268
            $this->modal = $this->pSimpleGetValue($this->ide, "modal");
269
        }
270
    }
271
272
    /**
273
     * monta
274
     * @param string $orientacao L ou P
275
     * @param string $papel A4
276
     * @param string $logoAlign C, L ou R
277
     * @param Pdf $classPDF
278
     * @return string montagem
279
     */
280
    public function monta(
281
        $orientacao = '',
282
        $papel = 'A4',
283
        $logoAlign = 'C',
284
        $classPDF = false
285
    ) {
286
    
287
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 284 can also be of type object<NFePHP\DA\Legacy\Pdf>; however, NFePHP\DA\CTe\DacteV3::montaDACTE() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
288
    }
289
290
    /**
291
     * printDocument
292
     * @param string $nome
293
     * @param string $destino
294
     * @param string $printer
295
     * @return
296
     */
297
    public function printDocument($nome = '', $destino = 'I', $printer = '')
298
    {
299
        return $this->printDACTE($nome, $destino, $printer);
300
    }
301
302
    /**
303
     * Dados brutos do PDF
304
     * @return string
305
     */
306
    public function render()
307
    {
308
        return $this->pdf->getPdf();
309
    }
310
311
312
    protected function zCteDPEC()
313
    {
314
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
315
    }
316
317
318
    /**
319
     * montaDACTE
320
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
321
     * durante sua construção.
322
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
323
     * pelo conteúdo da funçao e podem ser modificados.
324
     *
325
     * @param  string $orientacao (Opcional) Estabelece a orientação da
326
     *                impressão (ex. P-retrato), se nada for fornecido será
327
     *                usado o padrão da NFe
328
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
329
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
330
     */
331
    public function montaDACTE(
332
        $orientacao = '',
333
        $papel = 'A4',
334
        $logoAlign = 'C',
335
        $classPDF = false
336
    ) {
337
    
338
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
339
        if ($orientacao == '') {
340
            if ($this->tpImp == '1') {
341
                $orientacao = 'P';
342
            } else {
343
                $orientacao = 'P';
344
            }
345
        }
346
        $this->orientacao = $orientacao;
347
        $this->papel = $papel;
348
        $this->logoAlign = $logoAlign;
349
350
        //$this->situacao_externa = $situacao_externa;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
351
        //instancia a classe pdf
352
        if ($classPDF !== false) {
353
            $this->pdf = $classPDF;
354
        } else {
355
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
356
        }
357
        if ($this->orientacao == 'P') {
358
            // margens do PDF
359
            $margSup = 2;
360
            $margEsq = 2;
361
            $margDir = 2;
362
            // posição inicial do relatorio
363
            $xInic = 1;
364
            $yInic = 1;
365
            if ($papel == 'A4') {
366
                //A4 210x297mm
367
                $maxW = 210;
368
                $maxH = 297;
369
            }
370
        } else {
371
            // margens do PDF
372
            $margSup = 3;
373
            $margEsq = 3;
374
            $margDir = 3;
375
            // posição inicial do relatorio
376
            $xInic = 5;
377
            $yInic = 5;
378
            if ($papel == 'A4') {
379
                //A4 210x297mm
380
                $maxH = 210;
381
                $maxW = 297;
382
                $this->wCanhoto = 25;
0 ignored issues
show
Bug introduced by
The property wCanhoto 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...
383
            }
384
        }
385
        //total inicial de paginas
386
        $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...
387
        //largura imprimivel em mm
388
        $this->wPrint = $maxW - ($margEsq + $xInic);
0 ignored issues
show
Bug introduced by
The variable $maxW 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...
389
        //comprimento imprimivel em mm
390
        $this->hPrint = $maxH - ($margSup + $yInic);
0 ignored issues
show
Bug introduced by
The variable $maxH 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...
391
        // estabelece contagem de paginas
392
        $this->pdf->AliasNbPages();
393
        // fixa as margens
394
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
395
        $this->pdf->SetDrawColor(0, 0, 0);
396
        $this->pdf->SetFillColor(255, 255, 255);
397
        // inicia o documento
398
        $this->pdf->Open();
399
        // adiciona a primeira página
400
        $this->pdf->AddPage($this->orientacao, $this->papel);
401
        $this->pdf->SetLineWidth(0.1);
402
        $this->pdf->SetTextColor(0, 0, 0);
403
        //calculo do numero de páginas ???
404
        $totPag = 1;
405
        //montagem da primeira página
406
        $pag = 1;
407
        $x = $xInic;
408
        $y = $yInic;
409
        //coloca o cabeçalho
410
        //$r = $this->zCabecalho($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
411
        $y += 70;
412
        $r = $this->zRemetente($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
413
        $x = $this->wPrint * 0.5 + 2;
414
        $r = $this->zDestinatario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
415
        $y += 19;
416
        $x = $xInic;
417
        $r = $this->zExpedidor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
418
        $x = $this->wPrint * 0.5 + 2;
419
        $r = $this->zRecebedor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
420
        $y += 19;
421
        $x = $xInic;
422
        $r = $this->zTomador($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
423
        if ($this->tpCTe == '0') {
424
            //Normal
425
            $y += 10;
426
            $x = $xInic;
427
            $r = $this->zDescricaoCarga($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
428
            $y += 17;
429
            $x = $xInic;
430
            $r = $this->zCompValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
431
            $y += 25;
432
            $x = $xInic;
433
            $r = $this->zImpostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
434
            $y += 13;
435
            $x = $xInic;
436
            $r = $this->zDocOrig($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
437
            if ($this->modal == '1') {
438
                if ($this->lota == 1) {
439
                    //$y += 24.95;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
440
                    $y += 35;
441
                } else {
442
                    $y += 53;
443
                }
444
            } elseif ($this->modal == '3') {
445
                $y += 37.75;
446
            } else {
447
                $y += 24.95;
448
            }
449
            $x = $xInic;
450
            $r = $this->zObs($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
451
            $y = $y-6;
452
            switch ($this->modal) {
453
                case '1':
454
                    $y += 25.9;
455
                    $x = $xInic;
456
                    $r = $this->zModalRod($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
457
                    break;
458
                case '2':
459
                    $y += 17.9;
460
                    $x = $xInic;
461
                    // TODO fmertins 31/10/14: este método não existe...
462
                    $r = $this->zModalAereo($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalAereo() does not seem to exist on object<NFePHP\DA\CTe\DacteV3>.

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...
Unused Code introduced by
$r 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...
463
                    break;
464
                case '3':
465
                    $y += 17.9;
466
                    $x = $xInic;
467
                    $r = $this->zModalAquaviario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
468
                    break;
469
                case '4':
470
                    $y += 17.9;
471
                    $x = $xInic;
472
                    $r = $this->zModalFerr($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
473
                    break;
474
                case '5':
475
                    $y += 17.9;
476
                    $x = $xInic;
477
                    // TODO fmertins 31/10/14: este método não existe...
478
                    $r = $this->zModalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalDutoviario() does not seem to exist on object<NFePHP\DA\CTe\DacteV3>.

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...
Unused Code introduced by
$r 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...
479
                    break;
480
            }
481
            if ($this->modal == '1') {
482
                if ($this->lota == 1) {
483
                    $y += 37;
484
                } else {
485
                    $y += 8.9;
486
                }
487
            } elseif ($this->modal == '3') {
488
                $y += 24.15;
489
            } else {
490
                $y += 37;
491
            }
492
        } else {
493
            $r = $this->zCabecalho(1, 1, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
494
            //Complementado
495
            $y += 10;
496
            $x = $xInic;
497
            $r = $this->zDocCompl($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
498
            $y += 80;
499
            $x = $xInic;
500
            $r = $this->zCompValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
501
            $y += 25;
502
            $x = $xInic;
503
            $r = $this->zImpostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
504
            $y += 13;
505
            $x = $xInic;
506
            $r = $this->zObs($x, $y);
0 ignored issues
show
Unused Code introduced by
$r 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...
507
            $y += 15;
508
        }
509
        $x = $xInic;
510
        $r = $this->zDadosAdic($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
511
        
512
        //$y += 19;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
513
        $y += 11;
514
        $y = $this->zCanhoto($x, $y);
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...
515
        
516
        //coloca o rodapé da página
517
        if ($this->orientacao == 'P') {
518
            $this->zRodape(2, $this->hPrint - 2);
519
        } else {
520
            $this->zRodape($xInic, $this->hPrint + 2.3);
521
        }
522
        if ($this->flagDocOrigContinuacao == 1) {
523
            $this->zdocOrigContinuacao(1, 71);
524
        }
525
        //retorna o ID na CTe
526
        if ($classPDF !== false) {
527
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
528
            return $aR;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $aR; (array) is incompatible with the return type documented by NFePHP\DA\CTe\DacteV3::montaDACTE of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

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

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
529
        } else {
530
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
531
        }
532
    } //fim da função montaDACTE
533
534
    /**
535
     * printDACTE
536
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
537
     * O destino da impressão pode ser :
538
     * I-browser
539
     * D-browser com download
540
     * F-salva em um arquivo local com o nome informado
541
     * S-retorna o documento como uma string e o nome é ignorado.
542
     * Para enviar o pdf diretamente para uma impressora indique o
543
     * nome da impressora e o destino deve ser 'S'.
544
     *
545
     * @param  string $nome Path completo com o nome do arquivo pdf
546
     * @param  string $destino Direção do envio do PDF
547
     * @param  string $printer Identificação da impressora no sistema
548
     * @return string Caso o destino seja S o pdf é retornado como uma string
549
     * @todo Rotina de impressão direta do arquivo pdf criado
550
     */
551
    public function printDACTE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer is not used and could be removed.

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

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

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

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

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

could be turned into

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

This is much more concise to read.

Loading history...
555
            //aqui pode entrar a rotina de impressão direta
556
        }
557
        return $arq;
558
    } //fim função printDACTE
559
560
    /**
561
     * zCabecalho
562
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
563
     *
564
     * @param  number $x Posição horizontal inicial, canto esquerdo
565
     * @param  number $y Posição vertical inicial, canto superior
566
     * @param  number $pag Número da Página
567
     * @param  number $totPag Total de páginas
568
     * @return number Posição vertical final
569
     */
570
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
571
    {
572
        $oldX = $x;
573
        $oldY = $y;
574
        if ($this->orientacao == 'P') {
575
            $maxW = $this->wPrint;
576
        } else {
577
            if ($pag == 1) {
578
                // primeira página
579
                $maxW = $this->wPrint - $this->wCanhoto;
580
            } else {
581
                // páginas seguintes
582
                $maxW = $this->wPrint;
583
            }
584
        }
585
        //##################################################################
586
        //coluna esquerda identificação do emitente
587
        $w = round($maxW * 0.42);
588
        if ($this->orientacao == 'P') {
589
            $aFont = array(
0 ignored issues
show
Unused Code introduced by
$aFont 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...
590
                'font' => $this->fontePadrao,
591
                'size' => 6,
592
                'style' => '');
593
        } else {
594
            $aFont = $this->formatNegrito;
0 ignored issues
show
Unused Code introduced by
$aFont 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...
595
        }
596
        $w1 = $w;
0 ignored issues
show
Unused Code introduced by
$w1 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...
597
        $h = 35;
598
        $oldY += $h;
599
        //desenha a caixa
600
        $this->pTextBox($x, $y, $w + 2, $h + 1);
601
        // coloca o logo
602
        if (is_file($this->logomarca)) {
603
            $logoInfo = getimagesize($this->logomarca);
604
            //largura da imagem em mm
605
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
606
            //altura da imagem em mm
607
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
608
            if ($this->logoAlign == 'L') {
609
                $nImgW = round($w / 3, 0);
610
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
611
                $xImg = $x + 1;
612
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
613
                //estabelecer posições do texto
614
                $x1 = round($xImg + $nImgW + 1, 0);
615
                $y1 = round($h / 3 + $y, 0);
616
                $tw = round(2 * $w / 3, 0);
617
            } elseif ($this->logoAlign == 'C') {
618
                $nImgH = round($h / 3, 0);
619
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
620
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
621
                $yImg = $y + 3;
622
                $x1 = $x;
623
                $y1 = round($yImg + $nImgH + 1, 0);
624
                $tw = $w;
625
            } elseif ($this->logoAlign == 'R') {
626
                $nImgW = round($w / 3, 0);
627
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
628
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
629
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
630
                $x1 = $x;
631
                $y1 = round($h / 3 + $y, 0);
632
                $tw = round(2 * $w / 3, 0);
633
            }
634
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
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...
635
        } else {
636
            $x1 = $x;
637
            $y1 = round($h / 3 + $y, 0);
638
            $tw = $w;
639
        }
640
        //Nome emitente
641
        $aFont = array(
642
            'font' => $this->fontePadrao,
643
            'size' => 9,
644
            'style' => 'B');
645
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
646
        $this->pTextBox($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...
647
        //endereço
648
        $y1 = $y1 + 3;
649
        $aFont = array(
650
            'font' => $this->fontePadrao,
651
            'size' => 7,
652
            'style' => '');
653
        $fone = $this->pSimpleGetValue($this->enderEmit, "fone")!=""? $this->zFormatFone($this->enderEmit):'';
0 ignored issues
show
Documentation introduced by
$this->enderEmit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
654
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
655
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
656
        $cpl = $this->pSimpleGetValue($this->enderEmit, "xCpl");
0 ignored issues
show
Unused Code introduced by
$cpl is not used, you could remove the assignment.

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

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

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

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

Loading history...
657
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
658
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
659
        $CEP = $this->pFormat($CEP, "#####-###");
660
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
661
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
662
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
663
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
664
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
665
            . "\n  Fone/Fax: " . $fone;
666
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
667
        //CNPJ/CPF IE
668
        $cpfCnpj = $this->zFormatCNPJCPF($this->emit);
0 ignored issues
show
Documentation introduced by
$this->emit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
669
        $ie = $this->pSimpleGetValue($this->emit, "IE");
670
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
671
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
672
        //outra caixa
673
        $h1 = 17.5;
674
        $y1 = $y + $h + 1;
675
        $this->pTextBox($x, $y1, $w + 2, $h1);
676
        //TIPO DO CT-E
677
        $texto = 'TIPO DO CTE';
678
        $wa = 37;
679
        $aFont = array(
680
            'font' => $this->fontePadrao,
681
            'size' => 8,
682
            'style' => '');
683
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
684
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
685
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
686
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
687
        switch ($tpCTe) {
688
            case '0':
689
                $texto = 'Normal';
690
                break;
691
            case '1':
692
                $texto = 'Complemento de Valores';
693
                break;
694
            case '2':
695
                $texto = 'Anulação de Valores';
696
                break;
697
            case '3':
698
                $texto = 'Substituto';
699
                break;
700
            default:
701
                $texto = 'ERRO' . $tpCTe . $tpServ;
0 ignored issues
show
Bug introduced by
The variable $tpServ seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
702
        }
703
        $aFont = $this->formatNegrito;
704
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
705
        //TIPO DO SERVIÇO
706
        $texto = 'TIPO DO SERVIÇO';
707
        $wb = 36;
0 ignored issues
show
Unused Code introduced by
$wb 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...
708
        $aFont = array(
709
            'font' => $this->fontePadrao,
710
            'size' => 8,
711
            'style' => '');
712
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
713
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
714
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
715
        switch ($tpServ) {
716
            case '0':
717
                $texto = 'Normal';
718
                break;
719
            case '1':
720
                $texto = 'Subcontratação';
721
                break;
722
            case '2':
723
                $texto = 'Redespacho';
724
                break;
725
            case '3':
726
                $texto = 'Redespacho Intermediário';
727
                break;
728
            default:
729
                $texto = 'ERRO' . $tpServ;
730
        }
731
        $aFont = $this->formatNegrito;
732
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
733
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
734
        //TOMADOR DO SERVIÇO
735
        $texto = 'INDICADOR DO CT-E GLOBALIZADO';
736
        $wc = 37;
0 ignored issues
show
Unused Code introduced by
$wc 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...
737
        $y2 = $y1 + 8;
738
        $aFont = array(
739
            'font' => $this->fontePadrao,
740
            'size' => 6,
741
            'style' => '');
742
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
743
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
744
        $toma = $this->pSimpleGetValue($this->ide, "indGlobalizado");
745
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
746
        if ($toma==1) {
747
            $aFont = array(
748
            'font' => $this->fontePadrao,
749
            'size' => 11,
750
            'style' => '');
751
            $this->pTextBox($x-14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
752
        } else {
753
            $aFont = array(
754
            'font' => $this->fontePadrao,
755
            'size' => 11,
756
            'style' => '');
757
            $this->pTextBox($x+3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
758
        }
759
        $aFont = $this->formatNegrito;
760
        $this->pdf->Line($x+5, $x+48, $x+5, $x+52);
761
        $this->pdf->Line($x+10, $x+48, $x+10, $x+52);
762
        $this->pdf->Line($x+5, $x+48, $x+10, $x+48);
763
        $this->pdf->Line($x+5, $x+52, $x+10, $x+52);
764
        $this->pTextBox($x-9, $y2+1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
765
766
        $this->pdf->Line($x+23, $x+48, $x+23, $x+52);
767
        $this->pdf->Line($x+28, $x+48, $x+28, $x+52);
768
        $this->pdf->Line($x+23, $x+48, $x+28, $x+48);
769
        $this->pdf->Line($x+23, $x+52, $x+28, $x+52);
770
        $this->pTextBox($x+9.8, $y2+1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
771
772
        //FORMA DE PAGAMENTO
773
        $texto = 'NFORMAÇÕES DO CT-E GLOBALIZADO';
774
        $wd = 36;
0 ignored issues
show
Unused Code introduced by
$wd 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...
775
        $aFont = array(
776
            'font' => $this->fontePadrao,
777
            'size' => 8,
778
            'style' => '');
779
        $this->pTextBox($x+2 + $wa + 4.5, $y2-0.7, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
780
        $forma = $this->pSimpleGetValue($this->ide, "forPag");
0 ignored issues
show
Unused Code introduced by
$forma 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...
781
        //##################################################################
782
        //coluna direita
783
        $x += $w + 2;
784
        $w = round($maxW * 0.335);
785
        $w1 = $w;
786
        $h = 11;
787
        $this->pTextBox($x, $y, $w + 2, $h + 1);
788
        $texto = "DACTE";
789
        $aFont = array(
790
            'font' => $this->fontePadrao,
791
            'size' => 10,
792
            'style' => 'B');
793
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
794
        $aFont = array(
795
            'font' => $this->fontePadrao,
796
            'size' => 8,
797
            'style' => '');
798
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
799
        $h = 10;
800
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
801
        $x1 = $x + $w + 2;
802
        $w = round($maxW * 0.22, 0);
803
        $w2 = $w;
804
        $h = 11;
805
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
806
        $texto = "MODAL";
807
        $aFont = array(
808
            'font' => $this->fontePadrao,
809
            'size' => 8,
810
            'style' => '');
811
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
812
        switch ($this->modal) {
813
            case '1':
814
                $texto = 'Rodoviário';
815
                break;
816
            case '2':
817
                $texto = 'Aéreo';
818
                break;
819
            case '3':
820
                $texto = 'Aquaviário';
821
                break;
822
            case '4':
823
                $texto = 'Ferroviário';
824
                break;
825
            case '5':
826
                $texto = 'Dutoviário';
827
                break;
828
        }
829
        $aFont = array(
830
            'font' => $this->fontePadrao,
831
            'size' => 10,
832
            'style' => 'B');
833
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
834
        //outra caixa
835
        $y += 12;
836
        $h = 9;
837
        $w = $w1 + $w2 + 2;
838
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
839
        //modelo
840
        $wa = 12;
841
        $xa = $x;
842
        $texto = 'MODELO';
843
        $aFont = array(
844
            'font' => $this->fontePadrao,
845
            'size' => 8,
846
            'style' => '');
847
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
848
        $texto = $this->pSimpleGetValue($this->ide, "mod");
849
        $aFont = $this->formatNegrito;
850
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
851
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
852
        //serie
853
        $xa += $wa;
854
        $texto = 'SÉRIE';
855
        $aFont = array(
856
            'font' => $this->fontePadrao,
857
            'size' => 8,
858
            'style' => '');
859
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
860
        $texto = $this->pSimpleGetValue($this->ide, "serie");
861
        $aFont = $this->formatNegrito;
862
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
863
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
864
        //numero
865
        $xa += $wa;
866
        $wa = 20;
867
        $texto = 'NÚMERO';
868
        $aFont = array(
869
            'font' => $this->fontePadrao,
870
            'size' => 8,
871
            'style' => '');
872
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
873
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
874
        $aFont = $this->formatNegrito;
875
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
876
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
877
        //folha
878
        $xa += $wa;
879
        $wa = 12;
880
        $texto = 'FL';
881
        $aFont = array(
882
            'font' => $this->fontePadrao,
883
            'size' => 8,
884
            'style' => '');
885
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
886
        //$texto = '1/1';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
887
        $texto = $pag."/".$totPag;
888
        $aFont = $this->formatNegrito;
889
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
890
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
891
        //data  hora de emissão
892
        $xa += $wa;
893
        $wa = 30;
894
        $texto = 'DATA E HORA DE EMISSÃO';
895
        $aFont = array(
896
            'font' => $this->fontePadrao,
897
            'size' => 8,
898
            'style' => '');
899
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
900
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
901
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
902
        $aFont = $this->formatNegrito;
903
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
904
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
905
        //ISUF
906
        $xa += $wa;
907
        $wa = 32;
908
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
909
        $aFont = $this->formatPadrao;
910
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
911
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
912
        $aFont = array(
913
            'font' => $this->fontePadrao,
914
            'size' => 7,
915
            'style' => 'B');
916
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
917
        //outra caixa
918
        $y += $h + 1;
919
        $h = 23;
920
        $h1 = 14;
921
        $this->pTextBox($x, $y, $w + 0.5, $h1);
922
        //CODIGO DE BARRAS
923
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
924
        $bW = 85;
925
        $bH = 10;
926
        //codigo de barras
927
        $this->pdf->SetFillColor(0, 0, 0);
928
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
929
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
930
        $texto = 'CHAVE DE ACESSO';
931
        $aFont = $this->formatPadrao;
932
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
933
        $aFont = $this->formatNegrito;
934
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
935
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
936
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
937
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
938
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
939
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
940
            $texto = "";
941
            $this->pdf->SetFillColor(0, 0, 0);
942
            if ($this->tpEmis == 5) {
943
                $chaveContingencia = $this->zGeraChaveAdicCont();
944
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
945
            } else {
946
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
947
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
948
            }
949
            //codigo de barras
950
        }
951
        $aFont = array(
952
            'font' => $this->fontePadrao,
953
            'size' => 8,
954
            'style' => '');
955
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
956
        //outra caixa
957
        $y += $h + 1;
958
        $h = 8.5;
959
        $wa = $w;
960
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
961
        if ($this->zCteDPEC()) {
962
            $texto = 'NÚMERO DE REGISTRO DPEC';
963
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
964
            $texto = "DADOS DO CT-E";
965
        } else {
966
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
967
        }
968
        $aFont = $this->formatPadrao;
969
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
970
        if ($this->zCteDPEC()) {
971
            $texto = $this->numero_registro_dpec;
972
        } elseif ($this->tpEmis == 5) {
973
            $chaveContingencia = $this->zGeraChaveAdicCont();
974
            $aFont = array(
0 ignored issues
show
Unused Code introduced by
$aFont 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...
975
                'font' => $this->fontePadrao,
976
                'size' => 8,
977
                'style' => 'B');
978
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
979
            $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...
980
        } else {
981
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
982
            // empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue)
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
983
            if (!empty($this->protCTe)
984
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
985
            ) {
986
                $texto .= date(
987
                    'd/m/Y   H:i:s',
988
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
989
                );
990
            }
991
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
992
        }
993
        $aFont = $this->formatNegrito;
994
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
995
        //CFOP
996
        $x = $oldX;
997
        $h = 8.5;
998
        $w = round($maxW * 0.42);
999
        $y1 = $y + 7.5;
1000
        $this->pTextBox($x, $y1, $w + 2, $h);
1001
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
1002
        $aFont = array(
1003
            'font' => $this->fontePadrao,
1004
            'size' => 8,
1005
            'style' => '');
1006
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1007
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
1008
        $aFont = $this->formatNegrito;
1009
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1010
        //ORIGEM DA PRESTAÇÃO
1011
        $y += $h + 7.5;
1012
        $x = $oldX;
1013
        $h = 8;
1014
        $w = ($maxW * 0.5);
1015
        $this->pTextBox($x, $y, $w + 0.5, $h);
1016
        $texto = 'INÍCIO DA PRESTAÇÃO';
1017
        $aFont = array(
1018
            'font' => $this->fontePadrao,
1019
            'size' => 8,
1020
            'style' => '');
1021
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1022
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1023
        $aFont = $this->formatNegrito;
1024
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1025
        //DESTINO DA PRESTAÇÃO
1026
        $x = $oldX + $w + 1;
1027
        $h = 8;
1028
        $w = $w - 1.3;
1029
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1030
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1031
        $aFont = array(
1032
            'font' => $this->fontePadrao,
1033
            'size' => 8,
1034
            'style' => '');
1035
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1036
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1037
        $aFont = $this->formatNegrito;
1038
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1039
        //#########################################################################
1040
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1041
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1042
        //indicar cancelamento
1043
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1044
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1045
            //101 Cancelamento
1046
            $x = 10;
1047
            $y = $this->hPrint - 130;
1048
            $h = 25;
1049
            $w = $maxW - (2 * $x);
1050
            $this->pdf->SetTextColor(90, 90, 90);
1051
            $texto = "CTe CANCELADO";
1052
            $aFont = array(
1053
                'font' => $this->fontePadrao,
1054
                'size' => 48,
1055
                'style' => 'B');
1056
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1057
            $this->pdf->SetTextColor(0, 0, 0);
1058
        }
1059
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1060
        if ($cStat == '110' ||
1061
            $cStat == '301' ||
1062
            $cStat == '302' ||
1063
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1064
        ) {
1065
            //110 Denegada
1066
            $x = 10;
1067
            $y = $this->hPrint - 130;
1068
            $h = 25;
1069
            $w = $maxW - (2 * $x);
1070
            $this->pdf->SetTextColor(90, 90, 90);
1071
            $texto = "CTe USO DENEGADO";
1072
            $aFont = array(
1073
                'font' => $this->fontePadrao,
1074
                'size' => 48,
1075
                'style' => 'B');
1076
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1077
            $y += $h;
1078
            $h = 5;
1079
            $w = $maxW - (2 * $x);
1080
            $texto = "SEM VALOR FISCAL";
1081
            $aFont = array(
1082
                'font' => $this->fontePadrao,
1083
                'size' => 48,
1084
                'style' => 'B');
1085
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1086
            $this->pdf->SetTextColor(0, 0, 0);
1087
        }
1088
        //indicar sem valor
1089
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1090
            $x = 10;
1091
            if ($this->orientacao == 'P') {
1092
                $y = round($this->hPrint * 2 / 3, 0);
1093
            } else {
1094
                $y = round($this->hPrint / 2, 0);
1095
            }
1096
            $h = 5;
1097
            $w = $maxW - (2 * $x);
1098
            $this->pdf->SetTextColor(90, 90, 90);
1099
            $texto = "SEM VALOR FISCAL";
1100
            $aFont = array(
1101
                'font' => $this->fontePadrao,
1102
                'size' => 48,
1103
                'style' => 'B');
1104
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1105
            $aFont = array(
1106
                'font' => $this->fontePadrao,
1107
                'size' => 30,
1108
                'style' => 'B');
1109
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1110
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1111
            $this->pdf->SetTextColor(0, 0, 0);
1112
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1113
            $h = 5;
1114
            $w = $maxW - (2 * 10);
1115
            $x = 55;
1116
            $y = 240;
1117
            $this->pdf->SetTextColor(255, 100, 100);
1118
            $aFont = array(
1119
                'font' => $this->fontePadrao,
1120
                'size' => 40,
1121
                'style' => 'B');
1122
            $texto = "Pré-visualização";
1123
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1124
            $this->pdf->SetTextColor(255, 100, 100);
1125
            $aFont = array(
1126
                'font' => $this->fontePadrao,
1127
                'size' => 41,
1128
                'style' => 'B');
1129
            $texto = "Sem Validade Jurídica";
1130
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1131
            $this->pdf->SetTextColor(90, 90, 90);
1132
            $texto = "SEM VALOR FISCAL";
1133
            $aFont = array(
1134
                'font' => $this->fontePadrao,
1135
                'size' => 48,
1136
                'style' => 'B');
1137
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1138
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1139
        } else {
1140
            $x = 10;
1141
            if ($this->orientacao == 'P') {
1142
                $y = round($this->hPrint * 2 / 3, 0);
1143
            } else {
1144
                $y = round($this->hPrint / 2, 0);
1145
            } //fim orientacao
1146
            $h = 5;
1147
            $w = $maxW - (2 * $x);
1148
            $this->pdf->SetTextColor(90, 90, 90);
1149
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1150
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1151
                //Contingência
1152
                $texto = "DACTE Emitido em Contingência";
1153
                $aFont = array(
1154
                    'font' => $this->fontePadrao,
1155
                    'size' => 48,
1156
                    'style' => 'B');
1157
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1158
                $aFont = array(
1159
                    'font' => $this->fontePadrao,
1160
                    'size' => 30,
1161
                    'style' => 'B');
1162
                $texto = "devido à problemas técnicos";
1163
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1164
            } else {
1165
                if (!isset($this->protCTe)) {
1166
                    if (!$this->zCteDPEC()) {
1167
                        $texto = "SEM VALOR FISCAL";
1168
                        $aFont = array(
1169
                            'font' => $this->fontePadrao,
1170
                            'size' => 48,
1171
                            'style' => 'B');
1172
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1173
                    }
1174
                    $aFont = array(
1175
                        'font' => $this->fontePadrao,
1176
                        'size' => 30,
1177
                        'style' => 'B');
1178
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1179
                    if (!$this->zCteDPEC()) {
1180
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1181
                    } else {
1182
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1183
                    }
1184
                } //fim cteProc
1185
                if ($this->tpEmis == 4) {
1186
                    //DPEC
1187
                    $x = 10;
1188
                    $y = $this->hPrint - 130;
1189
                    $h = 25;
1190
                    $w = $maxW - (2 * $x);
1191
                    $this->pdf->SetTextColor(200, 200, 200); // 90,90,90 é muito escuro
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
1192
                    $texto = "DACTE impresso em contingência -\n"
1193
                        . "DPEC regularmente recebido pela Receita\n"
1194
                        . "Federal do Brasil";
1195
                    $aFont = array(
1196
                        'font' => $this->fontePadrao,
1197
                        'size' => 48,
1198
                        'style' => 'B');
1199
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1200
                    $this->pdf->SetTextColor(0, 0, 0);
1201
                }
1202
            } //fim tpEmis
1203
            $this->pdf->SetTextColor(0, 0, 0);
1204
        }
1205
        return $oldY;
1206
    } //fim zCabecalho
1207
1208
    /**
1209
     * rodapeDACTE
1210
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1211
     *
1212
     * @param number $xInic Posição horizontal canto esquerdo
0 ignored issues
show
Bug introduced by
There is no parameter named $xInic. 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...
1213
     * @param number $yFinal Posição vertical final para impressão
0 ignored issues
show
Bug introduced by
There is no parameter named $yFinal. 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...
1214
     */
1215
    protected function zRodape($x, $y)
1216
    {
1217
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1218
        $w = $this->wPrint - 4;
1219
        $aFont = array(
1220
            'font' => $this->fontePadrao,
1221
            'size' => 6,
1222
            'style' => '');
1223
        $this->pTextBox($x-1, $y+2, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1224
        $texto = $this->nomeDesenvolvedor . ' - '. $this->siteDesenvolvedor;
1225
        $aFont = array(
1226
            'font' => $this->fontePadrao,
1227
            'size' => 6,
1228
            'style' => '');
1229
        $this->pTextBox($x-50, $y+2, $w, 4, $texto, $aFont, 'T', 'R', 0, $this->siteDesenvolvedor);
1230
    } //fim zRodape
1231
1232
    /**
1233
     * zRemetente
1234
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1235
     *
1236
     * @param  number $x Posição horizontal canto esquerdo
1237
     * @param  number $y Posição vertical canto superior
1238
     * @return number Posição vertical final
1239
     */
1240
    protected function zRemetente($x = 0, $y = 0)
1241
    {
1242
        $oldX = $x;
1243
        $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...
1244
        if ($this->orientacao == 'P') {
1245
            $maxW = $this->wPrint;
1246
        } else {
1247
            $maxW = $this->wPrint - $this->wCanhoto;
1248
        }
1249
        $w = $maxW * 0.5 + 0.5;
1250
        $h = 19;
1251
        $x1 = $x + 16;
1252
        $texto = 'REMETENTE';
1253
        $aFont = $this->formatPadrao;
1254
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1255
        $aFont = $this->formatNegrito;
1256
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1257
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1258
        $y += 3;
1259
        $texto = 'ENDEREÇO';
1260
        $aFont = $this->formatPadrao;
1261
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1262
        $aFont = $this->formatNegrito;
1263
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1264
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1265
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1266
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1267
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1268
        $y += 3;
1269
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1270
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1271
        $y += 3;
1272
        $texto = 'MUNICÍPIO';
1273
        $aFont = $this->formatPadrao;
1274
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1275
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1276
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1277
        $aFont = $this->formatNegrito;
1278
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1279
        $x = $w - 18;
1280
        $texto = 'CEP';
1281
        $aFont = $this->formatPadrao;
1282
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1283
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1284
        $aFont = $this->formatNegrito;
1285
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1286
        $x = $oldX;
1287
        $y += 3;
1288
        $texto = 'CNPJ/CPF';
1289
        $aFont = $this->formatPadrao;
1290
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1291
        $cpfCnpj = $this->zFormatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1292
        $aFont = $this->formatNegrito;
1293
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1294
        $x = $w - 45;
1295
        $texto = 'INSCRIÇÃO ESTADUAL';
1296
        $aFont = $this->formatPadrao;
1297
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1298
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1299
        $aFont = $this->formatNegrito;
1300
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1301
        $x = $oldX;
1302
        $y += 3;
1303
        $texto = 'PAÍS';
1304
        $aFont = $this->formatPadrao;
1305
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1306
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1307
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1308
        $aFont = $this->formatNegrito;
1309
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1310
        $x = $w - 25;
1311
        $texto = 'FONE';
1312
        $aFont = $this->formatPadrao;
1313
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1314
        //$texto = $this->zFormatFone($this->rem);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
1315
        $texto = $this->pSimpleGetValue($this->rem, "fone")!=""? $this->zFormatFone($this->rem):'';
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1316
        $aFont = $this->formatNegrito;
1317
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1318
    } //fim da função remetenteDACTE
1319
1320
    /**
1321
     * zDestinatario
1322
     * Monta o campo com os dados do destinatário na DACTE.
1323
     *
1324
     * @param  number $x Posição horizontal canto esquerdo
1325
     * @param  number $y Posição vertical canto superior
1326
     * @return number Posição vertical final
1327
     */
1328
    protected function zDestinatario($x = 0, $y = 0)
1329
    {
1330
        $oldX = $x;
1331
        $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...
1332
        if ($this->orientacao == 'P') {
1333
            $maxW = $this->wPrint;
1334
        } else {
1335
            $maxW = $this->wPrint - $this->wCanhoto;
1336
        }
1337
        $w = ($maxW * 0.5) - 0.7;
1338
        $h = 19;
1339
        $x1 = $x + 19;
1340
        $texto = 'DESTINATÁRIO';
1341
        $aFont = $this->formatPadrao;
1342
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1343
        $aFont = $this->formatNegrito;
1344
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1345
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1346
        $y += 3;
1347
        $texto = 'ENDEREÇO';
1348
        $aFont = $this->formatPadrao;
1349
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1350
        $aFont = $this->formatNegrito;
1351
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1352
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1353
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1354
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1355
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1356
        $y += 3;
1357
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1358
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1359
        $y += 3;
1360
        $texto = 'MUNICÍPIO';
1361
        $aFont = $this->formatPadrao;
1362
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1363
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1364
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1365
        $aFont = $this->formatNegrito;
1366
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1367
        $x = $w - 19 + $oldX;
1368
        $texto = 'CEP';
1369
        $aFont = $this->formatPadrao;
1370
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1371
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1372
        $aFont = $this->formatNegrito;
1373
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1374
        $x = $oldX;
1375
        $y += 3;
1376
        $texto = 'CNPJ/CPF';
1377
        $aFont = $this->formatPadrao;
1378
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1379
        $cpfCnpj = $this->zFormatCNPJCPF($this->dest);
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1380
        $aFont = $this->formatNegrito;
1381
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1382
        $x = $w - 47.5 + $oldX;
1383
        $texto = 'INSCRIÇÃO ESTADUAL';
1384
        $aFont = $this->formatPadrao;
1385
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1386
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1387
        $aFont = $this->formatNegrito;
1388
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1389
        $x = $oldX;
1390
        $y += 3;
1391
        $texto = 'PAÍS';
1392
        $aFont = $this->formatPadrao;
1393
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1394
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1395
        $aFont = $this->formatNegrito;
1396
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1397
        $x = $w - 27 + $oldX;
1398
        $texto = 'FONE';
1399
        $aFont = $this->formatPadrao;
1400
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1401
        //$texto = $this->zFormatFone($this->dest);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
1402
        $texto = $this->pSimpleGetValue($this->dest, "fone")!=""? $this->zFormatFone($this->dest):'';
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1403
        $aFont = $this->formatNegrito;
1404
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1405
    } //fim da função destinatarioDACTE
1406
1407
    /**
1408
     * zExpedidor
1409
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1410
     *
1411
     * @param  number $x Posição horizontal canto esquerdo
1412
     * @param  number $y Posição vertical canto superior
1413
     * @return number Posição vertical final
1414
     */
1415
    protected function zExpedidor($x = 0, $y = 0)
1416
    {
1417
        $oldX = $x;
1418
        $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...
1419
        if ($this->orientacao == 'P') {
1420
            $maxW = $this->wPrint;
1421
        } else {
1422
            $maxW = $this->wPrint - $this->wCanhoto;
1423
        }
1424
        $w = $maxW * 0.5 + 0.5;
1425
        $h = 19;
1426
        $x1 = $x + 16;
1427
        $texto = 'EXPEDIDOR';
1428
        $aFont = $this->formatPadrao;
1429
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1430
        $aFont = $this->formatNegrito;
1431
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1432
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1433
        $y += 3;
1434
        $texto = 'ENDEREÇO';
1435
        $aFont = $this->formatPadrao;
1436
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1437
        $aFont = $this->formatNegrito;
1438
        if (isset($this->enderExped)) {
1439
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1440
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1441
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1442
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1443
                '';
1444
        } else {
1445
            $texto = '';
1446
        }
1447
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1448
        $y += 3;
1449
        $texto = $this->pSimpleGetValue($this->enderExped, "xBairro");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1450
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1451
        $y += 3;
1452
        $texto = 'MUNICÍPIO';
1453
        $aFont = $this->formatPadrao;
1454
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1455
        if (isset($this->enderExped)) {
1456
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1457
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1458
        } else {
1459
            $texto = '';
1460
        }
1461
        $aFont = $this->formatNegrito;
1462
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1463
        $x = $w - 18;
1464
        $texto = 'CEP';
1465
        $aFont = $this->formatPadrao;
1466
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1467
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderExped, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1468
        $aFont = $this->formatNegrito;
1469
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1470
        $x = $oldX;
1471
        $y += 3;
1472
        $texto = 'CNPJ/CPF';
1473
        $aFont = $this->formatPadrao;
1474
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1475
        $cpfCnpj = $this->zFormatCNPJCPF($this->exped);
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1476
        $aFont = $this->formatNegrito;
1477
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1478
        $x = $w - 45;
1479
        $texto = 'INSCRIÇÃO ESTADUAL';
1480
        $aFont = $this->formatPadrao;
1481
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1482
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1483
        $aFont = $this->formatNegrito;
1484
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1485
        $x = $oldX;
1486
        $y += 3;
1487
        $texto = 'PAÍS';
1488
        $aFont = $this->formatPadrao;
1489
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1490
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1491
        $aFont = $this->formatNegrito;
1492
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1493
        $x = $w - 25;
1494
        $texto = 'FONE';
1495
        $aFont = $this->formatPadrao;
1496
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1497
        if (isset($this->exped)) {
1498
            $texto = $this->pSimpleGetValue($this->exped, "fone")!=""? $this->zFormatFone($this->exped):'';
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1499
            $aFont = $this->formatNegrito;
1500
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1501
        }
1502
    } //fim da função remetenteDACTE
1503
1504
    /**
1505
     * zRecebedor
1506
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1507
     *
1508
     * @param  number $x Posição horizontal canto esquerdo
1509
     * @param  number $y Posição vertical canto superior
1510
     * @return number Posição vertical final
1511
     */
1512
    protected function zRecebedor($x = 0, $y = 0)
1513
    {
1514
        $oldX = $x;
1515
        $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...
1516
        if ($this->orientacao == 'P') {
1517
            $maxW = $this->wPrint;
1518
        } else {
1519
            $maxW = $this->wPrint - $this->wCanhoto;
1520
        }
1521
        $w = ($maxW * 0.5) - 0.7;
1522
        $h = 19;
1523
        $x1 = $x + 19;
1524
        $texto = 'RECEBEDOR';
1525
        $aFont = $this->formatPadrao;
1526
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1527
        $aFont = $this->formatNegrito;
1528
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1529
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1530
        $y += 3;
1531
        $texto = 'ENDEREÇO';
1532
        $aFont = $this->formatPadrao;
1533
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1534
        $aFont = $this->formatNegrito;
1535
        if (isset($this->enderReceb)) {
1536
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1537
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1538
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1539
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1540
                '';
1541
        } else {
1542
            $texto = '';
1543
        }
1544
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1545
        $y += 3;
1546
        $texto = $this->pSimpleGetValue($this->enderReceb, "xBairro");
0 ignored issues
show
Bug introduced by
It seems like $this->enderReceb can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1547
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1548
        $y += 3;
1549
        $texto = 'MUNICÍPIO';
1550
        $aFont = $this->formatPadrao;
1551
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1552
        if (isset($this->enderReceb)) {
1553
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1554
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1555
        } else {
1556
            $texto = '';
1557
        }
1558
        $aFont = $this->formatNegrito;
1559
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1560
        $x = $w - 19 + $oldX;
1561
        $texto = 'CEP';
1562
        $aFont = $this->formatPadrao;
1563
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1564
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReceb, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderReceb can be null; however, pSimpleGetValue() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1565
        $aFont = $this->formatNegrito;
1566
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1567
        $x = $oldX;
1568
        $y += 3;
1569
        $texto = 'CNPJ/CPF';
1570
        $aFont = $this->formatPadrao;
1571
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1572
        $texto = $this->zFormatCNPJCPF($this->receb);
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1573
        $aFont = $this->formatNegrito;
1574
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1575
        $x = $w - 47 + $oldX;
1576
        $texto = 'INSCRIÇÃO ESTADUAL';
1577
        $aFont = $this->formatPadrao;
1578
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1579
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1580
        $aFont = $this->formatNegrito;
1581
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1582
        $x = $oldX;
1583
        $y += 3;
1584
        $texto = 'PAÍS';
1585
        $aFont = $this->formatPadrao;
1586
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1587
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1588
        $aFont = $this->formatNegrito;
1589
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1590
        $x = $w - 27 + $oldX;
1591
        $texto = 'FONE';
1592
        $aFont = $this->formatPadrao;
1593
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1594
        if (isset($this->receb)) {
1595
            $texto = $this->pSimpleGetValue($this->receb, "fone")!=""? $this->zFormatFone($this->receb):'';
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1596
            $aFont = $this->formatNegrito;
1597
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1598
        }
1599
    } //fim da função recebedorDACTE
1600
1601
    /**
1602
     * zTomador
1603
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1604
     *
1605
     * @param  number $x Posição horizontal canto esquerdo
1606
     * @param  number $y Posição vertical canto superior
1607
     * @return number Posição vertical final
1608
     */
1609
    protected function zTomador($x = 0, $y = 0)
1610
    {
1611
        $oldX = $x;
1612
        $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...
1613
        if ($this->orientacao == 'P') {
1614
            $maxW = $this->wPrint;
1615
        } else {
1616
            $maxW = $this->wPrint - $this->wCanhoto;
1617
        }
1618
        $w = $maxW;
1619
        $h = 10;
1620
        $texto = 'TOMADOR DO SERVIÇO';
1621
        $aFont = $this->formatPadrao;
1622
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1623
        $aFont = $this->formatNegrito;
1624
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1625
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1626
        $x = $maxW * 0.60;
1627
        $texto = 'MUNICÍPIO';
1628
        $aFont = $this->formatPadrao;
1629
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1630
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1631
        $aFont = $this->formatNegrito;
1632
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1633
        $x = $maxW * 0.85;
1634
        $texto = 'UF';
1635
        $aFont = $this->formatPadrao;
1636
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1637
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1638
        $aFont = $this->formatNegrito;
1639
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1640
        $x = $w - 18;
1641
        $texto = 'CEP';
1642
        $aFont = $this->formatPadrao;
1643
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1644
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1645
        $aFont = $this->formatNegrito;
1646
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1647
        $y += 3;
1648
        $x = $oldX;
1649
        $texto = 'ENDEREÇO';
1650
        $aFont = $this->formatPadrao;
1651
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1652
        $aFont = $this->formatNegrito;
1653
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1654
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1655
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1656
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1657
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1658
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1659
        $y += 3;
1660
        $texto = 'CNPJ/CPF';
1661
        $aFont = $this->formatPadrao;
1662
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1663
        $texto = $this->zFormatCNPJCPF($this->toma);
1664
        $aFont = $this->formatNegrito;
1665
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1666
        $x = $x + 65;
1667
        $texto = 'INSCRIÇÃO ESTADUAL';
1668
        $aFont = $this->formatPadrao;
1669
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1670
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1671
        $aFont = $this->formatNegrito;
1672
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1673
        $x = $w * 0.75;
1674
        $texto = 'PAÍS';
1675
        $aFont = $this->formatPadrao;
1676
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1677
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1678
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1679
        $aFont = $this->formatNegrito;
1680
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1681
        $x = $w - 27;
1682
        $texto = 'FONE';
1683
        $aFont = $this->formatPadrao;
1684
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1685
        $texto = $this->pSimpleGetValue($this->toma, "fone")!=""? $this->zFormatFone($this->toma):'';
1686
        $aFont = $this->formatNegrito;
1687
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1688
    } //fim da função tomadorDACTE
1689
1690
    /**
1691
     * zDescricaoCarga
1692
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1693
     *
1694
     * @param  number $x Posição horizontal canto esquerdo
1695
     * @param  number $y Posição vertical canto superior
1696
     * @return number Posição vertical final
1697
     */
1698
    protected function zDescricaoCarga($x = 0, $y = 0)
1699
    {
1700
        $oldX = $x;
1701
        $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...
1702
        if ($this->orientacao == 'P') {
1703
            $maxW = $this->wPrint;
1704
        } else {
1705
            $maxW = $this->wPrint - $this->wCanhoto;
1706
        }
1707
        $w = $maxW;
1708
        $h = 17;
1709
        $texto = 'PRODUTO PREDOMINANTE';
1710
        $aFont = array(
1711
            'font' => $this->fontePadrao,
1712
            'size' => 6,
1713
            'style' => '');
1714
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1715
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1716
        $aFont = $this->formatNegrito;
1717
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1718
        $x = $w * 0.56;
1719
        $this->pdf->Line($x, $y, $x, $y + 8);
1720
        $aFont = $this->formatPadrao;
1721
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1722
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1723
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1724
        $aFont = $this->formatNegrito;
1725
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1726
        $x = $w * 0.8;
1727
        $this->pdf->Line($x, $y, $x, $y + 8);
1728
        $aFont = $this->formatPadrao;
1729
        $texto = 'VALOR TOTAL DA CARGA';
1730
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1731
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1732
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1733
        $texto = number_format($texto, 2, ",", ".");
1734
        $aFont = $this->formatNegrito;
1735
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1736
        $y += 8;
1737
        $x = $oldX;
1738
        $this->pdf->Line($x, $y, $w + 1, $y);
1739
        
1740
        //Identifica código da unidade
1741
        //01 = KG (QUILOS)
1742
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '01') {
1743
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1744
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == '01') {
1745
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1746
        } elseif ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == '01') {
1747
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1748
        }
1749
        $texto = 'PESO BRUTO (KG)';
1750
        $aFont = array(
1751
            'font' => $this->fontePadrao,
1752
            'size' => 5,
1753
            'style' => '');
1754
        $this->pTextBox($x+8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1755
        $texto = number_format($qCarga, 3, ",", ".");
0 ignored issues
show
Bug introduced by
The variable $qCarga 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...
1756
        $aFont = array(
1757
            'font' => $this->fontePadrao,
1758
            'size' => 7,
1759
            'style' => 'B');
1760
        $this->pTextBox($x+2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1761
        $x = $w * 0.12;
1762
        $this->pdf->Line($x+13.5, $y, $x+13.5, $y + 9);
1763
        
1764
        $texto = 'PESO BASE CÁLCULO (KG)';
1765
        $aFont = array(
1766
            'font' => $this->fontePadrao,
1767
            'size' => 5,
1768
            'style' => '');
1769
        $this->pTextBox($x+20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1770
        $texto = number_format($qCarga, 3, ",", ".");
1771
        $aFont = array(
1772
            'font' => $this->fontePadrao,
1773
            'size' => 7,
1774
            'style' => 'B');
1775
        $this->pTextBox($x+17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1776
        $x = $w * 0.24;
1777
        $this->pdf->Line($x+25, $y, $x+25, $y + 9);
1778
        
1779
        $texto = 'PESO AFERIDO (KG)';
1780
        $aFont = array(
1781
            'font' => $this->fontePadrao,
1782
            'size' => 5,
1783
            'style' => '');
1784
        $this->pTextBox($x+35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1785
        $texto = number_format($qCarga, 3, ",", ".");
1786
        $aFont = array(
1787
            'font' => $this->fontePadrao,
1788
            'size' => 7,
1789
            'style' => 'B');
1790
        $this->pTextBox($x+28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1791
        $x = $w * 0.36;
1792
        $this->pdf->Line($x+41.3, $y, $x+41.3, $y + 9);
1793
        $texto = 'CUBAGEM(M3)';
1794
        $aFont = $this->formatPadrao;
1795
        $this->pTextBox($x+60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1796
        $qCarga = '';
1797
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '00') {
1798
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1799
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == '00') {
1800
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1801
        } elseif ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == '00') {
1802
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1803
        }
1804
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1805
        $aFont = array(
1806
            'font' => $this->fontePadrao,
1807
            'size' => 7,
1808
            'style' => 'B');
1809
        $this->pTextBox($x+50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1810
        $x = $w * 0.45;
1811
        //$this->pdf->Line($x+37, $y, $x+37, $y + 9);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
1812
        $texto = 'QTDE(VOL)';
1813
        $aFont = $this->formatPadrao;
1814
        $this->pTextBox($x+85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1815
        $qCarga = '';
1816
        if ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == 03) {
1817
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1818
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == 03) {
1819
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1820
        }
1821
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1822
        $aFont = array(
1823
            'font' => $this->fontePadrao,
1824
            'size' => 7,
1825
            'style' => 'B');
1826
        $this->pTextBox($x+85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1827
        $x = $w * 0.53;
1828
        $this->pdf->Line($x+56, $y, $x+56, $y + 9);
1829
        /*$texto = 'NOME DA SEGURADORA';
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
1830
        $aFont = $this->formatPadrao;
1831
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1832
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1833
        $aFont = array(
1834
            'font' => $this->fontePadrao,
1835
            'size' => 7,
1836
            'style' => 'B');
1837
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1838
        $y += 3;
1839
        $this->pdf->Line($x, $y, $w + 1, $y);
1840
        $texto = 'RESPONSÁVEL';
1841
        $aFont = $this->formatPadrao;
1842
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1843
        $texto = $this->respSeg;
1844
        $aFont = array(
1845
            'font' => $this->fontePadrao,
1846
            'size' => 7,
1847
            'style' => 'B');
1848
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1849
        $x = $w * 0.68;
1850
        $this->pdf->Line($x, $y, $x, $y + 6);
1851
        $texto = 'NÚMERO DA APOLICE';
1852
        $aFont = $this->formatPadrao;
1853
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1854
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1855
        $aFont = array(
1856
            'font' => $this->fontePadrao,
1857
            'size' => 7,
1858
            'style' => 'B');
1859
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1860
        $x = $w * 0.85;
1861
        $this->pdf->Line($x, $y, $x, $y + 6);
1862
        $texto = 'NÚMERO DA AVERBAÇÃO';
1863
        $aFont = $this->formatPadrao;
1864
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1865
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
1866
        $aFont = array(
1867
            'font' => $this->fontePadrao,
1868
            'size' => 7,
1869
            'style' => 'B');
1870
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1871
    } //fim da função zDescricaoCarga
1872
1873
    /**
1874
     * zCompValorServ
1875
     * Monta o campo com os componentes da prestação de serviços.
1876
     *
1877
     * @param  number $x Posição horizontal canto esquerdo
1878
     * @param  number $y Posição vertical canto superior
1879
     * @return number Posição vertical final
1880
     */
1881
    protected function zCompValorServ($x = 0, $y = 0)
1882
    {
1883
        $oldX = $x;
1884
        $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...
1885
        if ($this->orientacao == 'P') {
1886
            $maxW = $this->wPrint;
1887
        } else {
1888
            $maxW = $this->wPrint - $this->wCanhoto;
1889
        }
1890
        $w = $maxW;
1891
        $h = 25;
1892
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1893
        $aFont = $this->formatPadrao;
1894
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1895
        $y += 3.4;
1896
        $this->pdf->Line($x, $y, $w + 1, $y);
1897
        $texto = 'NOME';
1898
        $aFont = $this->formatPadrao;
1899
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1900
        $yIniDados = $y;
1901
        $x = $w * 0.14;
1902
        $texto = 'VALOR';
1903
        $aFont = $this->formatPadrao;
1904
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1905
        $x = $w * 0.28;
1906
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1907
        $texto = 'NOME';
1908
        $aFont = $this->formatPadrao;
1909
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1910
        $x = $w * 0.42;
1911
        $texto = 'VALOR';
1912
        $aFont = $this->formatPadrao;
1913
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1914
        $x = $w * 0.56;
1915
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1916
        $texto = 'NOME';
1917
        $aFont = $this->formatPadrao;
1918
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1919
        $x = $w * 0.70;
1920
        $texto = 'VALOR';
1921
        $aFont = $this->formatPadrao;
1922
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1923
        $x = $w * 0.86;
1924
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1925
        $y += 1;
1926
        $texto = 'VALOR TOTAL DO SERVIÇO';
1927
        $aFont = $this->formatPadrao;
1928
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1929
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1930
        $aFont = array(
1931
            'font' => $this->fontePadrao,
1932
            'size' => 9,
1933
            'style' => 'B');
1934
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1935
        $y += 10;
1936
        $this->pdf->Line($x, $y, $w + 1, $y);
1937
        $y += 1;
1938
        $texto = 'VALOR A RECEBER';
1939
        $aFont = $this->formatPadrao;
1940
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1941
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1942
        $aFont = array(
1943
            'font' => $this->fontePadrao,
1944
            'size' => 9,
1945
            'style' => 'B');
1946
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1947
        $auxX = $oldX;
1948
        $yIniDados += 4;
1949
        foreach ($this->Comp as $k => $d) {
1950
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1951
            $valor = number_format(
1952
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1953
                2,
1954
                ",",
1955
                "."
1956
            );
1957
            if ($auxX > $w * 0.60) {
1958
                $yIniDados = $yIniDados + 4;
1959
                $auxX = $oldX;
1960
            }
1961
            $texto = $nome;
1962
            $aFont = $this->formatPadrao;
1963
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1964
            $auxX += $w * 0.14;
1965
            $texto = $valor;
1966
            $aFont = $this->formatPadrao;
1967
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1968
            $auxX += $w * 0.14;
1969
        }
1970
    } //fim da função compValorDACTE
1971
1972
    /**
1973
     * zImpostos
1974
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1975
     *
1976
     * @param  number $x Posição horizontal canto esquerdo
1977
     * @param  number $y Posição vertical canto superior
1978
     * @return number Posição vertical final
1979
     */
1980
    protected function zImpostos($x = 0, $y = 0)
1981
    {
1982
        $oldX = $x;
1983
        $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...
1984
        if ($this->orientacao == 'P') {
1985
            $maxW = $this->wPrint;
1986
        } else {
1987
            $maxW = $this->wPrint - $this->wCanhoto;
1988
        }
1989
        $w = $maxW;
1990
        $h = 13;
1991
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1992
        $aFont = $this->formatPadrao;
1993
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1994
        
1995
        $y += 3.4;
1996
        $this->pdf->Line($x, $y, $w + 1, $y);
1997
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1998
        $aFont = $this->formatPadrao;
1999
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2000
        
2001
        $x += $w * 0.26;
2002
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2003
        $texto = 'BASE DE CALCULO';
2004
        $aFont = $this->formatPadrao;
2005
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2006
        
2007
        $wCol02=0.18;
2008
        $x += $w * $wCol02;
2009
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2010
        $texto = 'ALÍQ ICMS';
2011
        $aFont = $this->formatPadrao;
2012
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2013
        
2014
        $x += $w * $wCol02;
2015
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2016
        $texto = 'VALOR ICMS';
2017
        $aFont = $this->formatPadrao;
2018
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2019
        
2020
        $x += $w * $wCol02;
2021
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2022
        $texto = '% RED. BC ICMS';
2023
        $aFont = $this->formatPadrao;
2024
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2025
        
2026
        /*$x += $w * 0.14;
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2027
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2028
        $texto = 'ICMS ST';
2029
        $aFont = $this->formatPadrao;
2030
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2031
         * */
2032
        
2033
        $x = $oldX;
2034
        $y = $y + 4;
2035
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2036
        switch ($texto) {
2037
            case '00':
2038
                $texto = "00 - Tributação normal ICMS";
2039
                break;
2040
            case '20':
2041
                $texto = "20 - Tributação com BC reduzida do ICMS";
2042
                break;
2043
            case '40':
2044
                $texto = "40 - ICMS isenção";
2045
                break;
2046
            case '41':
2047
                $texto = "41 - ICMS não tributada";
2048
                break;
2049
            case '51':
2050
                $texto = "51 - ICMS diferido";
2051
                break;
2052
            case '60':
2053
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2054
                break;
2055
            case '90':
2056
                if ($this->ICMSOutraUF) {
2057
                    $texto = "90 - ICMS Outra UF";
2058
                } elseif ($this->ICMSSN) {
2059
                    $texto = "90 - ICMS Simples Nacional";
2060
                } else {
2061
                    $texto = "90 - ICMS Outros";
2062
                }
2063
                break;
2064
        }
2065
        $aFont = $this->formatNegrito;
2066
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2067
        $x += $w * 0.26;
2068
        
2069
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2070
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : '';
2071
        $aFont = $this->formatNegrito;
2072
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2073
        $x += $w * $wCol02;
2074
        
2075
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2076
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
2077
        $aFont = $this->formatNegrito;
2078
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2079
        $x += $w * $wCol02;
2080
        
2081
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2082
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
2083
        $aFont = $this->formatNegrito;
2084
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2085
        $x += $w * $wCol02;
2086
        
2087
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2088
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
2089
        $aFont = $this->formatNegrito;
2090
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2091
        
2092
        /*$x += $w * 0.14;
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2093
        $texto = '';
2094
        $aFont = $this->formatNegrito;
2095
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2096
    } //fim da função compValorDACTE
2097
2098
    /**
2099
     * zGeraChaveAdicCont
2100
     *
2101
     * @return string chave
2102
     */
2103
    protected function zGeraChaveAdicCont()
2104
    {
2105
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2106
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2107
        $forma = "%02d%d%s%014d%01d%01d%02d";
2108
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2109
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2110
        $CNPJ = substr($CNPJ, -14);
2111
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2112
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2113
        switch ($ICMS_CST) {
2114
            case '00':
2115
            case '20':
2116
                $ICMSp = '1';
2117
                $ICMSs = '2';
2118
                break;
2119
            case '40':
2120
            case '41':
2121
            case '51':
2122
            case '90':
2123
                $ICMSp = '2';
2124
                $ICMSs = '2';
2125
                break;
2126
            case '60':
2127
                $ICMSp = '2';
2128
                $ICMSs = '1';
2129
                break;
2130
        }
2131
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2132
        $rpos = strrpos($dd, '-');
2133
        $dd = substr($dd, $rpos + 1);
2134
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vCT, $ICMSp, $ICMSs, $dd);
0 ignored issues
show
Bug introduced by
The variable $ICMSp 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 $ICMSs 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...
2135
        $chave = $chave . $this->pModulo11($chave);
2136
        return $chave;
2137
    } //fim zGeraChaveAdicCont
2138
2139
    /**
2140
     * zDocOrig
2141
     * Monta o campo com os documentos originarios.
2142
     *
2143
     * @param  number $x Posição horizontal canto esquerdo
2144
     * @param  number $y Posição vertical canto superior
2145
     * @return number Posição vertical final
2146
     */
2147
    protected function zDocOrig($x = 0, $y = 0)
2148
    {
2149
        $oldX = $x;
2150
        $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...
2151
        if ($this->orientacao == 'P') {
2152
            $maxW = $this->wPrint;
2153
        } else {
2154
            $maxW = $this->wPrint - $this->wCanhoto;
2155
        }
2156
        $w = $maxW;
2157
2158
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2159
        if ($this->modal == '1') {
2160
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2161
            // ou combinação veicular, e por viagem
2162
            $h = $this->lota == 1 ? 35 : 53;
2163
        } elseif ($this->modal == '3') {
2164
            $h = 37.6;
2165
        } else {
2166
            $h = 35;
2167
        }
2168
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2169
        $aFont = $this->formatPadrao;
2170
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2171
        $descr1 = 'TIPO DOC';
2172
        $descr2 = 'CNPJ/CHAVE/OBS';
2173
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2174
2175
        $y += 3.4;
2176
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2177
        $texto = $descr1;
2178
        $aFont = $this->formatPadrao;
2179
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2180
        $yIniDados = $y;
2181
2182
        $x += $w * 0.07;
2183
        $texto = $descr2;
2184
        $aFont = $this->formatPadrao;
2185
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2186
2187
        $x += $w * 0.28;
2188
        $texto = $descr3;
2189
        $aFont = $this->formatPadrao;
2190
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2191
2192
        $x += $w * 0.14;
2193
        if ($this->modal == '1') {
2194
            if ($this->lota == 1) {
2195
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2196
            } else {
2197
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2198
            }
2199
        } elseif ($this->modal == '3') {
2200
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2201
        } else {
2202
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2203
        }
2204
        $texto = $descr1;
2205
        $aFont = $this->formatPadrao;
2206
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2207
2208
        $x += $w * 0.08;
2209
        $texto = $descr2;
2210
        $aFont = $this->formatPadrao;
2211
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2212
2213
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2214
        $texto = $descr3;
2215
        $aFont = $this->formatPadrao;
2216
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2217
        $auxX = $oldX;
2218
        $yIniDados += 3;
2219
        foreach ($this->infNF as $k => $d) {
2220
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2221
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2222
            $cnpj = $this->zFormatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
2223
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2224
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2225
            if ($auxX > $w * 0.90) {
2226
                $yIniDados = $yIniDados + 3;
2227
                $auxX = $oldX;
2228
            }
2229
            $texto = $tp;
2230
            $aFont = array(
2231
                'font' => $this->fontePadrao,
2232
                'size' => 8,
2233
                'style' => '');
2234
            //$this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2235
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2236
            //$auxX += $w * 0.09;
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2237
            $auxX += $w * 0.07;
2238
            $texto = $cnpj;
2239
            $aFont = array(
2240
                'font' => $this->fontePadrao,
2241
                'size' => 8,
2242
                'style' => '');
2243
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2244
            $auxX += $w * 0.28;
2245
            $texto = $doc;
2246
            $aFont = array(
2247
                'font' => $this->fontePadrao,
2248
                'size' => 8,
2249
                'style' => '');
2250
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2251
            $auxX += $w * 0.15;
2252
        }
2253
2254
        foreach ($this->infNFe as $k => $d) {
2255
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2256
            $this->arrayNFe[] = $chaveNFe;
2257
        }
2258
        $qtdeNFe = 1;
2259
        if (count($this->arrayNFe) >15) {
2260
            $this->flagDocOrigContinuacao = 1;
2261
            $qtdeNFe = count($this->arrayNFe);
2262
        }
2263
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2264
        switch ($qtdeNFe) {
2265
            default:
2266
                $this->totPag = 1;
2267
            case ($qtdeNFe >= 1134):
2268
                $this->totPag = 11;
2269
                break;
2270
            case ($qtdeNFe > 1008):
2271
                $this->totPag = 10;
2272
                break;
2273
            case ($qtdeNFe > 882):
2274
                $this->totPag = 9;
2275
                break;
2276
            case ($qtdeNFe > 756):
2277
                $this->totPag = 8;
2278
                break;
2279
            case ($qtdeNFe > 630):
2280
                $this->totPag = 7;
2281
                break;
2282
            case ($qtdeNFe > 504):
2283
                $this->totPag = 6;
2284
                break;
2285
            case ($qtdeNFe > 378):
2286
                $this->totPag = 5;
2287
                break;
2288
            case ($qtdeNFe > 252):
2289
                $this->totPag = 4;
2290
                break;
2291
            case ($qtdeNFe > 126):
2292
                $this->totPag = 3;
2293
                break;
2294
            case ($qtdeNFe > 26):
2295
                $this->totPag = 2;
2296
                break;
2297
            case ($qtdeNFe <= 26):
2298
                $this->totPag = 1;
2299
                break;
2300
        }
2301
        $r = $this->zCabecalho(1, 1, '1', $this->totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
2302
        $contador = 0;
2303
        while ($contador < count($this->arrayNFe)) {
2304
            if ($contador == 26) {
2305
                break;
2306
            }
2307
            $tp = 'NF-e';
2308
            $chaveNFe = $this->arrayNFe[$contador];
2309
            $numNFe = substr($chaveNFe, 25, 9);
2310
            $serieNFe = substr($chaveNFe, 22, 3);
2311
            $doc = $serieNFe . '/' . $numNFe;
2312
            if ($auxX > $w * 0.90) {
2313
                $yIniDados = $yIniDados + 3.5;
2314
                $auxX = $oldX;
2315
            }
2316
            $texto = $tp;
2317
            $aFont = array(
2318
                'font' => $this->fontePadrao,
2319
                'size' => 7,
2320
                'style' => '');
2321
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2322
            $auxX += $w * 0.07;
2323
            $texto = $chaveNFe;
2324
            $aFont = array(
2325
                'font' => $this->fontePadrao,
2326
                'size' => 7,
2327
                'style' => '');
2328
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2329
            $auxX += $w * 0.28;
2330
            $texto = $doc;
2331
            $aFont = array(
2332
                'font' => $this->fontePadrao,
2333
                'size' => 7,
2334
                'style' => '');
2335
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2336
            $auxX += $w * 0.15;
2337
            $contador++;
2338
        }
2339
2340
        foreach ($this->infOutros as $k => $d) {
2341
            $temp = $this->infOutros->item($k);
2342
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2343
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2344
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2345
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2346
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2347
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2348
            switch ($tpDoc) {
2349
                case "00":
2350
                    $tpDoc = "00 - Declaração";
2351
                    break;
2352
                case "10":
2353
                    $tpDoc = "10 - Dutoviário";
2354
                    break;
2355
                case "99":
2356
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2357
                    break;
2358
                default:
2359
                    break;
2360
            }
2361
            $numeroDocumento = $nDoc;
0 ignored issues
show
Unused Code introduced by
$numeroDocumento 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...
2362
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2363
            if ($auxX > $w * 0.90) {
2364
                $yIniDados = $yIniDados + 4;
2365
                $auxX = $oldX;
2366
            }
2367
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2368
            $auxX += $w * 0.09;
2369
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2370
            $auxX += $w * 0.28;
2371
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2372
            $auxX += $w * 0.14;
2373
        }
2374
        foreach ($this->idDocAntEle as $k => $d) {
2375
            $tp = 'CT-e';
2376
            $chaveCTe = $this->idDocAntEle->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The method item cannot be called on $this->idDocAntEle (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
2377
            $numCTe = substr($chaveCTe, 25, 9);
2378
            $serieCTe = substr($chaveCTe, 22, 3);
2379
            $doc = $serieCTe . '/' . $numCTe;
2380
            if ($auxX > $w * 0.90) {
2381
                $yIniDados = $yIniDados + 4;
2382
                $auxX = $oldX;
2383
            }
2384
            $texto = $tp;
2385
            $aFont = array(
2386
                'font' => $this->fontePadrao,
2387
                'size' => 8,
2388
                'style' => '');
2389
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2390
            $auxX += $w * 0.09;
2391
            $texto = $chaveCTe;
2392
            $aFont = array(
2393
                'font' => $this->fontePadrao,
2394
                'size' => 8,
2395
                'style' => '');
2396
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2397
            $auxX += $w * 0.28;
2398
            $texto = $doc;
2399
            $aFont = array(
2400
                'font' => $this->fontePadrao,
2401
                'size' => 8,
2402
                'style' => '');
2403
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2404
            $auxX += $w * 0.14;
2405
        }
2406
    } //fim da função zDocOrig
2407
2408
    /**
2409
     * zDocOrigContinuacao
2410
     * Monta o campo com os documentos originarios.
2411
     *
2412
     * @param  number $x Posição horizontal canto esquerdo
2413
     * @param  number $y Posição vertical canto superior
2414
     * @return number Posição vertical final
2415
     */
2416
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2417
    {
2418
        $x2 = $x;
2419
        $y2 = $y;
2420
        $contador = 26;
2421
        for ($i = 2; $i <= $this->totPag; $i++) {
2422
            $x = $x2;
2423
            $y = $y2;
2424
            $this->pdf->AddPage($this->orientacao, $this->papel);
2425
            $r = $this->zCabecalho(1, 1, $i, $this->totPag);
0 ignored issues
show
Unused Code introduced by
$r 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...
2426
            $oldX = $x;
2427
            $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...
2428
            if ($this->orientacao == 'P') {
2429
                $maxW = $this->wPrint;
2430
            } else {
2431
                $maxW = $this->wPrint - $this->wCanhoto;
2432
            }
2433
            $w = $maxW;
2434
2435
            //$h = 6; // de sub-titulo
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2436
            //$h = 6 + 3; // de altura do texto (primeira linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2437
            //$h = 9 + 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2438
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2439
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2440
            if (count($this->arrayNFe)%2 !=0) {
2441
                $h = $h+3.5;
2442
            } // Caso tenha apenas 1 registro na ultima linha
2443
2444
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2445
            $aFont = $this->formatPadrao;
2446
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2447
            $descr1 = 'TIPO DOC';
2448
            $descr2 = 'CNPJ/CHAVE/OBS';
2449
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2450
2451
            $y += 3.4;
2452
            $this->pdf->Line($x, $y, $w + 1, $y);
2453
            $texto = $descr1;
2454
            $aFont = $this->formatPadrao;
2455
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2456
            $yIniDados = $y;
2457
2458
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2459
            $texto = $descr2;
2460
            $aFont = $this->formatPadrao;
2461
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2462
2463
            $x += $w * 0.28;
2464
            $texto = $descr3;
2465
            $aFont = $this->formatPadrao;
2466
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2467
2468
            $x += $w * 0.14;
2469
            if ($this->modal == '1') {
2470
                if ($this->lota == 1) {
2471
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2472
                } else {
2473
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2474
                }
2475
            } elseif ($this->modal == '3') {
2476
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2477
            } else {
2478
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2479
            }
2480
            $texto = $descr1;
2481
            $aFont = $this->formatPadrao;
2482
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2483
2484
            $x += $w * 0.08;
2485
            $texto = $descr2;
2486
            $aFont = $this->formatPadrao;
2487
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2488
2489
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2490
            $texto = $descr3;
2491
            $aFont = $this->formatPadrao;
2492
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2493
            $auxX = $oldX;
2494
            $yIniDados += 3;
2495
2496
            while ($contador < (count($this->arrayNFe))) {
2497
                if ($contador%(116*($i-1)) == 0) {
2498
//                    $contador++;
2499
                    break;
2500
                }
2501
                $tp = 'NF-e';
2502
                $chaveNFe = $this->arrayNFe[$contador];
2503
                $numNFe = substr($chaveNFe, 25, 9);
2504
                $serieNFe = substr($chaveNFe, 22, 3);
2505
                $doc = $serieNFe . '/' . $numNFe;
2506
                if ($auxX > $w * 0.90) {
2507
                    $yIniDados = $yIniDados + 3.5;
2508
                    $auxX = $oldX;
2509
                }
2510
                $texto = $tp;
2511
                $aFont = array(
2512
                    'font' => $this->fontePadrao,
2513
                    'size' => 7,
2514
                    'style' => '');
2515
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2516
                $auxX += $w * 0.07;
2517
                $texto = $chaveNFe;
2518
                $aFont = array(
2519
                    'font' => $this->fontePadrao,
2520
                    'size' => 7,
2521
                    'style' => '');
2522
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2523
                $auxX += $w * 0.28;
2524
                $texto = $doc;
2525
                $aFont = array(
2526
                    'font' => $this->fontePadrao,
2527
                    'size' => 7,
2528
                    'style' => '');
2529
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2530
                $auxX += $w * 0.15;
2531
                $contador++;
2532
            }
2533
        }
2534
    } //fim da função zDocOrigContinuacao
2535
2536
    /**
2537
     * zDocCompl
2538
     * Monta o campo com os dados do remetente na DACTE.
2539
     *
2540
     * @param number $x Posição horizontal canto esquerdo
2541
     * @param number $y Posição vertical canto superior
2542
     * @return number Posição vertical final
2543
     */
2544
    protected function zDocCompl($x = 0, $y = 0)
2545
    {
2546
        $oldX = $x;
2547
        $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...
2548
        if ($this->orientacao == 'P') {
2549
            $maxW = $this->wPrint;
2550
        } else {
2551
            $maxW = $this->wPrint - $this->wCanhoto;
2552
        }
2553
        $w = $maxW;
2554
        $h = 80;
2555
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2556
        $aFont = $this->formatPadrao;
2557
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2558
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2559
        $descr2 = 'VALOR COMPLEMENTADO';
2560
        $y += 3.4;
2561
        $this->pdf->Line($x, $y, $w + 1, $y);
2562
        $texto = $descr1;
2563
        $aFont = $this->formatPadrao;
2564
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2565
        $yIniDados = $y;
2566
        $x += $w * 0.37;
2567
        $texto = $descr2;
2568
        $aFont = $this->formatPadrao;
2569
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2570
        $x += $w * 0.13;
2571
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2572
        $texto = $descr1;
2573
        $aFont = $this->formatPadrao;
2574
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2575
        $x += $w * 0.3;
2576
        $texto = $descr2;
2577
        $aFont = $this->formatPadrao;
2578
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2579
        $auxX = $oldX;
2580
        $yIniDados += 4;
2581
        if ($auxX > $w * 0.90) {
2582
            $yIniDados = $yIniDados + 4;
2583
            $auxX = $oldX;
2584
        }
2585
        $texto = $this->chaveCTeRef;
2586
        $aFont = array(
2587
            'font' => $this->fontePadrao,
2588
            'size' => 8,
2589
            'style' => '');
2590
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2591
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2592
        $aFont = array(
2593
            'font' => $this->fontePadrao,
2594
            'size' => 8,
2595
            'style' => '');
2596
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2597
    } //fim da função zDocCompl
2598
2599
    /**
2600
     * zObs
2601
     * Monta o campo com os dados do remetente na DACTE.
2602
     *
2603
     * @param  number $x Posição horizontal canto esquerdo
2604
     * @param  number $y Posição vertical canto superior
2605
     * @return number Posição vertical final
2606
     */
2607
    protected function zObs($x = 0, $y = 0)
2608
    {
2609
        $oldX = $x;
2610
        $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...
2611
        if ($this->orientacao == 'P') {
2612
            $maxW = $this->wPrint;
2613
        } else {
2614
            $maxW = $this->wPrint - $this->wCanhoto;
2615
        }
2616
        $w = $maxW;
2617
        //$h = 18;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
2618
        $h = 18.8;
2619
        $texto = 'OBSERVAÇÕES';
2620
        $aFont = $this->formatPadrao;
2621
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2622
        $y += 3.4;
2623
        $this->pdf->Line($x, $y, $w + 1, $y);
2624
        $auxX = $oldX;
0 ignored issues
show
Unused Code introduced by
$auxX 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...
2625
        $yIniDados = $y;
0 ignored issues
show
Unused Code introduced by
$yIniDados 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...
2626
        $texto = '';
2627
        foreach ($this->compl as $k => $d) {
2628
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2629
            $texto .= $xObs;
2630
        }
2631
        $textoObs = explode("Motorista:", $texto);
2632
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2633
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2634
        $aFont = array(
2635
            'font' => $this->fontePadrao,
2636
            'size' => 7.5,
2637
            'style' => '');
2638
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2639
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2640
    } //fim da função obsDACTE
2641
2642
    /**
2643
     * zModalRod
2644
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2645
     *
2646
     * @param  number $x Posição horizontal canto esquerdo
2647
     * @param  number $y Posição vertical canto superior
2648
     * @return number Posição vertical final
2649
     */
2650
    protected function zModalRod($x = 0, $y = 0)
2651
    {
2652
        $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...
2653
        $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...
2654
        $lotacao = '';
0 ignored issues
show
Unused Code introduced by
$lotacao 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...
2655
        if ($this->orientacao == 'P') {
2656
            $maxW = $this->wPrint;
2657
        } else {
2658
            $maxW = $this->wPrint - $this->wCanhoto;
2659
        }
2660
        $w = $maxW;
2661
        $h = 18.5;
2662
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2663
        $aFont = $this->formatPadrao;
2664
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2665
        if ($this->lota == 1) {
2666
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2667
        }
2668
        $y += 3.4;
2669
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2670
        $texto = 'RNTRC DA EMPRESA';
2671
        $aFont = $this->formatPadrao;
2672
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2673
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2674
        $aFont = $this->formatNegrito;
2675
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2676
        $x += $w * 0.23;
2677
        
2678
        $this->pdf->Line($x-20, $y, $x-20, $y + 8.5); // LINHA A FRENTE DA RNTRC DA EMPRESA
2679
        
2680
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2681
        $aFont = $this->formatPadrao;
2682
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2683
    } //fim da função zModalRod
2684
2685
    /**
2686
     * zModalAquaviario
2687
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2688
     *
2689
     * @param  number $x Posição horizontal canto esquerdo
2690
     * @param  number $y Posição vertical canto superior
2691
     * @return number Posição vertical final
2692
     */
2693
    protected function zModalAquaviario($x = 0, $y = 0)
2694
    {
2695
        $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...
2696
        $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...
2697
        if ($this->orientacao == 'P') {
2698
            $maxW = $this->wPrint;
2699
        } else {
2700
            $maxW = $this->wPrint - $this->wCanhoto;
2701
        }
2702
        $w = $maxW;
2703
        $h = 8.5;
2704
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2705
        $aFont = $this->formatPadrao;
2706
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2707
        $y += 3.4;
2708
        $this->pdf->Line($x, $y, $w + 1, $y);
2709
        $texto = 'PORTO DE EMBARQUE';
2710
        $aFont = $this->formatPadrao;
2711
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2712
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2713
        $aFont = $this->formatNegrito;
2714
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2715
        $x += $w * 0.50;
2716
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2717
        $texto = 'PORTO DE DESTINO';
2718
        $aFont = $this->formatPadrao;
2719
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2720
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2721
        $aFont = $this->formatNegrito;
2722
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2723
        $y += 8;
2724
        $this->pdf->Line(208, $y, 1, $y);
2725
        $x = 1;
2726
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2727
        $aFont = $this->formatPadrao;
2728
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2729
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2730
        $aFont = $this->formatNegrito;
2731
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2732
        $x += $w * 0.50;
2733
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2734
        $texto = 'VR DA B. DE CALC. AFRMM';
2735
        $aFont = $this->formatPadrao;
2736
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2737
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2738
        $aFont = $this->formatNegrito;
2739
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2740
        $x += $w * 0.17;
2741
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2742
        $texto = 'VALOR DO AFRMM';
2743
        $aFont = $this->formatPadrao;
2744
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2745
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2746
        $aFont = $this->formatNegrito;
2747
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2748
        $x += $w * 0.12;
2749
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2750
        $texto = 'TIPO DE NAVEGAÇÃO';
2751
        $aFont = $this->formatPadrao;
2752
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2753
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2754
        switch ($texto) {
2755
            case '0':
2756
                $texto = 'INTERIOR';
2757
                break;
2758
            case '1':
2759
                $texto = 'CABOTAGEM';
2760
                break;
2761
        }
2762
        $aFont = $this->formatNegrito;
2763
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2764
        $x += $w * 0.14;
2765
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2766
        $texto = 'DIREÇÃO';
2767
        $aFont = $this->formatPadrao;
2768
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2769
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2770
        switch ($texto) {
2771
            case 'N':
2772
                $texto = 'NORTE';
2773
                break;
2774
            case 'L':
2775
                $texto = 'LESTE';
2776
                break;
2777
            case 'S':
2778
                $texto = 'SUL';
2779
                break;
2780
            case 'O':
2781
                $texto = 'OESTE';
2782
                break;
2783
        }
2784
        $aFont = $this->formatNegrito;
2785
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2786
        $y += 8;
2787
        $this->pdf->Line(208, $y, 1, $y);
2788
        $x = 1;
2789
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2790
        $aFont = $this->formatPadrao;
2791
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2792
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2793
            $texto = $this->infNF
2794
                ->item(0)
2795
                ->getElementsByTagName('infUnidCarga')
2796
                ->item(0)
2797
                ->getElementsByTagName('idUnidCarga')
2798
                ->item(0)->nodeValue;
2799
        } elseif ($this->infNFe->item(0) !== null
2800
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2801
        ) {
2802
            $texto = $this->infNFe
2803
                ->item(0)
2804
                ->getElementsByTagName('infUnidCarga')
2805
                ->item(0)
2806
                ->getElementsByTagName('idUnidCarga')
2807
                ->item(0)
2808
                ->nodeValue;
2809
        } elseif ($this->infOutros->item(0) !== null
2810
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2811
        ) {
2812
            $texto = $this->infOutros
2813
                ->item(0)
2814
                ->getElementsByTagName('infUnidCarga')
2815
                ->item(0)
2816
                ->getElementsByTagName('idUnidCarga')
2817
                ->item(0)
2818
                ->nodeValue;
2819
        } else {
2820
            $texto = '';
2821
        }
2822
        $aFont = $this->formatNegrito;
2823
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2824
        $x += $w * 0.50;
2825
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2826
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2827
        $aFont = $this->formatPadrao;
2828
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2829
        $texto = '';
2830
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2831
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2832
                if ($k == 0) {
2833
                    $texto = $this->aquav
2834
                        ->getElementsByTagName('balsa')
2835
                        ->item($k)
2836
                        ->getElementsByTagName('xBalsa')
2837
                        ->item(0)
2838
                        ->nodeValue;
2839
                } else {
2840
                    $texto = $texto
2841
                        . ' / '
2842
                        . $this->aquav
2843
                            ->getElementsByTagName('balsa')
2844
                            ->item($k)
2845
                            ->getElementsByTagName('xBalsa')
2846
                            ->item(0)
2847
                            ->nodeValue;
2848
                }
2849
            }
2850
        }
2851
        $aFont = $this->formatNegrito;
2852
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2853
    } //fim da função zModalRod
2854
2855
    /**
2856
     * zModalFerr
2857
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2858
     *
2859
     * @param  number $x Posição horizontal canto esquerdo
2860
     * @param  number $y Posição vertical canto superior
2861
     * @return number Posição vertical final
2862
     */
2863
    protected function zModalFerr($x = 0, $y = 0)
2864
    {
2865
        $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...
2866
        $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...
2867
        if ($this->orientacao == 'P') {
2868
            $maxW = $this->wPrint;
2869
        } else {
2870
            $maxW = $this->wPrint - $this->wCanhoto;
2871
        }
2872
        $w = $maxW;
2873
        $h = 19.6;
2874
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2875
        $aFont = $this->formatPadrao;
2876
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2877
        $y += 3.4;
2878
        $this->pdf->Line($x, $y, $w + 1, $y);
2879
        $texto = 'DCL';
2880
        $aFont = array(
2881
            'font' => $this->fontePadrao,
2882
            'size' => 7,
2883
            'style' => 'B');
2884
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2885
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2886
        $texto = 'VAGÕES';
2887
        $aFont = array(
2888
            'font' => $this->fontePadrao,
2889
            'size' => 7,
2890
            'style' => 'B');
2891
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2892
        $y += 3.4;
2893
        $this->pdf->Line($x, $y, $w + 1, $y);
2894
        // DCL
2895
        $texto = 'ID TREM';
2896
        $aFont = array(
2897
            'font' => $this->fontePadrao,
2898
            'size' => 6,
2899
            'style' => '');
2900
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2901
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
2902
        $aFont = array(
2903
            'font' => $this->fontePadrao,
2904
            'size' => 6,
2905
            'style' => 'B');
2906
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2907
        $x += $w * 0.06;
2908
        $y1 = $y + 12.5;
2909
        $this->pdf->Line($x, $y, $x, $y1);
2910
        $texto = 'NUM';
2911
        $aFont = array(
2912
            'font' => $this->fontePadrao,
2913
            'size' => 6,
2914
            'style' => '');
2915
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2916
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
2917
        $aFont = array(
2918
            'font' => $this->fontePadrao,
2919
            'size' => 6,
2920
            'style' => 'B');
2921
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2922
        $x += $w * 0.06;
2923
        $this->pdf->Line($x, $y, $x, $y1);
2924
        $texto = 'SÉRIE';
2925
        $aFont = array(
2926
            'font' => $this->fontePadrao,
2927
            'size' => 6,
2928
            'style' => '');
2929
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2930
        $texto = $this->pSimpleGetValue($this->rem, "serie");
2931
        $aFont = array(
2932
            'font' => $this->fontePadrao,
2933
            'size' => 6,
2934
            'style' => 'B');
2935
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2936
        $x += $w * 0.06;
2937
        $this->pdf->Line($x, $y, $x, $y1);
2938
        $texto = 'EMISSÃO';
2939
        $aFont = array(
2940
            'font' => $this->fontePadrao,
2941
            'size' => 6,
2942
            'style' => '');
2943
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2944
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
2945
        $aFont = array(
2946
            'font' => $this->fontePadrao,
2947
            'size' => 6,
2948
            'style' => 'B');
2949
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2950
        // VAGOES
2951
        $x += $w * 0.06;
2952
        $this->pdf->Line($x, $y, $x, $y1);
2953
        $texto = 'NUM';
2954
        $aFont = array(
2955
            'font' => $this->fontePadrao,
2956
            'size' => 6,
2957
            'style' => '');
2958
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2959
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
2960
        $aFont = array(
2961
            'font' => $this->fontePadrao,
2962
            'size' => 6,
2963
            'style' => 'B');
2964
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2965
        $x += $w * 0.06;
2966
        $this->pdf->Line($x, $y, $x, $y1);
2967
        $texto = 'TIPO';
2968
        $aFont = array(
2969
            'font' => $this->fontePadrao,
2970
            'size' => 6,
2971
            'style' => '');
2972
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2973
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
2974
        $aFont = array(
2975
            'font' => $this->fontePadrao,
2976
            'size' => 6,
2977
            'style' => 'B');
2978
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2979
        $x += $w * 0.06;
2980
        $this->pdf->Line($x, $y, $x, $y1);
2981
        $texto = 'CAPACIDADE';
2982
        $aFont = array(
2983
            'font' => $this->fontePadrao,
2984
            'size' => 6,
2985
            'style' => '');
2986
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2987
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
2988
        $aFont = array(
2989
            'font' => $this->fontePadrao,
2990
            'size' => 6,
2991
            'style' => 'B');
2992
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2993
        $x += $w * 0.08;
2994
        $this->pdf->Line($x, $y, $x, $y1);
2995
        $texto = 'PESO REAL/TON';
2996
        $aFont = array(
2997
            'font' => $this->fontePadrao,
2998
            'size' => 6,
2999
            'style' => '');
3000
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3001
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3002
        $aFont = array(
3003
            'font' => $this->fontePadrao,
3004
            'size' => 6,
3005
            'style' => 'B');
3006
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3007
        $x += $w * 0.09;
3008
        $this->pdf->Line($x, $y, $x, $y1);
3009
        $texto = 'PESO BRUTO/TON';
3010
        $aFont = array(
3011
            'font' => $this->fontePadrao,
3012
            'size' => 6,
3013
            'style' => '');
3014
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3015
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3016
        $aFont = array(
3017
            'font' => $this->fontePadrao,
3018
            'size' => 6,
3019
            'style' => 'B');
3020
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3021
        $x += $w * 0.1;
3022
        $this->pdf->Line($x, $y, $x, $y1);
3023
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3024
        $aFont = array(
3025
            'font' => $this->fontePadrao,
3026
            'size' => 6,
3027
            'style' => '');
3028
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3029
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3030
        $aFont = array(
3031
            'font' => $this->fontePadrao,
3032
            'size' => 6,
3033
            'style' => 'B');
3034
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3035
        // FLUXO
3036
        $x = 1;
3037
        $y += 12.9;
3038
        $h1 = $h * 0.5 + 0.27;
3039
        $wa = round($w * 0.103) + 0.5;
3040
        $texto = 'FLUXO FERROVIARIO';
3041
        $aFont = $this->formatPadrao;
3042
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3043
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3044
        $aFont = array(
3045
            'font' => $this->fontePadrao,
3046
            'size' => 7,
3047
            'style' => 'B');
3048
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3049
        $y += 10;
3050
        $texto = 'TIPO DE TRÁFEGO';
3051
        $aFont = $this->formatPadrao;
3052
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3053
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3054
        $aFont = array(
3055
            'font' => $this->fontePadrao,
3056
            'size' => 7,
3057
            'style' => 'B');
3058
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3059
        // Novo Box Relativo a Modal Ferroviário
3060
        $x = 22.5;
3061
        $y += -10.2;
3062
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3063
        $aFont = $this->formatPadrao;
3064
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3065
        $y += 3.4;
3066
        $this->pdf->Line($x, $y, $w + 1, $y);
3067
        $w = $w * 0.2;
3068
        $h = $h * 1.04;
3069
        $texto = 'CÓDIGO INTERNO';
3070
        $aFont = array(
3071
            'font' => $this->fontePadrao,
3072
            'size' => 6,
3073
            'style' => '');
3074
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3075
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3076
        $aFont = array(
3077
            'font' => $this->fontePadrao,
3078
            'size' => 6,
3079
            'style' => 'B');
3080
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3081
        $texto = 'CNPJ';
3082
        $aFont = array(
3083
            'font' => $this->fontePadrao,
3084
            'size' => 6,
3085
            'style' => '');
3086
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3087
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3088
        $aFont = array(
3089
            'font' => $this->fontePadrao,
3090
            'size' => 6,
3091
            'style' => 'B');
3092
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3093
        $x += 50;
3094
        $texto = 'NOME';
3095
        $aFont = array(
3096
            'font' => $this->fontePadrao,
3097
            'size' => 6,
3098
            'style' => '');
3099
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3100
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3101
        $aFont = array(
3102
            'font' => $this->fontePadrao,
3103
            'size' => 6,
3104
            'style' => 'B');
3105
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3106
        $texto = 'INSCRICAO ESTADUAL';
3107
        $aFont = array(
3108
            'font' => $this->fontePadrao,
3109
            'size' => 6,
3110
            'style' => '');
3111
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3112
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3113
        $aFont = array(
3114
            'font' => $this->fontePadrao,
3115
            'size' => 6,
3116
            'style' => 'B');
3117
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3118
        $x += 50;
3119
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3120
        $aFont = array(
3121
            'font' => $this->fontePadrao,
3122
            'size' => 6,
3123
            'style' => '');
3124
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3125
        $texto = '';
3126
        $aFont = array(
3127
            'font' => $this->fontePadrao,
3128
            'size' => 6,
3129
            'style' => 'B');
3130
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3131
    } //fim da função zModalFerr
3132
3133
    /**
3134
     * zCanhoto
3135
     * Monta o campo com os dados do remetente na DACTE.
3136
     *
3137
     * @param  number $x Posição horizontal canto esquerdo
3138
     * @param  number $y Posição vertical canto superior
3139
     * @return number Posição vertical final
3140
     */
3141
    protected function zCanhoto($x = 0, $y = 0)
3142
    {
3143
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3144
        $y = $y + 2;
3145
        $oldX = $x;
3146
        $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...
3147
        if ($this->orientacao == 'P') {
3148
            $maxW = $this->wPrint;
3149
        } else {
3150
            $maxW = $this->wPrint - $this->wCanhoto;
3151
        }
3152
        $w = $maxW - 1;
3153
        $h = 20;
3154
        $y = $y + 1;
3155
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3156
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3157
        $aFont = $this->formatPadrao;
3158
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3159
        $y += 3.4;
3160
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3161
        
3162
        $texto = 'NOME';
3163
        $aFont = array(
3164
            'font' => $this->fontePadrao,
3165
            'size' => 6,
3166
            'style' => '');
3167
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3168
        $x += $w * 0.25;
3169
        
3170
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3171
        
3172
        $texto = 'ASSINATURA / CARIMBO';
3173
        $aFont = array(
3174
            'font' => $this->fontePadrao,
3175
            'size' => 6,
3176
            'style' => '');
3177
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3178
        $x += $w * 0.25;
3179
        
3180
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3181
        
3182
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3183
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3184
        $aFont = array(
3185
            'font' => $this->fontePadrao,
3186
            'size' => 6,
3187
            'style' => '');
3188
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3189
        $x = $oldX;
3190
        $y = $y + 5;
3191
        
3192
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3193
        
3194
        $texto = 'RG';
3195
        $aFont = array(
3196
            'font' => $this->fontePadrao,
3197
            'size' => 6,
3198
            'style' => '');
3199
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3200
        $x += $w * 0.85;
3201
        
3202
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3203
        
3204
        $texto = "CT-E";
3205
        $aFont = $this->formatNegrito;
3206
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3207
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3208
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3209
        $aFont = array(
3210
            'font' => $this->fontePadrao,
3211
            'size' => 6,
3212
            'style' => '');
3213
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3214
        $x = $oldX;
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...
3215
        //$this->zhDashedLine($x, $y + 7.5, $this->wPrint, 0.1, 80);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
3216
    } //fim da função canhotoDACTE
3217
3218
    /**
3219
     * zDadosAdic
3220
     * Coloca o grupo de dados adicionais da DACTE.
3221
     *
3222
     * @param  number $x Posição horizontal canto esquerdo
3223
     * @param  number $y Posição vertical canto superior
3224
     * @param  number $h altura do campo
3225
     * @return number Posição vertical final
3226
     */
3227
    protected function zDadosAdic($x, $y, $pag, $h)
0 ignored issues
show
Unused Code introduced by
The parameter $pag is not used and could be removed.

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

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

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

Loading history...
3228
    {
3229
        $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...
3230
        //###########################################################################
3231
        //DADOS ADICIONAIS DACTE
3232
        if ($this->orientacao == 'P') {
3233
            $w = $this->wPrint;
0 ignored issues
show
Unused Code introduced by
$w 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...
3234
        } else {
3235
            $w = $this->wPrint - $this->wCanhoto;
0 ignored issues
show
Unused Code introduced by
$w 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...
3236
        }
3237
        //INFORMAÇÕES COMPLEMENTARES
3238
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3239
        $y += 3;
3240
        $w = $this->wAdic;
3241
        $h = 8; //mudar
3242
        $aFont = array(
3243
            'font' => $this->fontePadrao,
3244
            'size' => 6,
3245
            'style' => '');
3246
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3247
        //$this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
3248
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3249
        //o texto com os dados adicionais foi obtido na função xxxxxx
3250
        //e carregado em uma propriedade privada da classe
3251
        //$this->wAdic com a largura do campo
3252
        //$this->textoAdic com o texto completo do campo
3253
        $y += 1;
3254
        $aFont = $this->formatPadrao;
3255
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3256
        //RESERVADO AO FISCO
3257
        $texto = "RESERVADO AO FISCO";
3258
        $x += $w;
3259
        $y -= 1;
3260
        if ($this->orientacao == 'P') {
3261
            $w = $this->wPrint - $w;
3262
        } else {
3263
            $w = $this->wPrint - $w - $this->wCanhoto;
3264
        }
3265
        $aFont = array(
3266
            'font' => $this->fontePadrao,
3267
            'size' => 6,
3268
            'style' => '');
3269
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3270
        //inserir texto informando caso de contingência
3271
        //1 – Normal – emissão normal;
3272
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3273
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3274
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3275
        //Emissão em Contingência – DPEC;
3276
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3277
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3278
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3279
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3280
        $texto = '';
3281
        switch ($this->tpEmis) {
3282
            case 2:
3283
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3284
                break;
3285
            case 3:
3286
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3287
                break;
3288
            case 4:
3289
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3290
                break;
3291
            case 5:
3292
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3293
                break;
3294
        }
3295
        $y += 2;
3296
        $aFont = $this->formatPadrao;
3297
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3298
        return $y + $h;
3299
    } //fim zDadosAdic
3300
3301
    /**
3302
     * zhDashedLine
3303
     * Desenha uma linha horizontal tracejada com o FPDF
3304
     *
3305
     * @param  number $x Posição horizontal inicial, em mm
3306
     * @param  number $y Posição vertical inicial, em mm
3307
     * @param  number $w Comprimento da linha, em mm
3308
     * @param  number $h Espessura da linha, em mm
3309
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3310
     * @return none
3311
     */
3312
    protected function zhDashedLine($x, $y, $w, $h, $n)
3313
    {
3314
        $this->pdf->SetLineWidth($h);
3315
        $wDash = ($w / $n) / 2; // comprimento dos traços
3316
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3317
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3318
                if ($j <= ($x + $w - 1)) {
3319
                    $this->pdf->Line($j, $y, $j + 1, $y);
3320
                }
3321
            }
3322
        }
3323
    } //fim função hDashedLine
3324
3325
    /**
3326
     * zhDashedVerticalLine
3327
     * Desenha uma linha vertical tracejada com o FPDF
3328
     *
3329
     * @param  number $x Posição horizontal inicial, em mm
3330
     * @param  number $y Posição vertical inicial, em mm
3331
     * @param  number $w Comprimento da linha, em mm
3332
     * @param  number $yfinal Espessura da linha, em mm
3333
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3334
     * @return none
3335
     */
3336
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3337
    {
3338
        $this->pdf->SetLineWidth($w);
3339
        /* Organizando valores */
3340
        if ($y > $yfinal) {
3341
            $aux = $yfinal;
3342
            $yfinal = $y;
3343
            $y = $aux;
3344
        }
3345
        while ($y < $yfinal && $n > 0) {
3346
            $this->pdf->Line($x, $y, $x, $y + 1);
3347
            $y += 3;
3348
            $n--;
3349
        }
3350
    } //fim função hDashedVerticalLine
3351
3352
    /**
3353
     * zFormatCNPJCPF
3354
     * Formata campo CnpjCpf contida na CTe
3355
     *
3356
     * @param  string $field campo cnpjCpf da CT-e
3357
     * @return string
3358
     */
3359
    protected function zFormatCNPJCPF($field)
3360
    {
3361
        if (!isset($field)) {
3362
            return '';
3363
        }
3364
        $cnpj = !empty($field->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3365
            $field->getElementsByTagName("CNPJ")->item(0)->nodeValue : "";
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3366
        if ($cnpj != "" && $cnpj != "00000000000000") {
3367
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3368
        } else {
3369
            $cnpj = !empty($field->getElementsByTagName("CPF")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3370
                $this->pFormat($field->getElementsByTagName("CPF")->item(0)->nodeValue, '###.###.###.###-##') : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3371
        }
3372
        return $cnpj;
3373
    } //fim formatCNPJCPF
3374
3375
    /**
3376
     * zFormatFone
3377
     * Formata campo fone contida na CTe
3378
     *
3379
     * @param  string $field campo fone da CT-e
3380
     * @return string
3381
     */
3382
    protected function zFormatFone($field)
3383
    {
3384
        try {
3385
            $fone = !empty($field->getElementsByTagName("fone")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3386
            $field->getElementsByTagName("fone")->item(0)->nodeValue : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
3387
            $foneLen = strlen($fone);
3388
            if ($foneLen > 0) {
3389
                $fone2 = substr($fone, 0, $foneLen - 4);
3390
                $fone1 = substr($fone, 0, $foneLen - 8);
3391
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3392
            } else {
3393
                $fone = '';
3394
            }
3395
            return $fone;
3396
        } catch (Exception $exc) {
3397
            return '';
3398
        }
3399
    } //fim formatFone
3400
3401
    /**
3402
     * zUnidade
3403
     * Converte a imformação de peso contida na CTe
3404
     *
3405
     * @param  string $c unidade de trafego extraida da CTe
3406
     * @return string
3407
     */
3408
    protected function zUnidade($c = '')
3409
    {
3410
        switch ($c) {
3411
            case '00':
3412
                $r = 'M3';
3413
                break;
3414
            case '01':
3415
                $r = 'KG';
3416
                break;
3417
            case '02':
3418
                $r = 'TON';
3419
                break;
3420
            case '03':
3421
                $r = 'UN';
3422
                break;
3423
            case '04':
3424
                $r = 'LT';
3425
                break;
3426
            case '05':
3427
                $r = 'MMBTU';
3428
                break;
3429
            default:
3430
                $r = '';
3431
        }
3432
        return $r;
3433
    } //fim unidade
3434
3435
    /**
3436
     * zConvertUnidTrafego
3437
     * Converte a imformação de peso contida na CTe
3438
     *
3439
     * @param  string $U Informação de trafego extraida da CTe
3440
     * @return string
3441
     */
3442
    protected function zConvertUnidTrafego($U = '')
3443
    {
3444
        if ($U) {
3445
            switch ($U) {
3446
                case '0':
3447
                    $stringU = 'Próprio';
3448
                    break;
3449
                case '1':
3450
                    $stringU = 'Mútuo';
3451
                    break;
3452
                case '2':
3453
                    $stringU = 'Rodoferroviário';
3454
                    break;
3455
                case '3':
3456
                    $stringU = 'Rodoviário';
3457
                    break;
3458
            }
3459
            return $stringU;
0 ignored issues
show
Bug introduced by
The variable $stringU 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...
3460
        }
3461
    } //fim da função zConvertUnidTrafego
3462
3463
    /**
3464
     * zMultiUniPeso
3465
     * Fornece a imformação multiplicação de peso contida na CTe
3466
     *
3467
     * @param  interger $U Informação de peso extraida da CTe
3468
     * @return interger
3469
     */
3470
    protected function zMultiUniPeso($U = '')
3471
    {
3472
        if ($U === "01") {
3473
            // tonelada
3474
            //return 1000;
3475
            return 1;
3476
        }
3477
        return 1; // M3, KG, Unidade, litros, mmbtu
3478
    } //fim da função zMultiUniPeso
3479
}
3480