Completed
Push — master ( dd807b...7193d1 )
by Roberto
16s
created

Dacte::zCteDPEC()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 6
rs 10
1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Exception;
19
use NFePHP\Common\Dom\Dom;
20
use NFePHP\DA\Legacy\Pdf;
21
use NFePHP\DA\Legacy\Common;
22
23
class Dacte extends Common
24
{
25
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
26
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
27
    const SIT_DPEC = 3;
28
29
    protected $logoAlign = 'C';
30
    protected $yDados = 0;
31
    protected $situacao_externa = 0;
32
    protected $numero_registro_dpec = '';
33
    protected $pdf;
34
    protected $xml;
35
    protected $logomarca = '';
36
    protected $errMsg = '';
37
    protected $errStatus = false;
38
    protected $orientacao = 'P';
39
    protected $papel = 'A4';
40
    protected $destino = 'I';
41
    protected $pdfDir = '';
42
    protected $fontePadrao = 'Times';
43
    protected $version = '1.3.0';
44
    protected $wPrint;
45
    protected $hPrint;
46
    protected $dom;
47
    protected $infCte;
48
    protected $infCteComp;
49
    protected $chaveCTeRef;
50
    protected $tpCTe;
51
    protected $ide;
52
    protected $emit;
53
    protected $enderEmit;
54
    protected $rem;
55
    protected $enderReme;
56
    protected $dest;
57
    protected $enderDest;
58
    protected $exped;
59
    protected $enderExped;
60
    protected $receb;
61
    protected $enderReceb;
62
    protected $infCarga;
63
    protected $infQ;
64
    protected $seg;
65
    protected $modal;
66
    protected $rodo;
67
    protected $moto;
68
    protected $veic;
69
    protected $ferrov;
70
    protected $Comp;
71
    protected $infNF;
72
    protected $infNFe;
73
    protected $compl;
74
    protected $ICMS;
75
    protected $imp;
76
    protected $toma4;
77
    protected $toma03;
78
    protected $tpEmis;
79
    protected $tpImp;
80
    protected $tpAmb;
81
    protected $vPrest;
82
    protected $wAdic = 150;
83
    protected $textoAdic = '';
84
    protected $debugMode = 2;
85
    protected $formatPadrao;
86
    protected $formatNegrito;
87
    protected $aquav;
88
89
    /**
90
     * __construct
91
     *
92
     * @param string $docXML Arquivo XML da CTe
93
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
94
     * @param string $sPapel Tamanho do papel (Ex. A4)
95
     * @param string $sPathLogo Caminho para o arquivo do logo
96
     * @param string $sDestino Estabelece a direção do envio do documento PDF
97
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
98
     * @param string $fonteDACTE Nome da fonte a ser utilizada
99
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
100
     */
101
    public function __construct(
102
        $docXML = '',
103
        $sOrientacao = '',
104
        $sPapel = '',
105
        $sPathLogo = '',
106
        $sDestino = 'I',
107
        $sDirPDF = '',
108
        $fonteDACTE = '',
109
        $mododebug = 2
110
    ) {
111
    
112
        if (is_numeric($mododebug)) {
113
            $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...
114
        }
115
        if ($mododebug == 1) {
116
            //ativar modo debug
117
            error_reporting(E_ALL);
118
            ini_set('display_errors', 'On');
119
        } elseif ($mododebug == 0) {
120
            //desativar modo debug
121
            error_reporting(0);
122
            ini_set('display_errors', 'Off');
123
        }
124
        $this->orientacao = $sOrientacao;
125
        $this->papel = $sPapel;
126
        $this->pdf = '';
127
        $this->xml = $docXML;
128
        $this->logomarca = $sPathLogo;
129
        $this->destino = $sDestino;
130
        $this->pdfDir = $sDirPDF;
131
        // verifica se foi passa a fonte a ser usada
132
        if (!empty($fonteDACTE)) {
133
            $this->fontePadrao = $fonteDACTE;
134
        }
135
        $this->formatPadrao = array(
136
            'font' => $this->fontePadrao,
137
            'size' => 7,
138
            'style' => '');
139
        $this->formatNegrito = array(
140
            'font' => $this->fontePadrao,
141
            'size' => 8,
142
            'style' => 'B');
143
        //se for passado o xml
144
        if (!empty($this->xml)) {
145
            $this->dom = new Dom();
146
            $this->dom->loadXML($this->xml);
147
            $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...
148
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
149
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
150
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
151
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
152
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
153
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
154
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
155
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
156
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
157
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
158
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
159
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
160
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
161
            $this->infQ = $this->dom->getElementsByTagName("infQ");
162
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
163
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
164
            $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...
165
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
166
            $this->veic = $this->dom->getElementsByTagName("veic");
167
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
168
            // adicionar outros modais
169
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
170
            $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chave");
171
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
172
            $this->Comp = $this->dom->getElementsByTagName("Comp");
173
            $this->infNF = $this->dom->getElementsByTagName("infNF");
174
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
175
            $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...
176
            $this->compl = $this->dom->getElementsByTagName("compl");
177
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
178
            $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...
179
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
180
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
181
            $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
182
            //modal aquaviário
183
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
184
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
185
            //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...
186
            switch ($tomador) {
187
                case '0':
188
                    $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...
189
                    $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...
190
                    break;
191
                case '1':
192
                    $this->toma = $this->exped;
193
                    $this->enderToma = $this->enderExped;
194
                    break;
195
                case '2':
196
                    $this->toma = $this->receb;
197
                    $this->enderToma = $this->enderReceb;
198
                    break;
199
                case '3':
200
                    $this->toma = $this->dest;
201
                    $this->enderToma = $this->enderDest;
202
                    break;
203
                default:
204
                    $this->toma = $this->toma4;
205
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
206
                    break;
207
            }
208
            $seguro = $this->pSimpleGetValue($this->seg, "respSeg");
209
            switch ($seguro) {
210
                case '0':
211
                    $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...
212
                    break;
213
                case '1':
214
                    $this->respSeg = 'Expedidor';
215
                    break;
216
                case '2':
217
                    $this->respSeg = 'Recebedor';
218
                    break;
219
                case '3':
220
                    $this->respSeg = 'Destinatário';
221
                    break;
222
                case '4':
223
                    $this->respSeg = 'Emitente';
224
                    break;
225
                case '5':
226
                    $this->respSeg = 'Tomador';
227
                    break;
228
                default:
229
                    $this->respSeg = '';
230
                    break;
231
            }
232
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
233
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
234
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
235
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
236
            $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...
237
        }
238
    }
239
240
    /**
241
     * monta
242
     * @param string $orientacao L ou P
243
     * @param string $papel A4
244
     * @param string $logoAlign C, L ou R
245
     * @param Pdf $classPDF
246
     * @return string montagem
247
     */
248
    public function monta(
249
        $orientacao = '',
250
        $papel = 'A4',
251
        $logoAlign = 'C',
252
        $classPDF = false
253
    ) {
254
    
255
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 252 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...
256
    }
257
258
    /**
259
     * printDocument
260
     * @param string $nome
261
     * @param string $destino
262
     * @param string $printer
263
     * @return
264
     */
265
    public function printDocument($nome = '', $destino = 'I', $printer = '')
266
    {
267
        return $this->printDACTE($nome, $destino, $printer);
268
    }
269
270
    /**
271
     * Dados brutos do PDF
272
     * @return string
273
     */
274
    public function render()
275
    {
276
        return $this->pdf->getPdf();
277
    }
278
279
280
    protected function zCteDPEC()
281
    {
282
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
283
    }
284
285
286
    /**
287
     * montaDACTE
288
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
289
     * durante sua construção.
290
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
291
     * pelo conteúdo da funçao e podem ser modificados.
292
     *
293
     * @param  string $orientacao (Opcional) Estabelece a orientação da
294
     *                impressão (ex. P-retrato), se nada for fornecido será
295
     *                usado o padrão da NFe
296
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
297
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
298
     */
299
    public function montaDACTE(
300
        $orientacao = '',
301
        $papel = 'A4',
302
        $logoAlign = 'C',
303
        $classPDF = false
304
    ) {
305
    
306
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
307 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...
308
            if ($this->tpImp == '1') {
309
                $orientacao = 'P';
310
            } else {
311
                $orientacao = 'P';
312
            }
313
        }
314
        $this->orientacao = $orientacao;
315
        $this->papel = $papel;
316
        $this->logoAlign = $logoAlign;
317
318
        //$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...
319
        //instancia a classe pdf
320
        if ($classPDF !== false) {
321
            $this->pdf = $classPDF;
322
        } else {
323
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
324
        }
325
        if ($this->orientacao == 'P') {
326
            // margens do PDF
327
            $margSup = 2;
328
            $margEsq = 2;
329
            $margDir = 2;
330
            // posição inicial do relatorio
331
            $xInic = 1;
332
            $yInic = 1;
333
            if ($papel == 'A4') {
334
                //A4 210x297mm
335
                $maxW = 210;
336
                $maxH = 297;
337
            }
338
        } else {
339
            // margens do PDF
340
            $margSup = 3;
341
            $margEsq = 3;
342
            $margDir = 3;
343
            // posição inicial do relatorio
344
            $xInic = 5;
345
            $yInic = 5;
346
            if ($papel == 'A4') {
347
                //A4 210x297mm
348
                $maxH = 210;
349
                $maxW = 297;
350
                $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...
351
            }
352
        }
353
        //total inicial de paginas
354
        $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...
355
        //largura imprimivel em mm
356
        $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...
357
        //comprimento imprimivel em mm
358
        $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...
359
        // estabelece contagem de paginas
360
        $this->pdf->AliasNbPages();
361
        // fixa as margens
362
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
363
        $this->pdf->SetDrawColor(0, 0, 0);
364
        $this->pdf->SetFillColor(255, 255, 255);
365
        // inicia o documento
366
        $this->pdf->Open();
367
        // adiciona a primeira página
368
        $this->pdf->AddPage($this->orientacao, $this->papel);
369
        $this->pdf->SetLineWidth(0.1);
370
        $this->pdf->SetTextColor(0, 0, 0);
371
        //calculo do numero de páginas ???
372
        $totPag = 1;
373
        //montagem da primeira página
374
        $pag = 1;
375
        $x = $xInic;
376
        $y = $yInic;
377
        //coloca o cabeçalho
378
        $y = $this->zCanhoto($x, $y);
379
        $y += 19;
380
        $r = $this->zCabecalho($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...
381
        $y += 70;
382
        $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...
383
        $x = $this->wPrint * 0.5 + 2;
384
        $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...
385
        $y += 19;
386
        $x = $xInic;
387
        $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...
388
        $x = $this->wPrint * 0.5 + 2;
389
        $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...
390
        $y += 19;
391
        $x = $xInic;
392
        $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...
393
        if ($this->tpCTe == '0') {
394
            //Normal
395
            $y += 10;
396
            $x = $xInic;
397
            $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...
398
            $y += 17;
399
            $x = $xInic;
400
            $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...
401
            $y += 25;
402
            $x = $xInic;
403
            $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...
404
            $y += 13;
405
            $x = $xInic;
406
            $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...
407 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...
408
                if ($this->lota == 1) {
409
                    $y += 24.95;
410
                } else {
411
                    $y += 53;
412
                }
413
            } elseif ($this->modal == '3') {
414
                $y += 37.75;
415
            } else {
416
                $y += 24.95;
417
            }
418
            $x = $xInic;
419
            $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...
420
            switch ($this->modal) {
421
                case '1':
422
                    $y += 17.9;
423
                    $x = $xInic;
424
                    $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...
425
                    break;
426
                case '2':
427
                    $y += 17.9;
428
                    $x = $xInic;
429
                    // TODO fmertins 31/10/14: este método não existe...
430
                    $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...
431
                    break;
432
                case '3':
433
                    $y += 17.9;
434
                    $x = $xInic;
435
                    $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...
436
                    break;
437
                case '4':
438
                    $y += 17.9;
439
                    $x = $xInic;
440
                    $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...
441
                    break;
442
                case '5':
443
                    $y += 17.9;
444
                    $x = $xInic;
445
                    // TODO fmertins 31/10/14: este método não existe...
446
                    $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...
447
                    break;
448
            }
449 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...
450
                if ($this->lota == 1) {
451
                    $y += 37;
452
                } else {
453
                    $y += 8.9;
454
                }
455
            } elseif ($this->modal == '3') {
456
                $y += 24.15;
457
            } else {
458
                $y += 37;
459
            }
460
        } else {
461
            //Complementado
462
            $y += 10;
463
            $x = $xInic;
464
            $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...
465
            $y += 80;
466
            $x = $xInic;
467
            $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...
468
            $y += 25;
469
            $x = $xInic;
470
            $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...
471
            $y += 13;
472
            $x = $xInic;
473
            $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...
474
            $y += 15;
475
        }
476
        $x = $xInic;
477
        $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...
478
        //coloca o rodapé da página
479
        if ($this->orientacao == 'P') {
480
            $this->zRodape(2, $this->hPrint - 2);
481
        } else {
482
            $this->zRodape($xInic, $this->hPrint + 2.3);
483
        }
484
        //retorna o ID na CTe
485 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...
486
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
487
            return $aR;
488
        } else {
489
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
490
        }
491
    } //fim da função montaDACTE
492
493
    /**
494
     * printDACTE
495
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
496
     * O destino da impressão pode ser :
497
     * I-browser
498
     * D-browser com download
499
     * F-salva em um arquivo local com o nome informado
500
     * S-retorna o documento como uma string e o nome é ignorado.
501
     * Para enviar o pdf diretamente para uma impressora indique o
502
     * nome da impressora e o destino deve ser 'S'.
503
     *
504
     * @param  string $nome Path completo com o nome do arquivo pdf
505
     * @param  string $destino Direção do envio do PDF
506
     * @param  string $printer Identificação da impressora no sistema
507
     * @return string Caso o destino seja S o pdf é retornado como uma string
508
     * @todo Rotina de impressão direta do arquivo pdf criado
509
     */
510 View Code Duplication
    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...
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...
511
    {
512
        $arq = $this->pdf->Output($nome, $destino);
513
        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...
514
            //aqui pode entrar a rotina de impressão direta
515
        }
516
        return $arq;
517
    } //fim função printDACTE
518
519
    /**
520
     * zCabecalho
521
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
522
     *
523
     * @param  number $x Posição horizontal inicial, canto esquerdo
524
     * @param  number $y Posição vertical inicial, canto superior
525
     * @param  number $pag Número da Página
526
     * @param  number $totPag Total de páginas
527
     * @return number Posição vertical final
528
     */
529
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
0 ignored issues
show
Unused Code introduced by
The parameter $totPag 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
        $oldX = $x;
532
        $oldY = $y;
533
        if ($this->orientacao == 'P') {
534
            $maxW = $this->wPrint;
535
        } else {
536
            if ($pag == 1) {
537
                // primeira página
538
                $maxW = $this->wPrint - $this->wCanhoto;
539
            } else {
540
                // páginas seguintes
541
                $maxW = $this->wPrint;
542
            }
543
        }
544
        //##################################################################
545
        //coluna esquerda identificação do emitente
546
        $w = round($maxW * 0.42);
547
        if ($this->orientacao == 'P') {
548
            $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...
549
                'font' => $this->fontePadrao,
550
                'size' => 6,
551
                'style' => '');
552
        } else {
553
            $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...
554
        }
555
        $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...
556
        $h = 35;
557
        $oldY += $h;
558
        //desenha a caixa
559
        $this->pTextBox($x, $y, $w + 2, $h + 1);
560
        // coloca o logo
561 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...
562
            $logoInfo = getimagesize($this->logomarca);
563
            //largura da imagem em mm
564
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
565
            //altura da imagem em mm
566
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
567
            if ($this->logoAlign == 'L') {
568
                $nImgW = round($w / 3, 0);
569
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
570
                $xImg = $x + 1;
571
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
572
                //estabelecer posições do texto
573
                $x1 = round($xImg + $nImgW + 1, 0);
574
                $y1 = round($h / 3 + $y, 0);
575
                $tw = round(2 * $w / 3, 0);
576
            } elseif ($this->logoAlign == 'C') {
577
                $nImgH = round($h / 3, 0);
578
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
579
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
580
                $yImg = $y + 3;
581
                $x1 = $x;
582
                $y1 = round($yImg + $nImgH + 1, 0);
583
                $tw = $w;
584
            } elseif ($this->logoAlign == 'R') {
585
                $nImgW = round($w / 3, 0);
586
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
587
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
588
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
589
                $x1 = $x;
590
                $y1 = round($h / 3 + $y, 0);
591
                $tw = round(2 * $w / 3, 0);
592
            }
593
            $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...
594
        } else {
595
            $x1 = $x;
596
            $y1 = round($h / 3 + $y, 0);
597
            $tw = $w;
598
        }
599
        //Nome emitente
600
        $aFont = array(
601
            'font' => $this->fontePadrao,
602
            'size' => 9,
603
            'style' => 'B');
604
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
605
        $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...
606
        //endereço
607
        $y1 = $y1 + 3;
608
        $aFont = array(
609
            'font' => $this->fontePadrao,
610
            'size' => 7,
611
            'style' => '');
612
        $fone = $this->zFormatFone($this->enderEmit);
0 ignored issues
show
Documentation introduced by
$this->enderEmit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
613
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
614
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
615
        $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...
616
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
617
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
618
        $CEP = $this->pFormat($CEP, "#####-###");
619
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
620
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
621
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
622
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
623
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
624
            . "\n  Fone/Fax: " . $fone;
625
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
626
        //CNPJ/CPF IE
627
        $cpfCnpj = $this->zFormatCNPJCPF($this->emit);
0 ignored issues
show
Documentation introduced by
$this->emit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
628
        $ie = $this->pSimpleGetValue($this->emit, "IE");
629
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
630
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
631
        //outra caixa
632
        $h1 = 17.5;
633
        $y1 = $y + $h + 1;
634
        $this->pTextBox($x, $y1, $w + 2, $h1);
635
        //TIPO DO CT-E
636
        $texto = 'TIPO DO CTE';
637
        $wa = 37;
638
        $aFont = array(
639
            'font' => $this->fontePadrao,
640
            'size' => 8,
641
            'style' => '');
642
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
643
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
644
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
645
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
646
        switch ($tpCTe) {
647
            case '0':
648
                $texto = 'Normal';
649
                break;
650
            case '1':
651
                $texto = 'Complemento de Valores';
652
                break;
653
            case '2':
654
                $texto = 'Anulação de Valores';
655
                break;
656
            case '3':
657
                $texto = 'Substituto';
658
                break;
659
            default:
660
                $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...
661
        }
662
        $aFont = $this->formatNegrito;
663
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
664
        //TIPO DO SERVIÇO
665
        $texto = 'TIPO DO SERVIÇO';
666
        $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...
667
        $aFont = array(
668
            'font' => $this->fontePadrao,
669
            'size' => 8,
670
            'style' => '');
671
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
672
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
673
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
674 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...
675
            case '0':
676
                $texto = 'Normal';
677
                break;
678
            case '1':
679
                $texto = 'Subcontratação';
680
                break;
681
            case '2':
682
                $texto = 'Redespacho';
683
                break;
684
            case '3':
685
                $texto = 'Redespacho Intermediário';
686
                break;
687
            default:
688
                $texto = 'ERRO' . $tpServ;
689
        }
690
        $aFont = $this->formatNegrito;
691
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
692
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
693
        //TOMADOR DO SERVIÇO
694
        $texto = 'TOMADOR DO SERVIÇO';
695
        $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...
696
        $y2 = $y1 + 8;
697
        $aFont = array(
698
            'font' => $this->fontePadrao,
699
            'size' => 8,
700
            'style' => '');
701
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
702
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
703
        $toma = $this->pSimpleGetValue($this->ide, "toma");
704
        //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...
705 View Code Duplication
        switch ($toma) {
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...
706
            case '0':
707
                $texto = 'Remetente';
708
                break;
709
            case '1':
710
                $texto = 'Expedidor';
711
                break;
712
            case '2':
713
                $texto = 'Recebedor';
714
                break;
715
            case '3':
716
                $texto = 'Destinatário';
717
                break;
718
            case '4':
719
                $texto = 'Outros';
720
                break;
721
            default:
722
                $texto = 'ERRO' . $toma;
723
        }
724
        $aFont = $this->formatNegrito;
725
        $this->pTextBox($x, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
726
        //FORMA DE PAGAMENTO
727
        $texto = 'FORMA DE PAGAMENTO';
728
        $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...
729
        $aFont = array(
730
            'font' => $this->fontePadrao,
731
            'size' => 8,
732
            'style' => '');
733
        $this->pTextBox($x + $wa + 4.5, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
734
        $forma = $this->pSimpleGetValue($this->ide, "forPag");
735
        //0 - Pago;1 - A pagar;2 - outros
736
        switch ($forma) {
737
            case '0':
738
                $texto = 'Pago';
739
                break;
740
            case '1':
741
                $texto = 'A pagar';
742
                break;
743
            case '2':
744
                $texto = 'Outros';
745
                break;
746
            default:
747
                $texto = 'ERRO' . $forma;
748
        }
749
        $aFont = $this->formatNegrito;
750
        $this->pTextBox($x + $wa + 4.5, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
751
        //##################################################################
752
        //coluna direita
753
        $x += $w + 2;
754
        $w = round($maxW * 0.335);
755
        $w1 = $w;
756
        $h = 11;
757
        $this->pTextBox($x, $y, $w + 2, $h + 1);
758
        $texto = "DACTE";
759
        $aFont = array(
760
            'font' => $this->fontePadrao,
761
            'size' => 10,
762
            'style' => 'B');
763
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
764
        $aFont = array(
765
            'font' => $this->fontePadrao,
766
            'size' => 8,
767
            'style' => '');
768
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
769
        $h = 10;
770
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
771
        $x1 = $x + $w + 2;
772
        $w = round($maxW * 0.22, 0);
773
        $w2 = $w;
774
        $h = 11;
775
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
776
        $texto = "MODAL";
777
        $aFont = array(
778
            'font' => $this->fontePadrao,
779
            'size' => 8,
780
            'style' => '');
781
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
782
        //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
783
        $modal = $this->pSimpleGetValue($this->ide, "modal");
784
        $this->modal = $modal;
785 View Code Duplication
        switch ($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...
786
            case '1':
787
                $texto = 'Rodoviário';
788
                break;
789
            case '2':
790
                $texto = 'Aéreo';
791
                break;
792
            case '3':
793
                $texto = 'Aquaviário';
794
                break;
795
            case '4':
796
                $texto = 'Ferroviário';
797
                break;
798
            case '5':
799
                $texto = 'Dutoviário';
800
                break;
801
        }
802
        $aFont = array(
803
            'font' => $this->fontePadrao,
804
            'size' => 10,
805
            'style' => 'B');
806
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
807
        //outra caixa
808
        $y += 12;
809
        $h = 9;
810
        $w = $w1 + $w2 + 2;
811
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
812
        //modelo
813
        $wa = 12;
814
        $xa = $x;
815
        $texto = 'MODELO';
816
        $aFont = array(
817
            'font' => $this->fontePadrao,
818
            'size' => 8,
819
            'style' => '');
820
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
821
        $texto = $this->pSimpleGetValue($this->ide, "mod");
822
        $aFont = $this->formatNegrito;
823
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
824
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
825
        //serie
826
        $xa += $wa;
827
        $texto = 'SÉRIE';
828
        $aFont = array(
829
            'font' => $this->fontePadrao,
830
            'size' => 8,
831
            'style' => '');
832
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
833
        $texto = $this->pSimpleGetValue($this->ide, "serie");
834
        $aFont = $this->formatNegrito;
835
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
836
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
837
        //numero
838
        $xa += $wa;
839
        $wa = 20;
840
        $texto = 'NÚMERO';
841
        $aFont = array(
842
            'font' => $this->fontePadrao,
843
            'size' => 8,
844
            'style' => '');
845
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
846
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
847
        $aFont = $this->formatNegrito;
848
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
849
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
850
        //folha
851
        $xa += $wa;
852
        $wa = 12;
853
        $texto = 'FL';
854
        $aFont = array(
855
            'font' => $this->fontePadrao,
856
            'size' => 8,
857
            'style' => '');
858
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
859
        $texto = '1/1';
860
        $aFont = $this->formatNegrito;
861
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
862
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
863
        //data  hora de emissão
864
        $xa += $wa;
865
        $wa = 30;
866
        $texto = 'DATA E HORA DE EMISSÃO';
867
        $aFont = array(
868
            'font' => $this->fontePadrao,
869
            'size' => 8,
870
            'style' => '');
871
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
872
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
873
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
874
        $aFont = $this->formatNegrito;
875
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
876
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
877
        //ISUF
878
        $xa += $wa;
879
        $wa = 32;
880
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
881
        $aFont = $this->formatPadrao;
882
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
883
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
884
        $aFont = array(
885
            'font' => $this->fontePadrao,
886
            'size' => 7,
887
            'style' => 'B');
888
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
889
        //outra caixa
890
        $y += $h + 1;
891
        $h = 23;
892
        $h1 = 14;
893
        $this->pTextBox($x, $y, $w + 0.5, $h1);
894
        //CODIGO DE BARRAS
895
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
896
        $bW = 85;
897
        $bH = 10;
898
        //codigo de barras
899
        $this->pdf->SetFillColor(0, 0, 0);
900
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
901
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
902
        $texto = 'CHAVE DE ACESSO';
903
        $aFont = $this->formatPadrao;
904
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
905
        $aFont = $this->formatNegrito;
906
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
907
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
908
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
909
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
910
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
911
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
912
            $texto = "";
913
            $this->pdf->SetFillColor(0, 0, 0);
914
            if ($this->tpEmis == 5) {
915
                $chaveContingencia = $this->zGeraChaveAdicCont();
916
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
917
            } else {
918
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
919
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
920
            }
921
            //codigo de barras
922
        }
923
        $aFont = array(
924
            'font' => $this->fontePadrao,
925
            'size' => 8,
926
            'style' => '');
927
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
928
        //outra caixa
929
        $y += $h + 1;
930
        $h = 8.5;
931
        $wa = $w;
932
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
933
        if ($this->zCteDPEC()) {
934
            $texto = 'NÚMERO DE REGISTRO DPEC';
935
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
936
            $texto = "DADOS DO CT-E";
937
        } else {
938
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
939
        }
940
        $aFont = $this->formatPadrao;
941
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
942
        if ($this->zCteDPEC()) {
943
            $texto = $this->numero_registro_dpec;
944
        } elseif ($this->tpEmis == 5) {
945
            $chaveContingencia = $this->zGeraChaveAdicCont();
946
            $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...
947
                'font' => $this->fontePadrao,
948
                'size' => 8,
949
                'style' => 'B');
950
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
951
            $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...
952
        } else {
953
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
954
            // 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...
955
            if (!empty($this->protCTe)
956
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
957
            ) {
958
                $texto .= date(
959
                    'd/m/Y   H:i:s',
960
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
961
                );
962
            }
963
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
964
        }
965
        $aFont = $this->formatNegrito;
966
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
967
        //CFOP
968
        $x = $oldX;
969
        $h = 8.5;
970
        $w = round($maxW * 0.42);
971
        $y1 = $y + 7.5;
972
        $this->pTextBox($x, $y1, $w + 2, $h);
973
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
974
        $aFont = array(
975
            'font' => $this->fontePadrao,
976
            'size' => 8,
977
            'style' => '');
978
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
979
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
980
        $aFont = $this->formatNegrito;
981
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
982
        //ORIGEM DA PRESTAÇÃO
983
        $y += $h + 7.5;
984
        $x = $oldX;
985
        $h = 8;
986
        $w = ($maxW * 0.5);
987
        $this->pTextBox($x, $y, $w + 0.5, $h);
988
        $texto = 'INÍCIO DA PRESTAÇÃO';
989
        $aFont = array(
990
            'font' => $this->fontePadrao,
991
            'size' => 8,
992
            'style' => '');
993
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
994
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
995
        $aFont = $this->formatNegrito;
996
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
997
        //DESTINO DA PRESTAÇÃO
998
        $x = $oldX + $w + 1;
999
        $h = 8;
1000
        $w = $w - 1.3;
1001
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1002
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1003
        $aFont = array(
1004
            'font' => $this->fontePadrao,
1005
            'size' => 8,
1006
            'style' => '');
1007
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1008
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1009
        $aFont = $this->formatNegrito;
1010
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1011
        //#########################################################################
1012
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1013
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1014
        //indicar cancelamento
1015
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1016
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1017
            //101 Cancelamento
1018
            $x = 10;
1019
            $y = $this->hPrint - 130;
1020
            $h = 25;
1021
            $w = $maxW - (2 * $x);
1022
            $this->pdf->SetTextColor(90, 90, 90);
1023
            $texto = "CTe CANCELADO";
1024
            $aFont = array(
1025
                'font' => $this->fontePadrao,
1026
                'size' => 48,
1027
                'style' => 'B');
1028
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1029
            $this->pdf->SetTextColor(0, 0, 0);
1030
        }
1031
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1032
        if ($cStat == '110' ||
1033
            $cStat == '301' ||
1034
            $cStat == '302' ||
1035
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1036
        ) {
1037
            //110 Denegada
1038
            $x = 10;
1039
            $y = $this->hPrint - 130;
1040
            $h = 25;
1041
            $w = $maxW - (2 * $x);
1042
            $this->pdf->SetTextColor(90, 90, 90);
1043
            $texto = "CTe USO DENEGADO";
1044
            $aFont = array(
1045
                'font' => $this->fontePadrao,
1046
                'size' => 48,
1047
                'style' => 'B');
1048
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1049
            $y += $h;
1050
            $h = 5;
1051
            $w = $maxW - (2 * $x);
1052
            $texto = "SEM VALOR FISCAL";
1053
            $aFont = array(
1054
                'font' => $this->fontePadrao,
1055
                'size' => 48,
1056
                'style' => 'B');
1057
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1058
            $this->pdf->SetTextColor(0, 0, 0);
1059
        }
1060
        //indicar sem valor
1061
        if ($tpAmb != 1) {
1062
            $x = 10;
1063
            if ($this->orientacao == 'P') {
1064
                $y = round($this->hPrint * 2 / 3, 0);
1065
            } else {
1066
                $y = round($this->hPrint / 2, 0);
1067
            }
1068
            $h = 5;
1069
            $w = $maxW - (2 * $x);
1070
            $this->pdf->SetTextColor(90, 90, 90);
1071
            $texto = "SEM VALOR FISCAL";
1072
            $aFont = array(
1073
                'font' => $this->fontePadrao,
1074
                'size' => 48,
1075
                'style' => 'B');
1076
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1077
            $aFont = array(
1078
                'font' => $this->fontePadrao,
1079
                'size' => 30,
1080
                'style' => 'B');
1081
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1082
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1083
            $this->pdf->SetTextColor(0, 0, 0);
1084
        } else {
1085
            $x = 10;
1086
            if ($this->orientacao == 'P') {
1087
                $y = round($this->hPrint * 2 / 3, 0);
1088
            } else {
1089
                $y = round($this->hPrint / 2, 0);
1090
            } //fim orientacao
1091
            $h = 5;
1092
            $w = $maxW - (2 * $x);
1093
            $this->pdf->SetTextColor(90, 90, 90);
1094
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1095
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1096
                //Contingência
1097
                $texto = "DACTE Emitido em Contingência";
1098
                $aFont = array(
1099
                    'font' => $this->fontePadrao,
1100
                    'size' => 48,
1101
                    'style' => 'B');
1102
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1103
                $aFont = array(
1104
                    'font' => $this->fontePadrao,
1105
                    'size' => 30,
1106
                    'style' => 'B');
1107
                $texto = "devido à problemas técnicos";
1108
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1109
            } else {
1110 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...
1111
                    if (!$this->zCteDPEC()) {
1112
                        $texto = "SEM VALOR FISCAL";
1113
                        $aFont = array(
1114
                            'font' => $this->fontePadrao,
1115
                            'size' => 48,
1116
                            'style' => 'B');
1117
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1118
                    }
1119
                    $aFont = array(
1120
                        'font' => $this->fontePadrao,
1121
                        'size' => 30,
1122
                        'style' => 'B');
1123
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1124
                    if (!$this->zCteDPEC()) {
1125
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1126
                    } else {
1127
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1128
                    }
1129
                } //fim cteProc
1130 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...
1131
                    //DPEC
1132
                    $x = 10;
1133
                    $y = $this->hPrint - 130;
1134
                    $h = 25;
1135
                    $w = $maxW - (2 * $x);
1136
                    $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...
1137
                    $texto = "DACTE impresso em contingência -\n"
1138
                        . "DPEC regularmente recebido pela Receita\n"
1139
                        . "Federal do Brasil";
1140
                    $aFont = array(
1141
                        'font' => $this->fontePadrao,
1142
                        'size' => 48,
1143
                        'style' => 'B');
1144
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1145
                    $this->pdf->SetTextColor(0, 0, 0);
1146
                }
1147
            } //fim tpEmis
1148
            $this->pdf->SetTextColor(0, 0, 0);
1149
        }
1150
        return $oldY;
1151
    } //fim zCabecalho
1152
1153
    /**
1154
     * rodapeDACTE
1155
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1156
     *
1157
     * @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...
1158
     * @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...
1159
     */
1160
    protected function zRodape($x, $y)
1161
    {
1162
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1163
        $w = $this->wPrint - 4;
1164
        $aFont = array(
1165
            'font' => $this->fontePadrao,
1166
            'size' => 6,
1167
            'style' => '');
1168
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1169
        $texto = "DacteNFePHP ver. " . $this->version . "  Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org";
1170
        $aFont = array(
1171
            'font' => $this->fontePadrao,
1172
            'size' => 6,
1173
            'style' => '');
1174
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org');
1175
    } //fim zRodape
1176
1177
    /**
1178
     * zRemetente
1179
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1180
     *
1181
     * @param  number $x Posição horizontal canto esquerdo
1182
     * @param  number $y Posição vertical canto superior
1183
     * @return number Posição vertical final
1184
     */
1185
    protected function zRemetente($x = 0, $y = 0)
1186
    {
1187
        $oldX = $x;
1188
        $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...
1189
        if ($this->orientacao == 'P') {
1190
            $maxW = $this->wPrint;
1191
        } else {
1192
            $maxW = $this->wPrint - $this->wCanhoto;
1193
        }
1194
        $w = $maxW * 0.5 + 0.5;
1195
        $h = 19;
1196
        $x1 = $x + 16;
1197
        $texto = 'REMETENTE';
1198
        $aFont = $this->formatPadrao;
1199
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1200
        $aFont = $this->formatNegrito;
1201
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1202
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1203
        $y += 3;
1204
        $texto = 'ENDEREÇO';
1205
        $aFont = $this->formatPadrao;
1206
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1207
        $aFont = $this->formatNegrito;
1208
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1209
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1210
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1211
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1212
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1213
        $y += 3;
1214
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1215
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1216
        $y += 3;
1217
        $texto = 'MUNICÍPIO';
1218
        $aFont = $this->formatPadrao;
1219
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1220
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1221
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1222
        $aFont = $this->formatNegrito;
1223
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1224
        $x = $w - 18;
1225
        $texto = 'CEP';
1226
        $aFont = $this->formatPadrao;
1227
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1228
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1229
        $aFont = $this->formatNegrito;
1230
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1231
        $x = $oldX;
1232
        $y += 3;
1233
        $texto = 'CNPJ/CPF';
1234
        $aFont = $this->formatPadrao;
1235
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1236
        $cpfCnpj = $this->zFormatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1237
        $aFont = $this->formatNegrito;
1238
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1239
        $x = $w - 45;
1240
        $texto = 'INSCRIÇÃO ESTADUAL';
1241
        $aFont = $this->formatPadrao;
1242
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1243
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1244
        $aFont = $this->formatNegrito;
1245
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1246
        $x = $oldX;
1247
        $y += 3;
1248
        $texto = 'PAÍS';
1249
        $aFont = $this->formatPadrao;
1250
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1251
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1252
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1253
        $aFont = $this->formatNegrito;
1254
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1255
        $x = $w - 25;
1256
        $texto = 'FONE';
1257
        $aFont = $this->formatPadrao;
1258
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1259
        $texto = $this->zFormatFone($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1260
        $aFont = $this->formatNegrito;
1261
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1262
    } //fim da função remetenteDACTE
1263
1264
    /**
1265
     * zDestinatario
1266
     * Monta o campo com os dados do destinatário na DACTE.
1267
     *
1268
     * @param  number $x Posição horizontal canto esquerdo
1269
     * @param  number $y Posição vertical canto superior
1270
     * @return number Posição vertical final
1271
     */
1272
    protected function zDestinatario($x = 0, $y = 0)
1273
    {
1274
        $oldX = $x;
1275
        $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...
1276
        if ($this->orientacao == 'P') {
1277
            $maxW = $this->wPrint;
1278
        } else {
1279
            $maxW = $this->wPrint - $this->wCanhoto;
1280
        }
1281
        $w = ($maxW * 0.5) - 0.7;
1282
        $h = 19;
1283
        $x1 = $x + 19;
1284
        $texto = 'DESTINATÁRIO';
1285
        $aFont = $this->formatPadrao;
1286
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1287
        $aFont = $this->formatNegrito;
1288
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1289
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1290
        $y += 3;
1291
        $texto = 'ENDEREÇO';
1292
        $aFont = $this->formatPadrao;
1293
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1294
        $aFont = $this->formatNegrito;
1295
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1296
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1297
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1298
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1299
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1300
        $y += 3;
1301
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1302
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1303
        $y += 3;
1304
        $texto = 'MUNICÍPIO';
1305
        $aFont = $this->formatPadrao;
1306
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1307
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1308
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1309
        $aFont = $this->formatNegrito;
1310
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1311
        $x = $w - 19 + $oldX;
1312
        $texto = 'CEP';
1313
        $aFont = $this->formatPadrao;
1314
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1315
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1316
        $aFont = $this->formatNegrito;
1317
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1318
        $x = $oldX;
1319
        $y += 3;
1320
        $texto = 'CNPJ/CPF';
1321
        $aFont = $this->formatPadrao;
1322
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1323
        $cpfCnpj = $this->zFormatCNPJCPF($this->dest);
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1324
        $aFont = $this->formatNegrito;
1325
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1326
        $x = $w - 47.5 + $oldX;
1327
        $texto = 'INSCRIÇÃO ESTADUAL';
1328
        $aFont = $this->formatPadrao;
1329
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1330
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1331
        $aFont = $this->formatNegrito;
1332
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1333
        $x = $oldX;
1334
        $y += 3;
1335
        $texto = 'PAÍS';
1336
        $aFont = $this->formatPadrao;
1337
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1338
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1339
        $aFont = $this->formatNegrito;
1340
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1341
        $x = $w - 27 + $oldX;
1342
        $texto = 'FONE';
1343
        $aFont = $this->formatPadrao;
1344
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1345
        $texto = $this->zFormatFone($this->dest);
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1346
        $aFont = $this->formatNegrito;
1347
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1348
    } //fim da função destinatarioDACTE
1349
1350
    /**
1351
     * zExpedidor
1352
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1353
     *
1354
     * @param  number $x Posição horizontal canto esquerdo
1355
     * @param  number $y Posição vertical canto superior
1356
     * @return number Posição vertical final
1357
     */
1358
    protected function zExpedidor($x = 0, $y = 0)
1359
    {
1360
        $oldX = $x;
1361
        $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...
1362
        if ($this->orientacao == 'P') {
1363
            $maxW = $this->wPrint;
1364
        } else {
1365
            $maxW = $this->wPrint - $this->wCanhoto;
1366
        }
1367
        $w = $maxW * 0.5 + 0.5;
1368
        $h = 19;
1369
        $x1 = $x + 16;
1370
        $texto = 'EXPEDIDOR';
1371
        $aFont = $this->formatPadrao;
1372
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1373
        $aFont = $this->formatNegrito;
1374
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1375
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1376
        $y += 3;
1377
        $texto = 'ENDEREÇO';
1378
        $aFont = $this->formatPadrao;
1379
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1380
        $aFont = $this->formatNegrito;
1381 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...
1382
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1383
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1384
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1385
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1386
                '';
1387
        } else {
1388
            $texto = '';
1389
        }
1390
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1391
        $y += 3;
1392
        $texto = $this->pSimpleGetValue($this->enderExped, "xBairro");
1393
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1394
        $y += 3;
1395
        $texto = 'MUNICÍPIO';
1396
        $aFont = $this->formatPadrao;
1397
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1398 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...
1399
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1400
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1401
        } else {
1402
            $texto = '';
1403
        }
1404
        $aFont = $this->formatNegrito;
1405
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1406
        $x = $w - 18;
1407
        $texto = 'CEP';
1408
        $aFont = $this->formatPadrao;
1409
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1410
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderExped, "CEP"), "#####-###");
1411
        $aFont = $this->formatNegrito;
1412
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1413
        $x = $oldX;
1414
        $y += 3;
1415
        $texto = 'CNPJ/CPF';
1416
        $aFont = $this->formatPadrao;
1417
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1418
        $cpfCnpj = $this->zFormatCNPJCPF($this->exped);
1419
        $aFont = $this->formatNegrito;
1420
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1421
        $x = $w - 45;
1422
        $texto = 'INSCRIÇÃO ESTADUAL';
1423
        $aFont = $this->formatPadrao;
1424
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1425
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1426
        $aFont = $this->formatNegrito;
1427
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1428
        $x = $oldX;
1429
        $y += 3;
1430
        $texto = 'PAÍS';
1431
        $aFont = $this->formatPadrao;
1432
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1433
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1434
        $aFont = $this->formatNegrito;
1435
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1436
        $x = $w - 25;
1437
        $texto = 'FONE';
1438
        $aFont = $this->formatPadrao;
1439
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1440 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...
1441
            $texto = $this->zFormatFone($this->exped);
1442
            $aFont = $this->formatNegrito;
1443
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1444
        }
1445
    } //fim da função remetenteDACTE
1446
1447
    /**
1448
     * zRecebedor
1449
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1450
     *
1451
     * @param  number $x Posição horizontal canto esquerdo
1452
     * @param  number $y Posição vertical canto superior
1453
     * @return number Posição vertical final
1454
     */
1455
    protected function zRecebedor($x = 0, $y = 0)
1456
    {
1457
        $oldX = $x;
1458
        $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...
1459
        if ($this->orientacao == 'P') {
1460
            $maxW = $this->wPrint;
1461
        } else {
1462
            $maxW = $this->wPrint - $this->wCanhoto;
1463
        }
1464
        $w = ($maxW * 0.5) - 0.7;
1465
        $h = 19;
1466
        $x1 = $x + 19;
1467
        $texto = 'RECEBEDOR';
1468
        $aFont = $this->formatPadrao;
1469
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1470
        $aFont = $this->formatNegrito;
1471
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1472
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1473
        $y += 3;
1474
        $texto = 'ENDEREÇO';
1475
        $aFont = $this->formatPadrao;
1476
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1477
        $aFont = $this->formatNegrito;
1478 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...
1479
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1480
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1481
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1482
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1483
                '';
1484
        } else {
1485
            $texto = '';
1486
        }
1487
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1488
        $y += 3;
1489
        $texto = $this->pSimpleGetValue($this->enderReceb, "xBairro");
1490
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1491
        $y += 3;
1492
        $texto = 'MUNICÍPIO';
1493
        $aFont = $this->formatPadrao;
1494
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1495 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...
1496
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1497
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1498
        } else {
1499
            $texto = '';
1500
        }
1501
        $aFont = $this->formatNegrito;
1502
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1503
        $x = $w - 19 + $oldX;
1504
        $texto = 'CEP';
1505
        $aFont = $this->formatPadrao;
1506
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1507
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReceb, "CEP"), "#####-###");
1508
        $aFont = $this->formatNegrito;
1509
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1510
        $x = $oldX;
1511
        $y += 3;
1512
        $texto = 'CNPJ/CPF';
1513
        $aFont = $this->formatPadrao;
1514
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1515
        $texto = $this->zFormatCNPJCPF($this->receb);
1516
        $aFont = $this->formatNegrito;
1517
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1518
        $x = $w - 47 + $oldX;
1519
        $texto = 'INSCRIÇÃO ESTADUAL';
1520
        $aFont = $this->formatPadrao;
1521
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1522
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1523
        $aFont = $this->formatNegrito;
1524
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1525
        $x = $oldX;
1526
        $y += 3;
1527
        $texto = 'PAÍS';
1528
        $aFont = $this->formatPadrao;
1529
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1530
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1531
        $aFont = $this->formatNegrito;
1532
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1533
        $x = $w - 27 + $oldX;
1534
        $texto = 'FONE';
1535
        $aFont = $this->formatPadrao;
1536
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1537 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...
1538
            $texto = $this->zFormatFone($this->receb);
1539
            $aFont = $this->formatNegrito;
1540
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1541
        }
1542
    } //fim da função recebedorDACTE
1543
1544
    /**
1545
     * zTomador
1546
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1547
     *
1548
     * @param  number $x Posição horizontal canto esquerdo
1549
     * @param  number $y Posição vertical canto superior
1550
     * @return number Posição vertical final
1551
     */
1552
    protected function zTomador($x = 0, $y = 0)
1553
    {
1554
        $oldX = $x;
1555
        $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...
1556
        if ($this->orientacao == 'P') {
1557
            $maxW = $this->wPrint;
1558
        } else {
1559
            $maxW = $this->wPrint - $this->wCanhoto;
1560
        }
1561
        $w = $maxW;
1562
        $h = 10;
1563
        $texto = 'TOMADOR DO SERVIÇO';
1564
        $aFont = $this->formatPadrao;
1565
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1566
        $aFont = $this->formatNegrito;
1567
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1568
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1569
        $x = $maxW * 0.60;
1570
        $texto = 'MUNICÍPIO';
1571
        $aFont = $this->formatPadrao;
1572
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1573
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1574
        $aFont = $this->formatNegrito;
1575
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1576
        $x = $maxW * 0.85;
1577
        $texto = 'UF';
1578
        $aFont = $this->formatPadrao;
1579
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1580
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1581
        $aFont = $this->formatNegrito;
1582
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1583
        $x = $w - 18;
1584
        $texto = 'CEP';
1585
        $aFont = $this->formatPadrao;
1586
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1587
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1588
        $aFont = $this->formatNegrito;
1589
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1590
        $y += 3;
1591
        $x = $oldX;
1592
        $texto = 'ENDEREÇO';
1593
        $aFont = $this->formatPadrao;
1594
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1595
        $aFont = $this->formatNegrito;
1596
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1597
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1598
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1599
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1600
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1601
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1602
        $y += 3;
1603
        $texto = 'CNPJ/CPF';
1604
        $aFont = $this->formatPadrao;
1605
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1606
        $texto = $this->zFormatCNPJCPF($this->toma);
1607
        $aFont = $this->formatNegrito;
1608
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1609
        $x = $x + 65;
1610
        $texto = 'INSCRIÇÃO ESTADUAL';
1611
        $aFont = $this->formatPadrao;
1612
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1613
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1614
        $aFont = $this->formatNegrito;
1615
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1616
        $x = $w * 0.75;
1617
        $texto = 'PAÍS';
1618
        $aFont = $this->formatPadrao;
1619
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1620
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1621
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1622
        $aFont = $this->formatNegrito;
1623
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1624
        $x = $w - 27;
1625
        $texto = 'FONE';
1626
        $aFont = $this->formatPadrao;
1627
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1628
        $texto = $this->zFormatFone($this->toma);
1629
        $aFont = $this->formatNegrito;
1630
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1631
    } //fim da função tomadorDACTE
1632
1633
    /**
1634
     * zDescricaoCarga
1635
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1636
     *
1637
     * @param  number $x Posição horizontal canto esquerdo
1638
     * @param  number $y Posição vertical canto superior
1639
     * @return number Posição vertical final
1640
     */
1641
    protected function zDescricaoCarga($x = 0, $y = 0)
1642
    {
1643
        $oldX = $x;
1644
        $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...
1645
        if ($this->orientacao == 'P') {
1646
            $maxW = $this->wPrint;
1647
        } else {
1648
            $maxW = $this->wPrint - $this->wCanhoto;
1649
        }
1650
        $w = $maxW;
1651
        $h = 17;
1652
        $texto = 'PRODUTO PREDOMINANTE';
1653
        $aFont = array(
1654
            'font' => $this->fontePadrao,
1655
            'size' => 6,
1656
            'style' => '');
1657
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1658
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1659
        $aFont = $this->formatNegrito;
1660
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1661
        $x = $w * 0.56;
1662
        $this->pdf->Line($x, $y, $x, $y + 8);
1663
        $aFont = $this->formatPadrao;
1664
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1665
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1666
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1667
        $aFont = $this->formatNegrito;
1668
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1669
        $x = $w * 0.8;
1670
        $this->pdf->Line($x, $y, $x, $y + 8);
1671
        $aFont = $this->formatPadrao;
1672
        $texto = 'VALOR TOTAL DA MERCADORIA';
1673
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1674
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1675
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1676
        $texto = number_format($texto, 2, ",", ".");
1677
        $aFont = $this->formatNegrito;
1678
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1679
        $y += 8;
1680
        $x = $oldX;
1681
        $this->pdf->Line($x, $y, $w + 1, $y);
1682
        $texto = 'TP MED /UN. MED';
1683
        $aFont = array(
1684
            'font' => $this->fontePadrao,
1685
            'size' => 5,
1686
            'style' => '');
1687
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1688
        $texto = $this->pSimpleGetValue($this->infQ->item(0), "tpMed") . "\r\n";
1689
        $texto .= number_format(
1690
            $this->pSimpleGetValue(
1691
                $this->infQ->item(0),
1692
                "qCarga"
1693
            )
1694
            / $this->zMultiUniPeso(
1695
                $this->pSimpleGetValue(
1696
                    $this->infQ->item(0),
1697
                    "cUnid"
1698
                )
1699
            ),
1700
            3,
1701
            ".",
1702
            ""
1703
        );
1704
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(0), "cUnid"));
1705
        $aFont = array(
1706
            'font' => $this->fontePadrao,
1707
            'size' => 7,
1708
            'style' => 'B');
1709
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1710
        $x = $w * 0.12;
1711
        $this->pdf->Line($x, $y, $x, $y + 9);
1712
        $texto = 'TP MED /UN. MED';
1713
        $aFont = array(
1714
            'font' => $this->fontePadrao,
1715
            'size' => 5,
1716
            'style' => '');
1717
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1718
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "tpMed") . "\r\n";
1719
        $texto .= number_format(
1720
            $this->pSimpleGetValue(
1721
                $this->infQ->item(1),
1722
                "qCarga"
1723
            )
1724
            / $this->zMultiUniPeso(
1725
                $this->pSimpleGetValue($this->infQ->item(1), "cUnid")
1726
            ),
1727
            3,
1728
            ".",
1729
            ""
1730
        );
1731
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "qCarga") == '' ? '' : $texto;
1732
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(1), "cUnid"));
1733
        $aFont = array(
1734
            'font' => $this->fontePadrao,
1735
            'size' => 7,
1736
            'style' => 'B');
1737
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1738
        $x = $w * 0.24;
1739
        $this->pdf->Line($x, $y, $x, $y + 9);
1740
        $texto = 'TP MED /UN. MED';
1741
        $aFont = array(
1742
            'font' => $this->fontePadrao,
1743
            'size' => 5,
1744
            'style' => '');
1745
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1746
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "tpMed") . "\r\n";
1747
        $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1748
        $texto .= !empty($qCarga) ?
1749
            number_format(
1750
                $qCarga
1751
                / $this->zMultiUniPeso(
1752
                    $this->pSimpleGetValue($this->infQ->item(2), "cUnid")
1753
                ),
1754
                3,
1755
                ".",
1756
                ""
1757
            ) :
1758
            '';
1759
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "qCarga") == '' ? '' : $texto;
1760
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(2), "cUnid"));
1761
        $aFont = array(
1762
            'font' => $this->fontePadrao,
1763
            'size' => 7,
1764
            'style' => 'B');
1765
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1766
        $x = $w * 0.36;
1767
        $this->pdf->Line($x, $y, $x, $y + 9);
1768
        $texto = 'CUBAGEM(M3)';
1769
        $aFont = $this->formatPadrao;
1770
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1771
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '00') {
1772
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1773
            $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1774
        } else {
1775
            $texto = '';
1776
        }
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.45;
1783
        $this->pdf->Line($x, $y, $x, $y + 9);
1784
        $texto = 'QTDE(VOL)';
1785
        $aFont = $this->formatPadrao;
1786
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1787
        $qCarga = $this->pSimpleGetValue($this->infQ->item(3), "qCarga");
1788
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1789
        $aFont = array(
1790
            'font' => $this->fontePadrao,
1791
            'size' => 7,
1792
            'style' => 'B');
1793
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1794
        $x = $w * 0.53;
1795
        $this->pdf->Line($x, $y, $x, $y + 9);
1796
        $texto = 'NOME DA SEGURADORA';
1797
        $aFont = $this->formatPadrao;
1798
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1799
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1800
        $aFont = array(
1801
            'font' => $this->fontePadrao,
1802
            'size' => 7,
1803
            'style' => 'B');
1804
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1805
        $y += 3;
1806
        $this->pdf->Line($x, $y, $w + 1, $y);
1807
        $texto = 'RESPONSÁVEL';
1808
        $aFont = $this->formatPadrao;
1809
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1810
        $texto = $this->respSeg;
1811
        $aFont = array(
1812
            'font' => $this->fontePadrao,
1813
            'size' => 7,
1814
            'style' => 'B');
1815
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1816
        $x = $w * 0.68;
1817
        $this->pdf->Line($x, $y, $x, $y + 6);
1818
        $texto = 'NÚMERO DA APOLICE';
1819
        $aFont = $this->formatPadrao;
1820
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1821
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1822
        $aFont = array(
1823
            'font' => $this->fontePadrao,
1824
            'size' => 7,
1825
            'style' => 'B');
1826
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1827
        $x = $w * 0.85;
1828
        $this->pdf->Line($x, $y, $x, $y + 6);
1829
        $texto = 'NÚMERO DA AVERBAÇÃO';
1830
        $aFont = $this->formatPadrao;
1831
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1832
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
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
    } //fim da função zDescricaoCarga
1839
1840
    /**
1841
     * zCompValorServ
1842
     * Monta o campo com os componentes da prestação de serviços.
1843
     *
1844
     * @param  number $x Posição horizontal canto esquerdo
1845
     * @param  number $y Posição vertical canto superior
1846
     * @return number Posição vertical final
1847
     */
1848
    protected function zCompValorServ($x = 0, $y = 0)
1849
    {
1850
        $oldX = $x;
1851
        $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...
1852
        if ($this->orientacao == 'P') {
1853
            $maxW = $this->wPrint;
1854
        } else {
1855
            $maxW = $this->wPrint - $this->wCanhoto;
1856
        }
1857
        $w = $maxW;
1858
        $h = 25;
1859
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1860
        $aFont = $this->formatPadrao;
1861
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1862
        $y += 3.4;
1863
        $this->pdf->Line($x, $y, $w + 1, $y);
1864
        $texto = 'NOME';
1865
        $aFont = $this->formatPadrao;
1866
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1867
        $yIniDados = $y;
1868
        $x = $w * 0.14;
1869
        $texto = 'VALOR';
1870
        $aFont = $this->formatPadrao;
1871
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1872
        $x = $w * 0.28;
1873
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1874
        $texto = 'NOME';
1875
        $aFont = $this->formatPadrao;
1876
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1877
        $x = $w * 0.42;
1878
        $texto = 'VALOR';
1879
        $aFont = $this->formatPadrao;
1880
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1881
        $x = $w * 0.56;
1882
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1883
        $texto = 'NOME';
1884
        $aFont = $this->formatPadrao;
1885
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1886
        $x = $w * 0.70;
1887
        $texto = 'VALOR';
1888
        $aFont = $this->formatPadrao;
1889
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1890
        $x = $w * 0.86;
1891
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1892
        $y += 1;
1893
        $texto = 'VALOR TOTAL DO SERVIÇO';
1894
        $aFont = $this->formatPadrao;
1895
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1896
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1897
        $aFont = array(
1898
            'font' => $this->fontePadrao,
1899
            'size' => 9,
1900
            'style' => 'B');
1901
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1902
        $y += 10;
1903
        $this->pdf->Line($x, $y, $w + 1, $y);
1904
        $y += 1;
1905
        $texto = 'VALOR A RECEBER';
1906
        $aFont = $this->formatPadrao;
1907
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1908
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1909
        $aFont = array(
1910
            'font' => $this->fontePadrao,
1911
            'size' => 9,
1912
            'style' => 'B');
1913
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1914
        $auxX = $oldX;
1915
        $yIniDados += 4;
1916
        foreach ($this->Comp as $k => $d) {
1917
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1918
            $valor = number_format(
1919
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1920
                2,
1921
                ",",
1922
                "."
1923
            );
1924
            if ($auxX > $w * 0.60) {
1925
                $yIniDados = $yIniDados + 4;
1926
                $auxX = $oldX;
1927
            }
1928
            $texto = $nome;
1929
            $aFont = $this->formatPadrao;
1930
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1931
            $auxX += $w * 0.14;
1932
            $texto = $valor;
1933
            $aFont = $this->formatPadrao;
1934
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1935
            $auxX += $w * 0.14;
1936
        }
1937
    } //fim da função compValorDACTE
1938
1939
    /**
1940
     * zImpostos
1941
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1942
     *
1943
     * @param  number $x Posição horizontal canto esquerdo
1944
     * @param  number $y Posição vertical canto superior
1945
     * @return number Posição vertical final
1946
     */
1947
    protected function zImpostos($x = 0, $y = 0)
1948
    {
1949
        $oldX = $x;
1950
        $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...
1951
        if ($this->orientacao == 'P') {
1952
            $maxW = $this->wPrint;
1953
        } else {
1954
            $maxW = $this->wPrint - $this->wCanhoto;
1955
        }
1956
        $w = $maxW;
1957
        $h = 13;
1958
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1959
        $aFont = $this->formatPadrao;
1960
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1961
        $y += 3.4;
1962
        $this->pdf->Line($x, $y, $w + 1, $y);
1963
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1964
        $aFont = $this->formatPadrao;
1965
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1966
        $x += $w * 0.26;
1967
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1968
        $texto = 'BASE DE CALCULO';
1969
        $aFont = $this->formatPadrao;
1970
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1971
        $x += $w * 0.14;
1972
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1973
        $texto = 'ALÍQ ICMS';
1974
        $aFont = $this->formatPadrao;
1975
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1976
        $x += $w * 0.14;
1977
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1978
        $texto = 'VALOR ICMS';
1979
        $aFont = $this->formatPadrao;
1980
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1981
        $x += $w * 0.14;
1982
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1983
        $texto = '% RED. BC ICMS';
1984
        $aFont = $this->formatPadrao;
1985
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1986
        $x += $w * 0.14;
1987
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1988
        $texto = 'ICMS ST';
1989
        $aFont = $this->formatPadrao;
1990
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1991
        $x = $oldX;
1992
        $y = $y + 4;
1993
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
1994
        switch ($texto) {
1995
            case '00':
1996
                $texto = "00 - Tributação normal ICMS";
1997
                break;
1998
            case '20':
1999
                $texto = "20 - Tributação com BC reduzida do ICMS";
2000
                break;
2001
            case '40':
2002
                $texto = "40 - ICMS isenção";
2003
                break;
2004
            case '41':
2005
                $texto = "41 - ICMS não tributada";
2006
                break;
2007
            case '51':
2008
                $texto = "51 - ICMS diferido";
2009
                break;
2010
            case '60':
2011
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2012
                break;
2013
            case '90':
2014
                $texto = "90 - ICMS outros";
2015
                break;
2016
        }
2017
        $texto .= $this->pSimpleGetValue($this->ICMSSN, "indSN");
2018
        $texto = $texto == 1 ? 'Simples Nacional' : $texto;
2019
        $aFont = $this->formatNegrito;
2020
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2021
        $x += $w * 0.26;
2022
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2023
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") :
2024
            '';
2025
        $aFont = $this->formatNegrito;
2026
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2027
        $x += $w * 0.14;
2028
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2029
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
2030
        $aFont = $this->formatNegrito;
2031
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2032
        $x += $w * 0.14;
2033
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2034
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
2035
        $aFont = $this->formatNegrito;
2036
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2037
        $x += $w * 0.14;
2038
        $texto = '';
2039
        $aFont = $this->formatNegrito;
2040
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2041
        $x += $w * 0.14;
2042
        $texto = '';
2043
        $aFont = $this->formatNegrito;
2044
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2045
    } //fim da função compValorDACTE
2046
2047
    /**
2048
     * zGeraChaveAdicCont
2049
     *
2050
     * @return string chave
2051
     */
2052
    protected function zGeraChaveAdicCont()
2053
    {
2054
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2055
        // 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...
2056
        $forma = "%02d%d%s%014d%01d%01d%02d";
2057
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2058
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2059
        $CNPJ = substr($CNPJ, -14);
2060
        $vCT = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2061
        $ICMS_CST = $this->pSimpleGetValue($this->ICMS, "CST");
2062
        switch ($ICMS_CST) {
2063
            case '00':
2064
            case '20':
2065
                $ICMSp = '1';
2066
                $ICMSs = '2';
2067
                break;
2068
            case '40':
2069
            case '41':
2070
            case '51':
2071
            case '90':
2072
                $ICMSp = '2';
2073
                $ICMSs = '2';
2074
                break;
2075
            case '60':
2076
                $ICMSp = '2';
2077
                $ICMSs = '1';
2078
                break;
2079
        }
2080
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2081
        $rpos = strrpos($dd, '-');
2082
        $dd = substr($dd, $rpos + 1);
2083
        $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...
2084
        $chave = $chave . $this->pModulo11($chave);
2085
        return $chave;
2086
    } //fim zGeraChaveAdicCont
2087
2088
    /**
2089
     * zDocOrig
2090
     * Monta o campo com os documentos originarios.
2091
     *
2092
     * @param  number $x Posição horizontal canto esquerdo
2093
     * @param  number $y Posição vertical canto superior
2094
     * @return number Posição vertical final
2095
     */
2096
    protected function zDocOrig($x = 0, $y = 0)
2097
    {
2098
        $oldX = $x;
2099
        $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...
2100
        if ($this->orientacao == 'P') {
2101
            $maxW = $this->wPrint;
2102
        } else {
2103
            $maxW = $this->wPrint - $this->wCanhoto;
2104
        }
2105
        $w = $maxW;
2106
        if ($this->modal == '1') {
2107
            $h = $this->lota == 1 ? 25 : 53;
2108
        } elseif ($this->modal == '3') {
2109
            $h = 37.6;
2110
        } else {
2111
            $h = 25;
2112
        }
2113
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2114
        $aFont = $this->formatPadrao;
2115
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2116
        $descr1 = 'TIPO DOC';
2117
        $descr2 = 'CNPJ/CHAVE/OBS';
2118
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2119
        $y += 3.4;
2120
        $this->pdf->Line($x, $y, $w + 1, $y);
2121
        $texto = $descr1;
2122
        $aFont = $this->formatPadrao;
2123
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2124
        $yIniDados = $y;
2125
        $x += $w * 0.09;
2126
        $texto = $descr2;
2127
        $aFont = $this->formatPadrao;
2128
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2129
        $x += $w * 0.28;
2130
        $texto = $descr3;
2131
        $aFont = $this->formatPadrao;
2132
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2133
        $x += $w * 0.13;
2134
        if ($this->modal == '1') {
2135
            if ($this->lota == 1) {
2136
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2137
            } else {
2138
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2139
            }
2140
        } elseif ($this->modal == '3') {
2141
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2142
        } else {
2143
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2144
        }
2145
        $texto = $descr1;
2146
        $aFont = $this->formatPadrao;
2147
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2148
        $x += $w * 0.10;
2149
        $texto = $descr2;
2150
        $aFont = $this->formatPadrao;
2151
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2152
        $x += $w * 0.27;
2153
        $texto = $descr3;
2154
        $aFont = $this->formatPadrao;
2155
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2156
        $auxX = $oldX;
2157
        $yIniDados += 4;
2158
        foreach ($this->infNF as $k => $d) {
2159
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2160
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2161
            $cnpj = $this->zFormatCNPJCPF($this->rem);
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
2162
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2163
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2164
            if ($auxX > $w * 0.90) {
2165
                $yIniDados = $yIniDados + 4;
2166
                $auxX = $oldX;
2167
            }
2168
            $texto = $tp;
2169
            $aFont = array(
2170
                'font' => $this->fontePadrao,
2171
                'size' => 8,
2172
                'style' => '');
2173
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2174
            $auxX += $w * 0.09;
2175
            $texto = $cnpj;
2176
            $aFont = array(
2177
                'font' => $this->fontePadrao,
2178
                'size' => 8,
2179
                'style' => '');
2180
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2181
            $auxX += $w * 0.28;
2182
            $texto = $doc;
2183
            $aFont = array(
2184
                'font' => $this->fontePadrao,
2185
                'size' => 8,
2186
                'style' => '');
2187
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2188
            $auxX += $w * 0.14;
2189
        }
2190
        foreach ($this->infNFe as $k => $d) {
2191
            $tp = 'NFE';
2192
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2193
            $numNFe = substr($chaveNFe, 25, 9);
2194
            $serieNFe = substr($chaveNFe, 22, 3);
2195
            $doc = $serieNFe . '/' . $numNFe;
2196
            if ($auxX > $w * 0.90) {
2197
                $yIniDados = $yIniDados + 4;
2198
                $auxX = $oldX;
2199
            }
2200
            $texto = $tp;
2201
            $aFont = array(
2202
                'font' => $this->fontePadrao,
2203
                'size' => 8,
2204
                'style' => '');
2205
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2206
            $auxX += $w * 0.09;
2207
            $texto = $chaveNFe;
2208
            $aFont = array(
2209
                'font' => $this->fontePadrao,
2210
                'size' => 8,
2211
                'style' => '');
2212
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2213
            $auxX += $w * 0.28;
2214
            $texto = $doc;
2215
            $aFont = array(
2216
                'font' => $this->fontePadrao,
2217
                'size' => 8,
2218
                'style' => '');
2219
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2220
            $auxX += $w * 0.14;
2221
        }
2222
        foreach ($this->infOutros as $k => $d) {
2223
            $temp = $this->infOutros->item($k);
2224
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2225
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2226
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2227
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2228
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2229
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2230
            switch ($tpDoc) {
2231
                case "00":
2232
                    $tpDoc = "00 - Declaração";
2233
                    break;
2234
                case "10":
2235
                    $tpDoc = "10 - Dutoviário";
2236
                    break;
2237
                case "99":
2238
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2239
                    break;
2240
                default:
2241
                    break;
2242
            }
2243
            $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...
2244
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2245
            if ($auxX > $w * 0.90) {
2246
                $yIniDados = $yIniDados + 4;
2247
                $auxX = $oldX;
2248
            }
2249
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2250
            $auxX += $w * 0.09;
2251
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2252
            $auxX += $w * 0.28;
2253
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2254
            $auxX += $w * 0.14;
2255
        }
2256
    } //fim da função zDocOrig
2257
2258
    /**
2259
     * zDocCompl
2260
     * Monta o campo com os dados do remetente na DACTE.
2261
     *
2262
     * @param number $x Posição horizontal canto esquerdo
2263
     * @param number $y Posição vertical canto superior
2264
     * @return number Posição vertical final
2265
     */
2266
    protected function zDocCompl($x = 0, $y = 0)
2267
    {
2268
        $oldX = $x;
2269
        $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...
2270
        if ($this->orientacao == 'P') {
2271
            $maxW = $this->wPrint;
2272
        } else {
2273
            $maxW = $this->wPrint - $this->wCanhoto;
2274
        }
2275
        $w = $maxW;
2276
        $h = 80;
2277
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2278
        $aFont = $this->formatPadrao;
2279
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2280
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2281
        $descr2 = 'VALOR COMPLEMENTADO';
2282
        $y += 3.4;
2283
        $this->pdf->Line($x, $y, $w + 1, $y);
2284
        $texto = $descr1;
2285
        $aFont = $this->formatPadrao;
2286
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2287
        $yIniDados = $y;
2288
        $x += $w * 0.37;
2289
        $texto = $descr2;
2290
        $aFont = $this->formatPadrao;
2291
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2292
        $x += $w * 0.13;
2293
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2294
        $texto = $descr1;
2295
        $aFont = $this->formatPadrao;
2296
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2297
        $x += $w * 0.3;
2298
        $texto = $descr2;
2299
        $aFont = $this->formatPadrao;
2300
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2301
        $auxX = $oldX;
2302
        $yIniDados += 4;
2303
        if ($auxX > $w * 0.90) {
2304
            $yIniDados = $yIniDados + 4;
2305
            $auxX = $oldX;
2306
        }
2307
        $texto = $this->chaveCTeRef;
2308
        $aFont = array(
2309
            'font' => $this->fontePadrao,
2310
            'size' => 8,
2311
            'style' => '');
2312
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2313
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2314
        $aFont = array(
2315
            'font' => $this->fontePadrao,
2316
            'size' => 8,
2317
            'style' => '');
2318
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2319
    } //fim da função zDocCompl
2320
2321
    /**
2322
     * zObs
2323
     * Monta o campo com os dados do remetente na DACTE.
2324
     *
2325
     * @param  number $x Posição horizontal canto esquerdo
2326
     * @param  number $y Posição vertical canto superior
2327
     * @return number Posição vertical final
2328
     */
2329
    protected function zObs($x = 0, $y = 0)
2330
    {
2331
        $oldX = $x;
2332
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY is not used, you could remove the assignment.

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

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

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

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

Loading history...
2333
        if ($this->orientacao == 'P') {
2334
            $maxW = $this->wPrint;
2335
        } else {
2336
            $maxW = $this->wPrint - $this->wCanhoto;
2337
        }
2338
        $w = $maxW;
2339
        $h = 18;
2340
        $texto = 'OBSERVAÇÕES';
2341
        $aFont = $this->formatPadrao;
2342
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2343
        $y += 3.4;
2344
        $this->pdf->Line($x, $y, $w + 1, $y);
2345
        $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...
2346
        $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...
2347
        $texto = '';
2348
        foreach ($this->compl as $k => $d) {
2349
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2350
            $texto .= "\r\n" . $xObs;
2351
        }
2352
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2353
        $texto .= $this->zLocalEntrega();
2354
        $aFont = array(
2355
            'font' => $this->fontePadrao,
2356
            'size' => 7.5,
2357
            'style' => '');
2358
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '', false);
2359
    } //fim da função obsDACTE
2360
2361
    /**
2362
     * zLocalEntrega
2363
     *
2364
     * @return string
2365
     */
2366
    protected function zLocalEntrega()
2367
    {
2368
        $locEntX = $this->dest->getElementsByTagName('locEnt');
2369
        if ($locEntX->length > 0) {
2370
            $locEnt = $locEntX->item(0);
2371
            $output = "Entrega: " . $output = $this->zFormatCNPJCPF($locEnt);
2372
            $output .= $this->pSimpleGetValue($locEnt, "CPF") . " ";
2373
            $output .= $this->pSimpleGetValue($locEnt, "xNome") . " ";
2374
            $output .= $this->pSimpleGetValue($locEnt, "xLgr") . " ";
2375
            $output .= $this->pSimpleGetValue($locEnt, "nro ") . " ";
2376
            $output .= $this->pSimpleGetValue($locEnt, "xCpl") . " ";
2377
            $output .= $this->pSimpleGetValue($locEnt, "xBairro") . " ";
2378
            $output .= $this->pSimpleGetValue($locEnt, "xMun") . " ";
2379
            $output .= $this->pSimpleGetValue($locEnt, "UF") . " ";
2380
            return $output;
2381
        }
2382
        return "";
2383
    } //fim zLocalEntrega
2384
2385
    /**
2386
     * zModalRod
2387
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2388
     *
2389
     * @param  number $x Posição horizontal canto esquerdo
2390
     * @param  number $y Posição vertical canto superior
2391
     * @return number Posição vertical final
2392
     */
2393
    protected function zModalRod($x = 0, $y = 0)
2394
    {
2395
        $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...
2396
        $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...
2397
        if ($this->orientacao == 'P') {
2398
            $maxW = $this->wPrint;
2399
        } else {
2400
            $maxW = $this->wPrint - $this->wCanhoto;
2401
        }
2402
        $w = $maxW;
2403
        if ($this->modal == '1') {
2404
            $h = $this->lota == 1 ? 12.5 : 3.7;
2405
        } else {
2406
            $h = 12.5;
2407
        }
2408
        $textolota = $this->lota == 1 ? 'LOTAÇÃO' : 'CARGA FRACIONADA';
2409
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO - ' . $textolota;
2410
        $aFont = $this->formatPadrao;
2411
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2412
        if ($this->lota == 1) {
2413
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12);
2414
        }
2415
        $y += 3.4;
2416
        $this->pdf->Line($x, $y, $w + 1, $y);
2417
        $texto = 'RNTRC DA EMPRESA';
2418
        $aFont = $this->formatPadrao;
2419
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2420
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2421
        $aFont = $this->formatNegrito;
2422
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2423
        $x += $w * 0.23;
2424
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2425
        $texto = 'CIOT';
2426
        $aFont = $this->formatPadrao;
2427
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2428
        $texto = $this->pSimpleGetValue($this->rodo, "CIOT");
2429
        $aFont = $this->formatNegrito;
2430
        $this->pTextBox($x, $y + 3, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2431
        $x += $w * 0.13;
2432
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2433
        $texto = 'DATA PREVISTA DE ENTREGA';
2434
        $aFont = $this->formatPadrao;
2435
        $this->pTextBox($x, $y, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2436
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rodo, "dPrev"));
2437
        $aFont = $this->formatNegrito;
2438
        $this->pTextBox($x, $y + 3, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2439
        $x += $w * 0.15;
2440
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2441
        $h = 25;
2442
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE ' . "\r\n";
2443
        $texto .= ' À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2444
        $aFont = $this->formatPadrao;
2445
        $this->pTextBox($x, $y + 1, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2446
        if ($this->lota == 1) {
2447
            $y += 10;
2448
            $x = 1;
2449
            $texto = 'IDENTIFICAÇÃO DO CONJUNTO TRANSPORTADOR';
2450
            $aFont = $this->formatPadrao;
2451
            $this->pTextBox($x, $y, $w * 0.465, $h, $texto, $aFont, 'T', 'C', 0, '');
2452
            $this->pdf->Line($x, $y + 3.5, $w * 0.465, $y + 3.5);
2453
            $y += 3.5;
2454
            $texto = 'TIPO';
2455
            $aFont = $this->formatPadrao;
2456
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2457
            $yIniDados = $y;
2458
            if (count($this->veic) >= 0) {
2459
                foreach ($this->veic as $k => $d) {
2460
                    $yIniDados = $yIniDados + 3;
2461
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "tpVeic");
2462
                    switch ($texto) {
2463
                        case '0':
2464
                            $texto = 'Tração';
2465
                            break;
2466
                        case '1':
2467
                            $texto = 'Reboque';
2468
                            break;
2469
                        default:
2470
                            $texto = ' ';
2471
                    }
2472
                    $aFont = array(
2473
                        'font' => $this->fontePadrao,
2474
                        'size' => 6,
2475
                        'style' => 'B');
2476
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2477
                } //fim foreach
2478
            }
2479
            $x += $w * 0.10;
2480
            $texto = 'PLACA';
2481
            $aFont = $this->formatPadrao;
2482
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2483
            $this->pdf->Line($x, $y, $x, $y + 14);
2484
            $yIniDados = $y;
2485 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...
2486
                foreach ($this->veic as $k => $d) {
2487
                    $yIniDados = $yIniDados + 3;
2488
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "placa");
2489
                    $aFont = array(
2490
                        'font' => $this->fontePadrao,
2491
                        'size' => 6,
2492
                        'style' => 'B');
2493
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2494
                }
2495
            }
2496
            $x += $w * 0.13;
2497
            $texto = 'UF';
2498
            $aFont = $this->formatPadrao;
2499
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2500
            $this->pdf->Line($x, $y, $x, $y + 23);
2501
            $yIniDados = $y;
2502 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...
2503
                foreach ($this->veic as $k => $d) {
2504
                    $yIniDados = $yIniDados + 3;
2505
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "UF");
2506
                    $aFont = array(
2507
                        'font' => $this->fontePadrao,
2508
                        'size' => 6,
2509
                        'style' => 'B');
2510
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2511
                }
2512
            }
2513
            $x += $w * 0.03;
2514
            $texto = 'RNTRC';
2515
            $aFont = $this->formatPadrao;
2516
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2517
            $this->pdf->Line($x, $y, $x, $y + 14);
2518
            $yIniDados = $y;
2519 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...
2520
                foreach ($this->veic as $k => $d) {
2521
                    $yIniDados = $yIniDados + 3;
2522
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "RNTRC");
2523
                    $aFont = array(
2524
                        'font' => $this->fontePadrao,
2525
                        'size' => 6,
2526
                        'style' => 'B');
2527
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2528
                }
2529
            }
2530
            $y += 14;
2531
            $x = 1;
2532
            $texto = 'NOME DO MOTORISTA';
2533
            $aFont = array(
2534
                'font' => $this->fontePadrao,
2535
                'size' => 5,
2536
                'style' => '');
2537
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2538
            $this->pdf->Line($x, $y, $w + 1, $y);
2539
            $texto = !empty($this->moto) ? $this->pSimpleGetValue($this->moto, "xNome") : '';
2540
            $aFont = array(
2541
                'font' => $this->fontePadrao,
2542
                'size' => 7,
2543
                'style' => 'B');
2544
            $this->pTextBox($x, $y + 3, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
2545
            $x += $w * 0.23;
2546
            $texto = 'CPF MOTORISTA';
2547
            $aFont = array(
2548
                'font' => $this->fontePadrao,
2549
                'size' => 5,
2550
                'style' => '');
2551
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2552
            $texto = !empty($this->moto) ? $this->pSimpleGetValue($this->moto, "CPF") : '';
2553
            $aFont = array(
2554
                'font' => $this->fontePadrao,
2555
                'size' => 7,
2556
                'style' => 'B');
2557
            $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2558
            $x += $w * 0.23;
2559
            $texto = 'IDENTIFICAÇÃO DOS LACRES EM TRANSITO';
2560
            $aFont = array(
2561
                'font' => $this->fontePadrao,
2562
                'size' => 5,
2563
                'style' => '');
2564
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2565
            $this->pdf->Line($x, $y, $x, $y - 18.7);
2566
            $this->pdf->Line($x, $y, $x, $y + 9);
2567
            $x = $w * 0.465;
2568
            $y -= 16;
2569
            $texto = 'INFORMAÇÕES REFERENTES AO VALE PEDÁGIO';
2570
            $aFont = $this->formatPadrao;
2571
            $this->pTextBox($x, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2572
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2573
            $y += 4;
2574
            $texto = 'CNPJ FORNECEDOR';
2575
            $aFont = array(
2576
                'font' => $this->fontePadrao,
2577
                'size' => 5,
2578
                'style' => '');
2579
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2580
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2581
            $y += 4;
2582
            $texto = 'NUMERO COMPROVANTE';
2583
            $aFont = array(
2584
                'font' => $this->fontePadrao,
2585
                'size' => 5,
2586
                'style' => '');
2587
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2588
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2589
            $y += 4;
2590
            $texto = 'CNPJ RESPONSÁVEL';
2591
            $aFont = array(
2592
                'font' => $this->fontePadrao,
2593
                'size' => 5,
2594
                'style' => '');
2595
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2596
        }
2597
    } //fim da função zModalRod
2598
2599
    /**
2600
     * zModalAquaviario
2601
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2602
     *
2603
     * @param  number $x Posição horizontal canto esquerdo
2604
     * @param  number $y Posição vertical canto superior
2605
     * @return number Posição vertical final
2606
     */
2607
    protected function zModalAquaviario($x = 0, $y = 0)
2608
    {
2609
        $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...
2610
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY is not used, you could remove the assignment.

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

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

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

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

Loading history...
2611
        if ($this->orientacao == 'P') {
2612
            $maxW = $this->wPrint;
2613
        } else {
2614
            $maxW = $this->wPrint - $this->wCanhoto;
2615
        }
2616
        $w = $maxW;
2617
        $h = 8.5;
2618
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2619
        $aFont = $this->formatPadrao;
2620
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2621
        $y += 3.4;
2622
        $this->pdf->Line($x, $y, $w + 1, $y);
2623
        $texto = 'PORTO DE EMBARQUE';
2624
        $aFont = $this->formatPadrao;
2625
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2626
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
2627
        $aFont = $this->formatNegrito;
2628
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2629
        $x += $w * 0.50;
2630
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2631
        $texto = 'PORTO DE DESTINO';
2632
        $aFont = $this->formatPadrao;
2633
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2634
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
2635
        $aFont = $this->formatNegrito;
2636
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2637
        $y += 8;
2638
        $this->pdf->Line(208, $y, 1, $y);
2639
        $x = 1;
2640
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2641
        $aFont = $this->formatPadrao;
2642
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2643
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
2644
        $aFont = $this->formatNegrito;
2645
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2646
        $x += $w * 0.50;
2647
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2648
        $texto = 'VR DA B. DE CALC. AFRMM';
2649
        $aFont = $this->formatPadrao;
2650
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2651
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
2652
        $aFont = $this->formatNegrito;
2653
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2654
        $x += $w * 0.17;
2655
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2656
        $texto = 'VALOR DO AFRMM';
2657
        $aFont = $this->formatPadrao;
2658
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2659
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
2660
        $aFont = $this->formatNegrito;
2661
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2662
        $x += $w * 0.12;
2663
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2664
        $texto = 'TIPO DE NAVEGAÇÃO';
2665
        $aFont = $this->formatPadrao;
2666
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2667
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
2668
        switch ($texto) {
2669
            case '0':
2670
                $texto = 'INTERIOR';
2671
                break;
2672
            case '1':
2673
                $texto = 'CABOTAGEM';
2674
                break;
2675
        }
2676
        $aFont = $this->formatNegrito;
2677
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2678
        $x += $w * 0.14;
2679
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2680
        $texto = 'DIREÇÃO';
2681
        $aFont = $this->formatPadrao;
2682
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2683
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
2684
        switch ($texto) {
2685
            case 'N':
2686
                $texto = 'NORTE';
2687
                break;
2688
            case 'L':
2689
                $texto = 'LESTE';
2690
                break;
2691
            case 'S':
2692
                $texto = 'SUL';
2693
                break;
2694
            case 'O':
2695
                $texto = 'OESTE';
2696
                break;
2697
        }
2698
        $aFont = $this->formatNegrito;
2699
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2700
        $y += 8;
2701
        $this->pdf->Line(208, $y, 1, $y);
2702
        $x = 1;
2703
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2704
        $aFont = $this->formatPadrao;
2705
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2706
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2707
            $texto = $this->infNF
2708
                ->item(0)
2709
                ->getElementsByTagName('infUnidCarga')
2710
                ->item(0)
2711
                ->getElementsByTagName('idUnidCarga')
2712
                ->item(0)->nodeValue;
2713
        } elseif ($this->infNFe->item(0) !== null
2714
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2715
        ) {
2716
            $texto = $this->infNFe
2717
                ->item(0)
2718
                ->getElementsByTagName('infUnidCarga')
2719
                ->item(0)
2720
                ->getElementsByTagName('idUnidCarga')
2721
                ->item(0)
2722
                ->nodeValue;
2723
        } elseif ($this->infOutros->item(0) !== null
2724
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2725
        ) {
2726
            $texto = $this->infOutros
2727
                ->item(0)
2728
                ->getElementsByTagName('infUnidCarga')
2729
                ->item(0)
2730
                ->getElementsByTagName('idUnidCarga')
2731
                ->item(0)
2732
                ->nodeValue;
2733
        } else {
2734
            $texto = '';
2735
        }
2736
        $aFont = $this->formatNegrito;
2737
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2738
        $x += $w * 0.50;
2739
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2740
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2741
        $aFont = $this->formatPadrao;
2742
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2743
        $texto = '';
2744
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
2745
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2746
                if ($k == 0) {
2747
                    $texto = $this->aquav
2748
                        ->getElementsByTagName('balsa')
2749
                        ->item($k)
2750
                        ->getElementsByTagName('xBalsa')
2751
                        ->item(0)
2752
                        ->nodeValue;
2753
                } else {
2754
                    $texto = $texto
2755
                        . ' / '
2756
                        . $this->aquav
2757
                            ->getElementsByTagName('balsa')
2758
                            ->item($k)
2759
                            ->getElementsByTagName('xBalsa')
2760
                            ->item(0)
2761
                            ->nodeValue;
2762
                }
2763
            }
2764
        }
2765
        $aFont = $this->formatNegrito;
2766
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2767
    } //fim da função zModalRod
2768
2769
    /**
2770
     * zModalFerr
2771
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2772
     *
2773
     * @param  number $x Posição horizontal canto esquerdo
2774
     * @param  number $y Posição vertical canto superior
2775
     * @return number Posição vertical final
2776
     */
2777
    protected function zModalFerr($x = 0, $y = 0)
2778
    {
2779
        $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...
2780
        $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...
2781
        if ($this->orientacao == 'P') {
2782
            $maxW = $this->wPrint;
2783
        } else {
2784
            $maxW = $this->wPrint - $this->wCanhoto;
2785
        }
2786
        $w = $maxW;
2787
        $h = 19.6;
2788
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2789
        $aFont = $this->formatPadrao;
2790
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2791
        $y += 3.4;
2792
        $this->pdf->Line($x, $y, $w + 1, $y);
2793
        $texto = 'DCL';
2794
        $aFont = array(
2795
            'font' => $this->fontePadrao,
2796
            'size' => 7,
2797
            'style' => 'B');
2798
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2799
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2800
        $texto = 'VAGÕES';
2801
        $aFont = array(
2802
            'font' => $this->fontePadrao,
2803
            'size' => 7,
2804
            'style' => 'B');
2805
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2806
        $y += 3.4;
2807
        $this->pdf->Line($x, $y, $w + 1, $y);
2808
        // DCL
2809
        $texto = 'ID TREM';
2810
        $aFont = array(
2811
            'font' => $this->fontePadrao,
2812
            'size' => 6,
2813
            'style' => '');
2814
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2815
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
2816
        $aFont = array(
2817
            'font' => $this->fontePadrao,
2818
            'size' => 6,
2819
            'style' => 'B');
2820
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2821
        $x += $w * 0.06;
2822
        $y1 = $y + 12.5;
2823
        $this->pdf->Line($x, $y, $x, $y1);
2824
        $texto = 'NUM';
2825
        $aFont = array(
2826
            'font' => $this->fontePadrao,
2827
            'size' => 6,
2828
            'style' => '');
2829
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2830
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
2831
        $aFont = array(
2832
            'font' => $this->fontePadrao,
2833
            'size' => 6,
2834
            'style' => 'B');
2835
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2836
        $x += $w * 0.06;
2837
        $this->pdf->Line($x, $y, $x, $y1);
2838
        $texto = 'SÉRIE';
2839
        $aFont = array(
2840
            'font' => $this->fontePadrao,
2841
            'size' => 6,
2842
            'style' => '');
2843
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2844
        $texto = $this->pSimpleGetValue($this->rem, "serie");
2845
        $aFont = array(
2846
            'font' => $this->fontePadrao,
2847
            'size' => 6,
2848
            'style' => 'B');
2849
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2850
        $x += $w * 0.06;
2851
        $this->pdf->Line($x, $y, $x, $y1);
2852
        $texto = 'EMISSÃO';
2853
        $aFont = array(
2854
            'font' => $this->fontePadrao,
2855
            'size' => 6,
2856
            'style' => '');
2857
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2858
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
2859
        $aFont = array(
2860
            'font' => $this->fontePadrao,
2861
            'size' => 6,
2862
            'style' => 'B');
2863
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2864
        // VAGOES
2865
        $x += $w * 0.06;
2866
        $this->pdf->Line($x, $y, $x, $y1);
2867
        $texto = 'NUM';
2868
        $aFont = array(
2869
            'font' => $this->fontePadrao,
2870
            'size' => 6,
2871
            'style' => '');
2872
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2873
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
2874
        $aFont = array(
2875
            'font' => $this->fontePadrao,
2876
            'size' => 6,
2877
            'style' => 'B');
2878
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2879
        $x += $w * 0.06;
2880
        $this->pdf->Line($x, $y, $x, $y1);
2881
        $texto = 'TIPO';
2882
        $aFont = array(
2883
            'font' => $this->fontePadrao,
2884
            'size' => 6,
2885
            'style' => '');
2886
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2887
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
2888
        $aFont = array(
2889
            'font' => $this->fontePadrao,
2890
            'size' => 6,
2891
            'style' => 'B');
2892
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2893
        $x += $w * 0.06;
2894
        $this->pdf->Line($x, $y, $x, $y1);
2895
        $texto = 'CAPACIDADE';
2896
        $aFont = array(
2897
            'font' => $this->fontePadrao,
2898
            'size' => 6,
2899
            'style' => '');
2900
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2901
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
2902
        $aFont = array(
2903
            'font' => $this->fontePadrao,
2904
            'size' => 6,
2905
            'style' => 'B');
2906
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2907
        $x += $w * 0.08;
2908
        $this->pdf->Line($x, $y, $x, $y1);
2909
        $texto = 'PESO REAL/TON';
2910
        $aFont = array(
2911
            'font' => $this->fontePadrao,
2912
            'size' => 6,
2913
            'style' => '');
2914
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2915
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
2916
        $aFont = array(
2917
            'font' => $this->fontePadrao,
2918
            'size' => 6,
2919
            'style' => 'B');
2920
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2921
        $x += $w * 0.09;
2922
        $this->pdf->Line($x, $y, $x, $y1);
2923
        $texto = 'PESO BRUTO/TON';
2924
        $aFont = array(
2925
            'font' => $this->fontePadrao,
2926
            'size' => 6,
2927
            'style' => '');
2928
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2929
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
2930
        $aFont = array(
2931
            'font' => $this->fontePadrao,
2932
            'size' => 6,
2933
            'style' => 'B');
2934
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2935
        $x += $w * 0.1;
2936
        $this->pdf->Line($x, $y, $x, $y1);
2937
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
2938
        $aFont = array(
2939
            'font' => $this->fontePadrao,
2940
            'size' => 6,
2941
            'style' => '');
2942
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2943
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
2944
        $aFont = array(
2945
            'font' => $this->fontePadrao,
2946
            'size' => 6,
2947
            'style' => 'B');
2948
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2949
        // FLUXO
2950
        $x = 1;
2951
        $y += 12.9;
2952
        $h1 = $h * 0.5 + 0.27;
2953
        $wa = round($w * 0.103) + 0.5;
2954
        $texto = 'FLUXO FERROVIARIO';
2955
        $aFont = $this->formatPadrao;
2956
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2957
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
2958
        $aFont = array(
2959
            'font' => $this->fontePadrao,
2960
            'size' => 7,
2961
            'style' => 'B');
2962
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2963
        $y += 10;
2964
        $texto = 'TIPO DE TRÁFEGO';
2965
        $aFont = $this->formatPadrao;
2966
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2967
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
2968
        $aFont = array(
2969
            'font' => $this->fontePadrao,
2970
            'size' => 7,
2971
            'style' => 'B');
2972
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2973
        // Novo Box Relativo a Modal Ferroviário
2974
        $x = 22.5;
2975
        $y += -10.2;
2976
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
2977
        $aFont = $this->formatPadrao;
2978
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
2979
        $y += 3.4;
2980
        $this->pdf->Line($x, $y, $w + 1, $y);
2981
        $w = $w * 0.2;
2982
        $h = $h * 1.04;
2983
        $texto = 'CÓDIGO INTERNO';
2984
        $aFont = array(
2985
            'font' => $this->fontePadrao,
2986
            'size' => 6,
2987
            'style' => '');
2988
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2989
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
2990
        $aFont = array(
2991
            'font' => $this->fontePadrao,
2992
            'size' => 6,
2993
            'style' => 'B');
2994
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2995
        $texto = 'CNPJ';
2996
        $aFont = array(
2997
            'font' => $this->fontePadrao,
2998
            'size' => 6,
2999
            'style' => '');
3000
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3001
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3002
        $aFont = array(
3003
            'font' => $this->fontePadrao,
3004
            'size' => 6,
3005
            'style' => 'B');
3006
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3007
        $x += 50;
3008
        $texto = 'NOME';
3009
        $aFont = array(
3010
            'font' => $this->fontePadrao,
3011
            'size' => 6,
3012
            'style' => '');
3013
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3014
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3015
        $aFont = array(
3016
            'font' => $this->fontePadrao,
3017
            'size' => 6,
3018
            'style' => 'B');
3019
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3020
        $texto = 'INSCRICAO ESTADUAL';
3021
        $aFont = array(
3022
            'font' => $this->fontePadrao,
3023
            'size' => 6,
3024
            'style' => '');
3025
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3026
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3027
        $aFont = array(
3028
            'font' => $this->fontePadrao,
3029
            'size' => 6,
3030
            'style' => 'B');
3031
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3032
        $x += 50;
3033
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3034
        $aFont = array(
3035
            'font' => $this->fontePadrao,
3036
            'size' => 6,
3037
            'style' => '');
3038
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3039
        $texto = '';
3040
        $aFont = array(
3041
            'font' => $this->fontePadrao,
3042
            'size' => 6,
3043
            'style' => 'B');
3044
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3045
    } //fim da função zModalFerr
3046
3047
    /**
3048
     * zCanhoto
3049
     * Monta o campo com os dados do remetente na DACTE.
3050
     *
3051
     * @param  number $x Posição horizontal canto esquerdo
3052
     * @param  number $y Posição vertical canto superior
3053
     * @return number Posição vertical final
3054
     */
3055
    protected function zCanhoto($x = 0, $y = 0)
3056
    {
3057
        $oldX = $x;
3058
        $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...
3059
        if ($this->orientacao == 'P') {
3060
            $maxW = $this->wPrint;
3061
        } else {
3062
            $maxW = $this->wPrint - $this->wCanhoto;
3063
        }
3064
        $w = $maxW - 1;
3065
        $h = 15;
3066
        $y = $y + 1;
3067
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3068
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3069
        $aFont = $this->formatPadrao;
3070
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3071
        $y += 3.4;
3072
        $this->pdf->Line($x, $y, $w + 1, $y);
3073
        $texto = 'NOME';
3074
        $aFont = array(
3075
            'font' => $this->fontePadrao,
3076
            'size' => 6,
3077
            'style' => '');
3078
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3079
        $x += $w * 0.25;
3080
        $this->pdf->Line($x, $y, $x, $y + 11.5);
3081
        $texto = 'ASSINATURA / CARIMBO';
3082
        $aFont = array(
3083
            'font' => $this->fontePadrao,
3084
            'size' => 6,
3085
            'style' => '');
3086
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3087
        $x += $w * 0.25;
3088
        $this->pdf->Line($x, $y, $x, $y + 11.5);
3089
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n";
3090
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3091
        $aFont = array(
3092
            'font' => $this->fontePadrao,
3093
            'size' => 6,
3094
            'style' => '');
3095
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3096
        $x = $oldX;
3097
        $y = $y + 5;
3098
        $this->pdf->Line($x, $y, $w * 0.255, $y);
3099
        $texto = 'RG';
3100
        $aFont = array(
3101
            'font' => $this->fontePadrao,
3102
            'size' => 6,
3103
            'style' => '');
3104
        $this->pTextBox($x, $y, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3105
        $x += $w * 0.85;
3106
        $this->pdf->Line($x, $y + 6.4, $x, $y - 5);
3107
        $texto = "CT-E";
3108
        $aFont = $this->formatNegrito;
3109
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3110
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3111
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3112
        $aFont = array(
3113
            'font' => $this->fontePadrao,
3114
            'size' => 6,
3115
            'style' => '');
3116
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3117
        $x = $oldX;
3118
        $this->zhDashedLine($x, $y + 7.5, $this->wPrint, 0.1, 80);
3119
    } //fim da função canhotoDACTE
3120
3121
    /**
3122
     * zDadosAdic
3123
     * Coloca o grupo de dados adicionais da DACTE.
3124
     *
3125
     * @param  number $x Posição horizontal canto esquerdo
3126
     * @param  number $y Posição vertical canto superior
3127
     * @param  number $h altura do campo
3128
     * @return number Posição vertical final
3129
     */
3130
    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...
3131
    {
3132
        $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...
3133
        //###########################################################################
3134
        //DADOS ADICIONAIS DACTE
3135
        if ($this->orientacao == 'P') {
3136
            $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...
3137
        } else {
3138
            $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...
3139
        }
3140
        //INFORMAÇÕES COMPLEMENTARES
3141
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3142
        $y += 3;
3143
        $w = $this->wAdic;
3144
        $h = 17; //mudar
3145
        $aFont = array(
3146
            'font' => $this->fontePadrao,
3147
            'size' => 6,
3148
            'style' => '');
3149
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3150
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3151
        //o texto com os dados adicionais foi obtido na função xxxxxx
3152
        //e carregado em uma propriedade privada da classe
3153
        //$this->wAdic com a largura do campo
3154
        //$this->textoAdic com o texto completo do campo
3155
        $y += 1;
3156
        $aFont = $this->formatPadrao;
3157
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3158
        //RESERVADO AO FISCO
3159
        $texto = "RESERVADO AO FISCO";
3160
        $x += $w;
3161
        $y -= 1;
3162 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...
3163
            $w = $this->wPrint - $w;
3164
        } else {
3165
            $w = $this->wPrint - $w - $this->wCanhoto;
3166
        }
3167
        $aFont = array(
3168
            'font' => $this->fontePadrao,
3169
            'size' => 6,
3170
            'style' => '');
3171
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3172
        //inserir texto informando caso de contingência
3173
        //1 – Normal – emissão normal;
3174
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3175
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3176
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3177
        //Emissão em Contingência – DPEC;
3178
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3179
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3180
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3181
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3182
        $texto = '';
3183
        switch ($this->tpEmis) {
3184
            case 2:
3185
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3186
                break;
3187
            case 3:
3188
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3189
                break;
3190
            case 4:
3191
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3192
                break;
3193
            case 5:
3194
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3195
                break;
3196
        }
3197
        $y += 2;
3198
        $aFont = $this->formatPadrao;
3199
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3200
        return $y + $h;
3201
    } //fim zDadosAdic
3202
3203
    /**
3204
     * zhDashedLine
3205
     * Desenha uma linha horizontal tracejada com o FPDF
3206
     *
3207
     * @param  number $x Posição horizontal inicial, em mm
3208
     * @param  number $y Posição vertical inicial, em mm
3209
     * @param  number $w Comprimento da linha, em mm
3210
     * @param  number $h Espessura da linha, em mm
3211
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3212
     * @return none
3213
     */
3214
    protected function zhDashedLine($x, $y, $w, $h, $n)
3215
    {
3216
        $this->pdf->SetLineWidth($h);
3217
        $wDash = ($w / $n) / 2; // comprimento dos traços
3218 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...
3219
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3220
                if ($j <= ($x + $w - 1)) {
3221
                    $this->pdf->Line($j, $y, $j + 1, $y);
3222
                }
3223
            }
3224
        }
3225
    } //fim função hDashedLine
3226
3227
    /**
3228
     * zhDashedVerticalLine
3229
     * Desenha uma linha vertical tracejada com o FPDF
3230
     *
3231
     * @param  number $x Posição horizontal inicial, em mm
3232
     * @param  number $y Posição vertical inicial, em mm
3233
     * @param  number $w Comprimento da linha, em mm
3234
     * @param  number $yfinal Espessura da linha, em mm
3235
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3236
     * @return none
3237
     */
3238 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...
3239
    {
3240
        $this->pdf->SetLineWidth($w);
3241
        /* Organizando valores */
3242
        if ($y > $yfinal) {
3243
            $aux = $yfinal;
3244
            $yfinal = $y;
3245
            $y = $aux;
3246
        }
3247
        while ($y < $yfinal && $n > 0) {
3248
            $this->pdf->Line($x, $y, $x, $y + 1);
3249
            $y += 3;
3250
            $n--;
3251
        }
3252
    } //fim função hDashedVerticalLine
3253
3254
    /**
3255
     * zFormatCNPJCPF
3256
     * Formata campo CnpjCpf contida na CTe
3257
     *
3258
     * @param  string $field campo cnpjCpf da CT-e
3259
     * @return string
3260
     */
3261
    protected function zFormatCNPJCPF($field)
3262
    {
3263
        if (!isset($field)) {
3264
            return '';
3265
        }
3266
        $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...
3267
            $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...
3268
        if ($cnpj != "" && $cnpj != "00000000000000") {
3269
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3270
        } else {
3271
            $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...
3272
                $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...
3273
        }
3274
        return $cnpj;
3275
    } //fim formatCNPJCPF
3276
3277
    /**
3278
     * zFormatFone
3279
     * Formata campo fone contida na CTe
3280
     *
3281
     * @param  string $field campo fone da CT-e
3282
     * @return string
3283
     */
3284
    protected function zFormatFone($field)
3285
    {
3286
        $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...
3287
            $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...
3288
        $foneLen = strlen($fone);
3289 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...
3290
            $fone2 = substr($fone, 0, $foneLen - 4);
3291
            $fone1 = substr($fone, 0, $foneLen - 8);
3292
            $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3293
        } else {
3294
            $fone = '';
3295
        }
3296
        return $fone;
3297
    } //fim formatFone
3298
3299
    /**
3300
     * zUnidade
3301
     * Converte a imformação de peso contida na CTe
3302
     *
3303
     * @param  string $c unidade de trafego extraida da CTe
3304
     * @return string
3305
     */
3306
    protected function zUnidade($c = '')
3307
    {
3308
        switch ($c) {
3309
            case '00':
3310
                $r = 'M3';
3311
                break;
3312
            case '01':
3313
                $r = 'KG';
3314
                break;
3315
            case '02':
3316
                $r = 'TON';
3317
                break;
3318
            case '03':
3319
                $r = 'UN';
3320
                break;
3321
            case '04':
3322
                $r = 'LT';
3323
                break;
3324
            case '05':
3325
                $r = 'MMBTU';
3326
                break;
3327
            default:
3328
                $r = '';
3329
        }
3330
        return $r;
3331
    } //fim unidade
3332
3333
    /**
3334
     * zConvertUnidTrafego
3335
     * Converte a imformação de peso contida na CTe
3336
     *
3337
     * @param  string $U Informação de trafego extraida da CTe
3338
     * @return string
3339
     */
3340
    protected function zConvertUnidTrafego($U = '')
3341
    {
3342
        if ($U) {
3343
            switch ($U) {
3344
                case '0':
3345
                    $stringU = 'Próprio';
3346
                    break;
3347
                case '1':
3348
                    $stringU = 'Mútuo';
3349
                    break;
3350
                case '2':
3351
                    $stringU = 'Rodoferroviário';
3352
                    break;
3353
                case '3':
3354
                    $stringU = 'Rodoviário';
3355
                    break;
3356
            }
3357
            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...
3358
        }
3359
    } //fim da função zConvertUnidTrafego
3360
3361
    /**
3362
     * zMultiUniPeso
3363
     * Fornece a imformação multiplicação de peso contida na CTe
3364
     *
3365
     * @param  interger $U Informação de peso extraida da CTe
3366
     * @return interger
3367
     */
3368
    protected function zMultiUniPeso($U = '')
3369
    {
3370
        if ($U === "01") {
3371
            // tonelada
3372
            //return 1000;
3373
            return 1;
3374
        }
3375
        return 1; // M3, KG, Unidade, litros, mmbtu
3376
    } //fim da função zMultiUniPeso
3377
}
3378