Completed
Push — master ( 8a0e3b...edebfd )
by Roberto
04:18 queued 50s
created

Dacte::zhDashedVerticalLine()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 10
c 0
b 0
f 0
nc 4
nop 5
dl 15
loc 15
ccs 0
cts 14
cp 0
crap 20
rs 9.2
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 NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Legacy\Common;
21
22
class Dacte extends Common
23
{
24
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
25
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
26
    const SIT_DPEC = 3;
27
28
    protected $logoAlign = 'C';
29
    protected $yDados = 0;
30
    protected $situacao_externa = 0;
31
    protected $numero_registro_dpec = '';
32
    protected $pdf;
33
    protected $xml;
34
    protected $logomarca = '';
35
    protected $errMsg = '';
36
    protected $errStatus = false;
37
    protected $orientacao = 'P';
38
    protected $papel = 'A4';
39
    protected $destino = 'I';
40
    protected $pdfDir = '';
41
    protected $fontePadrao = 'Times';
42
    protected $version = '1.3.0';
43
    protected $wPrint;
44
    protected $hPrint;
45
    protected $dom;
46
    protected $infCte;
47
    protected $infCteComp;
48
    protected $chaveCTeRef;
49
    protected $tpCTe;
50
    protected $ide;
51
    protected $emit;
52
    protected $enderEmit;
53
    protected $rem;
54
    protected $enderReme;
55
    protected $dest;
56
    protected $enderDest;
57
    protected $exped;
58
    protected $enderExped;
59
    protected $receb;
60
    protected $enderReceb;
61
    protected $infCarga;
62
    protected $infQ;
63
    protected $seg;
64
    protected $modal;
65
    protected $rodo;
66
    protected $moto;
67
    protected $veic;
68
    protected $ferrov;
69
    protected $Comp;
70
    protected $infNF;
71
    protected $infNFe;
72
    protected $compl;
73
    protected $ICMS;
74
    protected $imp;
75
    protected $toma4;
76
    protected $toma03;
77
    protected $tpEmis;
78
    protected $tpImp;
79
    protected $tpAmb;
80
    protected $vPrest;
81
    protected $wAdic = 150;
82
    protected $textoAdic = '';
83
    protected $debugMode = 2;
84
    protected $formatPadrao;
85
    protected $formatNegrito;
86
    protected $aquav;
87
    protected $preVisualizar;
88
    protected $flagDocOrigContinuacao;
89
    protected $arrayNFe = array();
90
91
    /**
92
     * __construct
93
     *
94
     * @param string $docXML Arquivo XML da CTe
95
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
96
     * @param string $sPapel Tamanho do papel (Ex. A4)
97
     * @param string $sPathLogo Caminho para o arquivo do logo
98
     * @param string $sDestino Estabelece a direção do envio do documento PDF
99
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
100
     * @param string $fonteDACTE Nome da fonte a ser utilizada
101
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
102
     * @param string $preVisualizar 0-Não 1-Sim
103
     */
104
    public function __construct(
105
        $docXML = '',
106
        $sOrientacao = '',
107
        $sPapel = '',
108
        $sPathLogo = '',
109
        $sDestino = 'I',
110
        $sDirPDF = '',
111
        $fonteDACTE = '',
112
        $mododebug = 2,
113
        $preVisualizar = false
114
    ) {
115
    
116
        if (is_numeric($mododebug)) {
117
            $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...
118
        }
119
        if ($mododebug == 1) {
120
            //ativar modo debug
121
            error_reporting(E_ALL);
122
            ini_set('display_errors', 'On');
123
        } elseif ($mododebug == 0) {
124
            //desativar modo debug
125
            error_reporting(0);
126
            ini_set('display_errors', 'Off');
127
        }
128
        $this->orientacao = $sOrientacao;
129
        $this->papel = $sPapel;
130
        $this->pdf = '';
131
        $this->xml = $docXML;
132
        $this->logomarca = $sPathLogo;
133
        $this->destino = $sDestino;
134
        $this->pdfDir = $sDirPDF;
135
        $this->preVisualizar = $preVisualizar;
136
        // verifica se foi passa a fonte a ser usada
137
        if (!empty($fonteDACTE)) {
138
            $this->fontePadrao = $fonteDACTE;
139
        }
140
        $this->formatPadrao = array(
141
            'font' => $this->fontePadrao,
142
            'size' => 6,
143
            'style' => '');
144
        $this->formatNegrito = array(
145
            'font' => $this->fontePadrao,
146
            'size' => 7,
147
            'style' => 'B');
148
        //se for passado o xml
149
        if (!empty($this->xml)) {
150
            $this->dom = new Dom();
151
            $this->dom->loadXML($this->xml);
152
            $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...
153
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
154
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
155
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
156
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
157
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
158
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
159
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
160
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
161
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
162
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
163
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
164
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
165
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
166
            $this->infQ = $this->dom->getElementsByTagName("infQ");
167
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
168
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
169
            $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...
170
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
171
            $this->veic = $this->dom->getElementsByTagName("veic");
172
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
173
            // adicionar outros modais
174
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
175
            $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chave");
176
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
177
            $this->Comp = $this->dom->getElementsByTagName("Comp");
178
            $this->infNF = $this->dom->getElementsByTagName("infNF");
179
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
180
            $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...
181
            $this->compl = $this->dom->getElementsByTagName("compl");
182
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
183
            $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...
184
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
185
            $textoAdic = number_format($this->pSimpleGetValue($this->imp, "vTotTrib"), 2, ",", ".");
186
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
187
                    .$textoAdic;
188
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
189
            $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
190
            //modal aquaviário
191
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
192
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
193
            //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...
194
            switch ($tomador) {
195
                case '0':
196
                    $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...
197
                    $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...
198
                    break;
199
                case '1':
200
                    $this->toma = $this->exped;
201
                    $this->enderToma = $this->enderExped;
202
                    break;
203
                case '2':
204
                    $this->toma = $this->receb;
205
                    $this->enderToma = $this->enderReceb;
206
                    break;
207
                case '3':
208
                    $this->toma = $this->dest;
209
                    $this->enderToma = $this->enderDest;
210
                    break;
211
                default:
212
                    $this->toma = $this->toma4;
213
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
214
                    break;
215
            }
216
            $seguro = $this->pSimpleGetValue($this->seg, "respSeg");
217
            switch ($seguro) {
218
                case '0':
219
                    $this->respSeg = 'Remetente';
0 ignored issues
show
Bug introduced by
The property respSeg does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
220
                    break;
221
                case '1':
222
                    $this->respSeg = 'Expedidor';
223
                    break;
224
                case '2':
225
                    $this->respSeg = 'Recebedor';
226
                    break;
227
                case '3':
228
                    $this->respSeg = 'Destinatário';
229
                    break;
230
                case '4':
231
                    $this->respSeg = 'Emitente';
232
                    break;
233
                case '5':
234
                    $this->respSeg = 'Tomador';
235
                    break;
236
                default:
237
                    $this->respSeg = '';
238
                    break;
239
            }
240
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
241
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
242
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
243
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
244
            $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...
245
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
246
            $this->modal = $this->pSimpleGetValue($this->ide, "modal");
247
        }
248
    }
249
250
    /**
251
     * monta
252
     * @param string $orientacao L ou P
253
     * @param string $papel A4
254
     * @param string $logoAlign C, L ou R
255
     * @param Pdf $classPDF
256
     * @return string montagem
257
     */
258
    public function monta(
259
        $orientacao = '',
260
        $papel = 'A4',
261
        $logoAlign = 'C',
262
        $classPDF = false
263
    ) {
264
    
265
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 262 can also be of type object<NFePHP\DA\Legacy\Pdf>; however, NFePHP\DA\CTe\Dacte::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...
266
    }
267
268
    /**
269
     * printDocument
270
     * @param string $nome
271
     * @param string $destino
272
     * @param string $printer
273
     * @return
274
     */
275
    public function printDocument($nome = '', $destino = 'I', $printer = '')
276
    {
277
        return $this->printDACTE($nome, $destino, $printer);
278
    }
279
280
    /**
281
     * Dados brutos do PDF
282
     * @return string
283
     */
284
    public function render()
285
    {
286
        return $this->pdf->getPdf();
287
    }
288
289
290
    protected function zCteDPEC()
291
    {
292
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
293
    }
294
295
296
    /**
297
     * montaDACTE
298
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
299
     * durante sua construção.
300
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
301
     * pelo conteúdo da funçao e podem ser modificados.
302
     *
303
     * @param  string $orientacao (Opcional) Estabelece a orientação da
304
     *                impressão (ex. P-retrato), se nada for fornecido será
305
     *                usado o padrão da NFe
306
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
307
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
308
     */
309
    public function montaDACTE(
310
        $orientacao = '',
311
        $papel = 'A4',
312
        $logoAlign = 'C',
313
        $classPDF = false
314
    ) {
315
    
316
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
317 View Code Duplication
        if ($orientacao == '') {
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...
318
            if ($this->tpImp == '1') {
319
                $orientacao = 'P';
320
            } else {
321
                $orientacao = 'P';
322
            }
323
        }
324
        $this->orientacao = $orientacao;
325
        $this->papel = $papel;
326
        $this->logoAlign = $logoAlign;
327
328
        //$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...
329
        //instancia a classe pdf
330 View Code Duplication
        if ($classPDF !== false) {
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...
331
            $this->pdf = $classPDF;
332
        } else {
333
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
334
        }
335
        if ($this->orientacao == 'P') {
336
            // margens do PDF
337
            $margSup = 2;
338
            $margEsq = 2;
339
            $margDir = 2;
340
            // posição inicial do relatorio
341
            $xInic = 1;
342
            $yInic = 1;
343
            if ($papel == 'A4') {
344
                //A4 210x297mm
345
                $maxW = 210;
346
                $maxH = 297;
347
            }
348
        } else {
349
            // margens do PDF
350
            $margSup = 3;
351
            $margEsq = 3;
352
            $margDir = 3;
353
            // posição inicial do relatorio
354
            $xInic = 5;
355
            $yInic = 5;
356
            if ($papel == 'A4') {
357
                //A4 210x297mm
358
                $maxH = 210;
359
                $maxW = 297;
360
                $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...
361
            }
362
        }
363
        //total inicial de paginas
364
        $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...
365
        //largura imprimivel em mm
366
        $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...
367
        //comprimento imprimivel em mm
368
        $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...
369
        // estabelece contagem de paginas
370
        $this->pdf->AliasNbPages();
371
        // fixa as margens
372
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
373
        $this->pdf->SetDrawColor(0, 0, 0);
374
        $this->pdf->SetFillColor(255, 255, 255);
375
        // inicia o documento
376
        $this->pdf->Open();
377
        // adiciona a primeira página
378
        $this->pdf->AddPage($this->orientacao, $this->papel);
379
        $this->pdf->SetLineWidth(0.1);
380
        $this->pdf->SetTextColor(0, 0, 0);
381
        //calculo do numero de páginas ???
382
        $totPag = 1;
383
        //montagem da primeira página
384
        $pag = 1;
385
        $x = $xInic;
386
        $y = $yInic;
387
        //coloca o cabeçalho
388
        //$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...
389
        $y += 70;
390
        $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...
391
        $x = $this->wPrint * 0.5 + 2;
392
        $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...
393
        $y += 19;
394
        $x = $xInic;
395
        $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...
396
        $x = $this->wPrint * 0.5 + 2;
397
        $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...
398
        $y += 19;
399
        $x = $xInic;
400
        $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...
401
        if ($this->tpCTe == '0') {
402
            //Normal
403
            $y += 10;
404
            $x = $xInic;
405
            $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...
406
            $y += 17;
407
            $x = $xInic;
408
            $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...
409
            $y += 25;
410
            $x = $xInic;
411
            $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...
412
            $y += 13;
413
            $x = $xInic;
414
            $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...
415 View Code Duplication
            if ($this->modal == '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...
416
                if ($this->lota == 1) {
417
                    //$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...
418
                    $y += 35;
419
                } else {
420
                    $y += 53;
421
                }
422
            } elseif ($this->modal == '3') {
423
                $y += 37.75;
424
            } else {
425
                $y += 24.95;
426
            }
427
            $x = $xInic;
428
            $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...
429
            $y = $y-6;
430
            switch ($this->modal) {
431
                case '1':
432
                    $y += 17.9;
433
                    $x = $xInic;
434
                    $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...
435
                    break;
436
                case '2':
437
                    $y += 17.9;
438
                    $x = $xInic;
439
                    // TODO fmertins 31/10/14: este método não existe...
440
                    $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\Dacte>.

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...
441
                    break;
442
                case '3':
443
                    $y += 17.9;
444
                    $x = $xInic;
445
                    $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...
446
                    break;
447
                case '4':
448
                    $y += 17.9;
449
                    $x = $xInic;
450
                    $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...
451
                    break;
452
                case '5':
453
                    $y += 17.9;
454
                    $x = $xInic;
455
                    // TODO fmertins 31/10/14: este método não existe...
456
                    $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\Dacte>.

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...
457
                    break;
458
            }
459 View Code Duplication
            if ($this->modal == '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...
460
                if ($this->lota == 1) {
461
                    $y += 37;
462
                } else {
463
                    $y += 8.9;
464
                }
465
            } elseif ($this->modal == '3') {
466
                $y += 24.15;
467
            } else {
468
                $y += 37;
469
            }
470
        } else {
471
            $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...
472
            //Complementado
473
            $y += 10;
474
            $x = $xInic;
475
            $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...
476
            $y += 80;
477
            $x = $xInic;
478
            $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...
479
            $y += 25;
480
            $x = $xInic;
481
            $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...
482
            $y += 13;
483
            $x = $xInic;
484
            $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...
485
            $y += 15;
486
        }
487
        $x = $xInic;
488
        $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...
489
        
490
        //$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...
491
        $y += 10;
492
        $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...
493
        
494
        //coloca o rodapé da página
495
        if ($this->orientacao == 'P') {
496
            $this->zRodape(2, $this->hPrint - 2);
497
        } else {
498
            $this->zRodape($xInic, $this->hPrint + 2.3);
499
        }
500
        if ($this->flagDocOrigContinuacao == 1) {
501
            $this->zdocOrigContinuacao(1, 71);
502
        }
503
        //retorna o ID na CTe
504
        if ($classPDF !== false) {
505
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
506
            return $aR;
507
        } else {
508
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
509
        }
510
    } //fim da função montaDACTE
511
512
    /**
513
     * printDACTE
514
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
515
     * O destino da impressão pode ser :
516
     * I-browser
517
     * D-browser com download
518
     * F-salva em um arquivo local com o nome informado
519
     * S-retorna o documento como uma string e o nome é ignorado.
520
     * Para enviar o pdf diretamente para uma impressora indique o
521
     * nome da impressora e o destino deve ser 'S'.
522
     *
523
     * @param  string $nome Path completo com o nome do arquivo pdf
524
     * @param  string $destino Direção do envio do PDF
525
     * @param  string $printer Identificação da impressora no sistema
526
     * @return string Caso o destino seja S o pdf é retornado como uma string
527
     * @todo Rotina de impressão direta do arquivo pdf criado
528
     */
529
    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...
530
    {
531
        $arq = $this->pdf->Output($nome, $destino);
532
        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...
533
            //aqui pode entrar a rotina de impressão direta
534
        }
535
        return $arq;
536
    } //fim função printDACTE
537
538
    /**
539
     * zCabecalho
540
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
541
     *
542
     * @param  number $x Posição horizontal inicial, canto esquerdo
543
     * @param  number $y Posição vertical inicial, canto superior
544
     * @param  number $pag Número da Página
545
     * @param  number $totPag Total de páginas
546
     * @return number Posição vertical final
547
     */
548
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
549
    {
550
        $oldX = $x;
551
        $oldY = $y;
552 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...
553
            $maxW = $this->wPrint;
554
        } else {
555
            if ($pag == 1) {
556
                // primeira página
557
                $maxW = $this->wPrint - $this->wCanhoto;
558
            } else {
559
                // páginas seguintes
560
                $maxW = $this->wPrint;
561
            }
562
        }
563
        //##################################################################
564
        //coluna esquerda identificação do emitente
565
        $w = round($maxW * 0.42);
566
        if ($this->orientacao == 'P') {
567
            $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...
568
                'font' => $this->fontePadrao,
569
                'size' => 6,
570
                'style' => '');
571
        } else {
572
            $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...
573
        }
574
        $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...
575
        $h = 35;
576
        $oldY += $h;
577
        //desenha a caixa
578
        $this->pTextBox($x, $y, $w + 2, $h + 1);
579
        // coloca o logo
580 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...
581
            $logoInfo = getimagesize($this->logomarca);
582
            //largura da imagem em mm
583
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
584
            //altura da imagem em mm
585
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
586
            if ($this->logoAlign == 'L') {
587
                $nImgW = round($w / 3, 0);
588
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
589
                $xImg = $x + 1;
590
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
591
                //estabelecer posições do texto
592
                $x1 = round($xImg + $nImgW + 1, 0);
593
                $y1 = round($h / 3 + $y, 0);
594
                $tw = round(2 * $w / 3, 0);
595
            } elseif ($this->logoAlign == 'C') {
596
                $nImgH = round($h / 3, 0);
597
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
598
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
599
                $yImg = $y + 3;
600
                $x1 = $x;
601
                $y1 = round($yImg + $nImgH + 1, 0);
602
                $tw = $w;
603
            } elseif ($this->logoAlign == 'R') {
604
                $nImgW = round($w / 3, 0);
605
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
606
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
607
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
608
                $x1 = $x;
609
                $y1 = round($h / 3 + $y, 0);
610
                $tw = round(2 * $w / 3, 0);
611
            }
612
            $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...
613
        } else {
614
            $x1 = $x;
615
            $y1 = round($h / 3 + $y, 0);
616
            $tw = $w;
617
        }
618
        //Nome emitente
619
        $aFont = array(
620
            'font' => $this->fontePadrao,
621
            'size' => 9,
622
            'style' => 'B');
623
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
624
        $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...
625
        //endereço
626
        $y1 = $y1 + 3;
627
        $aFont = array(
628
            'font' => $this->fontePadrao,
629
            'size' => 7,
630
            'style' => '');
631
        $fone = $this->zFormatFone($this->enderEmit);
632
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
633
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
634
        $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...
635
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
636
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
637
        $CEP = $this->pFormat($CEP, "#####-###");
638
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
639
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
640
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
641
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
642
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
643
            . "\n  Fone/Fax: " . $fone;
644
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
645
        //CNPJ/CPF IE
646
        $cpfCnpj = $this->zFormatCNPJCPF($this->emit);
647
        $ie = $this->pSimpleGetValue($this->emit, "IE");
648
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
649
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
650
        //outra caixa
651
        $h1 = 17.5;
652
        $y1 = $y + $h + 1;
653
        $this->pTextBox($x, $y1, $w + 2, $h1);
654
        //TIPO DO CT-E
655
        $texto = 'TIPO DO CTE';
656
        $wa = 37;
657
        $aFont = array(
658
            'font' => $this->fontePadrao,
659
            'size' => 8,
660
            'style' => '');
661
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
662
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
663
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
664
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
665
        switch ($tpCTe) {
666
            case '0':
667
                $texto = 'Normal';
668
                break;
669
            case '1':
670
                $texto = 'Complemento de Valores';
671
                break;
672
            case '2':
673
                $texto = 'Anulação de Valores';
674
                break;
675
            case '3':
676
                $texto = 'Substituto';
677
                break;
678
            default:
679
                $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...
680
        }
681
        $aFont = $this->formatNegrito;
682
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
683
        //TIPO DO SERVIÇO
684
        $texto = 'TIPO DO SERVIÇO';
685
        $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...
686
        $aFont = array(
687
            'font' => $this->fontePadrao,
688
            'size' => 8,
689
            'style' => '');
690
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
691
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
692
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
693 View Code Duplication
        switch ($tpServ) {
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...
694
            case '0':
695
                $texto = 'Normal';
696
                break;
697
            case '1':
698
                $texto = 'Subcontratação';
699
                break;
700
            case '2':
701
                $texto = 'Redespacho';
702
                break;
703
            case '3':
704
                $texto = 'Redespacho Intermediário';
705
                break;
706
            default:
707
                $texto = 'ERRO' . $tpServ;
708
        }
709
        $aFont = $this->formatNegrito;
710
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
711
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
712
        //TOMADOR DO SERVIÇO
713
        $texto = 'TOMADOR DO SERVIÇO';
714
        $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...
715
        $y2 = $y1 + 8;
716
        $aFont = array(
717
            'font' => $this->fontePadrao,
718
            'size' => 8,
719
            'style' => '');
720
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
721
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
722
        $toma = $this->pSimpleGetValue($this->ide, "toma");
723
        //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...
724
        switch ($toma) {
725
            case '0':
726
                $texto = 'Remetente';
727
                break;
728
            case '1':
729
                $texto = 'Expedidor';
730
                break;
731
            case '2':
732
                $texto = 'Recebedor';
733
                break;
734
            case '3':
735
                $texto = 'Destinatário';
736
                break;
737
            case '4':
738
                $texto = 'Outros';
739
                break;
740
            default:
741
                $texto = 'ERRO' . $toma;
742
        }
743
        $aFont = $this->formatNegrito;
744
        $this->pTextBox($x, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
745
        //FORMA DE PAGAMENTO
746
        $texto = 'FORMA DE PAGAMENTO';
747
        $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...
748
        $aFont = array(
749
            'font' => $this->fontePadrao,
750
            'size' => 8,
751
            'style' => '');
752
        $this->pTextBox($x + $wa + 4.5, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
753
        $forma = $this->pSimpleGetValue($this->ide, "forPag");
754
        //0 - Pago;1 - A pagar;2 - outros
755
        switch ($forma) {
756
            case '0':
757
                $texto = 'Pago';
758
                break;
759
            case '1':
760
                $texto = 'A pagar';
761
                break;
762
            case '2':
763
                $texto = 'Outros';
764
                break;
765
            default:
766
                $texto = 'ERRO' . $forma;
767
        }
768
        $aFont = $this->formatNegrito;
769
        $this->pTextBox($x + $wa + 4.5, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
770
        //##################################################################
771
        //coluna direita
772
        $x += $w + 2;
773
        $w = round($maxW * 0.335);
774
        $w1 = $w;
775
        $h = 11;
776
        $this->pTextBox($x, $y, $w + 2, $h + 1);
777
        $texto = "DACTE";
778
        $aFont = array(
779
            'font' => $this->fontePadrao,
780
            'size' => 10,
781
            'style' => 'B');
782
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
783
        $aFont = array(
784
            'font' => $this->fontePadrao,
785
            'size' => 8,
786
            'style' => '');
787
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
788
        $h = 10;
789
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
790
        $x1 = $x + $w + 2;
791
        $w = round($maxW * 0.22, 0);
792
        $w2 = $w;
793
        $h = 11;
794
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
795
        $texto = "MODAL";
796
        $aFont = array(
797
            'font' => $this->fontePadrao,
798
            'size' => 8,
799
            'style' => '');
800
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
801 View Code Duplication
        switch ($this->modal) {
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...
802
            case '1':
803
                $texto = 'Rodoviário';
804
                break;
805
            case '2':
806
                $texto = 'Aéreo';
807
                break;
808
            case '3':
809
                $texto = 'Aquaviário';
810
                break;
811
            case '4':
812
                $texto = 'Ferroviário';
813
                break;
814
            case '5':
815
                $texto = 'Dutoviário';
816
                break;
817
        }
818
        $aFont = array(
819
            'font' => $this->fontePadrao,
820
            'size' => 10,
821
            'style' => 'B');
822
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
823
        //outra caixa
824
        $y += 12;
825
        $h = 9;
826
        $w = $w1 + $w2 + 2;
827
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
828
        //modelo
829
        $wa = 12;
830
        $xa = $x;
831
        $texto = 'MODELO';
832
        $aFont = array(
833
            'font' => $this->fontePadrao,
834
            'size' => 8,
835
            'style' => '');
836
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
837
        $texto = $this->pSimpleGetValue($this->ide, "mod");
838
        $aFont = $this->formatNegrito;
839
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
840
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
841
        //serie
842
        $xa += $wa;
843
        $texto = 'SÉRIE';
844
        $aFont = array(
845
            'font' => $this->fontePadrao,
846
            'size' => 8,
847
            'style' => '');
848
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
849
        $texto = $this->pSimpleGetValue($this->ide, "serie");
850
        $aFont = $this->formatNegrito;
851
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
852
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
853
        //numero
854
        $xa += $wa;
855
        $wa = 20;
856
        $texto = 'NÚMERO';
857
        $aFont = array(
858
            'font' => $this->fontePadrao,
859
            'size' => 8,
860
            'style' => '');
861
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
862
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
863
        $aFont = $this->formatNegrito;
864
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
865
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
866
        //folha
867
        $xa += $wa;
868
        $wa = 12;
869
        $texto = 'FL';
870
        $aFont = array(
871
            'font' => $this->fontePadrao,
872
            'size' => 8,
873
            'style' => '');
874
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
875
        //$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...
876
        $texto = $pag."/".$totPag;
877
        $aFont = $this->formatNegrito;
878
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
879
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
880
        //data  hora de emissão
881
        $xa += $wa;
882
        $wa = 30;
883
        $texto = 'DATA E HORA DE EMISSÃO';
884
        $aFont = array(
885
            'font' => $this->fontePadrao,
886
            'size' => 8,
887
            'style' => '');
888
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
889
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
890
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
891
        $aFont = $this->formatNegrito;
892
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
893
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
894
        //ISUF
895
        $xa += $wa;
896
        $wa = 32;
897
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
898
        $aFont = $this->formatPadrao;
899
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
900
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
901
        $aFont = array(
902
            'font' => $this->fontePadrao,
903
            'size' => 7,
904
            'style' => 'B');
905
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
906
        //outra caixa
907
        $y += $h + 1;
908
        $h = 23;
909
        $h1 = 14;
910
        $this->pTextBox($x, $y, $w + 0.5, $h1);
911
        //CODIGO DE BARRAS
912
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
913
        $bW = 85;
914
        $bH = 10;
915
        //codigo de barras
916
        $this->pdf->SetFillColor(0, 0, 0);
917
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
918
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
919
        $texto = 'CHAVE DE ACESSO';
920
        $aFont = $this->formatPadrao;
921
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
922
        $aFont = $this->formatNegrito;
923
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
924
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
925
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
926
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
927
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
928
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
929
            $texto = "";
930
            $this->pdf->SetFillColor(0, 0, 0);
931
            if ($this->tpEmis == 5) {
932
                $chaveContingencia = $this->zGeraChaveAdicCont();
933
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
934
            } else {
935
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
936
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
937
            }
938
            //codigo de barras
939
        }
940
        $aFont = array(
941
            'font' => $this->fontePadrao,
942
            'size' => 8,
943
            'style' => '');
944
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
945
        //outra caixa
946
        $y += $h + 1;
947
        $h = 8.5;
948
        $wa = $w;
949
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
950
        if ($this->zCteDPEC()) {
951
            $texto = 'NÚMERO DE REGISTRO DPEC';
952
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
953
            $texto = "DADOS DO CT-E";
954
        } else {
955
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
956
        }
957
        $aFont = $this->formatPadrao;
958
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
959
        if ($this->zCteDPEC()) {
960
            $texto = $this->numero_registro_dpec;
961
        } elseif ($this->tpEmis == 5) {
962
            $chaveContingencia = $this->zGeraChaveAdicCont();
963
            $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...
964
                'font' => $this->fontePadrao,
965
                'size' => 8,
966
                'style' => 'B');
967
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
968
            $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...
969
        } else {
970
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
971
            // 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...
972
            if (!empty($this->protCTe)
973
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
974
            ) {
975
                $texto .= date(
976
                    'd/m/Y   H:i:s',
977
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
978
                );
979
            }
980
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
981
        }
982
        $aFont = $this->formatNegrito;
983
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
984
        //CFOP
985
        $x = $oldX;
986
        $h = 8.5;
987
        $w = round($maxW * 0.42);
988
        $y1 = $y + 7.5;
989
        $this->pTextBox($x, $y1, $w + 2, $h);
990
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
991
        $aFont = array(
992
            'font' => $this->fontePadrao,
993
            'size' => 8,
994
            'style' => '');
995
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
996
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
997
        $aFont = $this->formatNegrito;
998
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
999
        //ORIGEM DA PRESTAÇÃO
1000
        $y += $h + 7.5;
1001
        $x = $oldX;
1002
        $h = 8;
1003
        $w = ($maxW * 0.5);
1004
        $this->pTextBox($x, $y, $w + 0.5, $h);
1005
        $texto = 'INÍCIO DA PRESTAÇÃO';
1006
        $aFont = array(
1007
            'font' => $this->fontePadrao,
1008
            'size' => 8,
1009
            'style' => '');
1010
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1011
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1012
        $aFont = $this->formatNegrito;
1013
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1014
        //DESTINO DA PRESTAÇÃO
1015
        $x = $oldX + $w + 1;
1016
        $h = 8;
1017
        $w = $w - 1.3;
1018
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1019
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1020
        $aFont = array(
1021
            'font' => $this->fontePadrao,
1022
            'size' => 8,
1023
            'style' => '');
1024
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1025
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1026
        $aFont = $this->formatNegrito;
1027
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1028
        //#########################################################################
1029
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1030
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1031
        //indicar cancelamento
1032
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1033
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1034
            //101 Cancelamento
1035
            $x = 10;
1036
            $y = $this->hPrint - 130;
1037
            $h = 25;
1038
            $w = $maxW - (2 * $x);
1039
            $this->pdf->SetTextColor(90, 90, 90);
1040
            $texto = "CTe CANCELADO";
1041
            $aFont = array(
1042
                'font' => $this->fontePadrao,
1043
                'size' => 48,
1044
                'style' => 'B');
1045
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1046
            $this->pdf->SetTextColor(0, 0, 0);
1047
        }
1048
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1049
        if ($cStat == '110' ||
1050
            $cStat == '301' ||
1051
            $cStat == '302' ||
1052
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1053
        ) {
1054
            //110 Denegada
1055
            $x = 10;
1056
            $y = $this->hPrint - 130;
1057
            $h = 25;
1058
            $w = $maxW - (2 * $x);
1059
            $this->pdf->SetTextColor(90, 90, 90);
1060
            $texto = "CTe USO DENEGADO";
1061
            $aFont = array(
1062
                'font' => $this->fontePadrao,
1063
                'size' => 48,
1064
                'style' => 'B');
1065
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1066
            $y += $h;
1067
            $h = 5;
1068
            $w = $maxW - (2 * $x);
1069
            $texto = "SEM VALOR FISCAL";
1070
            $aFont = array(
1071
                'font' => $this->fontePadrao,
1072
                'size' => 48,
1073
                'style' => 'B');
1074
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1075
            $this->pdf->SetTextColor(0, 0, 0);
1076
        }
1077
        //indicar sem valor
1078
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1079
            $x = 10;
1080
            if ($this->orientacao == 'P') {
1081
                $y = round($this->hPrint * 2 / 3, 0);
1082
            } else {
1083
                $y = round($this->hPrint / 2, 0);
1084
            }
1085
            $h = 5;
1086
            $w = $maxW - (2 * $x);
1087
            $this->pdf->SetTextColor(90, 90, 90);
1088
            $texto = "SEM VALOR FISCAL";
1089
            $aFont = array(
1090
                'font' => $this->fontePadrao,
1091
                'size' => 48,
1092
                'style' => 'B');
1093
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1094
            $aFont = array(
1095
                'font' => $this->fontePadrao,
1096
                'size' => 30,
1097
                'style' => 'B');
1098
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1099
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1100
            $this->pdf->SetTextColor(0, 0, 0);
1101
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1102
            $h = 5;
1103
            $w = $maxW - (2 * 10);
1104
            $x = 55;
1105
            $y = 240;
1106
            $this->pdf->SetTextColor(255, 100, 100);
1107
            $aFont = array(
1108
                'font' => $this->fontePadrao,
1109
                'size' => 40,
1110
                'style' => 'B');
1111
            $texto = "Pré-visualização";
1112
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1113
            $this->pdf->SetTextColor(255, 100, 100);
1114
            $aFont = array(
1115
                'font' => $this->fontePadrao,
1116
                'size' => 41,
1117
                'style' => 'B');
1118
            $texto = "Sem Validade Jurídica";
1119
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1120
            $this->pdf->SetTextColor(90, 90, 90);
1121
            $texto = "SEM VALOR FISCAL";
1122
            $aFont = array(
1123
                'font' => $this->fontePadrao,
1124
                'size' => 48,
1125
                'style' => 'B');
1126
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1127
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1128
        } else {
1129
            $x = 10;
1130
            if ($this->orientacao == 'P') {
1131
                $y = round($this->hPrint * 2 / 3, 0);
1132
            } else {
1133
                $y = round($this->hPrint / 2, 0);
1134
            } //fim orientacao
1135
            $h = 5;
1136
            $w = $maxW - (2 * $x);
1137
            $this->pdf->SetTextColor(90, 90, 90);
1138
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1139
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1140
                //Contingência
1141
                $texto = "DACTE Emitido em Contingência";
1142
                $aFont = array(
1143
                    'font' => $this->fontePadrao,
1144
                    'size' => 48,
1145
                    'style' => 'B');
1146
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1147
                $aFont = array(
1148
                    'font' => $this->fontePadrao,
1149
                    'size' => 30,
1150
                    'style' => 'B');
1151
                $texto = "devido à problemas técnicos";
1152
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1153
            } else {
1154 View Code Duplication
                if (!isset($this->cteProc)) {
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...
1155
                    if (!$this->zCteDPEC()) {
1156
                        $texto = "SEM VALOR FISCAL";
1157
                        $aFont = array(
1158
                            'font' => $this->fontePadrao,
1159
                            'size' => 48,
1160
                            'style' => 'B');
1161
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1162
                    }
1163
                    $aFont = array(
1164
                        'font' => $this->fontePadrao,
1165
                        'size' => 30,
1166
                        'style' => 'B');
1167
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1168
                    if (!$this->zCteDPEC()) {
1169
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1170
                    } else {
1171
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1172
                    }
1173
                } //fim cteProc
1174 View Code Duplication
                if ($this->tpEmis == 4) {
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...
1175
                    //DPEC
1176
                    $x = 10;
1177
                    $y = $this->hPrint - 130;
1178
                    $h = 25;
1179
                    $w = $maxW - (2 * $x);
1180
                    $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...
1181
                    $texto = "DACTE impresso em contingência -\n"
1182
                        . "DPEC regularmente recebido pela Receita\n"
1183
                        . "Federal do Brasil";
1184
                    $aFont = array(
1185
                        'font' => $this->fontePadrao,
1186
                        'size' => 48,
1187
                        'style' => 'B');
1188
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1189
                    $this->pdf->SetTextColor(0, 0, 0);
1190
                }
1191
            } //fim tpEmis
1192
            $this->pdf->SetTextColor(0, 0, 0);
1193
        }
1194
        return $oldY;
1195
    } //fim zCabecalho
1196
1197
    /**
1198
     * rodapeDACTE
1199
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1200
     *
1201
     * @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...
1202
     * @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...
1203
     */
1204
    protected function zRodape($x, $y)
1205
    {
1206
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1207
        $w = $this->wPrint - 4;
1208
        $aFont = array(
1209
            'font' => $this->fontePadrao,
1210
            'size' => 6,
1211
            'style' => '');
1212
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1213
        $texto = "DacteNFePHP ver. " . $this->version . "  Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org";
1214
        $aFont = array(
1215
            'font' => $this->fontePadrao,
1216
            'size' => 6,
1217
            'style' => '');
1218
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org');
1219
    } //fim zRodape
1220
1221
    /**
1222
     * zRemetente
1223
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1224
     *
1225
     * @param  number $x Posição horizontal canto esquerdo
1226
     * @param  number $y Posição vertical canto superior
1227
     * @return number Posição vertical final
1228
     */
1229
    protected function zRemetente($x = 0, $y = 0)
1230
    {
1231
        $oldX = $x;
1232
        $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...
1233
        if ($this->orientacao == 'P') {
1234
            $maxW = $this->wPrint;
1235
        } else {
1236
            $maxW = $this->wPrint - $this->wCanhoto;
1237
        }
1238
        $w = $maxW * 0.5 + 0.5;
1239
        $h = 19;
1240
        $x1 = $x + 16;
1241
        $texto = 'REMETENTE';
1242
        $aFont = $this->formatPadrao;
1243
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1244
        $aFont = $this->formatNegrito;
1245
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1246
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1247
        $y += 3;
1248
        $texto = 'ENDEREÇO';
1249
        $aFont = $this->formatPadrao;
1250
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1251
        $aFont = $this->formatNegrito;
1252
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1253
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1254
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1255
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1256
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1257
        $y += 3;
1258
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1259
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1260
        $y += 3;
1261
        $texto = 'MUNICÍPIO';
1262
        $aFont = $this->formatPadrao;
1263
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1264
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1265
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1266
        $aFont = $this->formatNegrito;
1267
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1268
        $x = $w - 18;
1269
        $texto = 'CEP';
1270
        $aFont = $this->formatPadrao;
1271
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1272
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1273
        $aFont = $this->formatNegrito;
1274
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1275
        $x = $oldX;
1276
        $y += 3;
1277
        $texto = 'CNPJ/CPF';
1278
        $aFont = $this->formatPadrao;
1279
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1280
        $cpfCnpj = $this->zFormatCNPJCPF($this->rem);
1281
        $aFont = $this->formatNegrito;
1282
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1283
        $x = $w - 45;
1284
        $texto = 'INSCRIÇÃO ESTADUAL';
1285
        $aFont = $this->formatPadrao;
1286
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1287
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1288
        $aFont = $this->formatNegrito;
1289
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1290
        $x = $oldX;
1291
        $y += 3;
1292
        $texto = 'PAÍS';
1293
        $aFont = $this->formatPadrao;
1294
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1295
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1296
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1297
        $aFont = $this->formatNegrito;
1298
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1299
        $x = $w - 25;
1300
        $texto = 'FONE';
1301
        $aFont = $this->formatPadrao;
1302
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1303
        $texto = $this->zFormatFone($this->rem);
1304
        $aFont = $this->formatNegrito;
1305
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1306
    } //fim da função remetenteDACTE
1307
1308
    /**
1309
     * zDestinatario
1310
     * Monta o campo com os dados do destinatário na DACTE.
1311
     *
1312
     * @param  number $x Posição horizontal canto esquerdo
1313
     * @param  number $y Posição vertical canto superior
1314
     * @return number Posição vertical final
1315
     */
1316
    protected function zDestinatario($x = 0, $y = 0)
1317
    {
1318
        $oldX = $x;
1319
        $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...
1320
        if ($this->orientacao == 'P') {
1321
            $maxW = $this->wPrint;
1322
        } else {
1323
            $maxW = $this->wPrint - $this->wCanhoto;
1324
        }
1325
        $w = ($maxW * 0.5) - 0.7;
1326
        $h = 19;
1327
        $x1 = $x + 19;
1328
        $texto = 'DESTINATÁRIO';
1329
        $aFont = $this->formatPadrao;
1330
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1331
        $aFont = $this->formatNegrito;
1332
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1333
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1334
        $y += 3;
1335
        $texto = 'ENDEREÇO';
1336
        $aFont = $this->formatPadrao;
1337
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1338
        $aFont = $this->formatNegrito;
1339
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1340
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1341
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1342
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1343
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1344
        $y += 3;
1345
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1346
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1347
        $y += 3;
1348
        $texto = 'MUNICÍPIO';
1349
        $aFont = $this->formatPadrao;
1350
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1351
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1352
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1353
        $aFont = $this->formatNegrito;
1354
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1355
        $x = $w - 19 + $oldX;
1356
        $texto = 'CEP';
1357
        $aFont = $this->formatPadrao;
1358
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1359
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1360
        $aFont = $this->formatNegrito;
1361
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1362
        $x = $oldX;
1363
        $y += 3;
1364
        $texto = 'CNPJ/CPF';
1365
        $aFont = $this->formatPadrao;
1366
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1367
        $cpfCnpj = $this->zFormatCNPJCPF($this->dest);
1368
        $aFont = $this->formatNegrito;
1369
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1370
        $x = $w - 47.5 + $oldX;
1371
        $texto = 'INSCRIÇÃO ESTADUAL';
1372
        $aFont = $this->formatPadrao;
1373
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1374
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1375
        $aFont = $this->formatNegrito;
1376
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1377
        $x = $oldX;
1378
        $y += 3;
1379
        $texto = 'PAÍS';
1380
        $aFont = $this->formatPadrao;
1381
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1382
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1383
        $aFont = $this->formatNegrito;
1384
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1385
        $x = $w - 27 + $oldX;
1386
        $texto = 'FONE';
1387
        $aFont = $this->formatPadrao;
1388
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1389
        $texto = $this->zFormatFone($this->dest);
1390
        $aFont = $this->formatNegrito;
1391
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1392
    } //fim da função destinatarioDACTE
1393
1394
    /**
1395
     * zExpedidor
1396
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1397
     *
1398
     * @param  number $x Posição horizontal canto esquerdo
1399
     * @param  number $y Posição vertical canto superior
1400
     * @return number Posição vertical final
1401
     */
1402
    protected function zExpedidor($x = 0, $y = 0)
1403
    {
1404
        $oldX = $x;
1405
        $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...
1406
        if ($this->orientacao == 'P') {
1407
            $maxW = $this->wPrint;
1408
        } else {
1409
            $maxW = $this->wPrint - $this->wCanhoto;
1410
        }
1411
        $w = $maxW * 0.5 + 0.5;
1412
        $h = 19;
1413
        $x1 = $x + 16;
1414
        $texto = 'EXPEDIDOR';
1415
        $aFont = $this->formatPadrao;
1416
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1417
        $aFont = $this->formatNegrito;
1418
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1419
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1420
        $y += 3;
1421
        $texto = 'ENDEREÇO';
1422
        $aFont = $this->formatPadrao;
1423
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1424
        $aFont = $this->formatNegrito;
1425 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...
1426
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1427
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1428
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1429
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1430
                '';
1431
        } else {
1432
            $texto = '';
1433
        }
1434
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1435
        $y += 3;
1436
        $texto = $this->pSimpleGetValue($this->enderExped, "xBairro");
1437
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1438
        $y += 3;
1439
        $texto = 'MUNICÍPIO';
1440
        $aFont = $this->formatPadrao;
1441
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1442 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...
1443
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1444
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1445
        } else {
1446
            $texto = '';
1447
        }
1448
        $aFont = $this->formatNegrito;
1449
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1450
        $x = $w - 18;
1451
        $texto = 'CEP';
1452
        $aFont = $this->formatPadrao;
1453
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1454
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderExped, "CEP"), "#####-###");
1455
        $aFont = $this->formatNegrito;
1456
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1457
        $x = $oldX;
1458
        $y += 3;
1459
        $texto = 'CNPJ/CPF';
1460
        $aFont = $this->formatPadrao;
1461
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1462
        $cpfCnpj = $this->zFormatCNPJCPF($this->exped);
1463
        $aFont = $this->formatNegrito;
1464
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1465
        $x = $w - 45;
1466
        $texto = 'INSCRIÇÃO ESTADUAL';
1467
        $aFont = $this->formatPadrao;
1468
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1469
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1470
        $aFont = $this->formatNegrito;
1471
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1472
        $x = $oldX;
1473
        $y += 3;
1474
        $texto = 'PAÍS';
1475
        $aFont = $this->formatPadrao;
1476
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1477
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1478
        $aFont = $this->formatNegrito;
1479
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1480
        $x = $w - 25;
1481
        $texto = 'FONE';
1482
        $aFont = $this->formatPadrao;
1483
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1484 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...
1485
            $texto = $this->zFormatFone($this->exped);
1486
            $aFont = $this->formatNegrito;
1487
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1488
        }
1489
    } //fim da função remetenteDACTE
1490
1491
    /**
1492
     * zRecebedor
1493
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1494
     *
1495
     * @param  number $x Posição horizontal canto esquerdo
1496
     * @param  number $y Posição vertical canto superior
1497
     * @return number Posição vertical final
1498
     */
1499
    protected function zRecebedor($x = 0, $y = 0)
1500
    {
1501
        $oldX = $x;
1502
        $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...
1503
        if ($this->orientacao == 'P') {
1504
            $maxW = $this->wPrint;
1505
        } else {
1506
            $maxW = $this->wPrint - $this->wCanhoto;
1507
        }
1508
        $w = ($maxW * 0.5) - 0.7;
1509
        $h = 19;
1510
        $x1 = $x + 19;
1511
        $texto = 'RECEBEDOR';
1512
        $aFont = $this->formatPadrao;
1513
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1514
        $aFont = $this->formatNegrito;
1515
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1516
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1517
        $y += 3;
1518
        $texto = 'ENDEREÇO';
1519
        $aFont = $this->formatPadrao;
1520
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1521
        $aFont = $this->formatNegrito;
1522 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...
1523
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1524
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1525
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1526
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1527
                '';
1528
        } else {
1529
            $texto = '';
1530
        }
1531
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1532
        $y += 3;
1533
        $texto = $this->pSimpleGetValue($this->enderReceb, "xBairro");
1534
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1535
        $y += 3;
1536
        $texto = 'MUNICÍPIO';
1537
        $aFont = $this->formatPadrao;
1538
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1539 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...
1540
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1541
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1542
        } else {
1543
            $texto = '';
1544
        }
1545
        $aFont = $this->formatNegrito;
1546
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1547
        $x = $w - 19 + $oldX;
1548
        $texto = 'CEP';
1549
        $aFont = $this->formatPadrao;
1550
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1551
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReceb, "CEP"), "#####-###");
1552
        $aFont = $this->formatNegrito;
1553
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1554
        $x = $oldX;
1555
        $y += 3;
1556
        $texto = 'CNPJ/CPF';
1557
        $aFont = $this->formatPadrao;
1558
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1559
        $texto = $this->zFormatCNPJCPF($this->receb);
1560
        $aFont = $this->formatNegrito;
1561
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1562
        $x = $w - 47 + $oldX;
1563
        $texto = 'INSCRIÇÃO ESTADUAL';
1564
        $aFont = $this->formatPadrao;
1565
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1566
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1567
        $aFont = $this->formatNegrito;
1568
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1569
        $x = $oldX;
1570
        $y += 3;
1571
        $texto = 'PAÍS';
1572
        $aFont = $this->formatPadrao;
1573
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1574
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1575
        $aFont = $this->formatNegrito;
1576
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1577
        $x = $w - 27 + $oldX;
1578
        $texto = 'FONE';
1579
        $aFont = $this->formatPadrao;
1580
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1581 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...
1582
            $texto = $this->zFormatFone($this->receb);
1583
            $aFont = $this->formatNegrito;
1584
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1585
        }
1586
    } //fim da função recebedorDACTE
1587
1588
    /**
1589
     * zTomador
1590
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1591
     *
1592
     * @param  number $x Posição horizontal canto esquerdo
1593
     * @param  number $y Posição vertical canto superior
1594
     * @return number Posição vertical final
1595
     */
1596
    protected function zTomador($x = 0, $y = 0)
1597
    {
1598
        $oldX = $x;
1599
        $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...
1600
        if ($this->orientacao == 'P') {
1601
            $maxW = $this->wPrint;
1602
        } else {
1603
            $maxW = $this->wPrint - $this->wCanhoto;
1604
        }
1605
        $w = $maxW;
1606
        $h = 10;
1607
        $texto = 'TOMADOR DO SERVIÇO';
1608
        $aFont = $this->formatPadrao;
1609
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1610
        $aFont = $this->formatNegrito;
1611
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1612
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1613
        $x = $maxW * 0.60;
1614
        $texto = 'MUNICÍPIO';
1615
        $aFont = $this->formatPadrao;
1616
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1617
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1618
        $aFont = $this->formatNegrito;
1619
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1620
        $x = $maxW * 0.85;
1621
        $texto = 'UF';
1622
        $aFont = $this->formatPadrao;
1623
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1624
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1625
        $aFont = $this->formatNegrito;
1626
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1627
        $x = $w - 18;
1628
        $texto = 'CEP';
1629
        $aFont = $this->formatPadrao;
1630
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1631
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1632
        $aFont = $this->formatNegrito;
1633
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1634
        $y += 3;
1635
        $x = $oldX;
1636
        $texto = 'ENDEREÇO';
1637
        $aFont = $this->formatPadrao;
1638
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1639
        $aFont = $this->formatNegrito;
1640
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1641
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1642
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1643
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1644
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1645
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1646
        $y += 3;
1647
        $texto = 'CNPJ/CPF';
1648
        $aFont = $this->formatPadrao;
1649
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1650
        $texto = $this->zFormatCNPJCPF($this->toma);
1651
        $aFont = $this->formatNegrito;
1652
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1653
        $x = $x + 65;
1654
        $texto = 'INSCRIÇÃO ESTADUAL';
1655
        $aFont = $this->formatPadrao;
1656
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1657
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1658
        $aFont = $this->formatNegrito;
1659
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1660
        $x = $w * 0.75;
1661
        $texto = 'PAÍS';
1662
        $aFont = $this->formatPadrao;
1663
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1664
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1665
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1666
        $aFont = $this->formatNegrito;
1667
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1668
        $x = $w - 27;
1669
        $texto = 'FONE';
1670
        $aFont = $this->formatPadrao;
1671
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1672
        $texto = $this->zFormatFone($this->toma);
1673
        $aFont = $this->formatNegrito;
1674
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1675
    } //fim da função tomadorDACTE
1676
1677
    /**
1678
     * zDescricaoCarga
1679
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1680
     *
1681
     * @param  number $x Posição horizontal canto esquerdo
1682
     * @param  number $y Posição vertical canto superior
1683
     * @return number Posição vertical final
1684
     */
1685
    protected function zDescricaoCarga($x = 0, $y = 0)
1686
    {
1687
        $oldX = $x;
1688
        $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...
1689
        if ($this->orientacao == 'P') {
1690
            $maxW = $this->wPrint;
1691
        } else {
1692
            $maxW = $this->wPrint - $this->wCanhoto;
1693
        }
1694
        $w = $maxW;
1695
        $h = 17;
1696
        $texto = 'PRODUTO PREDOMINANTE';
1697
        $aFont = array(
1698
            'font' => $this->fontePadrao,
1699
            'size' => 6,
1700
            'style' => '');
1701
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1702
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1703
        $aFont = $this->formatNegrito;
1704
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1705
        $x = $w * 0.56;
1706
        $this->pdf->Line($x, $y, $x, $y + 8);
1707
        $aFont = $this->formatPadrao;
1708
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1709
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1710
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1711
        $aFont = $this->formatNegrito;
1712
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1713
        $x = $w * 0.8;
1714
        $this->pdf->Line($x, $y, $x, $y + 8);
1715
        $aFont = $this->formatPadrao;
1716
        $texto = 'VALOR TOTAL DA MERCADORIA';
1717
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1718
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1719
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1720
        $texto = number_format($texto, 2, ",", ".");
1721
        $aFont = $this->formatNegrito;
1722
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1723
        $y += 8;
1724
        $x = $oldX;
1725
        $this->pdf->Line($x, $y, $w + 1, $y);
1726
        $texto = 'TP MED /UN. MED';
1727
        $aFont = array(
1728
            'font' => $this->fontePadrao,
1729
            'size' => 5,
1730
            'style' => '');
1731
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1732
        $texto = $this->pSimpleGetValue($this->infQ->item(0), "tpMed") . "\r\n";
1733
        $texto .= number_format(
1734
            $this->pSimpleGetValue(
1735
                $this->infQ->item(0),
1736
                "qCarga"
1737
            )
1738
            / $this->zMultiUniPeso(
1739
                $this->pSimpleGetValue(
1740
                    $this->infQ->item(0),
1741
                    "cUnid"
1742
                )
1743
            ),
1744
            3,
1745
            ".",
1746
            ""
1747
        );
1748
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(0), "cUnid"));
1749
        $aFont = array(
1750
            'font' => $this->fontePadrao,
1751
            'size' => 7,
1752
            'style' => 'B');
1753
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1754
        $x = $w * 0.12;
1755
        $this->pdf->Line($x, $y, $x, $y + 9);
1756
        $texto = 'TP MED /UN. MED';
1757
        $aFont = array(
1758
            'font' => $this->fontePadrao,
1759
            'size' => 5,
1760
            'style' => '');
1761
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1762
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "tpMed") . "\r\n";
1763
        $texto .= number_format(
1764
            $this->pSimpleGetValue(
1765
                $this->infQ->item(1),
1766
                "qCarga"
1767
            )
1768
            / $this->zMultiUniPeso(
1769
                $this->pSimpleGetValue($this->infQ->item(1), "cUnid")
1770
            ),
1771
            3,
1772
            ".",
1773
            ""
1774
        );
1775
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "qCarga") == '' ? '' : $texto;
1776
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(1), "cUnid"));
1777
        $aFont = array(
1778
            'font' => $this->fontePadrao,
1779
            'size' => 7,
1780
            'style' => 'B');
1781
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1782
        $x = $w * 0.24;
1783
        $this->pdf->Line($x, $y, $x, $y + 9);
1784
        $texto = 'TP MED /UN. MED';
1785
        $aFont = array(
1786
            'font' => $this->fontePadrao,
1787
            'size' => 5,
1788
            'style' => '');
1789
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1790
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "tpMed") . "\r\n";
1791
        $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1792
        $texto .= !empty($qCarga) ?
1793
            number_format(
1794
                $qCarga
1795
                / $this->zMultiUniPeso(
1796
                    $this->pSimpleGetValue($this->infQ->item(2), "cUnid")
1797
                ),
1798
                3,
1799
                ".",
1800
                ""
1801
            ) :
1802
            '';
1803
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "qCarga") == '' ? '' : $texto;
1804
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(2), "cUnid"));
1805
        $aFont = array(
1806
            'font' => $this->fontePadrao,
1807
            'size' => 7,
1808
            'style' => 'B');
1809
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1810
        $x = $w * 0.36;
1811
        $this->pdf->Line($x, $y, $x, $y + 9);
1812
        $texto = 'CUBAGEM(M3)';
1813
        $aFont = $this->formatPadrao;
1814
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1815
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '00') {
1816
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1817
            $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1818
        } else {
1819
            $texto = '';
1820
        }
1821
        $aFont = array(
1822
            'font' => $this->fontePadrao,
1823
            'size' => 7,
1824
            'style' => 'B');
1825
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1826
        $x = $w * 0.45;
1827
        $this->pdf->Line($x, $y, $x, $y + 9);
1828
        $texto = 'QTDE(VOL)';
1829
        $aFont = $this->formatPadrao;
1830
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1831
        $qCarga = $this->pSimpleGetValue($this->infQ->item(3), "qCarga");
1832
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1833
        $aFont = array(
1834
            'font' => $this->fontePadrao,
1835
            'size' => 7,
1836
            'style' => 'B');
1837
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1838
        $x = $w * 0.53;
1839
        $this->pdf->Line($x, $y, $x, $y + 9);
1840
        $texto = 'NOME DA SEGURADORA';
1841
        $aFont = $this->formatPadrao;
1842
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1843
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1844
        $aFont = array(
1845
            'font' => $this->fontePadrao,
1846
            'size' => 7,
1847
            'style' => 'B');
1848
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1849
        $y += 3;
1850
        $this->pdf->Line($x, $y, $w + 1, $y);
1851
        $texto = 'RESPONSÁVEL';
1852
        $aFont = $this->formatPadrao;
1853
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1854
        $texto = $this->respSeg;
1855
        $aFont = array(
1856
            'font' => $this->fontePadrao,
1857
            'size' => 7,
1858
            'style' => 'B');
1859
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1860
        $x = $w * 0.68;
1861
        $this->pdf->Line($x, $y, $x, $y + 6);
1862
        $texto = 'NÚMERO DA APOLICE';
1863
        $aFont = $this->formatPadrao;
1864
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1865
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1866
        $aFont = array(
1867
            'font' => $this->fontePadrao,
1868
            'size' => 7,
1869
            'style' => 'B');
1870
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1871
        $x = $w * 0.85;
1872
        $this->pdf->Line($x, $y, $x, $y + 6);
1873
        $texto = 'NÚMERO DA AVERBAÇÃO';
1874
        $aFont = $this->formatPadrao;
1875
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1876
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
1877
        $aFont = array(
1878
            'font' => $this->fontePadrao,
1879
            'size' => 7,
1880
            'style' => 'B');
1881
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1882
    } //fim da função zDescricaoCarga
1883
1884
    /**
1885
     * zCompValorServ
1886
     * Monta o campo com os componentes da prestação de serviços.
1887
     *
1888
     * @param  number $x Posição horizontal canto esquerdo
1889
     * @param  number $y Posição vertical canto superior
1890
     * @return number Posição vertical final
1891
     */
1892
    protected function zCompValorServ($x = 0, $y = 0)
1893
    {
1894
        $oldX = $x;
1895
        $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...
1896
        if ($this->orientacao == 'P') {
1897
            $maxW = $this->wPrint;
1898
        } else {
1899
            $maxW = $this->wPrint - $this->wCanhoto;
1900
        }
1901
        $w = $maxW;
1902
        $h = 25;
1903
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1904
        $aFont = $this->formatPadrao;
1905
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1906
        $y += 3.4;
1907
        $this->pdf->Line($x, $y, $w + 1, $y);
1908
        $texto = 'NOME';
1909
        $aFont = $this->formatPadrao;
1910
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1911
        $yIniDados = $y;
1912
        $x = $w * 0.14;
1913
        $texto = 'VALOR';
1914
        $aFont = $this->formatPadrao;
1915
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1916
        $x = $w * 0.28;
1917
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1918
        $texto = 'NOME';
1919
        $aFont = $this->formatPadrao;
1920
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1921
        $x = $w * 0.42;
1922
        $texto = 'VALOR';
1923
        $aFont = $this->formatPadrao;
1924
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1925
        $x = $w * 0.56;
1926
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1927
        $texto = 'NOME';
1928
        $aFont = $this->formatPadrao;
1929
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1930
        $x = $w * 0.70;
1931
        $texto = 'VALOR';
1932
        $aFont = $this->formatPadrao;
1933
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1934
        $x = $w * 0.86;
1935
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1936
        $y += 1;
1937
        $texto = 'VALOR TOTAL DO SERVIÇO';
1938
        $aFont = $this->formatPadrao;
1939
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1940
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1941
        $aFont = array(
1942
            'font' => $this->fontePadrao,
1943
            'size' => 9,
1944
            'style' => 'B');
1945
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1946
        $y += 10;
1947
        $this->pdf->Line($x, $y, $w + 1, $y);
1948
        $y += 1;
1949
        $texto = 'VALOR A RECEBER';
1950
        $aFont = $this->formatPadrao;
1951
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1952
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1953
        $aFont = array(
1954
            'font' => $this->fontePadrao,
1955
            'size' => 9,
1956
            'style' => 'B');
1957
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1958
        $auxX = $oldX;
1959
        $yIniDados += 4;
1960
        foreach ($this->Comp as $k => $d) {
1961
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1962
            $valor = number_format(
1963
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1964
                2,
1965
                ",",
1966
                "."
1967
            );
1968
            if ($auxX > $w * 0.60) {
1969
                $yIniDados = $yIniDados + 4;
1970
                $auxX = $oldX;
1971
            }
1972
            $texto = $nome;
1973
            $aFont = $this->formatPadrao;
1974
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1975
            $auxX += $w * 0.14;
1976
            $texto = $valor;
1977
            $aFont = $this->formatPadrao;
1978
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1979
            $auxX += $w * 0.14;
1980
        }
1981
    } //fim da função compValorDACTE
1982
1983
    /**
1984
     * zImpostos
1985
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1986
     *
1987
     * @param  number $x Posição horizontal canto esquerdo
1988
     * @param  number $y Posição vertical canto superior
1989
     * @return number Posição vertical final
1990
     */
1991
    protected function zImpostos($x = 0, $y = 0)
1992
    {
1993
        $oldX = $x;
1994
        $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...
1995
        if ($this->orientacao == 'P') {
1996
            $maxW = $this->wPrint;
1997
        } else {
1998
            $maxW = $this->wPrint - $this->wCanhoto;
1999
        }
2000
        $w = $maxW;
2001
        $h = 13;
2002
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
2003
        $aFont = $this->formatPadrao;
2004
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2005
        
2006
        $y += 3.4;
2007
        $this->pdf->Line($x, $y, $w + 1, $y);
2008
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
2009
        $aFont = $this->formatPadrao;
2010
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2011
        
2012
        $x += $w * 0.26;
2013
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2014
        $texto = 'BASE DE CALCULO';
2015
        $aFont = $this->formatPadrao;
2016
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2017
        
2018
        $wCol02=0.18;
2019
        $x += $w * $wCol02;
2020
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2021
        $texto = 'ALÍQ ICMS';
2022
        $aFont = $this->formatPadrao;
2023
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2024
        
2025
        $x += $w * $wCol02;
2026
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2027
        $texto = 'VALOR ICMS';
2028
        $aFont = $this->formatPadrao;
2029
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2030
        
2031
        $x += $w * $wCol02;
2032
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2033
        $texto = '% RED. BC ICMS';
2034
        $aFont = $this->formatPadrao;
2035
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2036
        
2037
        /*$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...
2038
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2039
        $texto = 'ICMS ST';
2040
        $aFont = $this->formatPadrao;
2041
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2042
         * */
2043
        
2044
        $x = $oldX;
2045
        $y = $y + 4;
2046
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2047
        switch ($texto) {
2048
            case '00':
2049
                $texto = "00 - Tributação normal ICMS";
2050
                break;
2051
            case '20':
2052
                $texto = "20 - Tributação com BC reduzida do ICMS";
2053
                break;
2054
            case '40':
2055
                $texto = "40 - ICMS isenção";
2056
                break;
2057
            case '41':
2058
                $texto = "41 - ICMS não tributada";
2059
                break;
2060
            case '51':
2061
                $texto = "51 - ICMS diferido";
2062
                break;
2063
            case '60':
2064
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2065
                break;
2066
            case '90':
2067
                $texto = "90 - ICMS outros";
2068
                break;
2069
        }
2070
        $texto .= $this->pSimpleGetValue($this->ICMSSN, "indSN");
2071
        $texto = $texto == 1 ? 'Simples Nacional' : $texto;
2072
        $aFont = $this->formatNegrito;
2073
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2074
        $x += $w * 0.26;
2075
        
2076
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2077
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : '';
2078
        $aFont = $this->formatNegrito;
2079
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2080
        $x += $w * $wCol02;
2081
        
2082
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2083
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
2084
        $aFont = $this->formatNegrito;
2085
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2086
        $x += $w * $wCol02;
2087
        
2088
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2089
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
2090
        $aFont = $this->formatNegrito;
2091
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2092
        $x += $w * $wCol02;
2093
        
2094
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2095
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
2096
        $aFont = $this->formatNegrito;
2097
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2098
        
2099
        /*$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...
2100
        $texto = '';
2101
        $aFont = $this->formatNegrito;
2102
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2103
    } //fim da função compValorDACTE
2104
2105
    /**
2106
     * zGeraChaveAdicCont
2107
     *
2108
     * @return string chave
2109
     */
2110
    protected function zGeraChaveAdicCont()
2111
    {
2112
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2113
        // 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...
2114
        $forma = "%02d%d%s%014d%01d%01d%02d";
2115
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2116
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2117
        $CNPJ = substr($CNPJ, -14);
2118
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2119
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2120
        switch ($ICMS_CST) {
2121
            case '00':
2122
            case '20':
2123
                $ICMSp = '1';
2124
                $ICMSs = '2';
2125
                break;
2126
            case '40':
2127
            case '41':
2128
            case '51':
2129
            case '90':
2130
                $ICMSp = '2';
2131
                $ICMSs = '2';
2132
                break;
2133
            case '60':
2134
                $ICMSp = '2';
2135
                $ICMSs = '1';
2136
                break;
2137
        }
2138
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2139
        $rpos = strrpos($dd, '-');
2140
        $dd = substr($dd, $rpos + 1);
2141
        $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...
2142
        $chave = $chave . $this->pModulo11($chave);
2143
        return $chave;
2144
    } //fim zGeraChaveAdicCont
2145
2146
    /**
2147
     * zDocOrig
2148
     * Monta o campo com os documentos originarios.
2149
     *
2150
     * @param  number $x Posição horizontal canto esquerdo
2151
     * @param  number $y Posição vertical canto superior
2152
     * @return number Posição vertical final
2153
     */
2154
    protected function zDocOrig($x = 0, $y = 0)
2155
    {
2156
        $oldX = $x;
2157
        $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...
2158
        if ($this->orientacao == 'P') {
2159
            $maxW = $this->wPrint;
2160
        } else {
2161
            $maxW = $this->wPrint - $this->wCanhoto;
2162
        }
2163
        $w = $maxW;
2164
        
2165
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2166 View Code Duplication
        if ($this->modal == '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...
2167
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2168
            // ou combinação veicular, e por viagem
2169
            $h = $this->lota == 1 ? 35 : 53;
2170
        } elseif ($this->modal == '3') {
2171
            $h = 37.6;
2172
        } else {
2173
            $h = 35;
2174
        }
2175
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2176
        $aFont = $this->formatPadrao;
2177
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2178
        $descr1 = 'TIPO DOC';
2179
        $descr2 = 'CNPJ/CHAVE/OBS';
2180
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2181
        
2182
        $y += 3.4;
2183
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2184
        $texto = $descr1;
2185
        $aFont = $this->formatPadrao;
2186
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2187
        $yIniDados = $y;
2188
        
2189
        $x += $w * 0.07;
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;
2195
        $texto = $descr3;
2196
        $aFont = $this->formatPadrao;
2197
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2198
        
2199
        $x += $w * 0.14;
2200 View Code Duplication
        if ($this->modal == '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...
2201
            if ($this->lota == 1) {
2202
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2203
            } else {
2204
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2205
            }
2206
        } elseif ($this->modal == '3') {
2207
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2208
        } else {
2209
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2210
        }
2211
        $texto = $descr1;
2212
        $aFont = $this->formatPadrao;
2213
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2214
        
2215
        $x += $w * 0.08;
2216
        $texto = $descr2;
2217
        $aFont = $this->formatPadrao;
2218
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2219
        
2220
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2221
        $texto = $descr3;
2222
        $aFont = $this->formatPadrao;
2223
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2224
        $auxX = $oldX;
2225
        $yIniDados += 3;
2226
        foreach ($this->infNF as $k => $d) {
2227
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2228
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2229
            $cnpj = $this->zFormatCNPJCPF($this->rem);
2230
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2231
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2232
            if ($auxX > $w * 0.90) {
2233
                $yIniDados = $yIniDados + 3;
2234
                $auxX = $oldX;
2235
            }
2236
            $texto = $tp;
2237
            $aFont = array(
2238
                'font' => $this->fontePadrao,
2239
                'size' => 8,
2240
                'style' => '');
2241
            //$this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

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

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

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

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

Loading history...
2244
            $auxX += $w * 0.07;
2245
            $texto = $cnpj;
2246
            $aFont = array(
2247
                'font' => $this->fontePadrao,
2248
                'size' => 8,
2249
                'style' => '');
2250
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2251
            $auxX += $w * 0.28;
2252
            $texto = $doc;
2253
            $aFont = array(
2254
                'font' => $this->fontePadrao,
2255
                'size' => 8,
2256
                'style' => '');
2257
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2258
            $auxX += $w * 0.15;
2259
        }
2260
        
2261
        foreach ($this->infNFe as $k => $d) {
2262
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2263
            $this->arrayNFe[] = $chaveNFe;
2264
        }
2265
        if (count($this->arrayNFe) >15) {
2266
            $this->flagDocOrigContinuacao = 1;
2267
            $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...
2268
        } else {
2269
            $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...
2270
        }
2271
        $totPag = count($this->arrayNFe) >15 ? '2' : '1';
2272
        $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...
2273
        $contador = 0;
2274
        while ($contador < count($this->arrayNFe)) {
2275
            if ($contador == 15) {
2276
                break;
2277
            }
2278
            $tp = 'NF-e';
2279
            $chaveNFe = $this->arrayNFe[$contador];
2280
            $numNFe = substr($chaveNFe, 25, 9);
2281
            $serieNFe = substr($chaveNFe, 22, 3);
2282
            $doc = $serieNFe . '/' . $numNFe;
2283
            if ($auxX > $w * 0.90) {
2284
                $yIniDados = $yIniDados + 3.5;
2285
                $auxX = $oldX;
2286
            }
2287
            $texto = $tp;
2288
            $aFont = array(
2289
                'font' => $this->fontePadrao,
2290
                'size' => 7,
2291
                'style' => '');
2292
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2293
            $auxX += $w * 0.07;
2294
            $texto = $chaveNFe;
2295
            $aFont = array(
2296
                'font' => $this->fontePadrao,
2297
                'size' => 7,
2298
                'style' => '');
2299
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2300
            $auxX += $w * 0.28;
2301
            $texto = $doc;
2302
            $aFont = array(
2303
                'font' => $this->fontePadrao,
2304
                'size' => 7,
2305
                'style' => '');
2306
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2307
            $auxX += $w * 0.15;
2308
            $contador++;
2309
        }
2310
        
2311
        foreach ($this->infOutros as $k => $d) {
2312
            $temp = $this->infOutros->item($k);
2313
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2314
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2315
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2316
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2317
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2318
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2319
            switch ($tpDoc) {
2320
                case "00":
2321
                    $tpDoc = "00 - Declaração";
2322
                    break;
2323
                case "10":
2324
                    $tpDoc = "10 - Dutoviário";
2325
                    break;
2326
                case "99":
2327
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2328
                    break;
2329
                default:
2330
                    break;
2331
            }
2332
            $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...
2333
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2334
            if ($auxX > $w * 0.90) {
2335
                $yIniDados = $yIniDados + 4;
2336
                $auxX = $oldX;
2337
            }
2338
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2339
            $auxX += $w * 0.09;
2340
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2341
            $auxX += $w * 0.28;
2342
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2343
            $auxX += $w * 0.14;
2344
        }
2345
    } //fim da função zDocOrig
2346
2347
    /**
2348
     * zDocOrigContinuacao
2349
     * Monta o campo com os documentos originarios.
2350
     *
2351
     * @param  number $x Posição horizontal canto esquerdo
2352
     * @param  number $y Posição vertical canto superior
2353
     * @return number Posição vertical final
2354
     */
2355
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2356
    {
2357
        $this->pdf->AddPage($this->orientacao, $this->papel);
2358
        $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...
2359
        $oldX = $x;
2360
        $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...
2361
        if ($this->orientacao == 'P') {
2362
            $maxW = $this->wPrint;
2363
        } else {
2364
            $maxW = $this->wPrint - $this->wCanhoto;
2365
        }
2366
        $w = $maxW;
2367
        
2368
        //$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...
2369
        //$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...
2370
        //$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...
2371
        //$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...
2372
        $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2373
        if (count($this->arrayNFe)%2 !=0) {
2374
            $h = $h+3.5;
2375
        } // Caso tenha apenas 1 registro na ultima linha
2376
        
2377
        $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2378
        $aFont = $this->formatPadrao;
2379
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2380
        $descr1 = 'TIPO DOC';
2381
        $descr2 = 'CNPJ/CHAVE/OBS';
2382
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2383
        
2384
        $y += 3.4;
2385
        $this->pdf->Line($x, $y, $w + 1, $y);
2386
        $texto = $descr1;
2387
        $aFont = $this->formatPadrao;
2388
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2389
        $yIniDados = $y;
2390
        
2391
        $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2392
        $texto = $descr2;
2393
        $aFont = $this->formatPadrao;
2394
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2395
        
2396
        $x += $w * 0.28;
2397
        $texto = $descr3;
2398
        $aFont = $this->formatPadrao;
2399
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2400
        
2401
        $x += $w * 0.14;
2402 View Code Duplication
        if ($this->modal == '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...
2403
            if ($this->lota == 1) {
2404
                $this->pdf->Line($x, $y, $x, $y + 31.5);
2405
            } else {
2406
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2407
            }
2408
        } elseif ($this->modal == '3') {
2409
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2410
        } else {
2411
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2412
        }
2413
        $texto = $descr1;
2414
        $aFont = $this->formatPadrao;
2415
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2416
                
2417
        $x += $w * 0.08;
2418
        $texto = $descr2;
2419
        $aFont = $this->formatPadrao;
2420
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2421
        
2422
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2423
        $texto = $descr3;
2424
        $aFont = $this->formatPadrao;
2425
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2426
        $auxX = $oldX;
2427
        $yIniDados += 3;
2428
        
2429
        $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...
2430
        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...
2431
            $tp = 'NF-e';
2432
            $chaveNFe = $this->arrayNFe[$contador];
2433
            $numNFe = substr($chaveNFe, 25, 9);
2434
            $serieNFe = substr($chaveNFe, 22, 3);
2435
            $doc = $serieNFe . '/' . $numNFe;
2436
            if ($auxX > $w * 0.90) {
2437
                $yIniDados = $yIniDados + 3.5;
2438
                $auxX = $oldX;
2439
            }
2440
            $texto = $tp;
2441
            $aFont = array(
2442
                'font' => $this->fontePadrao,
2443
                'size' => 7,
2444
                'style' => '');
2445
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2446
            $auxX += $w * 0.07;
2447
            $texto = $chaveNFe;
2448
            $aFont = array(
2449
                'font' => $this->fontePadrao,
2450
                'size' => 7,
2451
                'style' => '');
2452
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2453
            $auxX += $w * 0.28;
2454
            $texto = $doc;
2455
            $aFont = array(
2456
                'font' => $this->fontePadrao,
2457
                'size' => 7,
2458
                'style' => '');
2459
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2460
            $auxX += $w * 0.15;
2461
        }
2462
    } //fim da função zDocOrigContinuacao
2463
2464
    /**
2465
     * zDocCompl
2466
     * Monta o campo com os dados do remetente na DACTE.
2467
     *
2468
     * @param number $x Posição horizontal canto esquerdo
2469
     * @param number $y Posição vertical canto superior
2470
     * @return number Posição vertical final
2471
     */
2472
    protected function zDocCompl($x = 0, $y = 0)
2473
    {
2474
        $oldX = $x;
2475
        $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...
2476
        if ($this->orientacao == 'P') {
2477
            $maxW = $this->wPrint;
2478
        } else {
2479
            $maxW = $this->wPrint - $this->wCanhoto;
2480
        }
2481
        $w = $maxW;
2482
        $h = 80;
2483
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2484
        $aFont = $this->formatPadrao;
2485
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2486
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2487
        $descr2 = 'VALOR COMPLEMENTADO';
2488
        $y += 3.4;
2489
        $this->pdf->Line($x, $y, $w + 1, $y);
2490
        $texto = $descr1;
2491
        $aFont = $this->formatPadrao;
2492
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2493
        $yIniDados = $y;
2494
        $x += $w * 0.37;
2495
        $texto = $descr2;
2496
        $aFont = $this->formatPadrao;
2497
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2498
        $x += $w * 0.13;
2499
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2500
        $texto = $descr1;
2501
        $aFont = $this->formatPadrao;
2502
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2503
        $x += $w * 0.3;
2504
        $texto = $descr2;
2505
        $aFont = $this->formatPadrao;
2506
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2507
        $auxX = $oldX;
2508
        $yIniDados += 4;
2509
        if ($auxX > $w * 0.90) {
2510
            $yIniDados = $yIniDados + 4;
2511
            $auxX = $oldX;
2512
        }
2513
        $texto = $this->chaveCTeRef;
2514
        $aFont = array(
2515
            'font' => $this->fontePadrao,
2516
            'size' => 8,
2517
            'style' => '');
2518
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2519
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2520
        $aFont = array(
2521
            'font' => $this->fontePadrao,
2522
            'size' => 8,
2523
            'style' => '');
2524
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2525
    } //fim da função zDocCompl
2526
2527
    /**
2528
     * zObs
2529
     * Monta o campo com os dados do remetente na DACTE.
2530
     *
2531
     * @param  number $x Posição horizontal canto esquerdo
2532
     * @param  number $y Posição vertical canto superior
2533
     * @return number Posição vertical final
2534
     */
2535
    protected function zObs($x = 0, $y = 0)
2536
    {
2537
        $oldX = $x;
2538
        $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...
2539
        if ($this->orientacao == 'P') {
2540
            $maxW = $this->wPrint;
2541
        } else {
2542
            $maxW = $this->wPrint - $this->wCanhoto;
2543
        }
2544
        $w = $maxW;
2545
        //$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...
2546
        $h = 12;
2547
        $texto = 'OBSERVAÇÕES';
2548
        $aFont = $this->formatPadrao;
2549
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2550
        $y += 3.4;
2551
        $this->pdf->Line($x, $y, $w + 1, $y);
2552
        $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...
2553
        $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...
2554
        $texto = '';
2555
        foreach ($this->compl as $k => $d) {
2556
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2557
            $texto .= "\r\n" . $xObs;
2558
        }
2559
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2560
        $texto .= $this->zLocalEntrega();
2561
        $aFont = array(
2562
            'font' => $this->fontePadrao,
2563
            'size' => 7.5,
2564
            'style' => '');
2565
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '', false);
2566
    } //fim da função obsDACTE
2567
2568
    /**
2569
     * zLocalEntrega
2570
     *
2571
     * @return string
2572
     */
2573
    protected function zLocalEntrega()
2574
    {
2575
        $locEntX = $this->dest->getElementsByTagName('locEnt');
2576
        if ($locEntX->length > 0) {
2577
            $locEnt = $locEntX->item(0);
2578
            $output = "Entrega: " . $output = $this->zFormatCNPJCPF($locEnt);
2579
            $output .= $this->pSimpleGetValue($locEnt, "CPF") . " ";
2580
            $output .= $this->pSimpleGetValue($locEnt, "xNome") . " ";
2581
            $output .= $this->pSimpleGetValue($locEnt, "xLgr") . " ";
2582
            $output .= $this->pSimpleGetValue($locEnt, "nro ") . " ";
2583
            $output .= $this->pSimpleGetValue($locEnt, "xCpl") . " ";
2584
            $output .= $this->pSimpleGetValue($locEnt, "xBairro") . " ";
2585
            $output .= $this->pSimpleGetValue($locEnt, "xMun") . " ";
2586
            $output .= $this->pSimpleGetValue($locEnt, "UF") . " ";
2587
            return $output;
2588
        }
2589
        return "";
2590
    } //fim zLocalEntrega
2591
2592
    /**
2593
     * zModalRod
2594
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2595
     *
2596
     * @param  number $x Posição horizontal canto esquerdo
2597
     * @param  number $y Posição vertical canto superior
2598
     * @return number Posição vertical final
2599
     */
2600
    protected function zModalRod($x = 0, $y = 0)
2601
    {
2602
        $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...
2603
        $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...
2604
        $lotacao = '';
2605
        if ($this->orientacao == 'P') {
2606
            $maxW = $this->wPrint;
2607
        } else {
2608
            $maxW = $this->wPrint - $this->wCanhoto;
2609
        }
2610
        $w = $maxW;
2611 View Code Duplication
        if ($this->modal == '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...
2612
            $h = $this->lota == 1 ? 12.5 : 3.7;
2613
            $lotacao = $this->lota == 1 ? 'Sim' : 'Não';
2614
        } else {
2615
            $h = 12.5;
2616
        }
2617
        $textolota = $this->lota == 1 ? 'LOTAÇÃO' : 'CARGA FRACIONADA';
2618
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO - ' . $textolota;
2619
        $aFont = $this->formatPadrao;
2620
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2621
        if ($this->lota == 1) {
2622
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2623
        }
2624
        $y += 3.4;
2625
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2626
        $texto = 'RNTRC DA EMPRESA';
2627
        $aFont = $this->formatPadrao;
2628
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2629
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2630
        $aFont = $this->formatNegrito;
2631
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2632
        $x += $w * 0.23;
2633
        
2634
        //$this->pdf->Line($x, $y, $x, $y + 8.5);
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...
2635
        $this->pdf->Line($x-20, $y, $x-20, $y + 8.5); // LINHA A FRENTE DA RNTRC DA EMPRESA
2636
        $texto = 'CIOT';
2637
        $aFont = $this->formatPadrao;
2638
        $this->pTextBox($x-20, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2639
        $texto = $this->pSimpleGetValue($this->rodo, "CIOT");
2640
        $aFont = $this->formatNegrito;
2641
        $this->pTextBox($x-20, $y + 3, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2642
        
2643
        //$this->pdf->Line($x, $y, $x, $y + 8.5);
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...
2644
        $this->pdf->Line($x+10, $y, $x+10, $y + 8.5); // LINHA A FRENTE DO CIOT
2645
        $texto = 'LOTAÇÃO';
2646
        $aFont = $this->formatPadrao;
2647
        $this->pTextBox($x+10, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2648
        $texto = $lotacao;
2649
        $aFont = $this->formatNegrito;
2650
        $this->pTextBox($x+10, $y + 3, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2651
        
2652
        $x += $w * 0.13;
2653
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2654
        $texto = 'DATA PREVISTA DE ENTREGA';
2655
        $aFont = $this->formatPadrao;
2656
        $this->pTextBox($x, $y, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2657
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rodo, "dPrev"));
2658
        $aFont = $this->formatNegrito;
2659
        $this->pTextBox($x, $y + 3, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2660
        $x += $w * 0.15;
2661
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2662
        $h = 25;
2663
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE ' . "\r\n";
2664
        $texto .= ' À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2665
        $aFont = $this->formatPadrao;
2666
        $this->pTextBox($x, $y + 1, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2667
        if ($this->lota == 1) {
2668
            $y += 10;
2669
            $x = 1;
2670
            $texto = 'IDENTIFICAÇÃO DO CONJUNTO TRANSPORTADOR';
2671
            $aFont = $this->formatPadrao;
2672
            $this->pTextBox($x, $y, $w * 0.465, $h, $texto, $aFont, 'T', 'C', 0, '');
2673
            $this->pdf->Line($x, $y + 3.5, $w * 0.465, $y + 3.5);
2674
            $y += 3.5;
2675
            $texto = 'TIPO';
2676
            $aFont = $this->formatPadrao;
2677
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2678
            $yIniDados = $y;
2679
            if (count($this->veic) >= 0) {
2680
                foreach ($this->veic as $k => $d) {
2681
                    $yIniDados = $yIniDados + 3;
2682
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "tpVeic");
2683
                    switch ($texto) {
2684
                        case '0':
2685
                            $texto = 'Tração';
2686
                            break;
2687
                        case '1':
2688
                            $texto = 'Reboque';
2689
                            break;
2690
                        default:
2691
                            $texto = ' ';
2692
                    }
2693
                    $aFont = array(
2694
                        'font' => $this->fontePadrao,
2695
                        'size' => 6,
2696
                        'style' => 'B');
2697
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2698
                } //fim foreach
2699
            }
2700
            $x += $w * 0.10;
2701
            $texto = 'PLACA';
2702
            $aFont = $this->formatPadrao;
2703
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2704
            $this->pdf->Line($x, $y, $x, $y + 14);
2705
            $yIniDados = $y;
2706 View Code Duplication
            if (count($this->veic) >= 0) {
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...
2707
                foreach ($this->veic as $k => $d) {
2708
                    $yIniDados = $yIniDados + 3;
2709
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "placa");
2710
                    $aFont = array(
2711
                        'font' => $this->fontePadrao,
2712
                        'size' => 6,
2713
                        'style' => 'B');
2714
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2715
                }
2716
            }
2717
            $x += $w * 0.13;
2718
            $texto = 'UF';
2719
            $aFont = $this->formatPadrao;
2720
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2721
            $this->pdf->Line($x, $y, $x, $y + 23);
2722
            $yIniDados = $y;
2723 View Code Duplication
            if (count($this->veic) >= 0) {
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...
2724
                foreach ($this->veic as $k => $d) {
2725
                    $yIniDados = $yIniDados + 3;
2726
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "UF");
2727
                    $aFont = array(
2728
                        'font' => $this->fontePadrao,
2729
                        'size' => 6,
2730
                        'style' => 'B');
2731
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2732
                }
2733
            }
2734
            $x += $w * 0.03;
2735
            $texto = 'RNTRC';
2736
            $aFont = $this->formatPadrao;
2737
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2738
            $this->pdf->Line($x, $y, $x, $y + 14);
2739
            $yIniDados = $y;
2740 View Code Duplication
            if (count($this->veic) >= 0) {
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...
2741
                foreach ($this->veic as $k => $d) {
2742
                    $yIniDados = $yIniDados + 3;
2743
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "RNTRC");
2744
                    $aFont = array(
2745
                        'font' => $this->fontePadrao,
2746
                        'size' => 6,
2747
                        'style' => 'B');
2748
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2749
                }
2750
            }
2751
            $y += 14;
2752
            $x = 1;
2753
            $texto = 'NOME DO MOTORISTA';
2754
            $aFont = array(
2755
                'font' => $this->fontePadrao,
2756
                'size' => 5,
2757
                'style' => '');
2758
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2759
            $this->pdf->Line($x, $y, $w + 1, $y);
2760
            $texto = !empty($this->moto) ? $this->pSimpleGetValue($this->moto, "xNome") : '';
2761
            $aFont = array(
2762
                'font' => $this->fontePadrao,
2763
                'size' => 7,
2764
                'style' => 'B');
2765
            $this->pTextBox($x, $y + 3, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
2766
            $x += $w * 0.23;
2767
            $texto = 'CPF MOTORISTA';
2768
            $aFont = array(
2769
                'font' => $this->fontePadrao,
2770
                'size' => 5,
2771
                'style' => '');
2772
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2773
            //$texto = !empty($this->moto) ? $this->pSimpleGetValue($this->moto, "CPF") : '';  // CPF SEM MASCARA
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...
2774
            $texto = !empty($this->moto) ? $this->zFormatCNPJCPF($this->moto) : '';            // CPF COM MASCARA
2775
            $aFont = array(
2776
                'font' => $this->fontePadrao,
2777
                'size' => 7,
2778
                'style' => 'B');
2779
            $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2780
            $x += $w * 0.23;
2781
            $texto = 'IDENTIFICAÇÃO DOS LACRES EM TRANSITO';
2782
            $aFont = array(
2783
                'font' => $this->fontePadrao,
2784
                'size' => 5,
2785
                'style' => '');
2786
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2787
            $this->pdf->Line($x, $y, $x, $y - 18.7);
2788
            $this->pdf->Line($x, $y, $x, $y + 9);
2789
            $x = $w * 0.465;
2790
            $y -= 16;
2791
            $texto = 'INFORMAÇÕES REFERENTES AO VALE PEDÁGIO';
2792
            $aFont = $this->formatPadrao;
2793
            $this->pTextBox($x, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2794
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2795
            $y += 4;
2796
            $texto = 'CNPJ FORNECEDOR';
2797
            $aFont = array(
2798
                'font' => $this->fontePadrao,
2799
                'size' => 5,
2800
                'style' => '');
2801
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2802
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2803
            $y += 4;
2804
            $texto = 'NUMERO COMPROVANTE';
2805
            $aFont = array(
2806
                'font' => $this->fontePadrao,
2807
                'size' => 5,
2808
                'style' => '');
2809
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2810
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2811
            $y += 4;
2812
            $texto = 'CNPJ RESPONSÁVEL';
2813
            $aFont = array(
2814
                'font' => $this->fontePadrao,
2815
                'size' => 5,
2816
                'style' => '');
2817
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2818
        }
2819
    } //fim da função zModalRod
2820
2821
    /**
2822
     * zModalAquaviario
2823
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2824
     *
2825
     * @param  number $x Posição horizontal canto esquerdo
2826
     * @param  number $y Posição vertical canto superior
2827
     * @return number Posição vertical final
2828
     */
2829
    protected function zModalAquaviario($x = 0, $y = 0)
2830
    {
2831
        $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...
2832
        $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...
2833
        if ($this->orientacao == 'P') {
2834
            $maxW = $this->wPrint;
2835
        } else {
2836
            $maxW = $this->wPrint - $this->wCanhoto;
2837
        }
2838
        $w = $maxW;
2839
        $h = 8.5;
2840
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2841
        $aFont = $this->formatPadrao;
2842
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2843
        $y += 3.4;
2844
        $this->pdf->Line($x, $y, $w + 1, $y);
2845
        $texto = 'PORTO DE EMBARQUE';
2846
        $aFont = $this->formatPadrao;
2847
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2848
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2849
        $aFont = $this->formatNegrito;
2850
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2851
        $x += $w * 0.50;
2852
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2853
        $texto = 'PORTO DE DESTINO';
2854
        $aFont = $this->formatPadrao;
2855
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2856
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2857
        $aFont = $this->formatNegrito;
2858
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2859
        $y += 8;
2860
        $this->pdf->Line(208, $y, 1, $y);
2861
        $x = 1;
2862
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2863
        $aFont = $this->formatPadrao;
2864
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2865
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2866
        $aFont = $this->formatNegrito;
2867
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2868
        $x += $w * 0.50;
2869
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2870
        $texto = 'VR DA B. DE CALC. AFRMM';
2871
        $aFont = $this->formatPadrao;
2872
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2873
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2874
        $aFont = $this->formatNegrito;
2875
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2876
        $x += $w * 0.17;
2877
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2878
        $texto = 'VALOR DO AFRMM';
2879
        $aFont = $this->formatPadrao;
2880
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2881
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2882
        $aFont = $this->formatNegrito;
2883
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2884
        $x += $w * 0.12;
2885
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2886
        $texto = 'TIPO DE NAVEGAÇÃO';
2887
        $aFont = $this->formatPadrao;
2888
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2889
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2890
        switch ($texto) {
2891
            case '0':
2892
                $texto = 'INTERIOR';
2893
                break;
2894
            case '1':
2895
                $texto = 'CABOTAGEM';
2896
                break;
2897
        }
2898
        $aFont = $this->formatNegrito;
2899
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2900
        $x += $w * 0.14;
2901
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2902
        $texto = 'DIREÇÃO';
2903
        $aFont = $this->formatPadrao;
2904
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2905
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2906
        switch ($texto) {
2907
            case 'N':
2908
                $texto = 'NORTE';
2909
                break;
2910
            case 'L':
2911
                $texto = 'LESTE';
2912
                break;
2913
            case 'S':
2914
                $texto = 'SUL';
2915
                break;
2916
            case 'O':
2917
                $texto = 'OESTE';
2918
                break;
2919
        }
2920
        $aFont = $this->formatNegrito;
2921
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2922
        $y += 8;
2923
        $this->pdf->Line(208, $y, 1, $y);
2924
        $x = 1;
2925
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2926
        $aFont = $this->formatPadrao;
2927
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2928
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2929
            $texto = $this->infNF
2930
                ->item(0)
2931
                ->getElementsByTagName('infUnidCarga')
2932
                ->item(0)
2933
                ->getElementsByTagName('idUnidCarga')
2934
                ->item(0)->nodeValue;
2935
        } elseif ($this->infNFe->item(0) !== null
2936
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2937
        ) {
2938
            $texto = $this->infNFe
2939
                ->item(0)
2940
                ->getElementsByTagName('infUnidCarga')
2941
                ->item(0)
2942
                ->getElementsByTagName('idUnidCarga')
2943
                ->item(0)
2944
                ->nodeValue;
2945
        } elseif ($this->infOutros->item(0) !== null
2946
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2947
        ) {
2948
            $texto = $this->infOutros
2949
                ->item(0)
2950
                ->getElementsByTagName('infUnidCarga')
2951
                ->item(0)
2952
                ->getElementsByTagName('idUnidCarga')
2953
                ->item(0)
2954
                ->nodeValue;
2955
        } else {
2956
            $texto = '';
2957
        }
2958
        $aFont = $this->formatNegrito;
2959
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2960
        $x += $w * 0.50;
2961
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2962
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2963
        $aFont = $this->formatPadrao;
2964
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2965
        $texto = '';
2966
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2967
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2968
                if ($k == 0) {
2969
                    $texto = $this->aquav
2970
                        ->getElementsByTagName('balsa')
2971
                        ->item($k)
2972
                        ->getElementsByTagName('xBalsa')
2973
                        ->item(0)
2974
                        ->nodeValue;
2975
                } else {
2976
                    $texto = $texto
2977
                        . ' / '
2978
                        . $this->aquav
2979
                            ->getElementsByTagName('balsa')
2980
                            ->item($k)
2981
                            ->getElementsByTagName('xBalsa')
2982
                            ->item(0)
2983
                            ->nodeValue;
2984
                }
2985
            }
2986
        }
2987
        $aFont = $this->formatNegrito;
2988
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2989
    } //fim da função zModalRod
2990
2991
    /**
2992
     * zModalFerr
2993
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2994
     *
2995
     * @param  number $x Posição horizontal canto esquerdo
2996
     * @param  number $y Posição vertical canto superior
2997
     * @return number Posição vertical final
2998
     */
2999
    protected function zModalFerr($x = 0, $y = 0)
3000
    {
3001
        $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...
3002
        $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...
3003
        if ($this->orientacao == 'P') {
3004
            $maxW = $this->wPrint;
3005
        } else {
3006
            $maxW = $this->wPrint - $this->wCanhoto;
3007
        }
3008
        $w = $maxW;
3009
        $h = 19.6;
3010
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
3011
        $aFont = $this->formatPadrao;
3012
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3013
        $y += 3.4;
3014
        $this->pdf->Line($x, $y, $w + 1, $y);
3015
        $texto = 'DCL';
3016
        $aFont = array(
3017
            'font' => $this->fontePadrao,
3018
            'size' => 7,
3019
            'style' => 'B');
3020
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
3021
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
3022
        $texto = 'VAGÕES';
3023
        $aFont = array(
3024
            'font' => $this->fontePadrao,
3025
            'size' => 7,
3026
            'style' => 'B');
3027
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
3028
        $y += 3.4;
3029
        $this->pdf->Line($x, $y, $w + 1, $y);
3030
        // DCL
3031
        $texto = 'ID TREM';
3032
        $aFont = array(
3033
            'font' => $this->fontePadrao,
3034
            'size' => 6,
3035
            'style' => '');
3036
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3037
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
3038
        $aFont = array(
3039
            'font' => $this->fontePadrao,
3040
            'size' => 6,
3041
            'style' => 'B');
3042
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3043
        $x += $w * 0.06;
3044
        $y1 = $y + 12.5;
3045
        $this->pdf->Line($x, $y, $x, $y1);
3046
        $texto = 'NUM';
3047
        $aFont = array(
3048
            'font' => $this->fontePadrao,
3049
            'size' => 6,
3050
            'style' => '');
3051
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3052
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
3053
        $aFont = array(
3054
            'font' => $this->fontePadrao,
3055
            'size' => 6,
3056
            'style' => 'B');
3057
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3058
        $x += $w * 0.06;
3059
        $this->pdf->Line($x, $y, $x, $y1);
3060
        $texto = 'SÉRIE';
3061
        $aFont = array(
3062
            'font' => $this->fontePadrao,
3063
            'size' => 6,
3064
            'style' => '');
3065
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3066
        $texto = $this->pSimpleGetValue($this->rem, "serie");
3067
        $aFont = array(
3068
            'font' => $this->fontePadrao,
3069
            'size' => 6,
3070
            'style' => 'B');
3071
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3072
        $x += $w * 0.06;
3073
        $this->pdf->Line($x, $y, $x, $y1);
3074
        $texto = 'EMISSÃO';
3075
        $aFont = array(
3076
            'font' => $this->fontePadrao,
3077
            'size' => 6,
3078
            'style' => '');
3079
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3080
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
3081
        $aFont = array(
3082
            'font' => $this->fontePadrao,
3083
            'size' => 6,
3084
            'style' => 'B');
3085
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3086
        // VAGOES
3087
        $x += $w * 0.06;
3088
        $this->pdf->Line($x, $y, $x, $y1);
3089
        $texto = 'NUM';
3090
        $aFont = array(
3091
            'font' => $this->fontePadrao,
3092
            'size' => 6,
3093
            'style' => '');
3094
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3095
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
3096
        $aFont = array(
3097
            'font' => $this->fontePadrao,
3098
            'size' => 6,
3099
            'style' => 'B');
3100
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3101
        $x += $w * 0.06;
3102
        $this->pdf->Line($x, $y, $x, $y1);
3103
        $texto = 'TIPO';
3104
        $aFont = array(
3105
            'font' => $this->fontePadrao,
3106
            'size' => 6,
3107
            'style' => '');
3108
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3109
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
3110
        $aFont = array(
3111
            'font' => $this->fontePadrao,
3112
            'size' => 6,
3113
            'style' => 'B');
3114
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3115
        $x += $w * 0.06;
3116
        $this->pdf->Line($x, $y, $x, $y1);
3117
        $texto = 'CAPACIDADE';
3118
        $aFont = array(
3119
            'font' => $this->fontePadrao,
3120
            'size' => 6,
3121
            'style' => '');
3122
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3123
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
3124
        $aFont = array(
3125
            'font' => $this->fontePadrao,
3126
            'size' => 6,
3127
            'style' => 'B');
3128
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3129
        $x += $w * 0.08;
3130
        $this->pdf->Line($x, $y, $x, $y1);
3131
        $texto = 'PESO REAL/TON';
3132
        $aFont = array(
3133
            'font' => $this->fontePadrao,
3134
            'size' => 6,
3135
            'style' => '');
3136
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3137
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3138
        $aFont = array(
3139
            'font' => $this->fontePadrao,
3140
            'size' => 6,
3141
            'style' => 'B');
3142
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3143
        $x += $w * 0.09;
3144
        $this->pdf->Line($x, $y, $x, $y1);
3145
        $texto = 'PESO BRUTO/TON';
3146
        $aFont = array(
3147
            'font' => $this->fontePadrao,
3148
            'size' => 6,
3149
            'style' => '');
3150
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3151
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3152
        $aFont = array(
3153
            'font' => $this->fontePadrao,
3154
            'size' => 6,
3155
            'style' => 'B');
3156
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3157
        $x += $w * 0.1;
3158
        $this->pdf->Line($x, $y, $x, $y1);
3159
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3160
        $aFont = array(
3161
            'font' => $this->fontePadrao,
3162
            'size' => 6,
3163
            'style' => '');
3164
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3165
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3166
        $aFont = array(
3167
            'font' => $this->fontePadrao,
3168
            'size' => 6,
3169
            'style' => 'B');
3170
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3171
        // FLUXO
3172
        $x = 1;
3173
        $y += 12.9;
3174
        $h1 = $h * 0.5 + 0.27;
3175
        $wa = round($w * 0.103) + 0.5;
3176
        $texto = 'FLUXO FERROVIARIO';
3177
        $aFont = $this->formatPadrao;
3178
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3179
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3180
        $aFont = array(
3181
            'font' => $this->fontePadrao,
3182
            'size' => 7,
3183
            'style' => 'B');
3184
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3185
        $y += 10;
3186
        $texto = 'TIPO DE TRÁFEGO';
3187
        $aFont = $this->formatPadrao;
3188
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3189
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3190
        $aFont = array(
3191
            'font' => $this->fontePadrao,
3192
            'size' => 7,
3193
            'style' => 'B');
3194
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3195
        // Novo Box Relativo a Modal Ferroviário
3196
        $x = 22.5;
3197
        $y += -10.2;
3198
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3199
        $aFont = $this->formatPadrao;
3200
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3201
        $y += 3.4;
3202
        $this->pdf->Line($x, $y, $w + 1, $y);
3203
        $w = $w * 0.2;
3204
        $h = $h * 1.04;
3205
        $texto = 'CÓDIGO INTERNO';
3206
        $aFont = array(
3207
            'font' => $this->fontePadrao,
3208
            'size' => 6,
3209
            'style' => '');
3210
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3211
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3212
        $aFont = array(
3213
            'font' => $this->fontePadrao,
3214
            'size' => 6,
3215
            'style' => 'B');
3216
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3217
        $texto = 'CNPJ';
3218
        $aFont = array(
3219
            'font' => $this->fontePadrao,
3220
            'size' => 6,
3221
            'style' => '');
3222
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3223
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3224
        $aFont = array(
3225
            'font' => $this->fontePadrao,
3226
            'size' => 6,
3227
            'style' => 'B');
3228
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3229
        $x += 50;
3230
        $texto = 'NOME';
3231
        $aFont = array(
3232
            'font' => $this->fontePadrao,
3233
            'size' => 6,
3234
            'style' => '');
3235
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3236
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3237
        $aFont = array(
3238
            'font' => $this->fontePadrao,
3239
            'size' => 6,
3240
            'style' => 'B');
3241
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3242
        $texto = 'INSCRICAO ESTADUAL';
3243
        $aFont = array(
3244
            'font' => $this->fontePadrao,
3245
            'size' => 6,
3246
            'style' => '');
3247
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3248
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3249
        $aFont = array(
3250
            'font' => $this->fontePadrao,
3251
            'size' => 6,
3252
            'style' => 'B');
3253
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3254
        $x += 50;
3255
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3256
        $aFont = array(
3257
            'font' => $this->fontePadrao,
3258
            'size' => 6,
3259
            'style' => '');
3260
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3261
        $texto = '';
3262
        $aFont = array(
3263
            'font' => $this->fontePadrao,
3264
            'size' => 6,
3265
            'style' => 'B');
3266
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3267
    } //fim da função zModalFerr
3268
3269
    /**
3270
     * zCanhoto
3271
     * Monta o campo com os dados do remetente na DACTE.
3272
     *
3273
     * @param  number $x Posição horizontal canto esquerdo
3274
     * @param  number $y Posição vertical canto superior
3275
     * @return number Posição vertical final
3276
     */
3277
    protected function zCanhoto($x = 0, $y = 0)
3278
    {
3279
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3280
        $y = $y + 2;
3281
        $oldX = $x;
3282
        $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...
3283
        if ($this->orientacao == 'P') {
3284
            $maxW = $this->wPrint;
3285
        } else {
3286
            $maxW = $this->wPrint - $this->wCanhoto;
3287
        }
3288
        $w = $maxW - 1;
3289
        $h = 20;
3290
        $y = $y + 1;
3291
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3292
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3293
        $aFont = $this->formatPadrao;
3294
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3295
        $y += 3.4;
3296
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3297
        
3298
        $texto = 'NOME';
3299
        $aFont = array(
3300
            'font' => $this->fontePadrao,
3301
            'size' => 6,
3302
            'style' => '');
3303
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3304
        $x += $w * 0.25;
3305
        
3306
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3307
        
3308
        $texto = 'ASSINATURA / CARIMBO';
3309
        $aFont = array(
3310
            'font' => $this->fontePadrao,
3311
            'size' => 6,
3312
            'style' => '');
3313
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3314
        $x += $w * 0.25;
3315
        
3316
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3317
        
3318
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3319
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3320
        $aFont = array(
3321
            'font' => $this->fontePadrao,
3322
            'size' => 6,
3323
            'style' => '');
3324
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3325
        $x = $oldX;
3326
        $y = $y + 5;
3327
        
3328
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3329
        
3330
        $texto = 'RG';
3331
        $aFont = array(
3332
            'font' => $this->fontePadrao,
3333
            'size' => 6,
3334
            'style' => '');
3335
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3336
        $x += $w * 0.85;
3337
        
3338
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3339
        
3340
        $texto = "CT-E";
3341
        $aFont = $this->formatNegrito;
3342
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3343
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3344
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3345
        $aFont = array(
3346
            'font' => $this->fontePadrao,
3347
            'size' => 6,
3348
            'style' => '');
3349
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3350
        $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...
3351
        //$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...
3352
    } //fim da função canhotoDACTE
3353
3354
    /**
3355
     * zDadosAdic
3356
     * Coloca o grupo de dados adicionais da DACTE.
3357
     *
3358
     * @param  number $x Posição horizontal canto esquerdo
3359
     * @param  number $y Posição vertical canto superior
3360
     * @param  number $h altura do campo
3361
     * @return number Posição vertical final
3362
     */
3363
    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...
3364
    {
3365
        $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...
3366
        //###########################################################################
3367
        //DADOS ADICIONAIS DACTE
3368
        if ($this->orientacao == 'P') {
3369
            $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...
3370
        } else {
3371
            $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...
3372
        }
3373
        //INFORMAÇÕES COMPLEMENTARES
3374
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3375
        $y += 3;
3376
        $w = $this->wAdic;
3377
        $h = 8; //mudar
3378
        $aFont = array(
3379
            'font' => $this->fontePadrao,
3380
            'size' => 6,
3381
            'style' => '');
3382
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3383
        //$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...
3384
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3385
        //o texto com os dados adicionais foi obtido na função xxxxxx
3386
        //e carregado em uma propriedade privada da classe
3387
        //$this->wAdic com a largura do campo
3388
        //$this->textoAdic com o texto completo do campo
3389
        $y += 1;
3390
        $aFont = $this->formatPadrao;
3391
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3392
        //RESERVADO AO FISCO
3393
        $texto = "RESERVADO AO FISCO";
3394
        $x += $w;
3395
        $y -= 1;
3396 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...
3397
            $w = $this->wPrint - $w;
3398
        } else {
3399
            $w = $this->wPrint - $w - $this->wCanhoto;
3400
        }
3401
        $aFont = array(
3402
            'font' => $this->fontePadrao,
3403
            'size' => 6,
3404
            'style' => '');
3405
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3406
        //inserir texto informando caso de contingência
3407
        //1 – Normal – emissão normal;
3408
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3409
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3410
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3411
        //Emissão em Contingência – DPEC;
3412
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3413
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3414
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3415
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3416
        $texto = '';
3417
        switch ($this->tpEmis) {
3418
            case 2:
3419
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3420
                break;
3421
            case 3:
3422
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3423
                break;
3424
            case 4:
3425
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3426
                break;
3427
            case 5:
3428
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3429
                break;
3430
        }
3431
        $y += 2;
3432
        $aFont = $this->formatPadrao;
3433
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3434
        return $y + $h;
3435
    } //fim zDadosAdic
3436
3437
    /**
3438
     * zhDashedLine
3439
     * Desenha uma linha horizontal tracejada com o FPDF
3440
     *
3441
     * @param  number $x Posição horizontal inicial, em mm
3442
     * @param  number $y Posição vertical inicial, em mm
3443
     * @param  number $w Comprimento da linha, em mm
3444
     * @param  number $h Espessura da linha, em mm
3445
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3446
     * @return none
3447
     */
3448
    protected function zhDashedLine($x, $y, $w, $h, $n)
3449
    {
3450
        $this->pdf->SetLineWidth($h);
3451
        $wDash = ($w / $n) / 2; // comprimento dos traços
3452 View Code Duplication
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
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...
3453
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3454
                if ($j <= ($x + $w - 1)) {
3455
                    $this->pdf->Line($j, $y, $j + 1, $y);
3456
                }
3457
            }
3458
        }
3459
    } //fim função hDashedLine
3460
3461
    /**
3462
     * zhDashedVerticalLine
3463
     * Desenha uma linha vertical tracejada com o FPDF
3464
     *
3465
     * @param  number $x Posição horizontal inicial, em mm
3466
     * @param  number $y Posição vertical inicial, em mm
3467
     * @param  number $w Comprimento da linha, em mm
3468
     * @param  number $yfinal Espessura da linha, em mm
3469
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3470
     * @return none
3471
     */
3472 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...
3473
    {
3474
        $this->pdf->SetLineWidth($w);
3475
        /* Organizando valores */
3476
        if ($y > $yfinal) {
3477
            $aux = $yfinal;
3478
            $yfinal = $y;
3479
            $y = $aux;
3480
        }
3481
        while ($y < $yfinal && $n > 0) {
3482
            $this->pdf->Line($x, $y, $x, $y + 1);
3483
            $y += 3;
3484
            $n--;
3485
        }
3486
    } //fim função hDashedVerticalLine
3487
3488
    /**
3489
     * zFormatCNPJCPF
3490
     * Formata campo CnpjCpf contida na CTe
3491
     *
3492
     * @param  string $field campo cnpjCpf da CT-e
3493
     * @return string
3494
     */
3495
    protected function zFormatCNPJCPF($field)
3496
    {
3497
        if (!isset($field)) {
3498
            return '';
3499
        }
3500
        $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...
3501
            $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...
3502
        if ($cnpj != "" && $cnpj != "00000000000000") {
3503
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3504
        } else {
3505
            $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...
3506
                $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...
3507
        }
3508
        return $cnpj;
3509
    } //fim formatCNPJCPF
3510
3511
    /**
3512
     * zFormatFone
3513
     * Formata campo fone contida na CTe
3514
     *
3515
     * @param  string $field campo fone da CT-e
3516
     * @return string
3517
     */
3518
    protected function zFormatFone($field)
3519
    {
3520
        $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...
3521
            $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...
3522
        $foneLen = strlen($fone);
3523 View Code Duplication
        if ($foneLen > 0) {
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...
3524
            $fone2 = substr($fone, 0, $foneLen - 4);
3525
            $fone1 = substr($fone, 0, $foneLen - 8);
3526
            $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3527
        } else {
3528
            $fone = '';
3529
        }
3530
        return $fone;
3531
    } //fim formatFone
3532
3533
    /**
3534
     * zUnidade
3535
     * Converte a imformação de peso contida na CTe
3536
     *
3537
     * @param  string $c unidade de trafego extraida da CTe
3538
     * @return string
3539
     */
3540
    protected function zUnidade($c = '')
3541
    {
3542
        switch ($c) {
3543
            case '00':
3544
                $r = 'M3';
3545
                break;
3546
            case '01':
3547
                $r = 'KG';
3548
                break;
3549
            case '02':
3550
                $r = 'TON';
3551
                break;
3552
            case '03':
3553
                $r = 'UN';
3554
                break;
3555
            case '04':
3556
                $r = 'LT';
3557
                break;
3558
            case '05':
3559
                $r = 'MMBTU';
3560
                break;
3561
            default:
3562
                $r = '';
3563
        }
3564
        return $r;
3565
    } //fim unidade
3566
3567
    /**
3568
     * zConvertUnidTrafego
3569
     * Converte a imformação de peso contida na CTe
3570
     *
3571
     * @param  string $U Informação de trafego extraida da CTe
3572
     * @return string
3573
     */
3574
    protected function zConvertUnidTrafego($U = '')
3575
    {
3576
        if ($U) {
3577
            switch ($U) {
3578
                case '0':
3579
                    $stringU = 'Próprio';
3580
                    break;
3581
                case '1':
3582
                    $stringU = 'Mútuo';
3583
                    break;
3584
                case '2':
3585
                    $stringU = 'Rodoferroviário';
3586
                    break;
3587
                case '3':
3588
                    $stringU = 'Rodoviário';
3589
                    break;
3590
            }
3591
            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...
3592
        }
3593
    } //fim da função zConvertUnidTrafego
3594
3595
    /**
3596
     * zMultiUniPeso
3597
     * Fornece a imformação multiplicação de peso contida na CTe
3598
     *
3599
     * @param  interger $U Informação de peso extraida da CTe
3600
     * @return interger
3601
     */
3602
    protected function zMultiUniPeso($U = '')
3603
    {
3604
        if ($U === "01") {
3605
            // tonelada
3606
            //return 1000;
3607
            return 1;
3608
        }
3609
        return 1; // M3, KG, Unidade, litros, mmbtu
3610
    } //fim da função zMultiUniPeso
3611
}
3612