Completed
Push — master ( 5d3f07...54bb63 )
by Roberto
09:04 queued 05:35
created

DacteV3::zLocalEntrega()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
nc 2
nop 0
dl 0
loc 18
ccs 0
cts 18
cp 0
crap 6
rs 9.4285
c 1
b 0
f 0
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 $imp;
76
    protected $toma4;
77
    protected $toma03;
78
    protected $tpEmis;
79
    protected $tpImp;
80
    protected $tpAmb;
81
    protected $vPrest;
82
    protected $wAdic = 150;
83
    protected $textoAdic = '';
84
    protected $debugMode = 2;
85
    protected $formatPadrao;
86
    protected $formatNegrito;
87
    protected $aquav;
88
    protected $preVisualizar;
89
    protected $flagDocOrigContinuacao;
90
    protected $arrayNFe = array();
91
    protected $siteDesenvolvedor;
92
    protected $nomeDesenvolvedor;
93
    protected $totPag;
94
    protected $idDocAntEle = [];
95
96
    /**
97
     * __construct
98
     *
99
     * @param string $docXML Arquivo XML da CTe
100
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
101
     * @param string $sPapel Tamanho do papel (Ex. A4)
102
     * @param string $sPathLogo Caminho para o arquivo do logo
103
     * @param string $sDestino Estabelece a direção do envio do documento PDF
104
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
105
     * @param string $fonteDACTE Nome da fonte a ser utilizada
106
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
107
     * @param string $preVisualizar 0-Não 1-Sim
108
     */
109
    public function __construct(
110
        $docXML = '',
111
        $sOrientacao = '',
112
        $sPapel = '',
113
        $sPathLogo = '',
114
        $sDestino = 'I',
115
        $sDirPDF = '',
116
        $fonteDACTE = '',
117
        $mododebug = 2,
118
        $preVisualizar = false,
119
        $nomeDesenvolvedor = 'Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org',
120
        $siteDesenvolvedor = 'http://www.nfephp.org'
121
    ) {
122
    
123
        if (is_numeric($mododebug)) {
124
            $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...
125
        }
126
        if ($mododebug == 1) {
127
            //ativar modo debug
128
            error_reporting(E_ALL);
129
            ini_set('display_errors', 'On');
130
        } elseif ($mododebug == 0) {
131
            //desativar modo debug
132
            error_reporting(0);
133
            ini_set('display_errors', 'Off');
134
        }
135
        $this->orientacao = $sOrientacao;
136
        $this->papel = $sPapel;
137
        $this->pdf = '';
138
        $this->xml = $docXML;
139
        $this->logomarca = $sPathLogo;
140
        $this->destino = $sDestino;
141
        $this->pdfDir = $sDirPDF;
142
        $this->preVisualizar = $preVisualizar;
143
        $this->siteDesenvolvedor = $siteDesenvolvedor;
144
        $this->nomeDesenvolvedor = $nomeDesenvolvedor;
145
        // verifica se foi passa a fonte a ser usada
146
        if (!empty($fonteDACTE)) {
147
            $this->fontePadrao = $fonteDACTE;
148
        }
149
        $this->formatPadrao = array(
150
            'font' => $this->fontePadrao,
151
            'size' => 6,
152
            'style' => '');
153
        $this->formatNegrito = array(
154
            'font' => $this->fontePadrao,
155
            'size' => 7,
156
            'style' => 'B');
157
        //se for passado o xml
158
        if (!empty($this->xml)) {
159
            $this->dom = new Dom();
160
            $this->dom->loadXML($this->xml);
161
            $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...
162
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
163
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
164
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
165
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
166
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
167
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
168
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
169
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
170
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
171
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
172
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
173
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
174
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
175
            $this->infQ = $this->dom->getElementsByTagName("infQ");
176
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
177
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
178
            $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...
179
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
180
            $this->veic = $this->dom->getElementsByTagName("veic");
181
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
182
            // adicionar outros modais
183
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
184
            $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chave");
185
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
186
            $this->Comp = $this->dom->getElementsByTagName("Comp");
187
            $this->infNF = $this->dom->getElementsByTagName("infNF");
188
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
189
            $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...
190
            $this->compl = $this->dom->getElementsByTagName("compl");
191
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
192
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
0 ignored issues
show
Bug introduced by
The property ICMSSN does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
193
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
194
195
            $vTrib = $this->pSimpleGetValue($this->imp, "vTotTrib");
196
            if (!is_numeric($vTrib)) {
197
                $vTrib = 0;
198
            }
199
            $textoAdic = number_format($vTrib, 2, ",", ".");
200
201
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
202
                    .$textoAdic;
203
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
204
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
205
            //modal aquaviário
206
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
207
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
208
            //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...
209
            switch ($tomador) {
210
                case '0':
211
                    $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...
212
                    $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...
213
                    break;
214
                case '1':
215
                    $this->toma = $this->exped;
216
                    $this->enderToma = $this->enderExped;
217
                    break;
218
                case '2':
219
                    $this->toma = $this->receb;
220
                    $this->enderToma = $this->enderReceb;
221
                    break;
222
                case '3':
223
                    $this->toma = $this->dest;
224
                    $this->enderToma = $this->enderDest;
225
                    break;
226
                default:
227
                    $this->toma = $this->toma4;
228
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
229
                    break;
230
            }
231
            /*$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...
232
            switch ($seguro) {
233
                case '0':
234
                    $this->respSeg = 'Remetente';
235
                    break;
236
                case '1':
237
                    $this->respSeg = 'Expedidor';
238
                    break;
239
                case '2':
240
                    $this->respSeg = 'Recebedor';
241
                    break;
242
                case '3':
243
                    $this->respSeg = 'Destinatário';
244
                    break;
245
                case '4':
246
                    $this->respSeg = 'Emitente';
247
                    break;
248
                case '5':
249
                    $this->respSeg = 'Tomador';
250
                    break;
251
                default:
252
                    $this->respSeg = '';
253
                    break;
254
            }*/
255
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
256
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
257
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
258
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
259
            $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...
260
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
261
            $this->modal = $this->pSimpleGetValue($this->ide, "modal");
262
        }
263
    }
264
265
    /**
266
     * monta
267
     * @param string $orientacao L ou P
268
     * @param string $papel A4
269
     * @param string $logoAlign C, L ou R
270
     * @param Pdf $classPDF
271
     * @return string montagem
272
     */
273
    public function monta(
274
        $orientacao = '',
275
        $papel = 'A4',
276
        $logoAlign = 'C',
277
        $classPDF = false
278
    ) {
279
    
280
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 277 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...
281
    }
282
283
    /**
284
     * printDocument
285
     * @param string $nome
286
     * @param string $destino
287
     * @param string $printer
288
     * @return
289
     */
290
    public function printDocument($nome = '', $destino = 'I', $printer = '')
291
    {
292
        return $this->printDACTE($nome, $destino, $printer);
293
    }
294
295
    /**
296
     * Dados brutos do PDF
297
     * @return string
298
     */
299
    public function render()
300
    {
301
        return $this->pdf->getPdf();
302
    }
303
304
305
    protected function zCteDPEC()
306
    {
307
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
308
    }
309
310
311
    /**
312
     * montaDACTE
313
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
314
     * durante sua construção.
315
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
316
     * pelo conteúdo da funçao e podem ser modificados.
317
     *
318
     * @param  string $orientacao (Opcional) Estabelece a orientação da
319
     *                impressão (ex. P-retrato), se nada for fornecido será
320
     *                usado o padrão da NFe
321
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
322
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
323
     */
324
    public function montaDACTE(
325
        $orientacao = '',
326
        $papel = 'A4',
327
        $logoAlign = 'C',
328
        $classPDF = false
329
    ) {
330
    
331
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
332
        if ($orientacao == '') {
333
            if ($this->tpImp == '1') {
334
                $orientacao = 'P';
335
            } else {
336
                $orientacao = 'P';
337
            }
338
        }
339
        $this->orientacao = $orientacao;
340
        $this->papel = $papel;
341
        $this->logoAlign = $logoAlign;
342
343
        //$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...
344
        //instancia a classe pdf
345
        if ($classPDF !== false) {
346
            $this->pdf = $classPDF;
347
        } else {
348
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
349
        }
350
        if ($this->orientacao == 'P') {
351
            // margens do PDF
352
            $margSup = 2;
353
            $margEsq = 2;
354
            $margDir = 2;
355
            // posição inicial do relatorio
356
            $xInic = 1;
357
            $yInic = 1;
358
            if ($papel == 'A4') {
359
                //A4 210x297mm
360
                $maxW = 210;
361
                $maxH = 297;
362
            }
363
        } else {
364
            // margens do PDF
365
            $margSup = 3;
366
            $margEsq = 3;
367
            $margDir = 3;
368
            // posição inicial do relatorio
369
            $xInic = 5;
370
            $yInic = 5;
371
            if ($papel == 'A4') {
372
                //A4 210x297mm
373
                $maxH = 210;
374
                $maxW = 297;
375
                $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...
376
            }
377
        }
378
        //total inicial de paginas
379
        $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...
380
        //largura imprimivel em mm
381
        $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...
382
        //comprimento imprimivel em mm
383
        $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...
384
        // estabelece contagem de paginas
385
        $this->pdf->AliasNbPages();
386
        // fixa as margens
387
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
388
        $this->pdf->SetDrawColor(0, 0, 0);
389
        $this->pdf->SetFillColor(255, 255, 255);
390
        // inicia o documento
391
        $this->pdf->Open();
392
        // adiciona a primeira página
393
        $this->pdf->AddPage($this->orientacao, $this->papel);
394
        $this->pdf->SetLineWidth(0.1);
395
        $this->pdf->SetTextColor(0, 0, 0);
396
        //calculo do numero de páginas ???
397
        $totPag = 1;
398
        //montagem da primeira página
399
        $pag = 1;
400
        $x = $xInic;
401
        $y = $yInic;
402
        //coloca o cabeçalho
403
        //$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...
404
        $y += 70;
405
        $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...
406
        $x = $this->wPrint * 0.5 + 2;
407
        $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...
408
        $y += 19;
409
        $x = $xInic;
410
        $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...
411
        $x = $this->wPrint * 0.5 + 2;
412
        $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...
413
        $y += 19;
414
        $x = $xInic;
415
        $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...
416
        if ($this->tpCTe == '0') {
417
            //Normal
418
            $y += 10;
419
            $x = $xInic;
420
            $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...
421
            $y += 17;
422
            $x = $xInic;
423
            $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...
424
            $y += 25;
425
            $x = $xInic;
426
            $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...
427
            $y += 13;
428
            $x = $xInic;
429
            $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...
430
            if ($this->modal == '1') {
431
                if ($this->lota == 1) {
432
                    //$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...
433
                    $y += 35;
434
                } else {
435
                    $y += 53;
436
                }
437
            } elseif ($this->modal == '3') {
438
                $y += 37.75;
439
            } else {
440
                $y += 24.95;
441
            }
442
            $x = $xInic;
443
            $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...
444
            $y = $y-6;
445
            switch ($this->modal) {
446
                case '1':
447
                    $y += 25.9;
448
                    $x = $xInic;
449
                    $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...
450
                    break;
451
                case '2':
452
                    $y += 17.9;
453
                    $x = $xInic;
454
                    // TODO fmertins 31/10/14: este método não existe...
455
                    $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...
456
                    break;
457
                case '3':
458
                    $y += 17.9;
459
                    $x = $xInic;
460
                    $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...
461
                    break;
462
                case '4':
463
                    $y += 17.9;
464
                    $x = $xInic;
465
                    $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...
466
                    break;
467
                case '5':
468
                    $y += 17.9;
469
                    $x = $xInic;
470
                    // TODO fmertins 31/10/14: este método não existe...
471
                    $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...
472
                    break;
473
            }
474
            if ($this->modal == '1') {
475
                if ($this->lota == 1) {
476
                    $y += 37;
477
                } else {
478
                    $y += 8.9;
479
                }
480
            } elseif ($this->modal == '3') {
481
                $y += 24.15;
482
            } else {
483
                $y += 37;
484
            }
485
        } else {
486
            $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...
487
            //Complementado
488
            $y += 10;
489
            $x = $xInic;
490
            $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...
491
            $y += 80;
492
            $x = $xInic;
493
            $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...
494
            $y += 25;
495
            $x = $xInic;
496
            $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...
497
            $y += 13;
498
            $x = $xInic;
499
            $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...
500
            $y += 15;
501
        }
502
        $x = $xInic;
503
        $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...
504
        
505
        //$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...
506
        $y += 11;
507
        $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...
508
        
509
        //coloca o rodapé da página
510
        if ($this->orientacao == 'P') {
511
            $this->zRodape(2, $this->hPrint - 2);
512
        } else {
513
            $this->zRodape($xInic, $this->hPrint + 2.3);
514
        }
515
        if ($this->flagDocOrigContinuacao == 1) {
516
            $this->zdocOrigContinuacao(1, 71);
517
        }
518
        //retorna o ID na CTe
519
        if ($classPDF !== false) {
520
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
521
            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...
522
        } else {
523
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
524
        }
525
    } //fim da função montaDACTE
526
527
    /**
528
     * printDACTE
529
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
530
     * O destino da impressão pode ser :
531
     * I-browser
532
     * D-browser com download
533
     * F-salva em um arquivo local com o nome informado
534
     * S-retorna o documento como uma string e o nome é ignorado.
535
     * Para enviar o pdf diretamente para uma impressora indique o
536
     * nome da impressora e o destino deve ser 'S'.
537
     *
538
     * @param  string $nome Path completo com o nome do arquivo pdf
539
     * @param  string $destino Direção do envio do PDF
540
     * @param  string $printer Identificação da impressora no sistema
541
     * @return string Caso o destino seja S o pdf é retornado como uma string
542
     * @todo Rotina de impressão direta do arquivo pdf criado
543
     */
544
    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...
545
    {
546
        $arq = $this->pdf->Output($nome, $destino);
547
        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...
548
            //aqui pode entrar a rotina de impressão direta
549
        }
550
        return $arq;
551
    } //fim função printDACTE
552
553
    /**
554
     * zCabecalho
555
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
556
     *
557
     * @param  number $x Posição horizontal inicial, canto esquerdo
558
     * @param  number $y Posição vertical inicial, canto superior
559
     * @param  number $pag Número da Página
560
     * @param  number $totPag Total de páginas
561
     * @return number Posição vertical final
562
     */
563
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
564
    {
565
        $oldX = $x;
566
        $oldY = $y;
567
        if ($this->orientacao == 'P') {
568
            $maxW = $this->wPrint;
569
        } else {
570
            if ($pag == 1) {
571
                // primeira página
572
                $maxW = $this->wPrint - $this->wCanhoto;
573
            } else {
574
                // páginas seguintes
575
                $maxW = $this->wPrint;
576
            }
577
        }
578
        //##################################################################
579
        //coluna esquerda identificação do emitente
580
        $w = round($maxW * 0.42);
581
        if ($this->orientacao == 'P') {
582
            $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...
583
                'font' => $this->fontePadrao,
584
                'size' => 6,
585
                'style' => '');
586
        } else {
587
            $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...
588
        }
589
        $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...
590
        $h = 35;
591
        $oldY += $h;
592
        //desenha a caixa
593
        $this->pTextBox($x, $y, $w + 2, $h + 1);
594
        // coloca o logo
595
        if (is_file($this->logomarca)) {
596
            $logoInfo = getimagesize($this->logomarca);
597
            //largura da imagem em mm
598
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
599
            //altura da imagem em mm
600
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
601
            if ($this->logoAlign == 'L') {
602
                $nImgW = round($w / 3, 0);
603
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
604
                $xImg = $x + 1;
605
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
606
                //estabelecer posições do texto
607
                $x1 = round($xImg + $nImgW + 1, 0);
608
                $y1 = round($h / 3 + $y, 0);
609
                $tw = round(2 * $w / 3, 0);
610
            } elseif ($this->logoAlign == 'C') {
611
                $nImgH = round($h / 3, 0);
612
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
613
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
614
                $yImg = $y + 3;
615
                $x1 = $x;
616
                $y1 = round($yImg + $nImgH + 1, 0);
617
                $tw = $w;
618
            } elseif ($this->logoAlign == 'R') {
619
                $nImgW = round($w / 3, 0);
620
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
621
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
622
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
623
                $x1 = $x;
624
                $y1 = round($h / 3 + $y, 0);
625
                $tw = round(2 * $w / 3, 0);
626
            }
627
            $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...
628
        } else {
629
            $x1 = $x;
630
            $y1 = round($h / 3 + $y, 0);
631
            $tw = $w;
632
        }
633
        //Nome emitente
634
        $aFont = array(
635
            'font' => $this->fontePadrao,
636
            'size' => 9,
637
            'style' => 'B');
638
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
639
        $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...
640
        //endereço
641
        $y1 = $y1 + 3;
642
        $aFont = array(
643
            'font' => $this->fontePadrao,
644
            'size' => 7,
645
            'style' => '');
646
        $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...
647
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
648
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
649
        $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...
650
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
651
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
652
        $CEP = $this->pFormat($CEP, "#####-###");
653
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
654
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
655
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
656
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
657
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
658
            . "\n  Fone/Fax: " . $fone;
659
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
660
        //CNPJ/CPF IE
661
        $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...
662
        $ie = $this->pSimpleGetValue($this->emit, "IE");
663
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
664
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
665
        //outra caixa
666
        $h1 = 17.5;
667
        $y1 = $y + $h + 1;
668
        $this->pTextBox($x, $y1, $w + 2, $h1);
669
        //TIPO DO CT-E
670
        $texto = 'TIPO DO CTE';
671
        $wa = 37;
672
        $aFont = array(
673
            'font' => $this->fontePadrao,
674
            'size' => 8,
675
            'style' => '');
676
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
677
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
678
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
679
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
680
        switch ($tpCTe) {
681
            case '0':
682
                $texto = 'Normal';
683
                break;
684
            case '1':
685
                $texto = 'Complemento de Valores';
686
                break;
687
            case '2':
688
                $texto = 'Anulação de Valores';
689
                break;
690
            case '3':
691
                $texto = 'Substituto';
692
                break;
693
            default:
694
                $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...
695
        }
696
        $aFont = $this->formatNegrito;
697
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
698
        //TIPO DO SERVIÇO
699
        $texto = 'TIPO DO SERVIÇO';
700
        $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...
701
        $aFont = array(
702
            'font' => $this->fontePadrao,
703
            'size' => 8,
704
            'style' => '');
705
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
706
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
707
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
708
        switch ($tpServ) {
709
            case '0':
710
                $texto = 'Normal';
711
                break;
712
            case '1':
713
                $texto = 'Subcontratação';
714
                break;
715
            case '2':
716
                $texto = 'Redespacho';
717
                break;
718
            case '3':
719
                $texto = 'Redespacho Intermediário';
720
                break;
721
            default:
722
                $texto = 'ERRO' . $tpServ;
723
        }
724
        $aFont = $this->formatNegrito;
725
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
726
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
727
        //TOMADOR DO SERVIÇO
728
        $texto = 'INDICADOR DO CT-E GLOBALIZADO';
729
        $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...
730
        $y2 = $y1 + 8;
731
        $aFont = array(
732
            'font' => $this->fontePadrao,
733
            'size' => 6,
734
            'style' => '');
735
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
736
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
737
        $toma = $this->pSimpleGetValue($this->ide, "indGlobalizado");
738
        //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...
739
        if ($toma==1) {
740
            $aFont = array(
741
            'font' => $this->fontePadrao,
742
            'size' => 11,
743
            'style' => '');
744
            $this->pTextBox($x-14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
745
        } else {
746
            $aFont = array(
747
            'font' => $this->fontePadrao,
748
            'size' => 11,
749
            'style' => '');
750
            $this->pTextBox($x+3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
751
        }
752
        $aFont = $this->formatNegrito;
753
        $this->pdf->Line($x+5, $x+48, $x+5, $x+52);
754
        $this->pdf->Line($x+10, $x+48, $x+10, $x+52);
755
        $this->pdf->Line($x+5, $x+48, $x+10, $x+48);
756
        $this->pdf->Line($x+5, $x+52, $x+10, $x+52);
757
        $this->pTextBox($x-9, $y2+1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
758
759
        $this->pdf->Line($x+23, $x+48, $x+23, $x+52);
760
        $this->pdf->Line($x+28, $x+48, $x+28, $x+52);
761
        $this->pdf->Line($x+23, $x+48, $x+28, $x+48);
762
        $this->pdf->Line($x+23, $x+52, $x+28, $x+52);
763
        $this->pTextBox($x+9.8, $y2+1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
764
765
        //FORMA DE PAGAMENTO
766
        $texto = 'NFORMAÇÕES DO CT-E GLOBALIZADO';
767
        $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...
768
        $aFont = array(
769
            'font' => $this->fontePadrao,
770
            'size' => 8,
771
            'style' => '');
772
        $this->pTextBox($x+2 + $wa + 4.5, $y2-0.7, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
773
        $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...
774
        //##################################################################
775
        //coluna direita
776
        $x += $w + 2;
777
        $w = round($maxW * 0.335);
778
        $w1 = $w;
779
        $h = 11;
780
        $this->pTextBox($x, $y, $w + 2, $h + 1);
781
        $texto = "DACTE";
782
        $aFont = array(
783
            'font' => $this->fontePadrao,
784
            'size' => 10,
785
            'style' => 'B');
786
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
787
        $aFont = array(
788
            'font' => $this->fontePadrao,
789
            'size' => 8,
790
            'style' => '');
791
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
792
        $h = 10;
793
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
794
        $x1 = $x + $w + 2;
795
        $w = round($maxW * 0.22, 0);
796
        $w2 = $w;
797
        $h = 11;
798
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
799
        $texto = "MODAL";
800
        $aFont = array(
801
            'font' => $this->fontePadrao,
802
            'size' => 8,
803
            'style' => '');
804
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
805
        switch ($this->modal) {
806
            case '1':
807
                $texto = 'Rodoviário';
808
                break;
809
            case '2':
810
                $texto = 'Aéreo';
811
                break;
812
            case '3':
813
                $texto = 'Aquaviário';
814
                break;
815
            case '4':
816
                $texto = 'Ferroviário';
817
                break;
818
            case '5':
819
                $texto = 'Dutoviário';
820
                break;
821
        }
822
        $aFont = array(
823
            'font' => $this->fontePadrao,
824
            'size' => 10,
825
            'style' => 'B');
826
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
827
        //outra caixa
828
        $y += 12;
829
        $h = 9;
830
        $w = $w1 + $w2 + 2;
831
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
832
        //modelo
833
        $wa = 12;
834
        $xa = $x;
835
        $texto = 'MODELO';
836
        $aFont = array(
837
            'font' => $this->fontePadrao,
838
            'size' => 8,
839
            'style' => '');
840
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
841
        $texto = $this->pSimpleGetValue($this->ide, "mod");
842
        $aFont = $this->formatNegrito;
843
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
844
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
845
        //serie
846
        $xa += $wa;
847
        $texto = 'SÉRIE';
848
        $aFont = array(
849
            'font' => $this->fontePadrao,
850
            'size' => 8,
851
            'style' => '');
852
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
853
        $texto = $this->pSimpleGetValue($this->ide, "serie");
854
        $aFont = $this->formatNegrito;
855
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
856
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
857
        //numero
858
        $xa += $wa;
859
        $wa = 20;
860
        $texto = 'NÚMERO';
861
        $aFont = array(
862
            'font' => $this->fontePadrao,
863
            'size' => 8,
864
            'style' => '');
865
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
866
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
867
        $aFont = $this->formatNegrito;
868
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
869
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
870
        //folha
871
        $xa += $wa;
872
        $wa = 12;
873
        $texto = 'FL';
874
        $aFont = array(
875
            'font' => $this->fontePadrao,
876
            'size' => 8,
877
            'style' => '');
878
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
879
        //$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...
880
        $texto = $pag."/".$totPag;
881
        $aFont = $this->formatNegrito;
882
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
883
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
884
        //data  hora de emissão
885
        $xa += $wa;
886
        $wa = 30;
887
        $texto = 'DATA E HORA DE EMISSÃO';
888
        $aFont = array(
889
            'font' => $this->fontePadrao,
890
            'size' => 8,
891
            'style' => '');
892
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
893
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
894
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
895
        $aFont = $this->formatNegrito;
896
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
897
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
898
        //ISUF
899
        $xa += $wa;
900
        $wa = 32;
901
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
902
        $aFont = $this->formatPadrao;
903
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
904
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
905
        $aFont = array(
906
            'font' => $this->fontePadrao,
907
            'size' => 7,
908
            'style' => 'B');
909
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
910
        //outra caixa
911
        $y += $h + 1;
912
        $h = 23;
913
        $h1 = 14;
914
        $this->pTextBox($x, $y, $w + 0.5, $h1);
915
        //CODIGO DE BARRAS
916
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
917
        $bW = 85;
918
        $bH = 10;
919
        //codigo de barras
920
        $this->pdf->SetFillColor(0, 0, 0);
921
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
922
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
923
        $texto = 'CHAVE DE ACESSO';
924
        $aFont = $this->formatPadrao;
925
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
926
        $aFont = $this->formatNegrito;
927
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
928
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
929
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
930
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
931
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
932
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
933
            $texto = "";
934
            $this->pdf->SetFillColor(0, 0, 0);
935
            if ($this->tpEmis == 5) {
936
                $chaveContingencia = $this->zGeraChaveAdicCont();
937
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
938
            } else {
939
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
940
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
941
            }
942
            //codigo de barras
943
        }
944
        $aFont = array(
945
            'font' => $this->fontePadrao,
946
            'size' => 8,
947
            'style' => '');
948
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
949
        //outra caixa
950
        $y += $h + 1;
951
        $h = 8.5;
952
        $wa = $w;
953
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
954
        if ($this->zCteDPEC()) {
955
            $texto = 'NÚMERO DE REGISTRO DPEC';
956
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
957
            $texto = "DADOS DO CT-E";
958
        } else {
959
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
960
        }
961
        $aFont = $this->formatPadrao;
962
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
963
        if ($this->zCteDPEC()) {
964
            $texto = $this->numero_registro_dpec;
965
        } elseif ($this->tpEmis == 5) {
966
            $chaveContingencia = $this->zGeraChaveAdicCont();
967
            $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...
968
                'font' => $this->fontePadrao,
969
                'size' => 8,
970
                'style' => 'B');
971
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
972
            $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...
973
        } else {
974
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
975
            // 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...
976
            if (!empty($this->protCTe)
977
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
978
            ) {
979
                $texto .= date(
980
                    'd/m/Y   H:i:s',
981
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
982
                );
983
            }
984
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
985
        }
986
        $aFont = $this->formatNegrito;
987
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
988
        //CFOP
989
        $x = $oldX;
990
        $h = 8.5;
991
        $w = round($maxW * 0.42);
992
        $y1 = $y + 7.5;
993
        $this->pTextBox($x, $y1, $w + 2, $h);
994
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
995
        $aFont = array(
996
            'font' => $this->fontePadrao,
997
            'size' => 8,
998
            'style' => '');
999
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1000
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
1001
        $aFont = $this->formatNegrito;
1002
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1003
        //ORIGEM DA PRESTAÇÃO
1004
        $y += $h + 7.5;
1005
        $x = $oldX;
1006
        $h = 8;
1007
        $w = ($maxW * 0.5);
1008
        $this->pTextBox($x, $y, $w + 0.5, $h);
1009
        $texto = 'INÍCIO DA PRESTAÇÃO';
1010
        $aFont = array(
1011
            'font' => $this->fontePadrao,
1012
            'size' => 8,
1013
            'style' => '');
1014
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1015
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1016
        $aFont = $this->formatNegrito;
1017
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1018
        //DESTINO DA PRESTAÇÃO
1019
        $x = $oldX + $w + 1;
1020
        $h = 8;
1021
        $w = $w - 1.3;
1022
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1023
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1024
        $aFont = array(
1025
            'font' => $this->fontePadrao,
1026
            'size' => 8,
1027
            'style' => '');
1028
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1029
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1030
        $aFont = $this->formatNegrito;
1031
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1032
        //#########################################################################
1033
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1034
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1035
        //indicar cancelamento
1036
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1037
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1038
            //101 Cancelamento
1039
            $x = 10;
1040
            $y = $this->hPrint - 130;
1041
            $h = 25;
1042
            $w = $maxW - (2 * $x);
1043
            $this->pdf->SetTextColor(90, 90, 90);
1044
            $texto = "CTe CANCELADO";
1045
            $aFont = array(
1046
                'font' => $this->fontePadrao,
1047
                'size' => 48,
1048
                'style' => 'B');
1049
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1050
            $this->pdf->SetTextColor(0, 0, 0);
1051
        }
1052
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1053
        if ($cStat == '110' ||
1054
            $cStat == '301' ||
1055
            $cStat == '302' ||
1056
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1057
        ) {
1058
            //110 Denegada
1059
            $x = 10;
1060
            $y = $this->hPrint - 130;
1061
            $h = 25;
1062
            $w = $maxW - (2 * $x);
1063
            $this->pdf->SetTextColor(90, 90, 90);
1064
            $texto = "CTe USO DENEGADO";
1065
            $aFont = array(
1066
                'font' => $this->fontePadrao,
1067
                'size' => 48,
1068
                'style' => 'B');
1069
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1070
            $y += $h;
1071
            $h = 5;
1072
            $w = $maxW - (2 * $x);
1073
            $texto = "SEM VALOR FISCAL";
1074
            $aFont = array(
1075
                'font' => $this->fontePadrao,
1076
                'size' => 48,
1077
                'style' => 'B');
1078
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1079
            $this->pdf->SetTextColor(0, 0, 0);
1080
        }
1081
        //indicar sem valor
1082
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1083
            $x = 10;
1084
            if ($this->orientacao == 'P') {
1085
                $y = round($this->hPrint * 2 / 3, 0);
1086
            } else {
1087
                $y = round($this->hPrint / 2, 0);
1088
            }
1089
            $h = 5;
1090
            $w = $maxW - (2 * $x);
1091
            $this->pdf->SetTextColor(90, 90, 90);
1092
            $texto = "SEM VALOR FISCAL";
1093
            $aFont = array(
1094
                'font' => $this->fontePadrao,
1095
                'size' => 48,
1096
                'style' => 'B');
1097
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1098
            $aFont = array(
1099
                'font' => $this->fontePadrao,
1100
                'size' => 30,
1101
                'style' => 'B');
1102
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1103
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1104
            $this->pdf->SetTextColor(0, 0, 0);
1105
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1106
            $h = 5;
1107
            $w = $maxW - (2 * 10);
1108
            $x = 55;
1109
            $y = 240;
1110
            $this->pdf->SetTextColor(255, 100, 100);
1111
            $aFont = array(
1112
                'font' => $this->fontePadrao,
1113
                'size' => 40,
1114
                'style' => 'B');
1115
            $texto = "Pré-visualização";
1116
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1117
            $this->pdf->SetTextColor(255, 100, 100);
1118
            $aFont = array(
1119
                'font' => $this->fontePadrao,
1120
                'size' => 41,
1121
                'style' => 'B');
1122
            $texto = "Sem Validade Jurídica";
1123
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1124
            $this->pdf->SetTextColor(90, 90, 90);
1125
            $texto = "SEM VALOR FISCAL";
1126
            $aFont = array(
1127
                'font' => $this->fontePadrao,
1128
                'size' => 48,
1129
                'style' => 'B');
1130
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1131
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1132
        } else {
1133
            $x = 10;
1134
            if ($this->orientacao == 'P') {
1135
                $y = round($this->hPrint * 2 / 3, 0);
1136
            } else {
1137
                $y = round($this->hPrint / 2, 0);
1138
            } //fim orientacao
1139
            $h = 5;
1140
            $w = $maxW - (2 * $x);
1141
            $this->pdf->SetTextColor(90, 90, 90);
1142
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1143
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1144
                //Contingência
1145
                $texto = "DACTE Emitido em Contingência";
1146
                $aFont = array(
1147
                    'font' => $this->fontePadrao,
1148
                    'size' => 48,
1149
                    'style' => 'B');
1150
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1151
                $aFont = array(
1152
                    'font' => $this->fontePadrao,
1153
                    'size' => 30,
1154
                    'style' => 'B');
1155
                $texto = "devido à problemas técnicos";
1156
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1157
            } else {
1158
                if (!isset($this->protCTe)) {
1159
                    if (!$this->zCteDPEC()) {
1160
                        $texto = "SEM VALOR FISCAL";
1161
                        $aFont = array(
1162
                            'font' => $this->fontePadrao,
1163
                            'size' => 48,
1164
                            'style' => 'B');
1165
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1166
                    }
1167
                    $aFont = array(
1168
                        'font' => $this->fontePadrao,
1169
                        'size' => 30,
1170
                        'style' => 'B');
1171
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1172
                    if (!$this->zCteDPEC()) {
1173
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1174
                    } else {
1175
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1176
                    }
1177
                } //fim cteProc
1178
                if ($this->tpEmis == 4) {
1179
                    //DPEC
1180
                    $x = 10;
1181
                    $y = $this->hPrint - 130;
1182
                    $h = 25;
1183
                    $w = $maxW - (2 * $x);
1184
                    $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...
1185
                    $texto = "DACTE impresso em contingência -\n"
1186
                        . "DPEC regularmente recebido pela Receita\n"
1187
                        . "Federal do Brasil";
1188
                    $aFont = array(
1189
                        'font' => $this->fontePadrao,
1190
                        'size' => 48,
1191
                        'style' => 'B');
1192
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1193
                    $this->pdf->SetTextColor(0, 0, 0);
1194
                }
1195
            } //fim tpEmis
1196
            $this->pdf->SetTextColor(0, 0, 0);
1197
        }
1198
        return $oldY;
1199
    } //fim zCabecalho
1200
1201
    /**
1202
     * rodapeDACTE
1203
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1204
     *
1205
     * @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...
1206
     * @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...
1207
     */
1208
    protected function zRodape($x, $y)
1209
    {
1210
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1211
        $w = $this->wPrint - 4;
1212
        $aFont = array(
1213
            'font' => $this->fontePadrao,
1214
            'size' => 6,
1215
            'style' => '');
1216
        $this->pTextBox($x-1, $y+2, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1217
        $texto = $this->nomeDesenvolvedor . ' - '. $this->siteDesenvolvedor;
1218
        $aFont = array(
1219
            'font' => $this->fontePadrao,
1220
            'size' => 6,
1221
            'style' => '');
1222
        $this->pTextBox($x-50, $y+2, $w, 4, $texto, $aFont, 'T', 'R', 0, $this->siteDesenvolvedor);
1223
    } //fim zRodape
1224
1225
    /**
1226
     * zRemetente
1227
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1228
     *
1229
     * @param  number $x Posição horizontal canto esquerdo
1230
     * @param  number $y Posição vertical canto superior
1231
     * @return number Posição vertical final
1232
     */
1233
    protected function zRemetente($x = 0, $y = 0)
1234
    {
1235
        $oldX = $x;
1236
        $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...
1237
        if ($this->orientacao == 'P') {
1238
            $maxW = $this->wPrint;
1239
        } else {
1240
            $maxW = $this->wPrint - $this->wCanhoto;
1241
        }
1242
        $w = $maxW * 0.5 + 0.5;
1243
        $h = 19;
1244
        $x1 = $x + 16;
1245
        $texto = 'REMETENTE';
1246
        $aFont = $this->formatPadrao;
1247
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1248
        $aFont = $this->formatNegrito;
1249
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1250
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1251
        $y += 3;
1252
        $texto = 'ENDEREÇO';
1253
        $aFont = $this->formatPadrao;
1254
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1255
        $aFont = $this->formatNegrito;
1256
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1257
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1258
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1259
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1260
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1261
        $y += 3;
1262
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1263
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1264
        $y += 3;
1265
        $texto = 'MUNICÍPIO';
1266
        $aFont = $this->formatPadrao;
1267
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1268
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1269
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1270
        $aFont = $this->formatNegrito;
1271
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1272
        $x = $w - 18;
1273
        $texto = 'CEP';
1274
        $aFont = $this->formatPadrao;
1275
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1276
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1277
        $aFont = $this->formatNegrito;
1278
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1279
        $x = $oldX;
1280
        $y += 3;
1281
        $texto = 'CNPJ/CPF';
1282
        $aFont = $this->formatPadrao;
1283
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1284
        $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...
1285
        $aFont = $this->formatNegrito;
1286
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1287
        $x = $w - 45;
1288
        $texto = 'INSCRIÇÃO ESTADUAL';
1289
        $aFont = $this->formatPadrao;
1290
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1291
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1292
        $aFont = $this->formatNegrito;
1293
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1294
        $x = $oldX;
1295
        $y += 3;
1296
        $texto = 'PAÍS';
1297
        $aFont = $this->formatPadrao;
1298
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1299
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1300
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1301
        $aFont = $this->formatNegrito;
1302
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1303
        $x = $w - 25;
1304
        $texto = 'FONE';
1305
        $aFont = $this->formatPadrao;
1306
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1307
        //$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...
1308
        $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...
1309
        $aFont = $this->formatNegrito;
1310
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1311
    } //fim da função remetenteDACTE
1312
1313
    /**
1314
     * zDestinatario
1315
     * Monta o campo com os dados do destinatário na DACTE.
1316
     *
1317
     * @param  number $x Posição horizontal canto esquerdo
1318
     * @param  number $y Posição vertical canto superior
1319
     * @return number Posição vertical final
1320
     */
1321
    protected function zDestinatario($x = 0, $y = 0)
1322
    {
1323
        $oldX = $x;
1324
        $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...
1325
        if ($this->orientacao == 'P') {
1326
            $maxW = $this->wPrint;
1327
        } else {
1328
            $maxW = $this->wPrint - $this->wCanhoto;
1329
        }
1330
        $w = ($maxW * 0.5) - 0.7;
1331
        $h = 19;
1332
        $x1 = $x + 19;
1333
        $texto = 'DESTINATÁRIO';
1334
        $aFont = $this->formatPadrao;
1335
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1336
        $aFont = $this->formatNegrito;
1337
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1338
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1339
        $y += 3;
1340
        $texto = 'ENDEREÇO';
1341
        $aFont = $this->formatPadrao;
1342
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1343
        $aFont = $this->formatNegrito;
1344
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1345
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1346
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1347
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1348
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1349
        $y += 3;
1350
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1351
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1352
        $y += 3;
1353
        $texto = 'MUNICÍPIO';
1354
        $aFont = $this->formatPadrao;
1355
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1356
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1357
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1358
        $aFont = $this->formatNegrito;
1359
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1360
        $x = $w - 19 + $oldX;
1361
        $texto = 'CEP';
1362
        $aFont = $this->formatPadrao;
1363
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1364
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1365
        $aFont = $this->formatNegrito;
1366
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1367
        $x = $oldX;
1368
        $y += 3;
1369
        $texto = 'CNPJ/CPF';
1370
        $aFont = $this->formatPadrao;
1371
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1372
        $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...
1373
        $aFont = $this->formatNegrito;
1374
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1375
        $x = $w - 47.5 + $oldX;
1376
        $texto = 'INSCRIÇÃO ESTADUAL';
1377
        $aFont = $this->formatPadrao;
1378
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1379
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1380
        $aFont = $this->formatNegrito;
1381
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1382
        $x = $oldX;
1383
        $y += 3;
1384
        $texto = 'PAÍS';
1385
        $aFont = $this->formatPadrao;
1386
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1387
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1388
        $aFont = $this->formatNegrito;
1389
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1390
        $x = $w - 27 + $oldX;
1391
        $texto = 'FONE';
1392
        $aFont = $this->formatPadrao;
1393
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1394
        //$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...
1395
        $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...
1396
        $aFont = $this->formatNegrito;
1397
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1398
    } //fim da função destinatarioDACTE
1399
1400
    /**
1401
     * zExpedidor
1402
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1403
     *
1404
     * @param  number $x Posição horizontal canto esquerdo
1405
     * @param  number $y Posição vertical canto superior
1406
     * @return number Posição vertical final
1407
     */
1408
    protected function zExpedidor($x = 0, $y = 0)
1409
    {
1410
        $oldX = $x;
1411
        $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...
1412
        if ($this->orientacao == 'P') {
1413
            $maxW = $this->wPrint;
1414
        } else {
1415
            $maxW = $this->wPrint - $this->wCanhoto;
1416
        }
1417
        $w = $maxW * 0.5 + 0.5;
1418
        $h = 19;
1419
        $x1 = $x + 16;
1420
        $texto = 'EXPEDIDOR';
1421
        $aFont = $this->formatPadrao;
1422
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1423
        $aFont = $this->formatNegrito;
1424
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1425
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1426
        $y += 3;
1427
        $texto = 'ENDEREÇO';
1428
        $aFont = $this->formatPadrao;
1429
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1430
        $aFont = $this->formatNegrito;
1431
        if (isset($this->enderExped)) {
1432
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1433
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1434
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1435
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1436
                '';
1437
        } else {
1438
            $texto = '';
1439
        }
1440
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1441
        $y += 3;
1442
        $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...
1443
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1444
        $y += 3;
1445
        $texto = 'MUNICÍPIO';
1446
        $aFont = $this->formatPadrao;
1447
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1448
        if (isset($this->enderExped)) {
1449
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1450
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1451
        } else {
1452
            $texto = '';
1453
        }
1454
        $aFont = $this->formatNegrito;
1455
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1456
        $x = $w - 18;
1457
        $texto = 'CEP';
1458
        $aFont = $this->formatPadrao;
1459
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1460
        $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...
1461
        $aFont = $this->formatNegrito;
1462
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1463
        $x = $oldX;
1464
        $y += 3;
1465
        $texto = 'CNPJ/CPF';
1466
        $aFont = $this->formatPadrao;
1467
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1468
        $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...
1469
        $aFont = $this->formatNegrito;
1470
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1471
        $x = $w - 45;
1472
        $texto = 'INSCRIÇÃO ESTADUAL';
1473
        $aFont = $this->formatPadrao;
1474
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1475
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1476
        $aFont = $this->formatNegrito;
1477
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1478
        $x = $oldX;
1479
        $y += 3;
1480
        $texto = 'PAÍS';
1481
        $aFont = $this->formatPadrao;
1482
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1483
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1484
        $aFont = $this->formatNegrito;
1485
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1486
        $x = $w - 25;
1487
        $texto = 'FONE';
1488
        $aFont = $this->formatPadrao;
1489
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1490
        if (isset($this->exped)) {
1491
            $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...
1492
            $aFont = $this->formatNegrito;
1493
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1494
        }
1495
    } //fim da função remetenteDACTE
1496
1497
    /**
1498
     * zRecebedor
1499
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1500
     *
1501
     * @param  number $x Posição horizontal canto esquerdo
1502
     * @param  number $y Posição vertical canto superior
1503
     * @return number Posição vertical final
1504
     */
1505
    protected function zRecebedor($x = 0, $y = 0)
1506
    {
1507
        $oldX = $x;
1508
        $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...
1509
        if ($this->orientacao == 'P') {
1510
            $maxW = $this->wPrint;
1511
        } else {
1512
            $maxW = $this->wPrint - $this->wCanhoto;
1513
        }
1514
        $w = ($maxW * 0.5) - 0.7;
1515
        $h = 19;
1516
        $x1 = $x + 19;
1517
        $texto = 'RECEBEDOR';
1518
        $aFont = $this->formatPadrao;
1519
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1520
        $aFont = $this->formatNegrito;
1521
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1522
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1523
        $y += 3;
1524
        $texto = 'ENDEREÇO';
1525
        $aFont = $this->formatPadrao;
1526
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1527
        $aFont = $this->formatNegrito;
1528
        if (isset($this->enderReceb)) {
1529
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1530
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1531
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1532
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1533
                '';
1534
        } else {
1535
            $texto = '';
1536
        }
1537
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1538
        $y += 3;
1539
        $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...
1540
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1541
        $y += 3;
1542
        $texto = 'MUNICÍPIO';
1543
        $aFont = $this->formatPadrao;
1544
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1545
        if (isset($this->enderReceb)) {
1546
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1547
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1548
        } else {
1549
            $texto = '';
1550
        }
1551
        $aFont = $this->formatNegrito;
1552
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1553
        $x = $w - 19 + $oldX;
1554
        $texto = 'CEP';
1555
        $aFont = $this->formatPadrao;
1556
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1557
        $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...
1558
        $aFont = $this->formatNegrito;
1559
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1560
        $x = $oldX;
1561
        $y += 3;
1562
        $texto = 'CNPJ/CPF';
1563
        $aFont = $this->formatPadrao;
1564
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1565
        $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...
1566
        $aFont = $this->formatNegrito;
1567
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1568
        $x = $w - 47 + $oldX;
1569
        $texto = 'INSCRIÇÃO ESTADUAL';
1570
        $aFont = $this->formatPadrao;
1571
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1572
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1573
        $aFont = $this->formatNegrito;
1574
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1575
        $x = $oldX;
1576
        $y += 3;
1577
        $texto = 'PAÍS';
1578
        $aFont = $this->formatPadrao;
1579
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1580
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1581
        $aFont = $this->formatNegrito;
1582
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1583
        $x = $w - 27 + $oldX;
1584
        $texto = 'FONE';
1585
        $aFont = $this->formatPadrao;
1586
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1587
        if (isset($this->receb)) {
1588
            $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...
1589
            $aFont = $this->formatNegrito;
1590
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1591
        }
1592
    } //fim da função recebedorDACTE
1593
1594
    /**
1595
     * zTomador
1596
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1597
     *
1598
     * @param  number $x Posição horizontal canto esquerdo
1599
     * @param  number $y Posição vertical canto superior
1600
     * @return number Posição vertical final
1601
     */
1602
    protected function zTomador($x = 0, $y = 0)
1603
    {
1604
        $oldX = $x;
1605
        $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...
1606
        if ($this->orientacao == 'P') {
1607
            $maxW = $this->wPrint;
1608
        } else {
1609
            $maxW = $this->wPrint - $this->wCanhoto;
1610
        }
1611
        $w = $maxW;
1612
        $h = 10;
1613
        $texto = 'TOMADOR DO SERVIÇO';
1614
        $aFont = $this->formatPadrao;
1615
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1616
        $aFont = $this->formatNegrito;
1617
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1618
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1619
        $x = $maxW * 0.60;
1620
        $texto = 'MUNICÍPIO';
1621
        $aFont = $this->formatPadrao;
1622
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1623
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1624
        $aFont = $this->formatNegrito;
1625
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1626
        $x = $maxW * 0.85;
1627
        $texto = 'UF';
1628
        $aFont = $this->formatPadrao;
1629
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1630
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1631
        $aFont = $this->formatNegrito;
1632
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1633
        $x = $w - 18;
1634
        $texto = 'CEP';
1635
        $aFont = $this->formatPadrao;
1636
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1637
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1638
        $aFont = $this->formatNegrito;
1639
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1640
        $y += 3;
1641
        $x = $oldX;
1642
        $texto = 'ENDEREÇO';
1643
        $aFont = $this->formatPadrao;
1644
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1645
        $aFont = $this->formatNegrito;
1646
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1647
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1648
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1649
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1650
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1651
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1652
        $y += 3;
1653
        $texto = 'CNPJ/CPF';
1654
        $aFont = $this->formatPadrao;
1655
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1656
        $texto = $this->zFormatCNPJCPF($this->toma);
1657
        $aFont = $this->formatNegrito;
1658
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1659
        $x = $x + 65;
1660
        $texto = 'INSCRIÇÃO ESTADUAL';
1661
        $aFont = $this->formatPadrao;
1662
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1663
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1664
        $aFont = $this->formatNegrito;
1665
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1666
        $x = $w * 0.75;
1667
        $texto = 'PAÍS';
1668
        $aFont = $this->formatPadrao;
1669
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1670
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1671
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1672
        $aFont = $this->formatNegrito;
1673
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1674
        $x = $w - 27;
1675
        $texto = 'FONE';
1676
        $aFont = $this->formatPadrao;
1677
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1678
        $texto = $this->pSimpleGetValue($this->toma, "fone")!=""? $this->zFormatFone($this->toma):'';
1679
        $aFont = $this->formatNegrito;
1680
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1681
    } //fim da função tomadorDACTE
1682
1683
    /**
1684
     * zDescricaoCarga
1685
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1686
     *
1687
     * @param  number $x Posição horizontal canto esquerdo
1688
     * @param  number $y Posição vertical canto superior
1689
     * @return number Posição vertical final
1690
     */
1691
    protected function zDescricaoCarga($x = 0, $y = 0)
1692
    {
1693
        $oldX = $x;
1694
        $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...
1695
        if ($this->orientacao == 'P') {
1696
            $maxW = $this->wPrint;
1697
        } else {
1698
            $maxW = $this->wPrint - $this->wCanhoto;
1699
        }
1700
        $w = $maxW;
1701
        $h = 17;
1702
        $texto = 'PRODUTO PREDOMINANTE';
1703
        $aFont = array(
1704
            'font' => $this->fontePadrao,
1705
            'size' => 6,
1706
            'style' => '');
1707
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1708
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1709
        $aFont = $this->formatNegrito;
1710
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1711
        $x = $w * 0.56;
1712
        $this->pdf->Line($x, $y, $x, $y + 8);
1713
        $aFont = $this->formatPadrao;
1714
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1715
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1716
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1717
        $aFont = $this->formatNegrito;
1718
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1719
        $x = $w * 0.8;
1720
        $this->pdf->Line($x, $y, $x, $y + 8);
1721
        $aFont = $this->formatPadrao;
1722
        $texto = 'VALOR TOTAL DA CARGA';
1723
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1724
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1725
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1726
        $texto = number_format($texto, 2, ",", ".");
1727
        $aFont = $this->formatNegrito;
1728
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1729
        $y += 8;
1730
        $x = $oldX;
1731
        $this->pdf->Line($x, $y, $w + 1, $y);
1732
        $texto = 'PESO BRUTO (KG)';
1733
        $aFont = array(
1734
            'font' => $this->fontePadrao,
1735
            'size' => 5,
1736
            'style' => '');
1737
        $this->pTextBox($x+8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1738
        //$texto = $this->pSimpleGetValue($this->infQ->item(0), "qCarga") . "\r\n";
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...
1739
        $texto = number_format(
1740
            $this->pSimpleGetValue(
1741
                $this->infQ->item(0),
1742
                "qCarga"
1743
            ),
1744
            3,
1745
            ",",
1746
            "."
1747
        );
1748
        //$texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(0), "cUnid"));
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...
1749
        $aFont = array(
1750
            'font' => $this->fontePadrao,
1751
            'size' => 7,
1752
            'style' => 'B');
1753
        $this->pTextBox($x+2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1754
        $x = $w * 0.12;
1755
        $this->pdf->Line($x+13.5, $y, $x+13.5, $y + 9);
1756
        $texto = 'PESO BASE CÁLCULO (KG)';
1757
        $aFont = array(
1758
            'font' => $this->fontePadrao,
1759
            'size' => 5,
1760
            'style' => '');
1761
        $this->pTextBox($x+20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1762
        $texto = number_format(
1763
            $this->pSimpleGetValue(
1764
                $this->infQ->item(0),
1765
                "qCarga"
1766
            ),
1767
            3,
1768
            ",",
1769
            "."
1770
        );
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
        $texto = 'PESO AFERIDO (KG)';
1779
        $aFont = array(
1780
            'font' => $this->fontePadrao,
1781
            'size' => 5,
1782
            'style' => '');
1783
        $this->pTextBox($x+35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1784
        $texto = number_format(
1785
            $this->pSimpleGetValue(
1786
                $this->infQ->item(0),
1787
                "qCarga"
1788
            ),
1789
            3,
1790
            ",",
1791
            "."
1792
        );
1793
        $aFont = array(
1794
            'font' => $this->fontePadrao,
1795
            'size' => 7,
1796
            'style' => 'B');
1797
        $this->pTextBox($x+28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1798
        $x = $w * 0.36;
1799
        $this->pdf->Line($x+41.3, $y, $x+41.3, $y + 9);
1800
        $texto = 'CUBAGEM(M3)';
1801
        $aFont = $this->formatPadrao;
1802
        $this->pTextBox($x+60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1803
        $qCarga = '';
1804
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '00') {
1805
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1806
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == '00') {
1807
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1808
        } elseif ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == '00') {
1809
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1810
        }
1811
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1812
        $aFont = array(
1813
            'font' => $this->fontePadrao,
1814
            'size' => 7,
1815
            'style' => 'B');
1816
        $this->pTextBox($x+50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1817
        $x = $w * 0.45;
1818
        //$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...
1819
        $texto = 'QTDE(VOL)';
1820
        $aFont = $this->formatPadrao;
1821
        $this->pTextBox($x+85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1822
        $qCarga = '';
1823
        if ($this->pSimpleGetValue($this->infQ->item(2), "cUnid") == 03) {
1824
            $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1825
        } elseif ($this->pSimpleGetValue($this->infQ->item(1), "cUnid") == 03) {
1826
            $qCarga = $this->pSimpleGetValue($this->infQ->item(1), "qCarga");
1827
        }
1828
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1829
        $aFont = array(
1830
            'font' => $this->fontePadrao,
1831
            'size' => 7,
1832
            'style' => 'B');
1833
        $this->pTextBox($x+85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1834
        $x = $w * 0.53;
1835
        $this->pdf->Line($x+56, $y, $x+56, $y + 9);
1836
        /*$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...
1837
        $aFont = $this->formatPadrao;
1838
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1839
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1840
        $aFont = array(
1841
            'font' => $this->fontePadrao,
1842
            'size' => 7,
1843
            'style' => 'B');
1844
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1845
        $y += 3;
1846
        $this->pdf->Line($x, $y, $w + 1, $y);
1847
        $texto = 'RESPONSÁVEL';
1848
        $aFont = $this->formatPadrao;
1849
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1850
        $texto = $this->respSeg;
1851
        $aFont = array(
1852
            'font' => $this->fontePadrao,
1853
            'size' => 7,
1854
            'style' => 'B');
1855
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1856
        $x = $w * 0.68;
1857
        $this->pdf->Line($x, $y, $x, $y + 6);
1858
        $texto = 'NÚMERO DA APOLICE';
1859
        $aFont = $this->formatPadrao;
1860
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1861
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1862
        $aFont = array(
1863
            'font' => $this->fontePadrao,
1864
            'size' => 7,
1865
            'style' => 'B');
1866
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1867
        $x = $w * 0.85;
1868
        $this->pdf->Line($x, $y, $x, $y + 6);
1869
        $texto = 'NÚMERO DA AVERBAÇÃO';
1870
        $aFont = $this->formatPadrao;
1871
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1872
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
1873
        $aFont = array(
1874
            'font' => $this->fontePadrao,
1875
            'size' => 7,
1876
            'style' => 'B');
1877
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1878
    } //fim da função zDescricaoCarga
1879
1880
    /**
1881
     * zCompValorServ
1882
     * Monta o campo com os componentes da prestação de serviços.
1883
     *
1884
     * @param  number $x Posição horizontal canto esquerdo
1885
     * @param  number $y Posição vertical canto superior
1886
     * @return number Posição vertical final
1887
     */
1888
    protected function zCompValorServ($x = 0, $y = 0)
1889
    {
1890
        $oldX = $x;
1891
        $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...
1892
        if ($this->orientacao == 'P') {
1893
            $maxW = $this->wPrint;
1894
        } else {
1895
            $maxW = $this->wPrint - $this->wCanhoto;
1896
        }
1897
        $w = $maxW;
1898
        $h = 25;
1899
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1900
        $aFont = $this->formatPadrao;
1901
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1902
        $y += 3.4;
1903
        $this->pdf->Line($x, $y, $w + 1, $y);
1904
        $texto = 'NOME';
1905
        $aFont = $this->formatPadrao;
1906
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1907
        $yIniDados = $y;
1908
        $x = $w * 0.14;
1909
        $texto = 'VALOR';
1910
        $aFont = $this->formatPadrao;
1911
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1912
        $x = $w * 0.28;
1913
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1914
        $texto = 'NOME';
1915
        $aFont = $this->formatPadrao;
1916
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1917
        $x = $w * 0.42;
1918
        $texto = 'VALOR';
1919
        $aFont = $this->formatPadrao;
1920
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1921
        $x = $w * 0.56;
1922
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1923
        $texto = 'NOME';
1924
        $aFont = $this->formatPadrao;
1925
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1926
        $x = $w * 0.70;
1927
        $texto = 'VALOR';
1928
        $aFont = $this->formatPadrao;
1929
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1930
        $x = $w * 0.86;
1931
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1932
        $y += 1;
1933
        $texto = 'VALOR TOTAL DO SERVIÇO';
1934
        $aFont = $this->formatPadrao;
1935
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1936
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1937
        $aFont = array(
1938
            'font' => $this->fontePadrao,
1939
            'size' => 9,
1940
            'style' => 'B');
1941
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1942
        $y += 10;
1943
        $this->pdf->Line($x, $y, $w + 1, $y);
1944
        $y += 1;
1945
        $texto = 'VALOR A RECEBER';
1946
        $aFont = $this->formatPadrao;
1947
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1948
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1949
        $aFont = array(
1950
            'font' => $this->fontePadrao,
1951
            'size' => 9,
1952
            'style' => 'B');
1953
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1954
        $auxX = $oldX;
1955
        $yIniDados += 4;
1956
        foreach ($this->Comp as $k => $d) {
1957
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1958
            $valor = number_format(
1959
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1960
                2,
1961
                ",",
1962
                "."
1963
            );
1964
            if ($auxX > $w * 0.60) {
1965
                $yIniDados = $yIniDados + 4;
1966
                $auxX = $oldX;
1967
            }
1968
            $texto = $nome;
1969
            $aFont = $this->formatPadrao;
1970
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1971
            $auxX += $w * 0.14;
1972
            $texto = $valor;
1973
            $aFont = $this->formatPadrao;
1974
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1975
            $auxX += $w * 0.14;
1976
        }
1977
    } //fim da função compValorDACTE
1978
1979
    /**
1980
     * zImpostos
1981
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1982
     *
1983
     * @param  number $x Posição horizontal canto esquerdo
1984
     * @param  number $y Posição vertical canto superior
1985
     * @return number Posição vertical final
1986
     */
1987
    protected function zImpostos($x = 0, $y = 0)
1988
    {
1989
        $oldX = $x;
1990
        $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...
1991
        if ($this->orientacao == 'P') {
1992
            $maxW = $this->wPrint;
1993
        } else {
1994
            $maxW = $this->wPrint - $this->wCanhoto;
1995
        }
1996
        $w = $maxW;
1997
        $h = 13;
1998
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1999
        $aFont = $this->formatPadrao;
2000
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2001
        
2002
        $y += 3.4;
2003
        $this->pdf->Line($x, $y, $w + 1, $y);
2004
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
2005
        $aFont = $this->formatPadrao;
2006
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2007
        
2008
        $x += $w * 0.26;
2009
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2010
        $texto = 'BASE DE CALCULO';
2011
        $aFont = $this->formatPadrao;
2012
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2013
        
2014
        $wCol02=0.18;
2015
        $x += $w * $wCol02;
2016
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2017
        $texto = 'ALÍQ ICMS';
2018
        $aFont = $this->formatPadrao;
2019
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2020
        
2021
        $x += $w * $wCol02;
2022
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2023
        $texto = 'VALOR ICMS';
2024
        $aFont = $this->formatPadrao;
2025
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2026
        
2027
        $x += $w * $wCol02;
2028
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2029
        $texto = '% RED. BC ICMS';
2030
        $aFont = $this->formatPadrao;
2031
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2032
        
2033
        /*$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...
2034
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2035
        $texto = 'ICMS ST';
2036
        $aFont = $this->formatPadrao;
2037
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2038
         * */
2039
        
2040
        $x = $oldX;
2041
        $y = $y + 4;
2042
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2043
        switch ($texto) {
2044
            case '00':
2045
                $texto = "00 - Tributação normal ICMS";
2046
                break;
2047
            case '20':
2048
                $texto = "20 - Tributação com BC reduzida do ICMS";
2049
                break;
2050
            case '40':
2051
                $texto = "40 - ICMS isenção";
2052
                break;
2053
            case '41':
2054
                $texto = "41 - ICMS não tributada";
2055
                break;
2056
            case '51':
2057
                $texto = "51 - ICMS diferido";
2058
                break;
2059
            case '60':
2060
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2061
                break;
2062
            case '90':
2063
                $texto = "90 - ICMS outros";
2064
                break;
2065
        }
2066
        $texto .= $this->pSimpleGetValue($this->ICMSSN, "indSN");
2067
        $texto = $texto == 1 ? 'Simples Nacional' : $texto;
2068
        $aFont = $this->formatNegrito;
2069
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2070
        $x += $w * 0.26;
2071
        
2072
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2073
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : '';
2074
        $aFont = $this->formatNegrito;
2075
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2076
        $x += $w * $wCol02;
2077
        
2078
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2079
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
2080
        $aFont = $this->formatNegrito;
2081
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2082
        $x += $w * $wCol02;
2083
        
2084
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2085
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
2086
        $aFont = $this->formatNegrito;
2087
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2088
        $x += $w * $wCol02;
2089
        
2090
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2091
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
2092
        $aFont = $this->formatNegrito;
2093
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2094
        
2095
        /*$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...
2096
        $texto = '';
2097
        $aFont = $this->formatNegrito;
2098
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2099
    } //fim da função compValorDACTE
2100
2101
    /**
2102
     * zGeraChaveAdicCont
2103
     *
2104
     * @return string chave
2105
     */
2106
    protected function zGeraChaveAdicCont()
2107
    {
2108
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2109
        // 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...
2110
        $forma = "%02d%d%s%014d%01d%01d%02d";
2111
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2112
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2113
        $CNPJ = substr($CNPJ, -14);
2114
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2115
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2116
        switch ($ICMS_CST) {
2117
            case '00':
2118
            case '20':
2119
                $ICMSp = '1';
2120
                $ICMSs = '2';
2121
                break;
2122
            case '40':
2123
            case '41':
2124
            case '51':
2125
            case '90':
2126
                $ICMSp = '2';
2127
                $ICMSs = '2';
2128
                break;
2129
            case '60':
2130
                $ICMSp = '2';
2131
                $ICMSs = '1';
2132
                break;
2133
        }
2134
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2135
        $rpos = strrpos($dd, '-');
2136
        $dd = substr($dd, $rpos + 1);
2137
        $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...
2138
        $chave = $chave . $this->pModulo11($chave);
2139
        return $chave;
2140
    } //fim zGeraChaveAdicCont
2141
2142
    /**
2143
     * zDocOrig
2144
     * Monta o campo com os documentos originarios.
2145
     *
2146
     * @param  number $x Posição horizontal canto esquerdo
2147
     * @param  number $y Posição vertical canto superior
2148
     * @return number Posição vertical final
2149
     */
2150
    protected function zDocOrig($x = 0, $y = 0)
2151
    {
2152
        $oldX = $x;
2153
        $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...
2154
        if ($this->orientacao == 'P') {
2155
            $maxW = $this->wPrint;
2156
        } else {
2157
            $maxW = $this->wPrint - $this->wCanhoto;
2158
        }
2159
        $w = $maxW;
2160
2161
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2162
        if ($this->modal == '1') {
2163
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2164
            // ou combinação veicular, e por viagem
2165
            $h = $this->lota == 1 ? 35 : 53;
2166
        } elseif ($this->modal == '3') {
2167
            $h = 37.6;
2168
        } else {
2169
            $h = 35;
2170
        }
2171
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2172
        $aFont = $this->formatPadrao;
2173
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2174
        $descr1 = 'TIPO DOC';
2175
        $descr2 = 'CNPJ/CHAVE/OBS';
2176
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2177
2178
        $y += 3.4;
2179
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2180
        $texto = $descr1;
2181
        $aFont = $this->formatPadrao;
2182
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2183
        $yIniDados = $y;
2184
2185
        $x += $w * 0.07;
2186
        $texto = $descr2;
2187
        $aFont = $this->formatPadrao;
2188
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2189
2190
        $x += $w * 0.28;
2191
        $texto = $descr3;
2192
        $aFont = $this->formatPadrao;
2193
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2194
2195
        $x += $w * 0.14;
2196
        if ($this->modal == '1') {
2197
            if ($this->lota == 1) {
2198
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2199
            } else {
2200
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2201
            }
2202
        } elseif ($this->modal == '3') {
2203
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2204
        } else {
2205
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2206
        }
2207
        $texto = $descr1;
2208
        $aFont = $this->formatPadrao;
2209
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2210
2211
        $x += $w * 0.08;
2212
        $texto = $descr2;
2213
        $aFont = $this->formatPadrao;
2214
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2215
2216
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2217
        $texto = $descr3;
2218
        $aFont = $this->formatPadrao;
2219
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2220
        $auxX = $oldX;
2221
        $yIniDados += 3;
2222
        foreach ($this->infNF as $k => $d) {
2223
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2224
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2225
            $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...
2226
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2227
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2228
            if ($auxX > $w * 0.90) {
2229
                $yIniDados = $yIniDados + 3;
2230
                $auxX = $oldX;
2231
            }
2232
            $texto = $tp;
2233
            $aFont = array(
2234
                'font' => $this->fontePadrao,
2235
                'size' => 8,
2236
                'style' => '');
2237
            //$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...
2238
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2239
            //$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...
2240
            $auxX += $w * 0.07;
2241
            $texto = $cnpj;
2242
            $aFont = array(
2243
                'font' => $this->fontePadrao,
2244
                'size' => 8,
2245
                'style' => '');
2246
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2247
            $auxX += $w * 0.28;
2248
            $texto = $doc;
2249
            $aFont = array(
2250
                'font' => $this->fontePadrao,
2251
                'size' => 8,
2252
                'style' => '');
2253
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2254
            $auxX += $w * 0.15;
2255
        }
2256
2257
        foreach ($this->infNFe as $k => $d) {
2258
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2259
            $this->arrayNFe[] = $chaveNFe;
2260
        }
2261
        $qtdeNFe = 1;
2262
        if (count($this->arrayNFe) >15) {
2263
            $this->flagDocOrigContinuacao = 1;
2264
            $qtdeNFe = count($this->arrayNFe);
2265
        }
2266
//        $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...
2267
        switch ($qtdeNFe) {
2268
            default:
2269
                $this->totPag = 1;
2270
            case ($qtdeNFe >= 1044):
2271
                $this->totPag = 11;
2272
                break;
2273
            case ($qtdeNFe > 928):
2274
                $this->totPag = 10;
2275
                break;
2276
            case ($qtdeNFe > 812):
2277
                $this->totPag = 9;
2278
                break;
2279
            case ($qtdeNFe > 696):
2280
                $this->totPag = 8;
2281
                break;
2282
            case ($qtdeNFe > 580):
2283
                $this->totPag = 7;
2284
                break;
2285
            case ($qtdeNFe > 464):
2286
                $this->totPag = 6;
2287
                break;
2288
            case ($qtdeNFe > 348):
2289
                $this->totPag = 5;
2290
                break;
2291
            case ($qtdeNFe > 232):
2292
                $this->totPag = 4;
2293
                break;
2294
            case ($qtdeNFe > 116):
2295
                $this->totPag = 3;
2296
                break;
2297
            case ($qtdeNFe > 16):
2298
                $this->totPag = 2;
2299
                break;
2300
            case ($qtdeNFe <= 16):
2301
                $this->totPag = 1;
2302
                break;
2303
        }
2304
        $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...
2305
        $contador = 0;
2306
        while ($contador < count($this->arrayNFe)) {
2307
            if ($contador == 15) {
2308
                break;
2309
            }
2310
            $tp = 'NF-e';
2311
            $chaveNFe = $this->arrayNFe[$contador];
2312
            $numNFe = substr($chaveNFe, 25, 9);
2313
            $serieNFe = substr($chaveNFe, 22, 3);
2314
            $doc = $serieNFe . '/' . $numNFe;
2315
            if ($auxX > $w * 0.90) {
2316
                $yIniDados = $yIniDados + 3.5;
2317
                $auxX = $oldX;
2318
            }
2319
            $texto = $tp;
2320
            $aFont = array(
2321
                'font' => $this->fontePadrao,
2322
                'size' => 7,
2323
                'style' => '');
2324
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2325
            $auxX += $w * 0.07;
2326
            $texto = $chaveNFe;
2327
            $aFont = array(
2328
                'font' => $this->fontePadrao,
2329
                'size' => 7,
2330
                'style' => '');
2331
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2332
            $auxX += $w * 0.28;
2333
            $texto = $doc;
2334
            $aFont = array(
2335
                'font' => $this->fontePadrao,
2336
                'size' => 7,
2337
                'style' => '');
2338
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2339
            $auxX += $w * 0.15;
2340
            $contador++;
2341
        }
2342
2343
        foreach ($this->infOutros as $k => $d) {
2344
            $temp = $this->infOutros->item($k);
2345
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2346
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2347
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2348
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2349
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2350
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2351
            switch ($tpDoc) {
2352
                case "00":
2353
                    $tpDoc = "00 - Declaração";
2354
                    break;
2355
                case "10":
2356
                    $tpDoc = "10 - Dutoviário";
2357
                    break;
2358
                case "99":
2359
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2360
                    break;
2361
                default:
2362
                    break;
2363
            }
2364
            $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...
2365
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2366
            if ($auxX > $w * 0.90) {
2367
                $yIniDados = $yIniDados + 4;
2368
                $auxX = $oldX;
2369
            }
2370
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2371
            $auxX += $w * 0.09;
2372
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2373
            $auxX += $w * 0.28;
2374
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2375
            $auxX += $w * 0.14;
2376
        }
2377
        foreach ($this->idDocAntEle as $k => $d) {
2378
            $tp = 'CT-e';
2379
            $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...
2380
            $numCTe = substr($chaveCTe, 25, 9);
2381
            $serieCTe = substr($chaveCTe, 22, 3);
2382
            $doc = $serieCTe . '/' . $numCTe;
2383
            if ($auxX > $w * 0.90) {
2384
                $yIniDados = $yIniDados + 4;
2385
                $auxX = $oldX;
2386
            }
2387
            $texto = $tp;
2388
            $aFont = array(
2389
                'font' => $this->fontePadrao,
2390
                'size' => 8,
2391
                'style' => '');
2392
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2393
            $auxX += $w * 0.09;
2394
            $texto = $chaveCTe;
2395
            $aFont = array(
2396
                'font' => $this->fontePadrao,
2397
                'size' => 8,
2398
                'style' => '');
2399
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2400
            $auxX += $w * 0.28;
2401
            $texto = $doc;
2402
            $aFont = array(
2403
                'font' => $this->fontePadrao,
2404
                'size' => 8,
2405
                'style' => '');
2406
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2407
            $auxX += $w * 0.14;
2408
        }
2409
    } //fim da função zDocOrig
2410
2411
    /**
2412
     * zDocOrigContinuacao
2413
     * Monta o campo com os documentos originarios.
2414
     *
2415
     * @param  number $x Posição horizontal canto esquerdo
2416
     * @param  number $y Posição vertical canto superior
2417
     * @return number Posição vertical final
2418
     */
2419
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2420
    {
2421
        $x2 = $x;
2422
        $y2 = $y;
2423
        $contador = 16;
2424
        for ($i = 2; $i <= $this->totPag; $i++) {
2425
            $x = $x2;
2426
            $y = $y2;
2427
            $this->pdf->AddPage($this->orientacao, $this->papel);
2428
            $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...
2429
            $oldX = $x;
2430
            $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...
2431
            if ($this->orientacao == 'P') {
2432
                $maxW = $this->wPrint;
2433
            } else {
2434
                $maxW = $this->wPrint - $this->wCanhoto;
2435
            }
2436
            $w = $maxW;
2437
2438
            //$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...
2439
            //$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...
2440
            //$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...
2441
            //$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...
2442
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2443
            if (count($this->arrayNFe)%2 !=0) {
2444
                $h = $h+3.5;
2445
            } // Caso tenha apenas 1 registro na ultima linha
2446
2447
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2448
            $aFont = $this->formatPadrao;
2449
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2450
            $descr1 = 'TIPO DOC';
2451
            $descr2 = 'CNPJ/CHAVE/OBS';
2452
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2453
2454
            $y += 3.4;
2455
            $this->pdf->Line($x, $y, $w + 1, $y);
2456
            $texto = $descr1;
2457
            $aFont = $this->formatPadrao;
2458
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2459
            $yIniDados = $y;
2460
2461
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2462
            $texto = $descr2;
2463
            $aFont = $this->formatPadrao;
2464
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2465
2466
            $x += $w * 0.28;
2467
            $texto = $descr3;
2468
            $aFont = $this->formatPadrao;
2469
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2470
2471
            $x += $w * 0.14;
2472
            if ($this->modal == '1') {
2473
                if ($this->lota == 1) {
2474
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2475
                } else {
2476
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2477
                }
2478
            } elseif ($this->modal == '3') {
2479
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2480
            } else {
2481
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2482
            }
2483
            $texto = $descr1;
2484
            $aFont = $this->formatPadrao;
2485
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2486
2487
            $x += $w * 0.08;
2488
            $texto = $descr2;
2489
            $aFont = $this->formatPadrao;
2490
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2491
2492
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2493
            $texto = $descr3;
2494
            $aFont = $this->formatPadrao;
2495
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2496
            $auxX = $oldX;
2497
            $yIniDados += 3;
2498
2499
            while ($contador < (count($this->arrayNFe))) {
2500
                if ($contador%(116*($i-1)) == 0) {
2501
//                    $contador++;
2502
                    break;
2503
                }
2504
                $tp = 'NF-e';
2505
                $chaveNFe = $this->arrayNFe[$contador];
2506
                $numNFe = substr($chaveNFe, 25, 9);
2507
                $serieNFe = substr($chaveNFe, 22, 3);
2508
                $doc = $serieNFe . '/' . $numNFe;
2509
                if ($auxX > $w * 0.90) {
2510
                    $yIniDados = $yIniDados + 3.5;
2511
                    $auxX = $oldX;
2512
                }
2513
                $texto = $tp;
2514
                $aFont = array(
2515
                    'font' => $this->fontePadrao,
2516
                    'size' => 7,
2517
                    'style' => '');
2518
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2519
                $auxX += $w * 0.07;
2520
                $texto = $chaveNFe;
2521
                $aFont = array(
2522
                    'font' => $this->fontePadrao,
2523
                    'size' => 7,
2524
                    'style' => '');
2525
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2526
                $auxX += $w * 0.28;
2527
                $texto = $doc;
2528
                $aFont = array(
2529
                    'font' => $this->fontePadrao,
2530
                    'size' => 7,
2531
                    'style' => '');
2532
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2533
                $auxX += $w * 0.15;
2534
                $contador++;
2535
            }
2536
        }
2537
    } //fim da função zDocOrigContinuacao
2538
2539
    /**
2540
     * zDocCompl
2541
     * Monta o campo com os dados do remetente na DACTE.
2542
     *
2543
     * @param number $x Posição horizontal canto esquerdo
2544
     * @param number $y Posição vertical canto superior
2545
     * @return number Posição vertical final
2546
     */
2547
    protected function zDocCompl($x = 0, $y = 0)
2548
    {
2549
        $oldX = $x;
2550
        $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...
2551
        if ($this->orientacao == 'P') {
2552
            $maxW = $this->wPrint;
2553
        } else {
2554
            $maxW = $this->wPrint - $this->wCanhoto;
2555
        }
2556
        $w = $maxW;
2557
        $h = 80;
2558
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2559
        $aFont = $this->formatPadrao;
2560
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2561
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2562
        $descr2 = 'VALOR COMPLEMENTADO';
2563
        $y += 3.4;
2564
        $this->pdf->Line($x, $y, $w + 1, $y);
2565
        $texto = $descr1;
2566
        $aFont = $this->formatPadrao;
2567
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2568
        $yIniDados = $y;
2569
        $x += $w * 0.37;
2570
        $texto = $descr2;
2571
        $aFont = $this->formatPadrao;
2572
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2573
        $x += $w * 0.13;
2574
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2575
        $texto = $descr1;
2576
        $aFont = $this->formatPadrao;
2577
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2578
        $x += $w * 0.3;
2579
        $texto = $descr2;
2580
        $aFont = $this->formatPadrao;
2581
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2582
        $auxX = $oldX;
2583
        $yIniDados += 4;
2584
        if ($auxX > $w * 0.90) {
2585
            $yIniDados = $yIniDados + 4;
2586
            $auxX = $oldX;
2587
        }
2588
        $texto = $this->chaveCTeRef;
2589
        $aFont = array(
2590
            'font' => $this->fontePadrao,
2591
            'size' => 8,
2592
            'style' => '');
2593
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2594
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2595
        $aFont = array(
2596
            'font' => $this->fontePadrao,
2597
            'size' => 8,
2598
            'style' => '');
2599
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2600
    } //fim da função zDocCompl
2601
2602
    /**
2603
     * zObs
2604
     * Monta o campo com os dados do remetente na DACTE.
2605
     *
2606
     * @param  number $x Posição horizontal canto esquerdo
2607
     * @param  number $y Posição vertical canto superior
2608
     * @return number Posição vertical final
2609
     */
2610
    protected function zObs($x = 0, $y = 0)
2611
    {
2612
        $oldX = $x;
2613
        $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...
2614
        if ($this->orientacao == 'P') {
2615
            $maxW = $this->wPrint;
2616
        } else {
2617
            $maxW = $this->wPrint - $this->wCanhoto;
2618
        }
2619
        $w = $maxW;
2620
        //$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...
2621
        $h = 18.8;
2622
        $texto = 'OBSERVAÇÕES';
2623
        $aFont = $this->formatPadrao;
2624
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2625
        $y += 3.4;
2626
        $this->pdf->Line($x, $y, $w + 1, $y);
2627
        $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...
2628
        $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...
2629
        $texto = '';
2630
        foreach ($this->compl as $k => $d) {
2631
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2632
            $texto .= $xObs;
2633
        }
2634
        $textoObs = explode("Motorista:", $texto);
2635
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2636
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2637
        $aFont = array(
2638
            'font' => $this->fontePadrao,
2639
            'size' => 7.5,
2640
            'style' => '');
2641
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2642
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2643
    } //fim da função obsDACTE
2644
2645
    /**
2646
     * zModalRod
2647
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2648
     *
2649
     * @param  number $x Posição horizontal canto esquerdo
2650
     * @param  number $y Posição vertical canto superior
2651
     * @return number Posição vertical final
2652
     */
2653
    protected function zModalRod($x = 0, $y = 0)
2654
    {
2655
        $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...
2656
        $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...
2657
        $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...
2658
        if ($this->orientacao == 'P') {
2659
            $maxW = $this->wPrint;
2660
        } else {
2661
            $maxW = $this->wPrint - $this->wCanhoto;
2662
        }
2663
        $w = $maxW;
2664
        $h = 18.5;
2665
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2666
        $aFont = $this->formatPadrao;
2667
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2668
        if ($this->lota == 1) {
2669
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2670
        }
2671
        $y += 3.4;
2672
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2673
        $texto = 'RNTRC DA EMPRESA';
2674
        $aFont = $this->formatPadrao;
2675
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2676
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2677
        $aFont = $this->formatNegrito;
2678
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2679
        $x += $w * 0.23;
2680
        
2681
        $this->pdf->Line($x-20, $y, $x-20, $y + 8.5); // LINHA A FRENTE DA RNTRC DA EMPRESA
2682
        
2683
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2684
        $aFont = $this->formatPadrao;
2685
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2686
    } //fim da função zModalRod
2687
2688
    /**
2689
     * zModalAquaviario
2690
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2691
     *
2692
     * @param  number $x Posição horizontal canto esquerdo
2693
     * @param  number $y Posição vertical canto superior
2694
     * @return number Posição vertical final
2695
     */
2696
    protected function zModalAquaviario($x = 0, $y = 0)
2697
    {
2698
        $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...
2699
        $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...
2700
        if ($this->orientacao == 'P') {
2701
            $maxW = $this->wPrint;
2702
        } else {
2703
            $maxW = $this->wPrint - $this->wCanhoto;
2704
        }
2705
        $w = $maxW;
2706
        $h = 8.5;
2707
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2708
        $aFont = $this->formatPadrao;
2709
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2710
        $y += 3.4;
2711
        $this->pdf->Line($x, $y, $w + 1, $y);
2712
        $texto = 'PORTO DE EMBARQUE';
2713
        $aFont = $this->formatPadrao;
2714
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2715
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2716
        $aFont = $this->formatNegrito;
2717
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2718
        $x += $w * 0.50;
2719
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2720
        $texto = 'PORTO DE DESTINO';
2721
        $aFont = $this->formatPadrao;
2722
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2723
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2724
        $aFont = $this->formatNegrito;
2725
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2726
        $y += 8;
2727
        $this->pdf->Line(208, $y, 1, $y);
2728
        $x = 1;
2729
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2730
        $aFont = $this->formatPadrao;
2731
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2732
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2733
        $aFont = $this->formatNegrito;
2734
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2735
        $x += $w * 0.50;
2736
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2737
        $texto = 'VR DA B. DE CALC. AFRMM';
2738
        $aFont = $this->formatPadrao;
2739
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2740
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2741
        $aFont = $this->formatNegrito;
2742
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2743
        $x += $w * 0.17;
2744
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2745
        $texto = 'VALOR DO AFRMM';
2746
        $aFont = $this->formatPadrao;
2747
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2748
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2749
        $aFont = $this->formatNegrito;
2750
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2751
        $x += $w * 0.12;
2752
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2753
        $texto = 'TIPO DE NAVEGAÇÃO';
2754
        $aFont = $this->formatPadrao;
2755
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2756
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2757
        switch ($texto) {
2758
            case '0':
2759
                $texto = 'INTERIOR';
2760
                break;
2761
            case '1':
2762
                $texto = 'CABOTAGEM';
2763
                break;
2764
        }
2765
        $aFont = $this->formatNegrito;
2766
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2767
        $x += $w * 0.14;
2768
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2769
        $texto = 'DIREÇÃO';
2770
        $aFont = $this->formatPadrao;
2771
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2772
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2773
        switch ($texto) {
2774
            case 'N':
2775
                $texto = 'NORTE';
2776
                break;
2777
            case 'L':
2778
                $texto = 'LESTE';
2779
                break;
2780
            case 'S':
2781
                $texto = 'SUL';
2782
                break;
2783
            case 'O':
2784
                $texto = 'OESTE';
2785
                break;
2786
        }
2787
        $aFont = $this->formatNegrito;
2788
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2789
        $y += 8;
2790
        $this->pdf->Line(208, $y, 1, $y);
2791
        $x = 1;
2792
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2793
        $aFont = $this->formatPadrao;
2794
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2795
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2796
            $texto = $this->infNF
2797
                ->item(0)
2798
                ->getElementsByTagName('infUnidCarga')
2799
                ->item(0)
2800
                ->getElementsByTagName('idUnidCarga')
2801
                ->item(0)->nodeValue;
2802
        } elseif ($this->infNFe->item(0) !== null
2803
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2804
        ) {
2805
            $texto = $this->infNFe
2806
                ->item(0)
2807
                ->getElementsByTagName('infUnidCarga')
2808
                ->item(0)
2809
                ->getElementsByTagName('idUnidCarga')
2810
                ->item(0)
2811
                ->nodeValue;
2812
        } elseif ($this->infOutros->item(0) !== null
2813
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2814
        ) {
2815
            $texto = $this->infOutros
2816
                ->item(0)
2817
                ->getElementsByTagName('infUnidCarga')
2818
                ->item(0)
2819
                ->getElementsByTagName('idUnidCarga')
2820
                ->item(0)
2821
                ->nodeValue;
2822
        } else {
2823
            $texto = '';
2824
        }
2825
        $aFont = $this->formatNegrito;
2826
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2827
        $x += $w * 0.50;
2828
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2829
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2830
        $aFont = $this->formatPadrao;
2831
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2832
        $texto = '';
2833
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2834
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2835
                if ($k == 0) {
2836
                    $texto = $this->aquav
2837
                        ->getElementsByTagName('balsa')
2838
                        ->item($k)
2839
                        ->getElementsByTagName('xBalsa')
2840
                        ->item(0)
2841
                        ->nodeValue;
2842
                } else {
2843
                    $texto = $texto
2844
                        . ' / '
2845
                        . $this->aquav
2846
                            ->getElementsByTagName('balsa')
2847
                            ->item($k)
2848
                            ->getElementsByTagName('xBalsa')
2849
                            ->item(0)
2850
                            ->nodeValue;
2851
                }
2852
            }
2853
        }
2854
        $aFont = $this->formatNegrito;
2855
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2856
    } //fim da função zModalRod
2857
2858
    /**
2859
     * zModalFerr
2860
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2861
     *
2862
     * @param  number $x Posição horizontal canto esquerdo
2863
     * @param  number $y Posição vertical canto superior
2864
     * @return number Posição vertical final
2865
     */
2866
    protected function zModalFerr($x = 0, $y = 0)
2867
    {
2868
        $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...
2869
        $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...
2870
        if ($this->orientacao == 'P') {
2871
            $maxW = $this->wPrint;
2872
        } else {
2873
            $maxW = $this->wPrint - $this->wCanhoto;
2874
        }
2875
        $w = $maxW;
2876
        $h = 19.6;
2877
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2878
        $aFont = $this->formatPadrao;
2879
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2880
        $y += 3.4;
2881
        $this->pdf->Line($x, $y, $w + 1, $y);
2882
        $texto = 'DCL';
2883
        $aFont = array(
2884
            'font' => $this->fontePadrao,
2885
            'size' => 7,
2886
            'style' => 'B');
2887
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2888
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2889
        $texto = 'VAGÕES';
2890
        $aFont = array(
2891
            'font' => $this->fontePadrao,
2892
            'size' => 7,
2893
            'style' => 'B');
2894
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2895
        $y += 3.4;
2896
        $this->pdf->Line($x, $y, $w + 1, $y);
2897
        // DCL
2898
        $texto = 'ID TREM';
2899
        $aFont = array(
2900
            'font' => $this->fontePadrao,
2901
            'size' => 6,
2902
            'style' => '');
2903
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2904
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
2905
        $aFont = array(
2906
            'font' => $this->fontePadrao,
2907
            'size' => 6,
2908
            'style' => 'B');
2909
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2910
        $x += $w * 0.06;
2911
        $y1 = $y + 12.5;
2912
        $this->pdf->Line($x, $y, $x, $y1);
2913
        $texto = 'NUM';
2914
        $aFont = array(
2915
            'font' => $this->fontePadrao,
2916
            'size' => 6,
2917
            'style' => '');
2918
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2919
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
2920
        $aFont = array(
2921
            'font' => $this->fontePadrao,
2922
            'size' => 6,
2923
            'style' => 'B');
2924
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2925
        $x += $w * 0.06;
2926
        $this->pdf->Line($x, $y, $x, $y1);
2927
        $texto = 'SÉRIE';
2928
        $aFont = array(
2929
            'font' => $this->fontePadrao,
2930
            'size' => 6,
2931
            'style' => '');
2932
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2933
        $texto = $this->pSimpleGetValue($this->rem, "serie");
2934
        $aFont = array(
2935
            'font' => $this->fontePadrao,
2936
            'size' => 6,
2937
            'style' => 'B');
2938
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2939
        $x += $w * 0.06;
2940
        $this->pdf->Line($x, $y, $x, $y1);
2941
        $texto = 'EMISSÃO';
2942
        $aFont = array(
2943
            'font' => $this->fontePadrao,
2944
            'size' => 6,
2945
            'style' => '');
2946
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2947
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
2948
        $aFont = array(
2949
            'font' => $this->fontePadrao,
2950
            'size' => 6,
2951
            'style' => 'B');
2952
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2953
        // VAGOES
2954
        $x += $w * 0.06;
2955
        $this->pdf->Line($x, $y, $x, $y1);
2956
        $texto = 'NUM';
2957
        $aFont = array(
2958
            'font' => $this->fontePadrao,
2959
            'size' => 6,
2960
            'style' => '');
2961
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2962
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
2963
        $aFont = array(
2964
            'font' => $this->fontePadrao,
2965
            'size' => 6,
2966
            'style' => 'B');
2967
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2968
        $x += $w * 0.06;
2969
        $this->pdf->Line($x, $y, $x, $y1);
2970
        $texto = 'TIPO';
2971
        $aFont = array(
2972
            'font' => $this->fontePadrao,
2973
            'size' => 6,
2974
            'style' => '');
2975
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2976
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
2977
        $aFont = array(
2978
            'font' => $this->fontePadrao,
2979
            'size' => 6,
2980
            'style' => 'B');
2981
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2982
        $x += $w * 0.06;
2983
        $this->pdf->Line($x, $y, $x, $y1);
2984
        $texto = 'CAPACIDADE';
2985
        $aFont = array(
2986
            'font' => $this->fontePadrao,
2987
            'size' => 6,
2988
            'style' => '');
2989
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2990
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
2991
        $aFont = array(
2992
            'font' => $this->fontePadrao,
2993
            'size' => 6,
2994
            'style' => 'B');
2995
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2996
        $x += $w * 0.08;
2997
        $this->pdf->Line($x, $y, $x, $y1);
2998
        $texto = 'PESO REAL/TON';
2999
        $aFont = array(
3000
            'font' => $this->fontePadrao,
3001
            'size' => 6,
3002
            'style' => '');
3003
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3004
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3005
        $aFont = array(
3006
            'font' => $this->fontePadrao,
3007
            'size' => 6,
3008
            'style' => 'B');
3009
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3010
        $x += $w * 0.09;
3011
        $this->pdf->Line($x, $y, $x, $y1);
3012
        $texto = 'PESO BRUTO/TON';
3013
        $aFont = array(
3014
            'font' => $this->fontePadrao,
3015
            'size' => 6,
3016
            'style' => '');
3017
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3018
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3019
        $aFont = array(
3020
            'font' => $this->fontePadrao,
3021
            'size' => 6,
3022
            'style' => 'B');
3023
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3024
        $x += $w * 0.1;
3025
        $this->pdf->Line($x, $y, $x, $y1);
3026
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3027
        $aFont = array(
3028
            'font' => $this->fontePadrao,
3029
            'size' => 6,
3030
            'style' => '');
3031
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3032
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3033
        $aFont = array(
3034
            'font' => $this->fontePadrao,
3035
            'size' => 6,
3036
            'style' => 'B');
3037
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3038
        // FLUXO
3039
        $x = 1;
3040
        $y += 12.9;
3041
        $h1 = $h * 0.5 + 0.27;
3042
        $wa = round($w * 0.103) + 0.5;
3043
        $texto = 'FLUXO FERROVIARIO';
3044
        $aFont = $this->formatPadrao;
3045
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3046
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3047
        $aFont = array(
3048
            'font' => $this->fontePadrao,
3049
            'size' => 7,
3050
            'style' => 'B');
3051
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3052
        $y += 10;
3053
        $texto = 'TIPO DE TRÁFEGO';
3054
        $aFont = $this->formatPadrao;
3055
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3056
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3057
        $aFont = array(
3058
            'font' => $this->fontePadrao,
3059
            'size' => 7,
3060
            'style' => 'B');
3061
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3062
        // Novo Box Relativo a Modal Ferroviário
3063
        $x = 22.5;
3064
        $y += -10.2;
3065
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3066
        $aFont = $this->formatPadrao;
3067
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3068
        $y += 3.4;
3069
        $this->pdf->Line($x, $y, $w + 1, $y);
3070
        $w = $w * 0.2;
3071
        $h = $h * 1.04;
3072
        $texto = 'CÓDIGO INTERNO';
3073
        $aFont = array(
3074
            'font' => $this->fontePadrao,
3075
            'size' => 6,
3076
            'style' => '');
3077
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3078
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3079
        $aFont = array(
3080
            'font' => $this->fontePadrao,
3081
            'size' => 6,
3082
            'style' => 'B');
3083
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3084
        $texto = 'CNPJ';
3085
        $aFont = array(
3086
            'font' => $this->fontePadrao,
3087
            'size' => 6,
3088
            'style' => '');
3089
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3090
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3091
        $aFont = array(
3092
            'font' => $this->fontePadrao,
3093
            'size' => 6,
3094
            'style' => 'B');
3095
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3096
        $x += 50;
3097
        $texto = 'NOME';
3098
        $aFont = array(
3099
            'font' => $this->fontePadrao,
3100
            'size' => 6,
3101
            'style' => '');
3102
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3103
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3104
        $aFont = array(
3105
            'font' => $this->fontePadrao,
3106
            'size' => 6,
3107
            'style' => 'B');
3108
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3109
        $texto = 'INSCRICAO ESTADUAL';
3110
        $aFont = array(
3111
            'font' => $this->fontePadrao,
3112
            'size' => 6,
3113
            'style' => '');
3114
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3115
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3116
        $aFont = array(
3117
            'font' => $this->fontePadrao,
3118
            'size' => 6,
3119
            'style' => 'B');
3120
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3121
        $x += 50;
3122
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3123
        $aFont = array(
3124
            'font' => $this->fontePadrao,
3125
            'size' => 6,
3126
            'style' => '');
3127
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3128
        $texto = '';
3129
        $aFont = array(
3130
            'font' => $this->fontePadrao,
3131
            'size' => 6,
3132
            'style' => 'B');
3133
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3134
    } //fim da função zModalFerr
3135
3136
    /**
3137
     * zCanhoto
3138
     * Monta o campo com os dados do remetente na DACTE.
3139
     *
3140
     * @param  number $x Posição horizontal canto esquerdo
3141
     * @param  number $y Posição vertical canto superior
3142
     * @return number Posição vertical final
3143
     */
3144
    protected function zCanhoto($x = 0, $y = 0)
3145
    {
3146
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3147
        $y = $y + 2;
3148
        $oldX = $x;
3149
        $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...
3150
        if ($this->orientacao == 'P') {
3151
            $maxW = $this->wPrint;
3152
        } else {
3153
            $maxW = $this->wPrint - $this->wCanhoto;
3154
        }
3155
        $w = $maxW - 1;
3156
        $h = 20;
3157
        $y = $y + 1;
3158
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3159
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3160
        $aFont = $this->formatPadrao;
3161
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3162
        $y += 3.4;
3163
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3164
        
3165
        $texto = 'NOME';
3166
        $aFont = array(
3167
            'font' => $this->fontePadrao,
3168
            'size' => 6,
3169
            'style' => '');
3170
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3171
        $x += $w * 0.25;
3172
        
3173
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3174
        
3175
        $texto = 'ASSINATURA / CARIMBO';
3176
        $aFont = array(
3177
            'font' => $this->fontePadrao,
3178
            'size' => 6,
3179
            'style' => '');
3180
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3181
        $x += $w * 0.25;
3182
        
3183
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3184
        
3185
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3186
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3187
        $aFont = array(
3188
            'font' => $this->fontePadrao,
3189
            'size' => 6,
3190
            'style' => '');
3191
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3192
        $x = $oldX;
3193
        $y = $y + 5;
3194
        
3195
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3196
        
3197
        $texto = 'RG';
3198
        $aFont = array(
3199
            'font' => $this->fontePadrao,
3200
            'size' => 6,
3201
            'style' => '');
3202
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3203
        $x += $w * 0.85;
3204
        
3205
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3206
        
3207
        $texto = "CT-E";
3208
        $aFont = $this->formatNegrito;
3209
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3210
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3211
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3212
        $aFont = array(
3213
            'font' => $this->fontePadrao,
3214
            'size' => 6,
3215
            'style' => '');
3216
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3217
        $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...
3218
        //$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...
3219
    } //fim da função canhotoDACTE
3220
3221
    /**
3222
     * zDadosAdic
3223
     * Coloca o grupo de dados adicionais da DACTE.
3224
     *
3225
     * @param  number $x Posição horizontal canto esquerdo
3226
     * @param  number $y Posição vertical canto superior
3227
     * @param  number $h altura do campo
3228
     * @return number Posição vertical final
3229
     */
3230
    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...
3231
    {
3232
        $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...
3233
        //###########################################################################
3234
        //DADOS ADICIONAIS DACTE
3235
        if ($this->orientacao == 'P') {
3236
            $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...
3237
        } else {
3238
            $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...
3239
        }
3240
        //INFORMAÇÕES COMPLEMENTARES
3241
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3242
        $y += 3;
3243
        $w = $this->wAdic;
3244
        $h = 8; //mudar
3245
        $aFont = array(
3246
            'font' => $this->fontePadrao,
3247
            'size' => 6,
3248
            'style' => '');
3249
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3250
        //$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...
3251
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3252
        //o texto com os dados adicionais foi obtido na função xxxxxx
3253
        //e carregado em uma propriedade privada da classe
3254
        //$this->wAdic com a largura do campo
3255
        //$this->textoAdic com o texto completo do campo
3256
        $y += 1;
3257
        $aFont = $this->formatPadrao;
3258
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3259
        //RESERVADO AO FISCO
3260
        $texto = "RESERVADO AO FISCO";
3261
        $x += $w;
3262
        $y -= 1;
3263
        if ($this->orientacao == 'P') {
3264
            $w = $this->wPrint - $w;
3265
        } else {
3266
            $w = $this->wPrint - $w - $this->wCanhoto;
3267
        }
3268
        $aFont = array(
3269
            'font' => $this->fontePadrao,
3270
            'size' => 6,
3271
            'style' => '');
3272
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3273
        //inserir texto informando caso de contingência
3274
        //1 – Normal – emissão normal;
3275
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3276
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3277
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3278
        //Emissão em Contingência – DPEC;
3279
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3280
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3281
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3282
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3283
        $texto = '';
3284
        switch ($this->tpEmis) {
3285
            case 2:
3286
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3287
                break;
3288
            case 3:
3289
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3290
                break;
3291
            case 4:
3292
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3293
                break;
3294
            case 5:
3295
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3296
                break;
3297
        }
3298
        $y += 2;
3299
        $aFont = $this->formatPadrao;
3300
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3301
        return $y + $h;
3302
    } //fim zDadosAdic
3303
3304
    /**
3305
     * zhDashedLine
3306
     * Desenha uma linha horizontal tracejada com o FPDF
3307
     *
3308
     * @param  number $x Posição horizontal inicial, em mm
3309
     * @param  number $y Posição vertical inicial, em mm
3310
     * @param  number $w Comprimento da linha, em mm
3311
     * @param  number $h Espessura da linha, em mm
3312
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3313
     * @return none
3314
     */
3315
    protected function zhDashedLine($x, $y, $w, $h, $n)
3316
    {
3317
        $this->pdf->SetLineWidth($h);
3318
        $wDash = ($w / $n) / 2; // comprimento dos traços
3319
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3320
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3321
                if ($j <= ($x + $w - 1)) {
3322
                    $this->pdf->Line($j, $y, $j + 1, $y);
3323
                }
3324
            }
3325
        }
3326
    } //fim função hDashedLine
3327
3328
    /**
3329
     * zhDashedVerticalLine
3330
     * Desenha uma linha vertical tracejada com o FPDF
3331
     *
3332
     * @param  number $x Posição horizontal inicial, em mm
3333
     * @param  number $y Posição vertical inicial, em mm
3334
     * @param  number $w Comprimento da linha, em mm
3335
     * @param  number $yfinal Espessura da linha, em mm
3336
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3337
     * @return none
3338
     */
3339
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3340
    {
3341
        $this->pdf->SetLineWidth($w);
3342
        /* Organizando valores */
3343
        if ($y > $yfinal) {
3344
            $aux = $yfinal;
3345
            $yfinal = $y;
3346
            $y = $aux;
3347
        }
3348
        while ($y < $yfinal && $n > 0) {
3349
            $this->pdf->Line($x, $y, $x, $y + 1);
3350
            $y += 3;
3351
            $n--;
3352
        }
3353
    } //fim função hDashedVerticalLine
3354
3355
    /**
3356
     * zFormatCNPJCPF
3357
     * Formata campo CnpjCpf contida na CTe
3358
     *
3359
     * @param  string $field campo cnpjCpf da CT-e
3360
     * @return string
3361
     */
3362
    protected function zFormatCNPJCPF($field)
3363
    {
3364
        if (!isset($field)) {
3365
            return '';
3366
        }
3367
        $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...
3368
            $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...
3369
        if ($cnpj != "" && $cnpj != "00000000000000") {
3370
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3371
        } else {
3372
            $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...
3373
                $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...
3374
        }
3375
        return $cnpj;
3376
    } //fim formatCNPJCPF
3377
3378
    /**
3379
     * zFormatFone
3380
     * Formata campo fone contida na CTe
3381
     *
3382
     * @param  string $field campo fone da CT-e
3383
     * @return string
3384
     */
3385
    protected function zFormatFone($field)
3386
    {
3387
        try {
3388
            $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...
3389
            $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...
3390
            $foneLen = strlen($fone);
3391
            if ($foneLen > 0) {
3392
                $fone2 = substr($fone, 0, $foneLen - 4);
3393
                $fone1 = substr($fone, 0, $foneLen - 8);
3394
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3395
            } else {
3396
                $fone = '';
3397
            }
3398
            return $fone;
3399
        } catch (Exception $exc) {
3400
            return '';
3401
        }
3402
    } //fim formatFone
3403
3404
    /**
3405
     * zUnidade
3406
     * Converte a imformação de peso contida na CTe
3407
     *
3408
     * @param  string $c unidade de trafego extraida da CTe
3409
     * @return string
3410
     */
3411
    protected function zUnidade($c = '')
3412
    {
3413
        switch ($c) {
3414
            case '00':
3415
                $r = 'M3';
3416
                break;
3417
            case '01':
3418
                $r = 'KG';
3419
                break;
3420
            case '02':
3421
                $r = 'TON';
3422
                break;
3423
            case '03':
3424
                $r = 'UN';
3425
                break;
3426
            case '04':
3427
                $r = 'LT';
3428
                break;
3429
            case '05':
3430
                $r = 'MMBTU';
3431
                break;
3432
            default:
3433
                $r = '';
3434
        }
3435
        return $r;
3436
    } //fim unidade
3437
3438
    /**
3439
     * zConvertUnidTrafego
3440
     * Converte a imformação de peso contida na CTe
3441
     *
3442
     * @param  string $U Informação de trafego extraida da CTe
3443
     * @return string
3444
     */
3445
    protected function zConvertUnidTrafego($U = '')
3446
    {
3447
        if ($U) {
3448
            switch ($U) {
3449
                case '0':
3450
                    $stringU = 'Próprio';
3451
                    break;
3452
                case '1':
3453
                    $stringU = 'Mútuo';
3454
                    break;
3455
                case '2':
3456
                    $stringU = 'Rodoferroviário';
3457
                    break;
3458
                case '3':
3459
                    $stringU = 'Rodoviário';
3460
                    break;
3461
            }
3462
            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...
3463
        }
3464
    } //fim da função zConvertUnidTrafego
3465
3466
    /**
3467
     * zMultiUniPeso
3468
     * Fornece a imformação multiplicação de peso contida na CTe
3469
     *
3470
     * @param  interger $U Informação de peso extraida da CTe
3471
     * @return interger
3472
     */
3473
    protected function zMultiUniPeso($U = '')
3474
    {
3475
        if ($U === "01") {
3476
            // tonelada
3477
            //return 1000;
3478
            return 1;
3479
        }
3480
        return 1; // M3, KG, Unidade, litros, mmbtu
3481
    } //fim da função zMultiUniPeso
3482
}
3483