Completed
Push — master ( d7fe2b...cee598 )
by Roberto
13s
created

DacteV3::zRodape()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 2
dl 16
loc 16
rs 9.4285
c 0
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\Common\Dom\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
92
    /**
93
     * __construct
94
     *
95
     * @param string $docXML Arquivo XML da CTe
96
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
97
     * @param string $sPapel Tamanho do papel (Ex. A4)
98
     * @param string $sPathLogo Caminho para o arquivo do logo
99
     * @param string $sDestino Estabelece a direção do envio do documento PDF
100
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
101
     * @param string $fonteDACTE Nome da fonte a ser utilizada
102
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
103
     * @param string $preVisualizar 0-Não 1-Sim
104
     */
105
    public function __construct(
106
        $docXML = '',
107
        $sOrientacao = '',
108
        $sPapel = '',
109
        $sPathLogo = '',
110
        $sDestino = 'I',
111
        $sDirPDF = '',
112
        $fonteDACTE = '',
113
        $mododebug = 2,
114
        $preVisualizar = false
115
    ) {
116
    
117
        if (is_numeric($mododebug)) {
118
            $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...
119
        }
120 View Code Duplication
        if ($mododebug == 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
121
            //ativar modo debug
122
            error_reporting(E_ALL);
123
            ini_set('display_errors', 'On');
124
        } elseif ($mododebug == 0) {
125
            //desativar modo debug
126
            error_reporting(0);
127
            ini_set('display_errors', 'Off');
128
        }
129
        $this->orientacao = $sOrientacao;
130
        $this->papel = $sPapel;
131
        $this->pdf = '';
132
        $this->xml = $docXML;
133
        $this->logomarca = $sPathLogo;
134
        $this->destino = $sDestino;
135
        $this->pdfDir = $sDirPDF;
136
        $this->preVisualizar = $preVisualizar;
137
        // verifica se foi passa a fonte a ser usada
138
        if (!empty($fonteDACTE)) {
139
            $this->fontePadrao = $fonteDACTE;
140
        }
141
        $this->formatPadrao = array(
142
            'font' => $this->fontePadrao,
143
            'size' => 6,
144
            'style' => '');
145
        $this->formatNegrito = array(
146
            'font' => $this->fontePadrao,
147
            'size' => 7,
148
            'style' => 'B');
149
        //se for passado o xml
150
        if (!empty($this->xml)) {
151
            $this->dom = new Dom();
152
            $this->dom->loadXML($this->xml);
153
            $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...
154
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
155
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
156
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
157
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
158
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
159
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
160
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
161
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
162
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
163
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
164
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
165
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
166
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
167
            $this->infQ = $this->dom->getElementsByTagName("infQ");
168
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
169
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
170
            $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...
171
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
172
            $this->veic = $this->dom->getElementsByTagName("veic");
173
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
174
            // adicionar outros modais
175
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
176
            $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chave");
177
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
178
            $this->Comp = $this->dom->getElementsByTagName("Comp");
179
            $this->infNF = $this->dom->getElementsByTagName("infNF");
180
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
181
            $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...
182
            $this->compl = $this->dom->getElementsByTagName("compl");
183
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
184
            $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...
185
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
186
            $textoAdic = number_format($this->pSimpleGetValue($this->imp, "vTotTrib"), 2, ",", ".");
187
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
188
                    .$textoAdic;
189
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
190
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
191
            //modal aquaviário
192
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
193
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
194
            //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...
195 View Code Duplication
            switch ($tomador) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
196
                case '0':
197
                    $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...
198
                    $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...
199
                    break;
200
                case '1':
201
                    $this->toma = $this->exped;
202
                    $this->enderToma = $this->enderExped;
203
                    break;
204
                case '2':
205
                    $this->toma = $this->receb;
206
                    $this->enderToma = $this->enderReceb;
207
                    break;
208
                case '3':
209
                    $this->toma = $this->dest;
210
                    $this->enderToma = $this->enderDest;
211
                    break;
212
                default:
213
                    $this->toma = $this->toma4;
214
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
215
                    break;
216
            }
217
            /*$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...
218
            switch ($seguro) {
219
                case '0':
220
                    $this->respSeg = 'Remetente';
221
                    break;
222
                case '1':
223
                    $this->respSeg = 'Expedidor';
224
                    break;
225
                case '2':
226
                    $this->respSeg = 'Recebedor';
227
                    break;
228
                case '3':
229
                    $this->respSeg = 'Destinatário';
230
                    break;
231
                case '4':
232
                    $this->respSeg = 'Emitente';
233
                    break;
234
                case '5':
235
                    $this->respSeg = 'Tomador';
236
                    break;
237
                default:
238
                    $this->respSeg = '';
239
                    break;
240
            }*/
241
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
242
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
243
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
244
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
245
            $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...
246
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
247
            $this->modal = $this->pSimpleGetValue($this->ide, "modal");
248
        }
249
    }
250
251
    /**
252
     * monta
253
     * @param string $orientacao L ou P
254
     * @param string $papel A4
255
     * @param string $logoAlign C, L ou R
256
     * @param Pdf $classPDF
257
     * @return string montagem
258
     */
259
    public function monta(
260
        $orientacao = '',
261
        $papel = 'A4',
262
        $logoAlign = 'C',
263
        $classPDF = false
264
    ) {
265
    
266
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 263 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...
267
    }
268
269
    /**
270
     * printDocument
271
     * @param string $nome
272
     * @param string $destino
273
     * @param string $printer
274
     * @return
275
     */
276
    public function printDocument($nome = '', $destino = 'I', $printer = '')
277
    {
278
        return $this->printDACTE($nome, $destino, $printer);
279
    }
280
281
    /**
282
     * Dados brutos do PDF
283
     * @return string
284
     */
285
    public function render()
286
    {
287
        return $this->pdf->getPdf();
288
    }
289
290
291
    protected function zCteDPEC()
292
    {
293
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
294
    }
295
296
297
    /**
298
     * montaDACTE
299
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
300
     * durante sua construção.
301
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
302
     * pelo conteúdo da funçao e podem ser modificados.
303
     *
304
     * @param  string $orientacao (Opcional) Estabelece a orientação da
305
     *                impressão (ex. P-retrato), se nada for fornecido será
306
     *                usado o padrão da NFe
307
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
308
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
309
     */
310 View Code Duplication
    public function montaDACTE(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
311
        $orientacao = '',
312
        $papel = 'A4',
313
        $logoAlign = 'C',
314
        $classPDF = false
315
    ) {
316
    
317
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
318
        if ($orientacao == '') {
319
            if ($this->tpImp == '1') {
320
                $orientacao = 'P';
321
            } else {
322
                $orientacao = 'P';
323
            }
324
        }
325
        $this->orientacao = $orientacao;
326
        $this->papel = $papel;
327
        $this->logoAlign = $logoAlign;
328
329
        //$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...
330
        //instancia a classe pdf
331
        if ($classPDF !== false) {
332
            $this->pdf = $classPDF;
333
        } else {
334
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
335
        }
336
        if ($this->orientacao == 'P') {
337
            // margens do PDF
338
            $margSup = 2;
339
            $margEsq = 2;
340
            $margDir = 2;
341
            // posição inicial do relatorio
342
            $xInic = 1;
343
            $yInic = 1;
344
            if ($papel == 'A4') {
345
                //A4 210x297mm
346
                $maxW = 210;
347
                $maxH = 297;
348
            }
349
        } else {
350
            // margens do PDF
351
            $margSup = 3;
352
            $margEsq = 3;
353
            $margDir = 3;
354
            // posição inicial do relatorio
355
            $xInic = 5;
356
            $yInic = 5;
357
            if ($papel == 'A4') {
358
                //A4 210x297mm
359
                $maxH = 210;
360
                $maxW = 297;
361
                $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...
362
            }
363
        }
364
        //total inicial de paginas
365
        $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...
366
        //largura imprimivel em mm
367
        $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...
368
        //comprimento imprimivel em mm
369
        $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...
370
        // estabelece contagem de paginas
371
        $this->pdf->AliasNbPages();
372
        // fixa as margens
373
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
374
        $this->pdf->SetDrawColor(0, 0, 0);
375
        $this->pdf->SetFillColor(255, 255, 255);
376
        // inicia o documento
377
        $this->pdf->Open();
378
        // adiciona a primeira página
379
        $this->pdf->AddPage($this->orientacao, $this->papel);
380
        $this->pdf->SetLineWidth(0.1);
381
        $this->pdf->SetTextColor(0, 0, 0);
382
        //calculo do numero de páginas ???
383
        $totPag = 1;
384
        //montagem da primeira página
385
        $pag = 1;
386
        $x = $xInic;
387
        $y = $yInic;
388
        //coloca o cabeçalho
389
        //$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...
390
        $y += 70;
391
        $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...
392
        $x = $this->wPrint * 0.5 + 2;
393
        $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...
394
        $y += 19;
395
        $x = $xInic;
396
        $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...
397
        $x = $this->wPrint * 0.5 + 2;
398
        $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...
399
        $y += 19;
400
        $x = $xInic;
401
        $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...
402
        if ($this->tpCTe == '0') {
403
            //Normal
404
            $y += 10;
405
            $x = $xInic;
406
            $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...
407
            $y += 17;
408
            $x = $xInic;
409
            $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...
410
            $y += 25;
411
            $x = $xInic;
412
            $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...
413
            $y += 13;
414
            $x = $xInic;
415
            $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...
416
            if ($this->modal == '1') {
417
                if ($this->lota == 1) {
418
                    //$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...
419
                    $y += 35;
420
                } else {
421
                    $y += 53;
422
                }
423
            } elseif ($this->modal == '3') {
424
                $y += 37.75;
425
            } else {
426
                $y += 24.95;
427
            }
428
            $x = $xInic;
429
            $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...
430
            $y = $y-6;
431
            switch ($this->modal) {
432
                case '1':
433
                    $y += 25.9;
434
                    $x = $xInic;
435
                    $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...
436
                    break;
437
                case '2':
438
                    $y += 17.9;
439
                    $x = $xInic;
440
                    // TODO fmertins 31/10/14: este método não existe...
441
                    $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...
442
                    break;
443
                case '3':
444
                    $y += 17.9;
445
                    $x = $xInic;
446
                    $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...
447
                    break;
448
                case '4':
449
                    $y += 17.9;
450
                    $x = $xInic;
451
                    $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...
452
                    break;
453
                case '5':
454
                    $y += 17.9;
455
                    $x = $xInic;
456
                    // TODO fmertins 31/10/14: este método não existe...
457
                    $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...
458
                    break;
459
            }
460
            if ($this->modal == '1') {
461
                if ($this->lota == 1) {
462
                    $y += 37;
463
                } else {
464
                    $y += 8.9;
465
                }
466
            } elseif ($this->modal == '3') {
467
                $y += 24.15;
468
            } else {
469
                $y += 37;
470
            }
471
        } else {
472
            $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...
473
            //Complementado
474
            $y += 10;
475
            $x = $xInic;
476
            $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...
477
            $y += 80;
478
            $x = $xInic;
479
            $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...
480
            $y += 25;
481
            $x = $xInic;
482
            $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...
483
            $y += 13;
484
            $x = $xInic;
485
            $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...
486
            $y += 15;
487
        }
488
        $x = $xInic;
489
        $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...
490
        
491
        //$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...
492
        $y += 11;
493
        $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...
494
        
495
        //coloca o rodapé da página
496
        if ($this->orientacao == 'P') {
497
            $this->zRodape(2, $this->hPrint - 2);
498
        } else {
499
            $this->zRodape($xInic, $this->hPrint + 2.3);
500
        }
501
        if ($this->flagDocOrigContinuacao == 1) {
502
            $this->zdocOrigContinuacao(1, 71);
503
        }
504
        //retorna o ID na CTe
505
        if ($classPDF !== false) {
506
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
507
            return $aR;
508
        } else {
509
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
510
        }
511
    } //fim da função montaDACTE
512
513
    /**
514
     * printDACTE
515
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
516
     * O destino da impressão pode ser :
517
     * I-browser
518
     * D-browser com download
519
     * F-salva em um arquivo local com o nome informado
520
     * S-retorna o documento como uma string e o nome é ignorado.
521
     * Para enviar o pdf diretamente para uma impressora indique o
522
     * nome da impressora e o destino deve ser 'S'.
523
     *
524
     * @param  string $nome Path completo com o nome do arquivo pdf
525
     * @param  string $destino Direção do envio do PDF
526
     * @param  string $printer Identificação da impressora no sistema
527
     * @return string Caso o destino seja S o pdf é retornado como uma string
528
     * @todo Rotina de impressão direta do arquivo pdf criado
529
     */
530
    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...
531
    {
532
        $arq = $this->pdf->Output($nome, $destino);
533
        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...
534
            //aqui pode entrar a rotina de impressão direta
535
        }
536
        return $arq;
537
    } //fim função printDACTE
538
539
    /**
540
     * zCabecalho
541
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
542
     *
543
     * @param  number $x Posição horizontal inicial, canto esquerdo
544
     * @param  number $y Posição vertical inicial, canto superior
545
     * @param  number $pag Número da Página
546
     * @param  number $totPag Total de páginas
547
     * @return number Posição vertical final
548
     */
549
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
550
    {
551
        $oldX = $x;
552
        $oldY = $y;
553 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
554
            $maxW = $this->wPrint;
555
        } else {
556
            if ($pag == 1) {
557
                // primeira página
558
                $maxW = $this->wPrint - $this->wCanhoto;
559
            } else {
560
                // páginas seguintes
561
                $maxW = $this->wPrint;
562
            }
563
        }
564
        //##################################################################
565
        //coluna esquerda identificação do emitente
566
        $w = round($maxW * 0.42);
567 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
568
            $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...
569
                'font' => $this->fontePadrao,
570
                'size' => 6,
571
                'style' => '');
572
        } else {
573
            $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...
574
        }
575
        $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...
576
        $h = 35;
577
        $oldY += $h;
578
        //desenha a caixa
579
        $this->pTextBox($x, $y, $w + 2, $h + 1);
580
        // coloca o logo
581 View Code Duplication
        if (is_file($this->logomarca)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
582
            $logoInfo = getimagesize($this->logomarca);
583
            //largura da imagem em mm
584
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
585
            //altura da imagem em mm
586
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
587
            if ($this->logoAlign == 'L') {
588
                $nImgW = round($w / 3, 0);
589
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
590
                $xImg = $x + 1;
591
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
592
                //estabelecer posições do texto
593
                $x1 = round($xImg + $nImgW + 1, 0);
594
                $y1 = round($h / 3 + $y, 0);
595
                $tw = round(2 * $w / 3, 0);
596
            } elseif ($this->logoAlign == 'C') {
597
                $nImgH = round($h / 3, 0);
598
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
599
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
600
                $yImg = $y + 3;
601
                $x1 = $x;
602
                $y1 = round($yImg + $nImgH + 1, 0);
603
                $tw = $w;
604
            } elseif ($this->logoAlign == 'R') {
605
                $nImgW = round($w / 3, 0);
606
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
607
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
608
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
609
                $x1 = $x;
610
                $y1 = round($h / 3 + $y, 0);
611
                $tw = round(2 * $w / 3, 0);
612
            }
613
            $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...
614
        } else {
615
            $x1 = $x;
616
            $y1 = round($h / 3 + $y, 0);
617
            $tw = $w;
618
        }
619
        //Nome emitente
620
        $aFont = array(
621
            'font' => $this->fontePadrao,
622
            'size' => 9,
623
            'style' => 'B');
624
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
625
        $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...
626
        //endereço
627
        $y1 = $y1 + 3;
628
        $aFont = array(
629
            'font' => $this->fontePadrao,
630
            'size' => 7,
631
            'style' => '');
632
        $fone = $this->pSimpleGetValue($this->enderEmit, "fone")!=""? $this->zFormatFone($this->enderEmit):'';
633
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
634
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
635
        $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...
636
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
637
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
638
        $CEP = $this->pFormat($CEP, "#####-###");
639
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
640
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
641
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
642
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
643
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
644
            . "\n  Fone/Fax: " . $fone;
645
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
646
        //CNPJ/CPF IE
647
        $cpfCnpj = $this->zFormatCNPJCPF($this->emit);
648
        $ie = $this->pSimpleGetValue($this->emit, "IE");
649
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
650
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
651
        //outra caixa
652
        $h1 = 17.5;
653
        $y1 = $y + $h + 1;
654
        $this->pTextBox($x, $y1, $w + 2, $h1);
655
        //TIPO DO CT-E
656
        $texto = 'TIPO DO CTE';
657
        $wa = 37;
658
        $aFont = array(
659
            'font' => $this->fontePadrao,
660
            'size' => 8,
661
            'style' => '');
662
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
663
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
664
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
665
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
666
        switch ($tpCTe) {
667
            case '0':
668
                $texto = 'Normal';
669
                break;
670
            case '1':
671
                $texto = 'Complemento de Valores';
672
                break;
673
            case '2':
674
                $texto = 'Anulação de Valores';
675
                break;
676
            case '3':
677
                $texto = 'Substituto';
678
                break;
679
            default:
680
                $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...
681
        }
682
        $aFont = $this->formatNegrito;
683
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
684
        //TIPO DO SERVIÇO
685
        $texto = 'TIPO DO SERVIÇO';
686
        $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...
687
        $aFont = array(
688
            'font' => $this->fontePadrao,
689
            'size' => 8,
690
            'style' => '');
691
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
692
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
693
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
694
        switch ($tpServ) {
695
            case '0':
696
                $texto = 'Normal';
697
                break;
698
            case '1':
699
                $texto = 'Subcontratação';
700
                break;
701
            case '2':
702
                $texto = 'Redespacho';
703
                break;
704
            case '3':
705
                $texto = 'Redespacho Intermediário';
706
                break;
707
            default:
708
                $texto = 'ERRO' . $tpServ;
709
        }
710
        $aFont = $this->formatNegrito;
711
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
712
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
713
        //TOMADOR DO SERVIÇO
714
        $texto = 'INDICADOR DO CT-E GLOBALIZADO';
715
        $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...
716
        $y2 = $y1 + 8;
717
        $aFont = array(
718
            'font' => $this->fontePadrao,
719
            'size' => 6,
720
            'style' => '');
721
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
722
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
723
        $toma = $this->pSimpleGetValue($this->ide, "indGlobalizado");
724
        //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...
725
        if ($toma==1) {
726
            $aFont = array(
727
            'font' => $this->fontePadrao,
728
            'size' => 11,
729
            'style' => '');
730
            $this->pTextBox($x-14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
731
        } else {
732
            $aFont = array(
733
            'font' => $this->fontePadrao,
734
            'size' => 11,
735
            'style' => '');
736
            $this->pTextBox($x+3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
737
        }
738
        $aFont = $this->formatNegrito;
739
        $this->pdf->Line($x+5, $x+48, $x+5, $x+52);
740
        $this->pdf->Line($x+10, $x+48, $x+10, $x+52);
741
        $this->pdf->Line($x+5, $x+48, $x+10, $x+48);
742
        $this->pdf->Line($x+5, $x+52, $x+10, $x+52);
743
        $this->pTextBox($x-9, $y2+1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
744
745
        $this->pdf->Line($x+23, $x+48, $x+23, $x+52);
746
        $this->pdf->Line($x+28, $x+48, $x+28, $x+52);
747
        $this->pdf->Line($x+23, $x+48, $x+28, $x+48);
748
        $this->pdf->Line($x+23, $x+52, $x+28, $x+52);
749
        $this->pTextBox($x+9.8, $y2+1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
750
751
        //FORMA DE PAGAMENTO
752
        $texto = 'NFORMAÇÕES DO CT-E GLOBALIZADO';
753
        $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...
754
        $aFont = array(
755
            'font' => $this->fontePadrao,
756
            'size' => 8,
757
            'style' => '');
758
        $this->pTextBox($x+2 + $wa + 4.5, $y2-0.7, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
759
        $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...
760
        //##################################################################
761
        //coluna direita
762
        $x += $w + 2;
763
        $w = round($maxW * 0.335);
764
        $w1 = $w;
765
        $h = 11;
766
        $this->pTextBox($x, $y, $w + 2, $h + 1);
767
        $texto = "DACTE";
768
        $aFont = array(
769
            'font' => $this->fontePadrao,
770
            'size' => 10,
771
            'style' => 'B');
772
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
773
        $aFont = array(
774
            'font' => $this->fontePadrao,
775
            'size' => 8,
776
            'style' => '');
777
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
778
        $h = 10;
779
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
780
        $x1 = $x + $w + 2;
781
        $w = round($maxW * 0.22, 0);
782
        $w2 = $w;
783
        $h = 11;
784
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
785
        $texto = "MODAL";
786
        $aFont = array(
787
            'font' => $this->fontePadrao,
788
            'size' => 8,
789
            'style' => '');
790
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
791
        switch ($this->modal) {
792
            case '1':
793
                $texto = 'Rodoviário';
794
                break;
795
            case '2':
796
                $texto = 'Aéreo';
797
                break;
798
            case '3':
799
                $texto = 'Aquaviário';
800
                break;
801
            case '4':
802
                $texto = 'Ferroviário';
803
                break;
804
            case '5':
805
                $texto = 'Dutoviário';
806
                break;
807
        }
808
        $aFont = array(
809
            'font' => $this->fontePadrao,
810
            'size' => 10,
811
            'style' => 'B');
812
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
813
        //outra caixa
814
        $y += 12;
815
        $h = 9;
816
        $w = $w1 + $w2 + 2;
817
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
818
        //modelo
819
        $wa = 12;
820
        $xa = $x;
821
        $texto = 'MODELO';
822
        $aFont = array(
823
            'font' => $this->fontePadrao,
824
            'size' => 8,
825
            'style' => '');
826
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
827
        $texto = $this->pSimpleGetValue($this->ide, "mod");
828
        $aFont = $this->formatNegrito;
829
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
830
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
831
        //serie
832
        $xa += $wa;
833
        $texto = 'SÉRIE';
834
        $aFont = array(
835
            'font' => $this->fontePadrao,
836
            'size' => 8,
837
            'style' => '');
838
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
839
        $texto = $this->pSimpleGetValue($this->ide, "serie");
840
        $aFont = $this->formatNegrito;
841
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
842
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
843
        //numero
844
        $xa += $wa;
845
        $wa = 20;
846
        $texto = 'NÚMERO';
847
        $aFont = array(
848
            'font' => $this->fontePadrao,
849
            'size' => 8,
850
            'style' => '');
851
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
852
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
853
        $aFont = $this->formatNegrito;
854
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
855
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
856
        //folha
857
        $xa += $wa;
858
        $wa = 12;
859
        $texto = 'FL';
860
        $aFont = array(
861
            'font' => $this->fontePadrao,
862
            'size' => 8,
863
            'style' => '');
864
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
865
        //$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...
866
        $texto = $pag."/".$totPag;
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
        //data  hora de emissão
871
        $xa += $wa;
872
        $wa = 30;
873
        $texto = 'DATA E HORA DE EMISSÃO';
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 = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
880
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
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
        //ISUF
885
        $xa += $wa;
886
        $wa = 32;
887
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
888
        $aFont = $this->formatPadrao;
889
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
890
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
891
        $aFont = array(
892
            'font' => $this->fontePadrao,
893
            'size' => 7,
894
            'style' => 'B');
895
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
896
        //outra caixa
897
        $y += $h + 1;
898
        $h = 23;
899
        $h1 = 14;
900
        $this->pTextBox($x, $y, $w + 0.5, $h1);
901
        //CODIGO DE BARRAS
902
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
903
        $bW = 85;
904
        $bH = 10;
905
        //codigo de barras
906
        $this->pdf->SetFillColor(0, 0, 0);
907
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
908
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
909
        $texto = 'CHAVE DE ACESSO';
910
        $aFont = $this->formatPadrao;
911
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
912
        $aFont = $this->formatNegrito;
913
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
914
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
915
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
916
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
917
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
918 View Code Duplication
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
919
            $texto = "";
920
            $this->pdf->SetFillColor(0, 0, 0);
921
            if ($this->tpEmis == 5) {
922
                $chaveContingencia = $this->zGeraChaveAdicCont();
923
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
924
            } else {
925
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
926
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
927
            }
928
            //codigo de barras
929
        }
930
        $aFont = array(
931
            'font' => $this->fontePadrao,
932
            'size' => 8,
933
            'style' => '');
934
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
935
        //outra caixa
936
        $y += $h + 1;
937
        $h = 8.5;
938
        $wa = $w;
939
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
940 View Code Duplication
        if ($this->zCteDPEC()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
941
            $texto = 'NÚMERO DE REGISTRO DPEC';
942
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
943
            $texto = "DADOS DO CT-E";
944
        } else {
945
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
946
        }
947
        $aFont = $this->formatPadrao;
948
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
949 View Code Duplication
        if ($this->zCteDPEC()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
950
            $texto = $this->numero_registro_dpec;
951
        } elseif ($this->tpEmis == 5) {
952
            $chaveContingencia = $this->zGeraChaveAdicCont();
953
            $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...
954
                'font' => $this->fontePadrao,
955
                'size' => 8,
956
                'style' => 'B');
957
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
958
            $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...
959
        } else {
960
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
961
            // 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...
962
            if (!empty($this->protCTe)
963
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
964
            ) {
965
                $texto .= date(
966
                    'd/m/Y   H:i:s',
967
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
968
                );
969
            }
970
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
971
        }
972
        $aFont = $this->formatNegrito;
973
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
974
        //CFOP
975
        $x = $oldX;
976
        $h = 8.5;
977
        $w = round($maxW * 0.42);
978
        $y1 = $y + 7.5;
979
        $this->pTextBox($x, $y1, $w + 2, $h);
980
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
981
        $aFont = array(
982
            'font' => $this->fontePadrao,
983
            'size' => 8,
984
            'style' => '');
985
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
986
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
987
        $aFont = $this->formatNegrito;
988
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
989
        //ORIGEM DA PRESTAÇÃO
990
        $y += $h + 7.5;
991
        $x = $oldX;
992
        $h = 8;
993
        $w = ($maxW * 0.5);
994
        $this->pTextBox($x, $y, $w + 0.5, $h);
995
        $texto = 'INÍCIO DA PRESTAÇÃO';
996
        $aFont = array(
997
            'font' => $this->fontePadrao,
998
            'size' => 8,
999
            'style' => '');
1000
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1001
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1002
        $aFont = $this->formatNegrito;
1003
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1004
        //DESTINO DA PRESTAÇÃO
1005
        $x = $oldX + $w + 1;
1006
        $h = 8;
1007
        $w = $w - 1.3;
1008
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1009
        $texto = 'TÉRMINO 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, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1016
        $aFont = $this->formatNegrito;
1017
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1018
        //#########################################################################
1019
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1020
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1021
        //indicar cancelamento
1022
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1023 View Code Duplication
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1024
            //101 Cancelamento
1025
            $x = 10;
1026
            $y = $this->hPrint - 130;
1027
            $h = 25;
1028
            $w = $maxW - (2 * $x);
1029
            $this->pdf->SetTextColor(90, 90, 90);
1030
            $texto = "CTe CANCELADO";
1031
            $aFont = array(
1032
                'font' => $this->fontePadrao,
1033
                'size' => 48,
1034
                'style' => 'B');
1035
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1036
            $this->pdf->SetTextColor(0, 0, 0);
1037
        }
1038
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1039 View Code Duplication
        if ($cStat == '110' ||
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1040
            $cStat == '301' ||
1041
            $cStat == '302' ||
1042
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1043
        ) {
1044
            //110 Denegada
1045
            $x = 10;
1046
            $y = $this->hPrint - 130;
1047
            $h = 25;
1048
            $w = $maxW - (2 * $x);
1049
            $this->pdf->SetTextColor(90, 90, 90);
1050
            $texto = "CTe USO DENEGADO";
1051
            $aFont = array(
1052
                'font' => $this->fontePadrao,
1053
                'size' => 48,
1054
                'style' => 'B');
1055
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1056
            $y += $h;
1057
            $h = 5;
1058
            $w = $maxW - (2 * $x);
1059
            $texto = "SEM VALOR FISCAL";
1060
            $aFont = array(
1061
                'font' => $this->fontePadrao,
1062
                'size' => 48,
1063
                'style' => 'B');
1064
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1065
            $this->pdf->SetTextColor(0, 0, 0);
1066
        }
1067
        //indicar sem valor
1068 View Code Duplication
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1069
            $x = 10;
1070
            if ($this->orientacao == 'P') {
1071
                $y = round($this->hPrint * 2 / 3, 0);
1072
            } else {
1073
                $y = round($this->hPrint / 2, 0);
1074
            }
1075
            $h = 5;
1076
            $w = $maxW - (2 * $x);
1077
            $this->pdf->SetTextColor(90, 90, 90);
1078
            $texto = "SEM VALOR FISCAL";
1079
            $aFont = array(
1080
                'font' => $this->fontePadrao,
1081
                'size' => 48,
1082
                'style' => 'B');
1083
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1084
            $aFont = array(
1085
                'font' => $this->fontePadrao,
1086
                'size' => 30,
1087
                'style' => 'B');
1088
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1089
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1090
            $this->pdf->SetTextColor(0, 0, 0);
1091
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1092
            $h = 5;
1093
            $w = $maxW - (2 * 10);
1094
            $x = 55;
1095
            $y = 240;
1096
            $this->pdf->SetTextColor(255, 100, 100);
1097
            $aFont = array(
1098
                'font' => $this->fontePadrao,
1099
                'size' => 40,
1100
                'style' => 'B');
1101
            $texto = "Pré-visualização";
1102
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1103
            $this->pdf->SetTextColor(255, 100, 100);
1104
            $aFont = array(
1105
                'font' => $this->fontePadrao,
1106
                'size' => 41,
1107
                'style' => 'B');
1108
            $texto = "Sem Validade Jurídica";
1109
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1110
            $this->pdf->SetTextColor(90, 90, 90);
1111
            $texto = "SEM VALOR FISCAL";
1112
            $aFont = array(
1113
                'font' => $this->fontePadrao,
1114
                'size' => 48,
1115
                'style' => 'B');
1116
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1117
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1118
        } else {
1119
            $x = 10;
1120
            if ($this->orientacao == 'P') {
1121
                $y = round($this->hPrint * 2 / 3, 0);
1122
            } else {
1123
                $y = round($this->hPrint / 2, 0);
1124
            } //fim orientacao
1125
            $h = 5;
1126
            $w = $maxW - (2 * $x);
1127
            $this->pdf->SetTextColor(90, 90, 90);
1128
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1129
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1130
                //Contingência
1131
                $texto = "DACTE Emitido em Contingência";
1132
                $aFont = array(
1133
                    'font' => $this->fontePadrao,
1134
                    'size' => 48,
1135
                    'style' => 'B');
1136
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1137
                $aFont = array(
1138
                    'font' => $this->fontePadrao,
1139
                    'size' => 30,
1140
                    'style' => 'B');
1141
                $texto = "devido à problemas técnicos";
1142
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1143
            } else {
1144
                if (!isset($this->protCTe)) {
1145
                    if (!$this->zCteDPEC()) {
1146
                        $texto = "SEM VALOR FISCAL";
1147
                        $aFont = array(
1148
                            'font' => $this->fontePadrao,
1149
                            'size' => 48,
1150
                            'style' => 'B');
1151
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1152
                    }
1153
                    $aFont = array(
1154
                        'font' => $this->fontePadrao,
1155
                        'size' => 30,
1156
                        'style' => 'B');
1157
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1158
                    if (!$this->zCteDPEC()) {
1159
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1160
                    } else {
1161
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1162
                    }
1163
                } //fim cteProc
1164
                if ($this->tpEmis == 4) {
1165
                    //DPEC
1166
                    $x = 10;
1167
                    $y = $this->hPrint - 130;
1168
                    $h = 25;
1169
                    $w = $maxW - (2 * $x);
1170
                    $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...
1171
                    $texto = "DACTE impresso em contingência -\n"
1172
                        . "DPEC regularmente recebido pela Receita\n"
1173
                        . "Federal do Brasil";
1174
                    $aFont = array(
1175
                        'font' => $this->fontePadrao,
1176
                        'size' => 48,
1177
                        'style' => 'B');
1178
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1179
                    $this->pdf->SetTextColor(0, 0, 0);
1180
                }
1181
            } //fim tpEmis
1182
            $this->pdf->SetTextColor(0, 0, 0);
1183
        }
1184
        return $oldY;
1185
    } //fim zCabecalho
1186
1187
    /**
1188
     * rodapeDACTE
1189
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1190
     *
1191
     * @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...
1192
     * @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...
1193
     */
1194 View Code Duplication
    protected function zRodape($x, $y)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1195
    {
1196
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1197
        $w = $this->wPrint - 4;
1198
        $aFont = array(
1199
            'font' => $this->fontePadrao,
1200
            'size' => 6,
1201
            'style' => '');
1202
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1203
        $texto = "DacteNFePHP ver. " . $this->version . "  Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org";
1204
        $aFont = array(
1205
            'font' => $this->fontePadrao,
1206
            'size' => 6,
1207
            'style' => '');
1208
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org');
1209
    } //fim zRodape
1210
1211
    /**
1212
     * zRemetente
1213
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1214
     *
1215
     * @param  number $x Posição horizontal canto esquerdo
1216
     * @param  number $y Posição vertical canto superior
1217
     * @return number Posição vertical final
1218
     */
1219
    protected function zRemetente($x = 0, $y = 0)
1220
    {
1221
        $oldX = $x;
1222
        $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...
1223
        if ($this->orientacao == 'P') {
1224
            $maxW = $this->wPrint;
1225
        } else {
1226
            $maxW = $this->wPrint - $this->wCanhoto;
1227
        }
1228
        $w = $maxW * 0.5 + 0.5;
1229
        $h = 19;
1230
        $x1 = $x + 16;
1231
        $texto = 'REMETENTE';
1232
        $aFont = $this->formatPadrao;
1233
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1234
        $aFont = $this->formatNegrito;
1235
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1236
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1237
        $y += 3;
1238
        $texto = 'ENDEREÇO';
1239
        $aFont = $this->formatPadrao;
1240
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1241
        $aFont = $this->formatNegrito;
1242
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1243
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1244
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1245
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1246
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1247
        $y += 3;
1248
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1249
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1250
        $y += 3;
1251
        $texto = 'MUNICÍPIO';
1252
        $aFont = $this->formatPadrao;
1253
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1254
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1255
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1256
        $aFont = $this->formatNegrito;
1257
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1258
        $x = $w - 18;
1259
        $texto = 'CEP';
1260
        $aFont = $this->formatPadrao;
1261
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1262
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1263
        $aFont = $this->formatNegrito;
1264
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1265
        $x = $oldX;
1266
        $y += 3;
1267
        $texto = 'CNPJ/CPF';
1268
        $aFont = $this->formatPadrao;
1269
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1270
        $cpfCnpj = $this->zFormatCNPJCPF($this->rem);
1271
        $aFont = $this->formatNegrito;
1272
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1273
        $x = $w - 45;
1274
        $texto = 'INSCRIÇÃO ESTADUAL';
1275
        $aFont = $this->formatPadrao;
1276
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1277
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1278
        $aFont = $this->formatNegrito;
1279
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1280
        $x = $oldX;
1281
        $y += 3;
1282
        $texto = 'PAÍS';
1283
        $aFont = $this->formatPadrao;
1284
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1285
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1286
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1287
        $aFont = $this->formatNegrito;
1288
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1289
        $x = $w - 25;
1290
        $texto = 'FONE';
1291
        $aFont = $this->formatPadrao;
1292
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1293
        //$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...
1294
        $texto = $this->pSimpleGetValue($this->rem, "fone")!=""? $this->zFormatFone($this->rem):'';
1295
        $aFont = $this->formatNegrito;
1296
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1297
    } //fim da função remetenteDACTE
1298
1299
    /**
1300
     * zDestinatario
1301
     * Monta o campo com os dados do destinatário na DACTE.
1302
     *
1303
     * @param  number $x Posição horizontal canto esquerdo
1304
     * @param  number $y Posição vertical canto superior
1305
     * @return number Posição vertical final
1306
     */
1307
    protected function zDestinatario($x = 0, $y = 0)
1308
    {
1309
        $oldX = $x;
1310
        $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...
1311
        if ($this->orientacao == 'P') {
1312
            $maxW = $this->wPrint;
1313
        } else {
1314
            $maxW = $this->wPrint - $this->wCanhoto;
1315
        }
1316
        $w = ($maxW * 0.5) - 0.7;
1317
        $h = 19;
1318
        $x1 = $x + 19;
1319
        $texto = 'DESTINATÁRIO';
1320
        $aFont = $this->formatPadrao;
1321
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1322
        $aFont = $this->formatNegrito;
1323
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1324
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1325
        $y += 3;
1326
        $texto = 'ENDEREÇO';
1327
        $aFont = $this->formatPadrao;
1328
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1329
        $aFont = $this->formatNegrito;
1330
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1331
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1332
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1333
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1334
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1335
        $y += 3;
1336
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1337
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1338
        $y += 3;
1339
        $texto = 'MUNICÍPIO';
1340
        $aFont = $this->formatPadrao;
1341
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1342
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1343
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1344
        $aFont = $this->formatNegrito;
1345
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1346
        $x = $w - 19 + $oldX;
1347
        $texto = 'CEP';
1348
        $aFont = $this->formatPadrao;
1349
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1350
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1351
        $aFont = $this->formatNegrito;
1352
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1353
        $x = $oldX;
1354
        $y += 3;
1355
        $texto = 'CNPJ/CPF';
1356
        $aFont = $this->formatPadrao;
1357
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1358
        $cpfCnpj = $this->zFormatCNPJCPF($this->dest);
1359
        $aFont = $this->formatNegrito;
1360
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1361
        $x = $w - 47.5 + $oldX;
1362
        $texto = 'INSCRIÇÃO ESTADUAL';
1363
        $aFont = $this->formatPadrao;
1364
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1365
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1366
        $aFont = $this->formatNegrito;
1367
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1368
        $x = $oldX;
1369
        $y += 3;
1370
        $texto = 'PAÍS';
1371
        $aFont = $this->formatPadrao;
1372
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1373
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1374
        $aFont = $this->formatNegrito;
1375
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1376
        $x = $w - 27 + $oldX;
1377
        $texto = 'FONE';
1378
        $aFont = $this->formatPadrao;
1379
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1380
        //$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...
1381
        $texto = $this->pSimpleGetValue($this->dest, "fone")!=""? $this->zFormatFone($this->dest):'';
1382
        $aFont = $this->formatNegrito;
1383
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1384
    } //fim da função destinatarioDACTE
1385
1386
    /**
1387
     * zExpedidor
1388
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1389
     *
1390
     * @param  number $x Posição horizontal canto esquerdo
1391
     * @param  number $y Posição vertical canto superior
1392
     * @return number Posição vertical final
1393
     */
1394
    protected function zExpedidor($x = 0, $y = 0)
1395
    {
1396
        $oldX = $x;
1397
        $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...
1398
        if ($this->orientacao == 'P') {
1399
            $maxW = $this->wPrint;
1400
        } else {
1401
            $maxW = $this->wPrint - $this->wCanhoto;
1402
        }
1403
        $w = $maxW * 0.5 + 0.5;
1404
        $h = 19;
1405
        $x1 = $x + 16;
1406
        $texto = 'EXPEDIDOR';
1407
        $aFont = $this->formatPadrao;
1408
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1409
        $aFont = $this->formatNegrito;
1410
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1411
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1412
        $y += 3;
1413
        $texto = 'ENDEREÇO';
1414
        $aFont = $this->formatPadrao;
1415
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1416
        $aFont = $this->formatNegrito;
1417 View Code Duplication
        if (isset($this->enderExped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1418
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1419
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1420
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1421
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1422
                '';
1423
        } else {
1424
            $texto = '';
1425
        }
1426
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1427
        $y += 3;
1428
        $texto = $this->pSimpleGetValue($this->enderExped, "xBairro");
1429
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1430
        $y += 3;
1431
        $texto = 'MUNICÍPIO';
1432
        $aFont = $this->formatPadrao;
1433
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1434 View Code Duplication
        if (isset($this->enderExped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1435
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1436
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1437
        } else {
1438
            $texto = '';
1439
        }
1440
        $aFont = $this->formatNegrito;
1441
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1442
        $x = $w - 18;
1443
        $texto = 'CEP';
1444
        $aFont = $this->formatPadrao;
1445
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1446
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderExped, "CEP"), "#####-###");
1447
        $aFont = $this->formatNegrito;
1448
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1449
        $x = $oldX;
1450
        $y += 3;
1451
        $texto = 'CNPJ/CPF';
1452
        $aFont = $this->formatPadrao;
1453
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1454
        $cpfCnpj = $this->zFormatCNPJCPF($this->exped);
1455
        $aFont = $this->formatNegrito;
1456
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1457
        $x = $w - 45;
1458
        $texto = 'INSCRIÇÃO ESTADUAL';
1459
        $aFont = $this->formatPadrao;
1460
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1461
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1462
        $aFont = $this->formatNegrito;
1463
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1464
        $x = $oldX;
1465
        $y += 3;
1466
        $texto = 'PAÍS';
1467
        $aFont = $this->formatPadrao;
1468
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1469
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1470
        $aFont = $this->formatNegrito;
1471
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1472
        $x = $w - 25;
1473
        $texto = 'FONE';
1474
        $aFont = $this->formatPadrao;
1475
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1476 View Code Duplication
        if (isset($this->exped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1477
            $texto = $this->pSimpleGetValue($this->exped, "fone")!=""? $this->zFormatFone($this->exped):'';
1478
            $aFont = $this->formatNegrito;
1479
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1480
        }
1481
    } //fim da função remetenteDACTE
1482
1483
    /**
1484
     * zRecebedor
1485
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1486
     *
1487
     * @param  number $x Posição horizontal canto esquerdo
1488
     * @param  number $y Posição vertical canto superior
1489
     * @return number Posição vertical final
1490
     */
1491
    protected function zRecebedor($x = 0, $y = 0)
1492
    {
1493
        $oldX = $x;
1494
        $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...
1495
        if ($this->orientacao == 'P') {
1496
            $maxW = $this->wPrint;
1497
        } else {
1498
            $maxW = $this->wPrint - $this->wCanhoto;
1499
        }
1500
        $w = ($maxW * 0.5) - 0.7;
1501
        $h = 19;
1502
        $x1 = $x + 19;
1503
        $texto = 'RECEBEDOR';
1504
        $aFont = $this->formatPadrao;
1505
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1506
        $aFont = $this->formatNegrito;
1507
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1508
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1509
        $y += 3;
1510
        $texto = 'ENDEREÇO';
1511
        $aFont = $this->formatPadrao;
1512
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1513
        $aFont = $this->formatNegrito;
1514 View Code Duplication
        if (isset($this->enderReceb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1515
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1516
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1517
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1518
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1519
                '';
1520
        } else {
1521
            $texto = '';
1522
        }
1523
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1524
        $y += 3;
1525
        $texto = $this->pSimpleGetValue($this->enderReceb, "xBairro");
1526
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1527
        $y += 3;
1528
        $texto = 'MUNICÍPIO';
1529
        $aFont = $this->formatPadrao;
1530
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1531 View Code Duplication
        if (isset($this->enderReceb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1532
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1533
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1534
        } else {
1535
            $texto = '';
1536
        }
1537
        $aFont = $this->formatNegrito;
1538
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1539
        $x = $w - 19 + $oldX;
1540
        $texto = 'CEP';
1541
        $aFont = $this->formatPadrao;
1542
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1543
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReceb, "CEP"), "#####-###");
1544
        $aFont = $this->formatNegrito;
1545
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1546
        $x = $oldX;
1547
        $y += 3;
1548
        $texto = 'CNPJ/CPF';
1549
        $aFont = $this->formatPadrao;
1550
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1551
        $texto = $this->zFormatCNPJCPF($this->receb);
1552
        $aFont = $this->formatNegrito;
1553
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1554
        $x = $w - 47 + $oldX;
1555
        $texto = 'INSCRIÇÃO ESTADUAL';
1556
        $aFont = $this->formatPadrao;
1557
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1558
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1559
        $aFont = $this->formatNegrito;
1560
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1561
        $x = $oldX;
1562
        $y += 3;
1563
        $texto = 'PAÍS';
1564
        $aFont = $this->formatPadrao;
1565
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1566
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1567
        $aFont = $this->formatNegrito;
1568
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1569
        $x = $w - 27 + $oldX;
1570
        $texto = 'FONE';
1571
        $aFont = $this->formatPadrao;
1572
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1573 View Code Duplication
        if (isset($this->receb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1790
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1791
            $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1792
        } else {
1793
            $texto = '';
1794
        }
1795
        $aFont = array(
1796
            'font' => $this->fontePadrao,
1797
            'size' => 7,
1798
            'style' => 'B');
1799
        $this->pTextBox($x+50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1800
        $x = $w * 0.45;
1801
        //$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...
1802
        $texto = 'QTDE(VOL)';
1803
        $aFont = $this->formatPadrao;
1804
        $this->pTextBox($x+85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1805
        $qCarga = $this->pSimpleGetValue($this->infQ->item(3), "qCarga");
1806
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1807
        $aFont = array(
1808
            'font' => $this->fontePadrao,
1809
            'size' => 7,
1810
            'style' => 'B');
1811
        $this->pTextBox($x+85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1812
        $x = $w * 0.53;
1813
        $this->pdf->Line($x+56, $y, $x+56, $y + 9);
1814
        /*$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...
1815
        $aFont = $this->formatPadrao;
1816
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1817
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1818
        $aFont = array(
1819
            'font' => $this->fontePadrao,
1820
            'size' => 7,
1821
            'style' => 'B');
1822
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1823
        $y += 3;
1824
        $this->pdf->Line($x, $y, $w + 1, $y);
1825
        $texto = 'RESPONSÁVEL';
1826
        $aFont = $this->formatPadrao;
1827
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1828
        $texto = $this->respSeg;
1829
        $aFont = array(
1830
            'font' => $this->fontePadrao,
1831
            'size' => 7,
1832
            'style' => 'B');
1833
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1834
        $x = $w * 0.68;
1835
        $this->pdf->Line($x, $y, $x, $y + 6);
1836
        $texto = 'NÚMERO DA APOLICE';
1837
        $aFont = $this->formatPadrao;
1838
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1839
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1840
        $aFont = array(
1841
            'font' => $this->fontePadrao,
1842
            'size' => 7,
1843
            'style' => 'B');
1844
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1845
        $x = $w * 0.85;
1846
        $this->pdf->Line($x, $y, $x, $y + 6);
1847
        $texto = 'NÚMERO DA AVERBAÇÃO';
1848
        $aFont = $this->formatPadrao;
1849
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1850
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
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
    } //fim da função zDescricaoCarga
1857
1858
    /**
1859
     * zCompValorServ
1860
     * Monta o campo com os componentes da prestação de serviços.
1861
     *
1862
     * @param  number $x Posição horizontal canto esquerdo
1863
     * @param  number $y Posição vertical canto superior
1864
     * @return number Posição vertical final
1865
     */
1866 View Code Duplication
    protected function zCompValorServ($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1867
    {
1868
        $oldX = $x;
1869
        $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...
1870
        if ($this->orientacao == 'P') {
1871
            $maxW = $this->wPrint;
1872
        } else {
1873
            $maxW = $this->wPrint - $this->wCanhoto;
1874
        }
1875
        $w = $maxW;
1876
        $h = 25;
1877
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1878
        $aFont = $this->formatPadrao;
1879
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1880
        $y += 3.4;
1881
        $this->pdf->Line($x, $y, $w + 1, $y);
1882
        $texto = 'NOME';
1883
        $aFont = $this->formatPadrao;
1884
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1885
        $yIniDados = $y;
1886
        $x = $w * 0.14;
1887
        $texto = 'VALOR';
1888
        $aFont = $this->formatPadrao;
1889
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1890
        $x = $w * 0.28;
1891
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1892
        $texto = 'NOME';
1893
        $aFont = $this->formatPadrao;
1894
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1895
        $x = $w * 0.42;
1896
        $texto = 'VALOR';
1897
        $aFont = $this->formatPadrao;
1898
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1899
        $x = $w * 0.56;
1900
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1901
        $texto = 'NOME';
1902
        $aFont = $this->formatPadrao;
1903
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1904
        $x = $w * 0.70;
1905
        $texto = 'VALOR';
1906
        $aFont = $this->formatPadrao;
1907
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1908
        $x = $w * 0.86;
1909
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1910
        $y += 1;
1911
        $texto = 'VALOR TOTAL DO SERVIÇO';
1912
        $aFont = $this->formatPadrao;
1913
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1914
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1915
        $aFont = array(
1916
            'font' => $this->fontePadrao,
1917
            'size' => 9,
1918
            'style' => 'B');
1919
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1920
        $y += 10;
1921
        $this->pdf->Line($x, $y, $w + 1, $y);
1922
        $y += 1;
1923
        $texto = 'VALOR A RECEBER';
1924
        $aFont = $this->formatPadrao;
1925
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1926
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1927
        $aFont = array(
1928
            'font' => $this->fontePadrao,
1929
            'size' => 9,
1930
            'style' => 'B');
1931
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1932
        $auxX = $oldX;
1933
        $yIniDados += 4;
1934
        foreach ($this->Comp as $k => $d) {
1935
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1936
            $valor = number_format(
1937
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1938
                2,
1939
                ",",
1940
                "."
1941
            );
1942
            if ($auxX > $w * 0.60) {
1943
                $yIniDados = $yIniDados + 4;
1944
                $auxX = $oldX;
1945
            }
1946
            $texto = $nome;
1947
            $aFont = $this->formatPadrao;
1948
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1949
            $auxX += $w * 0.14;
1950
            $texto = $valor;
1951
            $aFont = $this->formatPadrao;
1952
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1953
            $auxX += $w * 0.14;
1954
        }
1955
    } //fim da função compValorDACTE
1956
1957
    /**
1958
     * zImpostos
1959
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1960
     *
1961
     * @param  number $x Posição horizontal canto esquerdo
1962
     * @param  number $y Posição vertical canto superior
1963
     * @return number Posição vertical final
1964
     */
1965 View Code Duplication
    protected function zImpostos($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1966
    {
1967
        $oldX = $x;
1968
        $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...
1969
        if ($this->orientacao == 'P') {
1970
            $maxW = $this->wPrint;
1971
        } else {
1972
            $maxW = $this->wPrint - $this->wCanhoto;
1973
        }
1974
        $w = $maxW;
1975
        $h = 13;
1976
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1977
        $aFont = $this->formatPadrao;
1978
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1979
        
1980
        $y += 3.4;
1981
        $this->pdf->Line($x, $y, $w + 1, $y);
1982
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1983
        $aFont = $this->formatPadrao;
1984
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1985
        
1986
        $x += $w * 0.26;
1987
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1988
        $texto = 'BASE DE CALCULO';
1989
        $aFont = $this->formatPadrao;
1990
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1991
        
1992
        $wCol02=0.18;
1993
        $x += $w * $wCol02;
1994
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1995
        $texto = 'ALÍQ ICMS';
1996
        $aFont = $this->formatPadrao;
1997
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1998
        
1999
        $x += $w * $wCol02;
2000
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2001
        $texto = 'VALOR ICMS';
2002
        $aFont = $this->formatPadrao;
2003
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2004
        
2005
        $x += $w * $wCol02;
2006
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2007
        $texto = '% RED. BC ICMS';
2008
        $aFont = $this->formatPadrao;
2009
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2010
        
2011
        /*$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...
2012
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2013
        $texto = 'ICMS ST';
2014
        $aFont = $this->formatPadrao;
2015
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2016
         * */
2017
        
2018
        $x = $oldX;
2019
        $y = $y + 4;
2020
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2021
        switch ($texto) {
2022
            case '00':
2023
                $texto = "00 - Tributação normal ICMS";
2024
                break;
2025
            case '20':
2026
                $texto = "20 - Tributação com BC reduzida do ICMS";
2027
                break;
2028
            case '40':
2029
                $texto = "40 - ICMS isenção";
2030
                break;
2031
            case '41':
2032
                $texto = "41 - ICMS não tributada";
2033
                break;
2034
            case '51':
2035
                $texto = "51 - ICMS diferido";
2036
                break;
2037
            case '60':
2038
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2039
                break;
2040
            case '90':
2041
                $texto = "90 - ICMS outros";
2042
                break;
2043
        }
2044
        $texto .= $this->pSimpleGetValue($this->ICMSSN, "indSN");
2045
        $texto = $texto == 1 ? 'Simples Nacional' : $texto;
2046
        $aFont = $this->formatNegrito;
2047
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2048
        $x += $w * 0.26;
2049
        
2050
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2051
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : '';
2052
        $aFont = $this->formatNegrito;
2053
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2054
        $x += $w * $wCol02;
2055
        
2056
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2057
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
2058
        $aFont = $this->formatNegrito;
2059
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2060
        $x += $w * $wCol02;
2061
        
2062
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2063
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
2064
        $aFont = $this->formatNegrito;
2065
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2066
        $x += $w * $wCol02;
2067
        
2068
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2069
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
2070
        $aFont = $this->formatNegrito;
2071
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2072
        
2073
        /*$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...
2074
        $texto = '';
2075
        $aFont = $this->formatNegrito;
2076
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2077
    } //fim da função compValorDACTE
2078
2079
    /**
2080
     * zGeraChaveAdicCont
2081
     *
2082
     * @return string chave
2083
     */
2084 View Code Duplication
    protected function zGeraChaveAdicCont()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2085
    {
2086
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2087
        // 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...
2088
        $forma = "%02d%d%s%014d%01d%01d%02d";
2089
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2090
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2091
        $CNPJ = substr($CNPJ, -14);
2092
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2093
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2094
        switch ($ICMS_CST) {
2095
            case '00':
2096
            case '20':
2097
                $ICMSp = '1';
2098
                $ICMSs = '2';
2099
                break;
2100
            case '40':
2101
            case '41':
2102
            case '51':
2103
            case '90':
2104
                $ICMSp = '2';
2105
                $ICMSs = '2';
2106
                break;
2107
            case '60':
2108
                $ICMSp = '2';
2109
                $ICMSs = '1';
2110
                break;
2111
        }
2112
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2113
        $rpos = strrpos($dd, '-');
2114
        $dd = substr($dd, $rpos + 1);
2115
        $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...
2116
        $chave = $chave . $this->pModulo11($chave);
2117
        return $chave;
2118
    } //fim zGeraChaveAdicCont
2119
2120
    /**
2121
     * zDocOrig
2122
     * Monta o campo com os documentos originarios.
2123
     *
2124
     * @param  number $x Posição horizontal canto esquerdo
2125
     * @param  number $y Posição vertical canto superior
2126
     * @return number Posição vertical final
2127
     */
2128 View Code Duplication
    protected function zDocOrig($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2129
    {
2130
        $oldX = $x;
2131
        $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...
2132
        if ($this->orientacao == 'P') {
2133
            $maxW = $this->wPrint;
2134
        } else {
2135
            $maxW = $this->wPrint - $this->wCanhoto;
2136
        }
2137
        $w = $maxW;
2138
        
2139
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2140
        if ($this->modal == '1') {
2141
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2142
            // ou combinação veicular, e por viagem
2143
            $h = $this->lota == 1 ? 35 : 53;
2144
        } elseif ($this->modal == '3') {
2145
            $h = 37.6;
2146
        } else {
2147
            $h = 35;
2148
        }
2149
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2150
        $aFont = $this->formatPadrao;
2151
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2152
        $descr1 = 'TIPO DOC';
2153
        $descr2 = 'CNPJ/CHAVE/OBS';
2154
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2155
        
2156
        $y += 3.4;
2157
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2158
        $texto = $descr1;
2159
        $aFont = $this->formatPadrao;
2160
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2161
        $yIniDados = $y;
2162
        
2163
        $x += $w * 0.07;
2164
        $texto = $descr2;
2165
        $aFont = $this->formatPadrao;
2166
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2167
        
2168
        $x += $w * 0.28;
2169
        $texto = $descr3;
2170
        $aFont = $this->formatPadrao;
2171
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2172
        
2173
        $x += $w * 0.14;
2174
        if ($this->modal == '1') {
2175
            if ($this->lota == 1) {
2176
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2177
            } else {
2178
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2179
            }
2180
        } elseif ($this->modal == '3') {
2181
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2182
        } else {
2183
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2184
        }
2185
        $texto = $descr1;
2186
        $aFont = $this->formatPadrao;
2187
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2188
        
2189
        $x += $w * 0.08;
2190
        $texto = $descr2;
2191
        $aFont = $this->formatPadrao;
2192
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2193
        
2194
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2195
        $texto = $descr3;
2196
        $aFont = $this->formatPadrao;
2197
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2198
        $auxX = $oldX;
2199
        $yIniDados += 3;
2200
        foreach ($this->infNF as $k => $d) {
2201
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2202
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2203
            $cnpj = $this->zFormatCNPJCPF($this->rem);
2204
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2205
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2206
            if ($auxX > $w * 0.90) {
2207
                $yIniDados = $yIniDados + 3;
2208
                $auxX = $oldX;
2209
            }
2210
            $texto = $tp;
2211
            $aFont = array(
2212
                'font' => $this->fontePadrao,
2213
                'size' => 8,
2214
                'style' => '');
2215
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2216
            $auxX += $w * 0.07;
2217
            $texto = $cnpj;
2218
            $aFont = array(
2219
                'font' => $this->fontePadrao,
2220
                'size' => 8,
2221
                'style' => '');
2222
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2223
            $auxX += $w * 0.28;
2224
            $texto = $doc;
2225
            $aFont = array(
2226
                'font' => $this->fontePadrao,
2227
                'size' => 8,
2228
                'style' => '');
2229
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2230
            $auxX += $w * 0.15;
2231
        }
2232
        
2233
        foreach ($this->infNFe as $k => $d) {
2234
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2235
            $this->arrayNFe[] = $chaveNFe;
2236
        }
2237
        if (count($this->arrayNFe) >15) {
2238
            $this->flagDocOrigContinuacao = 1;
2239
            $totPag = '2';
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...
2240
        } else {
2241
            $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...
2242
        }
2243
        $totPag = count($this->arrayNFe) >15 ? '2' : '1';
2244
        $r = $this->zCabecalho(1, 1, '1', $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...
2245
        $contador = 0;
2246
        while ($contador < count($this->arrayNFe)) {
2247
            if ($contador == 15) {
2248
                break;
2249
            }
2250
            $tp = 'NF-e';
2251
            $chaveNFe = $this->arrayNFe[$contador];
2252
            $numNFe = substr($chaveNFe, 25, 9);
2253
            $serieNFe = substr($chaveNFe, 22, 3);
2254
            $doc = $serieNFe . '/' . $numNFe;
2255
            if ($auxX > $w * 0.90) {
2256
                $yIniDados = $yIniDados + 3.5;
2257
                $auxX = $oldX;
2258
            }
2259
            $texto = $tp;
2260
            $aFont = array(
2261
                'font' => $this->fontePadrao,
2262
                'size' => 7,
2263
                'style' => '');
2264
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2265
            $auxX += $w * 0.07;
2266
            $texto = $chaveNFe;
2267
            $aFont = array(
2268
                'font' => $this->fontePadrao,
2269
                'size' => 7,
2270
                'style' => '');
2271
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2272
            $auxX += $w * 0.28;
2273
            $texto = $doc;
2274
            $aFont = array(
2275
                'font' => $this->fontePadrao,
2276
                'size' => 7,
2277
                'style' => '');
2278
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2279
            $auxX += $w * 0.15;
2280
            $contador++;
2281
        }
2282
        
2283
        foreach ($this->infOutros as $k => $d) {
2284
            $temp = $this->infOutros->item($k);
2285
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2286
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2287
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2288
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2289
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2290
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2291
            switch ($tpDoc) {
2292
                case "00":
2293
                    $tpDoc = "00 - Declaração";
2294
                    break;
2295
                case "10":
2296
                    $tpDoc = "10 - Dutoviário";
2297
                    break;
2298
                case "99":
2299
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2300
                    break;
2301
                default:
2302
                    break;
2303
            }
2304
            $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...
2305
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2306
            if ($auxX > $w * 0.90) {
2307
                $yIniDados = $yIniDados + 4;
2308
                $auxX = $oldX;
2309
            }
2310
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2311
            $auxX += $w * 0.09;
2312
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2313
            $auxX += $w * 0.28;
2314
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2315
            $auxX += $w * 0.14;
2316
        }
2317
    } //fim da função zDocOrig
2318
2319
    /**
2320
     * zDocOrigContinuacao
2321
     * Monta o campo com os documentos originarios.
2322
     *
2323
     * @param  number $x Posição horizontal canto esquerdo
2324
     * @param  number $y Posição vertical canto superior
2325
     * @return number Posição vertical final
2326
     */
2327 View Code Duplication
    protected function zDocOrigContinuacao($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2328
    {
2329
        $this->pdf->AddPage($this->orientacao, $this->papel);
2330
        $r = $this->zCabecalho(1, 1, '2', '2');
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...
2331
        $oldX = $x;
2332
        $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...
2333
        if ($this->orientacao == 'P') {
2334
            $maxW = $this->wPrint;
2335
        } else {
2336
            $maxW = $this->wPrint - $this->wCanhoto;
2337
        }
2338
        $w = $maxW;
2339
        
2340
        //$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...
2341
        //$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...
2342
        //$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...
2343
        //$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...
2344
        $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2345
        if (count($this->arrayNFe)%2 !=0) {
2346
            $h = $h+3.5;
2347
        } // Caso tenha apenas 1 registro na ultima linha
2348
        
2349
        $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2350
        $aFont = $this->formatPadrao;
2351
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2352
        $descr1 = 'TIPO DOC';
2353
        $descr2 = 'CNPJ/CHAVE/OBS';
2354
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2355
        
2356
        $y += 3.4;
2357
        $this->pdf->Line($x, $y, $w + 1, $y);
2358
        $texto = $descr1;
2359
        $aFont = $this->formatPadrao;
2360
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2361
        $yIniDados = $y;
2362
        
2363
        $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2364
        $texto = $descr2;
2365
        $aFont = $this->formatPadrao;
2366
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2367
        
2368
        $x += $w * 0.28;
2369
        $texto = $descr3;
2370
        $aFont = $this->formatPadrao;
2371
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2372
        
2373
        $x += $w * 0.14;
2374
        if ($this->modal == '1') {
2375
            if ($this->lota == 1) {
2376
                $this->pdf->Line($x, $y, $x, $y + 31.5);
2377
            } else {
2378
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2379
            }
2380
        } elseif ($this->modal == '3') {
2381
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2382
        } else {
2383
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2384
        }
2385
        $texto = $descr1;
2386
        $aFont = $this->formatPadrao;
2387
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2388
                
2389
        $x += $w * 0.08;
2390
        $texto = $descr2;
2391
        $aFont = $this->formatPadrao;
2392
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2393
        
2394
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2395
        $texto = $descr3;
2396
        $aFont = $this->formatPadrao;
2397
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2398
        $auxX = $oldX;
2399
        $yIniDados += 3;
2400
        
2401
        $contador = 16;
0 ignored issues
show
Unused Code introduced by
$contador 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...
2402
        for ($contador = 16; $contador < count($this->arrayNFe); $contador++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
2403
            $tp = 'NF-e';
2404
            $chaveNFe = $this->arrayNFe[$contador];
2405
            $numNFe = substr($chaveNFe, 25, 9);
2406
            $serieNFe = substr($chaveNFe, 22, 3);
2407
            $doc = $serieNFe . '/' . $numNFe;
2408
            if ($auxX > $w * 0.90) {
2409
                $yIniDados = $yIniDados + 3.5;
2410
                $auxX = $oldX;
2411
            }
2412
            $texto = $tp;
2413
            $aFont = array(
2414
                'font' => $this->fontePadrao,
2415
                'size' => 7,
2416
                'style' => '');
2417
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2418
            $auxX += $w * 0.07;
2419
            $texto = $chaveNFe;
2420
            $aFont = array(
2421
                'font' => $this->fontePadrao,
2422
                'size' => 7,
2423
                'style' => '');
2424
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2425
            $auxX += $w * 0.28;
2426
            $texto = $doc;
2427
            $aFont = array(
2428
                'font' => $this->fontePadrao,
2429
                'size' => 7,
2430
                'style' => '');
2431
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2432
            $auxX += $w * 0.15;
2433
        }
2434
    } //fim da função zDocOrigContinuacao
2435
2436
    /**
2437
     * zDocCompl
2438
     * Monta o campo com os dados do remetente na DACTE.
2439
     *
2440
     * @param number $x Posição horizontal canto esquerdo
2441
     * @param number $y Posição vertical canto superior
2442
     * @return number Posição vertical final
2443
     */
2444 View Code Duplication
    protected function zDocCompl($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2445
    {
2446
        $oldX = $x;
2447
        $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...
2448
        if ($this->orientacao == 'P') {
2449
            $maxW = $this->wPrint;
2450
        } else {
2451
            $maxW = $this->wPrint - $this->wCanhoto;
2452
        }
2453
        $w = $maxW;
2454
        $h = 80;
2455
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2456
        $aFont = $this->formatPadrao;
2457
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2458
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2459
        $descr2 = 'VALOR COMPLEMENTADO';
2460
        $y += 3.4;
2461
        $this->pdf->Line($x, $y, $w + 1, $y);
2462
        $texto = $descr1;
2463
        $aFont = $this->formatPadrao;
2464
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2465
        $yIniDados = $y;
2466
        $x += $w * 0.37;
2467
        $texto = $descr2;
2468
        $aFont = $this->formatPadrao;
2469
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2470
        $x += $w * 0.13;
2471
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2472
        $texto = $descr1;
2473
        $aFont = $this->formatPadrao;
2474
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2475
        $x += $w * 0.3;
2476
        $texto = $descr2;
2477
        $aFont = $this->formatPadrao;
2478
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2479
        $auxX = $oldX;
2480
        $yIniDados += 4;
2481
        if ($auxX > $w * 0.90) {
2482
            $yIniDados = $yIniDados + 4;
2483
            $auxX = $oldX;
2484
        }
2485
        $texto = $this->chaveCTeRef;
2486
        $aFont = array(
2487
            'font' => $this->fontePadrao,
2488
            'size' => 8,
2489
            'style' => '');
2490
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2491
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2492
        $aFont = array(
2493
            'font' => $this->fontePadrao,
2494
            'size' => 8,
2495
            'style' => '');
2496
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2497
    } //fim da função zDocCompl
2498
2499
    /**
2500
     * zObs
2501
     * Monta o campo com os dados do remetente na DACTE.
2502
     *
2503
     * @param  number $x Posição horizontal canto esquerdo
2504
     * @param  number $y Posição vertical canto superior
2505
     * @return number Posição vertical final
2506
     */
2507
    protected function zObs($x = 0, $y = 0)
2508
    {
2509
        $oldX = $x;
2510
        $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...
2511
        if ($this->orientacao == 'P') {
2512
            $maxW = $this->wPrint;
2513
        } else {
2514
            $maxW = $this->wPrint - $this->wCanhoto;
2515
        }
2516
        $w = $maxW;
2517
        //$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...
2518
        $h = 18.8;
2519
        $texto = 'OBSERVAÇÕES';
2520
        $aFont = $this->formatPadrao;
2521
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2522
        $y += 3.4;
2523
        $this->pdf->Line($x, $y, $w + 1, $y);
2524
        $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...
2525
        $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...
2526
        $texto = '';
2527 View Code Duplication
        foreach ($this->compl as $k => $d) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2528
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2529
            $texto .= $xObs;
2530
        }
2531
        $textoObs = explode("Motorista:", $texto);
2532
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2533
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2534
        $texto .= $this->zLocalEntrega();
2535
        $aFont = array(
2536
            'font' => $this->fontePadrao,
2537
            'size' => 7.5,
2538
            'style' => '');
2539
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2540
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2541
    } //fim da função obsDACTE
2542
2543
    /**
2544
     * zLocalEntrega
2545
     *
2546
     * @return string
2547
     */
2548 View Code Duplication
    protected function zLocalEntrega()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2549
    {
2550
        $locEntX = $this->dest->getElementsByTagName('locEnt');
2551
        if ($locEntX->length > 0) {
2552
            $locEnt = $locEntX->item(0);
2553
            $output = "Entrega: " . $output = $this->zFormatCNPJCPF($locEnt);
2554
            $output .= $this->pSimpleGetValue($locEnt, "CPF") . " ";
2555
            $output .= $this->pSimpleGetValue($locEnt, "xNome") . " ";
2556
            $output .= $this->pSimpleGetValue($locEnt, "xLgr") . " ";
2557
            $output .= $this->pSimpleGetValue($locEnt, "nro ") . " ";
2558
            $output .= $this->pSimpleGetValue($locEnt, "xCpl") . " ";
2559
            $output .= $this->pSimpleGetValue($locEnt, "xBairro") . " ";
2560
            $output .= $this->pSimpleGetValue($locEnt, "xMun") . " ";
2561
            $output .= $this->pSimpleGetValue($locEnt, "UF") . " ";
2562
            return $output;
2563
        }
2564
        return "";
2565
    } //fim zLocalEntrega
2566
2567
    /**
2568
     * zModalRod
2569
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2570
     *
2571
     * @param  number $x Posição horizontal canto esquerdo
2572
     * @param  number $y Posição vertical canto superior
2573
     * @return number Posição vertical final
2574
     */
2575
    protected function zModalRod($x = 0, $y = 0)
2576
    {
2577
        $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...
2578
        $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...
2579
        $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...
2580
        if ($this->orientacao == 'P') {
2581
            $maxW = $this->wPrint;
2582
        } else {
2583
            $maxW = $this->wPrint - $this->wCanhoto;
2584
        }
2585
        $w = $maxW;
2586
        $h = 18.5;
2587
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2588
        $aFont = $this->formatPadrao;
2589
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2590 View Code Duplication
        if ($this->lota == 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2591
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2592
        }
2593
        $y += 3.4;
2594
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2595
        $texto = 'RNTRC DA EMPRESA';
2596
        $aFont = $this->formatPadrao;
2597
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2598
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2599
        $aFont = $this->formatNegrito;
2600
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2601
        $x += $w * 0.23;
2602
        
2603
        $this->pdf->Line($x-20, $y, $x-20, $y + 8.5); // LINHA A FRENTE DA RNTRC DA EMPRESA
2604
        
2605
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2606
        $aFont = $this->formatPadrao;
2607
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2608
    } //fim da função zModalRod
2609
2610
    /**
2611
     * zModalAquaviario
2612
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2613
     *
2614
     * @param  number $x Posição horizontal canto esquerdo
2615
     * @param  number $y Posição vertical canto superior
2616
     * @return number Posição vertical final
2617
     */
2618 View Code Duplication
    protected function zModalAquaviario($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2619
    {
2620
        $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...
2621
        $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...
2622
        if ($this->orientacao == 'P') {
2623
            $maxW = $this->wPrint;
2624
        } else {
2625
            $maxW = $this->wPrint - $this->wCanhoto;
2626
        }
2627
        $w = $maxW;
2628
        $h = 8.5;
2629
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2630
        $aFont = $this->formatPadrao;
2631
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2632
        $y += 3.4;
2633
        $this->pdf->Line($x, $y, $w + 1, $y);
2634
        $texto = 'PORTO DE EMBARQUE';
2635
        $aFont = $this->formatPadrao;
2636
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2637
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2638
        $aFont = $this->formatNegrito;
2639
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2640
        $x += $w * 0.50;
2641
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2642
        $texto = 'PORTO DE DESTINO';
2643
        $aFont = $this->formatPadrao;
2644
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2645
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2646
        $aFont = $this->formatNegrito;
2647
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2648
        $y += 8;
2649
        $this->pdf->Line(208, $y, 1, $y);
2650
        $x = 1;
2651
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2652
        $aFont = $this->formatPadrao;
2653
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2654
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2655
        $aFont = $this->formatNegrito;
2656
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2657
        $x += $w * 0.50;
2658
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2659
        $texto = 'VR DA B. DE CALC. AFRMM';
2660
        $aFont = $this->formatPadrao;
2661
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2662
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2663
        $aFont = $this->formatNegrito;
2664
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2665
        $x += $w * 0.17;
2666
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2667
        $texto = 'VALOR DO AFRMM';
2668
        $aFont = $this->formatPadrao;
2669
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2670
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2671
        $aFont = $this->formatNegrito;
2672
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2673
        $x += $w * 0.12;
2674
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2675
        $texto = 'TIPO DE NAVEGAÇÃO';
2676
        $aFont = $this->formatPadrao;
2677
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2678
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2679
        switch ($texto) {
2680
            case '0':
2681
                $texto = 'INTERIOR';
2682
                break;
2683
            case '1':
2684
                $texto = 'CABOTAGEM';
2685
                break;
2686
        }
2687
        $aFont = $this->formatNegrito;
2688
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2689
        $x += $w * 0.14;
2690
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2691
        $texto = 'DIREÇÃO';
2692
        $aFont = $this->formatPadrao;
2693
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2694
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2695
        switch ($texto) {
2696
            case 'N':
2697
                $texto = 'NORTE';
2698
                break;
2699
            case 'L':
2700
                $texto = 'LESTE';
2701
                break;
2702
            case 'S':
2703
                $texto = 'SUL';
2704
                break;
2705
            case 'O':
2706
                $texto = 'OESTE';
2707
                break;
2708
        }
2709
        $aFont = $this->formatNegrito;
2710
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2711
        $y += 8;
2712
        $this->pdf->Line(208, $y, 1, $y);
2713
        $x = 1;
2714
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2715
        $aFont = $this->formatPadrao;
2716
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2717
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2718
            $texto = $this->infNF
2719
                ->item(0)
2720
                ->getElementsByTagName('infUnidCarga')
2721
                ->item(0)
2722
                ->getElementsByTagName('idUnidCarga')
2723
                ->item(0)->nodeValue;
2724
        } elseif ($this->infNFe->item(0) !== null
2725
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2726
        ) {
2727
            $texto = $this->infNFe
2728
                ->item(0)
2729
                ->getElementsByTagName('infUnidCarga')
2730
                ->item(0)
2731
                ->getElementsByTagName('idUnidCarga')
2732
                ->item(0)
2733
                ->nodeValue;
2734
        } elseif ($this->infOutros->item(0) !== null
2735
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2736
        ) {
2737
            $texto = $this->infOutros
2738
                ->item(0)
2739
                ->getElementsByTagName('infUnidCarga')
2740
                ->item(0)
2741
                ->getElementsByTagName('idUnidCarga')
2742
                ->item(0)
2743
                ->nodeValue;
2744
        } else {
2745
            $texto = '';
2746
        }
2747
        $aFont = $this->formatNegrito;
2748
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2749
        $x += $w * 0.50;
2750
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2751
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2752
        $aFont = $this->formatPadrao;
2753
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2754
        $texto = '';
2755
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2756
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2757
                if ($k == 0) {
2758
                    $texto = $this->aquav
2759
                        ->getElementsByTagName('balsa')
2760
                        ->item($k)
2761
                        ->getElementsByTagName('xBalsa')
2762
                        ->item(0)
2763
                        ->nodeValue;
2764
                } else {
2765
                    $texto = $texto
2766
                        . ' / '
2767
                        . $this->aquav
2768
                            ->getElementsByTagName('balsa')
2769
                            ->item($k)
2770
                            ->getElementsByTagName('xBalsa')
2771
                            ->item(0)
2772
                            ->nodeValue;
2773
                }
2774
            }
2775
        }
2776
        $aFont = $this->formatNegrito;
2777
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2778
    } //fim da função zModalRod
2779
2780
    /**
2781
     * zModalFerr
2782
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2783
     *
2784
     * @param  number $x Posição horizontal canto esquerdo
2785
     * @param  number $y Posição vertical canto superior
2786
     * @return number Posição vertical final
2787
     */
2788 View Code Duplication
    protected function zModalFerr($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2789
    {
2790
        $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...
2791
        $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...
2792
        if ($this->orientacao == 'P') {
2793
            $maxW = $this->wPrint;
2794
        } else {
2795
            $maxW = $this->wPrint - $this->wCanhoto;
2796
        }
2797
        $w = $maxW;
2798
        $h = 19.6;
2799
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2800
        $aFont = $this->formatPadrao;
2801
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2802
        $y += 3.4;
2803
        $this->pdf->Line($x, $y, $w + 1, $y);
2804
        $texto = 'DCL';
2805
        $aFont = array(
2806
            'font' => $this->fontePadrao,
2807
            'size' => 7,
2808
            'style' => 'B');
2809
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2810
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2811
        $texto = 'VAGÕES';
2812
        $aFont = array(
2813
            'font' => $this->fontePadrao,
2814
            'size' => 7,
2815
            'style' => 'B');
2816
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2817
        $y += 3.4;
2818
        $this->pdf->Line($x, $y, $w + 1, $y);
2819
        // DCL
2820
        $texto = 'ID TREM';
2821
        $aFont = array(
2822
            'font' => $this->fontePadrao,
2823
            'size' => 6,
2824
            'style' => '');
2825
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2826
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
2827
        $aFont = array(
2828
            'font' => $this->fontePadrao,
2829
            'size' => 6,
2830
            'style' => 'B');
2831
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2832
        $x += $w * 0.06;
2833
        $y1 = $y + 12.5;
2834
        $this->pdf->Line($x, $y, $x, $y1);
2835
        $texto = 'NUM';
2836
        $aFont = array(
2837
            'font' => $this->fontePadrao,
2838
            'size' => 6,
2839
            'style' => '');
2840
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2841
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
2842
        $aFont = array(
2843
            'font' => $this->fontePadrao,
2844
            'size' => 6,
2845
            'style' => 'B');
2846
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2847
        $x += $w * 0.06;
2848
        $this->pdf->Line($x, $y, $x, $y1);
2849
        $texto = 'SÉRIE';
2850
        $aFont = array(
2851
            'font' => $this->fontePadrao,
2852
            'size' => 6,
2853
            'style' => '');
2854
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2855
        $texto = $this->pSimpleGetValue($this->rem, "serie");
2856
        $aFont = array(
2857
            'font' => $this->fontePadrao,
2858
            'size' => 6,
2859
            'style' => 'B');
2860
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2861
        $x += $w * 0.06;
2862
        $this->pdf->Line($x, $y, $x, $y1);
2863
        $texto = 'EMISSÃO';
2864
        $aFont = array(
2865
            'font' => $this->fontePadrao,
2866
            'size' => 6,
2867
            'style' => '');
2868
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2869
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
2870
        $aFont = array(
2871
            'font' => $this->fontePadrao,
2872
            'size' => 6,
2873
            'style' => 'B');
2874
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2875
        // VAGOES
2876
        $x += $w * 0.06;
2877
        $this->pdf->Line($x, $y, $x, $y1);
2878
        $texto = 'NUM';
2879
        $aFont = array(
2880
            'font' => $this->fontePadrao,
2881
            'size' => 6,
2882
            'style' => '');
2883
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2884
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
2885
        $aFont = array(
2886
            'font' => $this->fontePadrao,
2887
            'size' => 6,
2888
            'style' => 'B');
2889
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2890
        $x += $w * 0.06;
2891
        $this->pdf->Line($x, $y, $x, $y1);
2892
        $texto = 'TIPO';
2893
        $aFont = array(
2894
            'font' => $this->fontePadrao,
2895
            'size' => 6,
2896
            'style' => '');
2897
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2898
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
2899
        $aFont = array(
2900
            'font' => $this->fontePadrao,
2901
            'size' => 6,
2902
            'style' => 'B');
2903
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2904
        $x += $w * 0.06;
2905
        $this->pdf->Line($x, $y, $x, $y1);
2906
        $texto = 'CAPACIDADE';
2907
        $aFont = array(
2908
            'font' => $this->fontePadrao,
2909
            'size' => 6,
2910
            'style' => '');
2911
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2912
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
2913
        $aFont = array(
2914
            'font' => $this->fontePadrao,
2915
            'size' => 6,
2916
            'style' => 'B');
2917
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2918
        $x += $w * 0.08;
2919
        $this->pdf->Line($x, $y, $x, $y1);
2920
        $texto = 'PESO REAL/TON';
2921
        $aFont = array(
2922
            'font' => $this->fontePadrao,
2923
            'size' => 6,
2924
            'style' => '');
2925
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2926
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
2927
        $aFont = array(
2928
            'font' => $this->fontePadrao,
2929
            'size' => 6,
2930
            'style' => 'B');
2931
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2932
        $x += $w * 0.09;
2933
        $this->pdf->Line($x, $y, $x, $y1);
2934
        $texto = 'PESO BRUTO/TON';
2935
        $aFont = array(
2936
            'font' => $this->fontePadrao,
2937
            'size' => 6,
2938
            'style' => '');
2939
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2940
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
2941
        $aFont = array(
2942
            'font' => $this->fontePadrao,
2943
            'size' => 6,
2944
            'style' => 'B');
2945
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2946
        $x += $w * 0.1;
2947
        $this->pdf->Line($x, $y, $x, $y1);
2948
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
2949
        $aFont = array(
2950
            'font' => $this->fontePadrao,
2951
            'size' => 6,
2952
            'style' => '');
2953
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2954
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
2955
        $aFont = array(
2956
            'font' => $this->fontePadrao,
2957
            'size' => 6,
2958
            'style' => 'B');
2959
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2960
        // FLUXO
2961
        $x = 1;
2962
        $y += 12.9;
2963
        $h1 = $h * 0.5 + 0.27;
2964
        $wa = round($w * 0.103) + 0.5;
2965
        $texto = 'FLUXO FERROVIARIO';
2966
        $aFont = $this->formatPadrao;
2967
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2968
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
2969
        $aFont = array(
2970
            'font' => $this->fontePadrao,
2971
            'size' => 7,
2972
            'style' => 'B');
2973
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2974
        $y += 10;
2975
        $texto = 'TIPO DE TRÁFEGO';
2976
        $aFont = $this->formatPadrao;
2977
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2978
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
2979
        $aFont = array(
2980
            'font' => $this->fontePadrao,
2981
            'size' => 7,
2982
            'style' => 'B');
2983
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2984
        // Novo Box Relativo a Modal Ferroviário
2985
        $x = 22.5;
2986
        $y += -10.2;
2987
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
2988
        $aFont = $this->formatPadrao;
2989
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
2990
        $y += 3.4;
2991
        $this->pdf->Line($x, $y, $w + 1, $y);
2992
        $w = $w * 0.2;
2993
        $h = $h * 1.04;
2994
        $texto = 'CÓDIGO INTERNO';
2995
        $aFont = array(
2996
            'font' => $this->fontePadrao,
2997
            'size' => 6,
2998
            'style' => '');
2999
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3000
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3001
        $aFont = array(
3002
            'font' => $this->fontePadrao,
3003
            'size' => 6,
3004
            'style' => 'B');
3005
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3006
        $texto = 'CNPJ';
3007
        $aFont = array(
3008
            'font' => $this->fontePadrao,
3009
            'size' => 6,
3010
            'style' => '');
3011
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3012
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3013
        $aFont = array(
3014
            'font' => $this->fontePadrao,
3015
            'size' => 6,
3016
            'style' => 'B');
3017
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3018
        $x += 50;
3019
        $texto = 'NOME';
3020
        $aFont = array(
3021
            'font' => $this->fontePadrao,
3022
            'size' => 6,
3023
            'style' => '');
3024
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3025
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3026
        $aFont = array(
3027
            'font' => $this->fontePadrao,
3028
            'size' => 6,
3029
            'style' => 'B');
3030
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3031
        $texto = 'INSCRICAO ESTADUAL';
3032
        $aFont = array(
3033
            'font' => $this->fontePadrao,
3034
            'size' => 6,
3035
            'style' => '');
3036
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3037
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3038
        $aFont = array(
3039
            'font' => $this->fontePadrao,
3040
            'size' => 6,
3041
            'style' => 'B');
3042
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3043
        $x += 50;
3044
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3045
        $aFont = array(
3046
            'font' => $this->fontePadrao,
3047
            'size' => 6,
3048
            'style' => '');
3049
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3050
        $texto = '';
3051
        $aFont = array(
3052
            'font' => $this->fontePadrao,
3053
            'size' => 6,
3054
            'style' => 'B');
3055
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3056
    } //fim da função zModalFerr
3057
3058
    /**
3059
     * zCanhoto
3060
     * Monta o campo com os dados do remetente na DACTE.
3061
     *
3062
     * @param  number $x Posição horizontal canto esquerdo
3063
     * @param  number $y Posição vertical canto superior
3064
     * @return number Posição vertical final
3065
     */
3066 View Code Duplication
    protected function zCanhoto($x = 0, $y = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3067
    {
3068
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3069
        $y = $y + 2;
3070
        $oldX = $x;
3071
        $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...
3072
        if ($this->orientacao == 'P') {
3073
            $maxW = $this->wPrint;
3074
        } else {
3075
            $maxW = $this->wPrint - $this->wCanhoto;
3076
        }
3077
        $w = $maxW - 1;
3078
        $h = 20;
3079
        $y = $y + 1;
3080
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3081
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3082
        $aFont = $this->formatPadrao;
3083
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3084
        $y += 3.4;
3085
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3086
        
3087
        $texto = 'NOME';
3088
        $aFont = array(
3089
            'font' => $this->fontePadrao,
3090
            'size' => 6,
3091
            'style' => '');
3092
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3093
        $x += $w * 0.25;
3094
        
3095
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3096
        
3097
        $texto = 'ASSINATURA / CARIMBO';
3098
        $aFont = array(
3099
            'font' => $this->fontePadrao,
3100
            'size' => 6,
3101
            'style' => '');
3102
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3103
        $x += $w * 0.25;
3104
        
3105
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3106
        
3107
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3108
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3109
        $aFont = array(
3110
            'font' => $this->fontePadrao,
3111
            'size' => 6,
3112
            'style' => '');
3113
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3114
        $x = $oldX;
3115
        $y = $y + 5;
3116
        
3117
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3118
        
3119
        $texto = 'RG';
3120
        $aFont = array(
3121
            'font' => $this->fontePadrao,
3122
            'size' => 6,
3123
            'style' => '');
3124
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3125
        $x += $w * 0.85;
3126
        
3127
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3128
        
3129
        $texto = "CT-E";
3130
        $aFont = $this->formatNegrito;
3131
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3132
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3133
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3134
        $aFont = array(
3135
            'font' => $this->fontePadrao,
3136
            'size' => 6,
3137
            'style' => '');
3138
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3139
        $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...
3140
        //$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...
3141
    } //fim da função canhotoDACTE
3142
3143
    /**
3144
     * zDadosAdic
3145
     * Coloca o grupo de dados adicionais da DACTE.
3146
     *
3147
     * @param  number $x Posição horizontal canto esquerdo
3148
     * @param  number $y Posição vertical canto superior
3149
     * @param  number $h altura do campo
3150
     * @return number Posição vertical final
3151
     */
3152 View Code Duplication
    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...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3153
    {
3154
        $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...
3155
        //###########################################################################
3156
        //DADOS ADICIONAIS DACTE
3157
        if ($this->orientacao == 'P') {
3158
            $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...
3159
        } else {
3160
            $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...
3161
        }
3162
        //INFORMAÇÕES COMPLEMENTARES
3163
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3164
        $y += 3;
3165
        $w = $this->wAdic;
3166
        $h = 8; //mudar
3167
        $aFont = array(
3168
            'font' => $this->fontePadrao,
3169
            'size' => 6,
3170
            'style' => '');
3171
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3172
        //$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...
3173
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3174
        //o texto com os dados adicionais foi obtido na função xxxxxx
3175
        //e carregado em uma propriedade privada da classe
3176
        //$this->wAdic com a largura do campo
3177
        //$this->textoAdic com o texto completo do campo
3178
        $y += 1;
3179
        $aFont = $this->formatPadrao;
3180
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3181
        //RESERVADO AO FISCO
3182
        $texto = "RESERVADO AO FISCO";
3183
        $x += $w;
3184
        $y -= 1;
3185
        if ($this->orientacao == 'P') {
3186
            $w = $this->wPrint - $w;
3187
        } else {
3188
            $w = $this->wPrint - $w - $this->wCanhoto;
3189
        }
3190
        $aFont = array(
3191
            'font' => $this->fontePadrao,
3192
            'size' => 6,
3193
            'style' => '');
3194
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3195
        //inserir texto informando caso de contingência
3196
        //1 – Normal – emissão normal;
3197
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3198
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3199
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3200
        //Emissão em Contingência – DPEC;
3201
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3202
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3203
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3204
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3205
        $texto = '';
3206
        switch ($this->tpEmis) {
3207
            case 2:
3208
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3209
                break;
3210
            case 3:
3211
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3212
                break;
3213
            case 4:
3214
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3215
                break;
3216
            case 5:
3217
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3218
                break;
3219
        }
3220
        $y += 2;
3221
        $aFont = $this->formatPadrao;
3222
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3223
        return $y + $h;
3224
    } //fim zDadosAdic
3225
3226
    /**
3227
     * zhDashedLine
3228
     * Desenha uma linha horizontal tracejada com o FPDF
3229
     *
3230
     * @param  number $x Posição horizontal inicial, em mm
3231
     * @param  number $y Posição vertical inicial, em mm
3232
     * @param  number $w Comprimento da linha, em mm
3233
     * @param  number $h Espessura da linha, em mm
3234
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3235
     * @return none
3236
     */
3237 View Code Duplication
    protected function zhDashedLine($x, $y, $w, $h, $n)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3238
    {
3239
        $this->pdf->SetLineWidth($h);
3240
        $wDash = ($w / $n) / 2; // comprimento dos traços
3241
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3242
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3243
                if ($j <= ($x + $w - 1)) {
3244
                    $this->pdf->Line($j, $y, $j + 1, $y);
3245
                }
3246
            }
3247
        }
3248
    } //fim função hDashedLine
3249
3250
    /**
3251
     * zhDashedVerticalLine
3252
     * Desenha uma linha vertical tracejada com o FPDF
3253
     *
3254
     * @param  number $x Posição horizontal inicial, em mm
3255
     * @param  number $y Posição vertical inicial, em mm
3256
     * @param  number $w Comprimento da linha, em mm
3257
     * @param  number $yfinal Espessura da linha, em mm
3258
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3259
     * @return none
3260
     */
3261 View Code Duplication
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3262
    {
3263
        $this->pdf->SetLineWidth($w);
3264
        /* Organizando valores */
3265
        if ($y > $yfinal) {
3266
            $aux = $yfinal;
3267
            $yfinal = $y;
3268
            $y = $aux;
3269
        }
3270
        while ($y < $yfinal && $n > 0) {
3271
            $this->pdf->Line($x, $y, $x, $y + 1);
3272
            $y += 3;
3273
            $n--;
3274
        }
3275
    } //fim função hDashedVerticalLine
3276
3277
    /**
3278
     * zFormatCNPJCPF
3279
     * Formata campo CnpjCpf contida na CTe
3280
     *
3281
     * @param  string $field campo cnpjCpf da CT-e
3282
     * @return string
3283
     */
3284 View Code Duplication
    protected function zFormatCNPJCPF($field)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3285
    {
3286
        if (!isset($field)) {
3287
            return '';
3288
        }
3289
        $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...
3290
            $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...
3291
        if ($cnpj != "" && $cnpj != "00000000000000") {
3292
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3293
        } else {
3294
            $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...
3295
                $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...
3296
        }
3297
        return $cnpj;
3298
    } //fim formatCNPJCPF
3299
3300
    /**
3301
     * zFormatFone
3302
     * Formata campo fone contida na CTe
3303
     *
3304
     * @param  string $field campo fone da CT-e
3305
     * @return string
3306
     */
3307 View Code Duplication
    protected function zFormatFone($field)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3308
    {
3309
        try {
3310
            $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...
3311
            $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...
3312
            $foneLen = strlen($fone);
3313
            if ($foneLen > 0) {
3314
                $fone2 = substr($fone, 0, $foneLen - 4);
3315
                $fone1 = substr($fone, 0, $foneLen - 8);
3316
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3317
            } else {
3318
                $fone = '';
3319
            }
3320
            return $fone;
3321
        } catch (Exception $exc) {
3322
            return '';
3323
        }
3324
    } //fim formatFone
3325
3326
    /**
3327
     * zUnidade
3328
     * Converte a imformação de peso contida na CTe
3329
     *
3330
     * @param  string $c unidade de trafego extraida da CTe
3331
     * @return string
3332
     */
3333 View Code Duplication
    protected function zUnidade($c = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3334
    {
3335
        switch ($c) {
3336
            case '00':
3337
                $r = 'M3';
3338
                break;
3339
            case '01':
3340
                $r = 'KG';
3341
                break;
3342
            case '02':
3343
                $r = 'TON';
3344
                break;
3345
            case '03':
3346
                $r = 'UN';
3347
                break;
3348
            case '04':
3349
                $r = 'LT';
3350
                break;
3351
            case '05':
3352
                $r = 'MMBTU';
3353
                break;
3354
            default:
3355
                $r = '';
3356
        }
3357
        return $r;
3358
    } //fim unidade
3359
3360
    /**
3361
     * zConvertUnidTrafego
3362
     * Converte a imformação de peso contida na CTe
3363
     *
3364
     * @param  string $U Informação de trafego extraida da CTe
3365
     * @return string
3366
     */
3367 View Code Duplication
    protected function zConvertUnidTrafego($U = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3368
    {
3369
        if ($U) {
3370
            switch ($U) {
3371
                case '0':
3372
                    $stringU = 'Próprio';
3373
                    break;
3374
                case '1':
3375
                    $stringU = 'Mútuo';
3376
                    break;
3377
                case '2':
3378
                    $stringU = 'Rodoferroviário';
3379
                    break;
3380
                case '3':
3381
                    $stringU = 'Rodoviário';
3382
                    break;
3383
            }
3384
            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...
3385
        }
3386
    } //fim da função zConvertUnidTrafego
3387
3388
    /**
3389
     * zMultiUniPeso
3390
     * Fornece a imformação multiplicação de peso contida na CTe
3391
     *
3392
     * @param  interger $U Informação de peso extraida da CTe
3393
     * @return interger
3394
     */
3395
    protected function zMultiUniPeso($U = '')
3396
    {
3397
        if ($U === "01") {
3398
            // tonelada
3399
            //return 1000;
3400
            return 1;
3401
        }
3402
        return 1; // M3, KG, Unidade, litros, mmbtu
3403
    } //fim da função zMultiUniPeso
3404
}
3405