Passed
Push — master ( 7e6c6e...a4cbc5 )
by Roberto
03:02 queued 11s
created

Dacte::qrCodeDacte()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 25
ccs 0
cts 24
cp 0
crap 6
rs 9.52
c 0
b 0
f 0
1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2019 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 Com\Tecnick\Barcode\Barcode;
19
use Exception;
20
use NFePHP\DA\Legacy\Dom;
21
use NFePHP\DA\Legacy\Pdf;
22
use NFePHP\DA\Legacy\Common;
23
24
class Dacte extends Common
25
{
26
27
    protected $logoAlign = 'C';
28
    protected $yDados = 0;
29
    protected $numero_registro_dpec = '';
30
    protected $pdf;
31
    protected $xml;
32
    protected $logomarca = '';
33
    protected $errMsg = '';
34
    protected $errStatus = false;
35
    protected $orientacao = 'P';
36
    protected $papel = 'A4';
37
    protected $fontePadrao = 'Times';
38
    protected $wPrint;
39
    protected $hPrint;
40
    protected $dom;
41
    protected $infCte;
42
    protected $infCteComp;
43
    protected $infCteAnu;
44
    protected $chaveCTeRef;
45
    protected $tpCTe;
46
    protected $ide;
47
    protected $emit;
48
    protected $enderEmit;
49
    protected $rem;
50
    protected $enderReme;
51
    protected $dest;
52
    protected $enderDest;
53
    protected $exped;
54
    protected $enderExped;
55
    protected $receb;
56
    protected $enderReceb;
57
    protected $infCarga;
58
    protected $infQ;
59
    protected $seg;
60
    protected $modal;
61
    protected $rodo;
62
    protected $moto;
63
    protected $veic;
64
    protected $ferrov;
65
    protected $Comp;
66
    protected $infNF;
67
    protected $infNFe;
68
    protected $compl;
69
    protected $ICMS;
70
    protected $ICMSSN;
71
    protected $ICMSOutraUF;
72
    protected $imp;
73
    protected $toma4;
74
    protected $toma03;
75
    protected $tpEmis;
76
    protected $tpImp;
77
    protected $tpAmb;
78
    protected $vPrest;
79
    protected $wAdic = 150;
80
    protected $textoAdic = '';
81
    protected $debugmode = false;
82
    protected $formatPadrao;
83
    protected $formatNegrito;
84
    protected $aquav;
85
    protected $preVisualizar;
86
    protected $flagDocOrigContinuacao;
87
    protected $arrayNFe = array();
88
    protected $totPag;
89
    protected $idDocAntEle = [];
90
    protected $qrCodCTe;
91
    protected $margemInterna = 0;
92
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
93
    private $creditos;
94
95
    /**
96
     * __construct
97
     *
98
     * @param string $xml Arquivo XML da CTe
99
     */
100
    public function __construct(
101
        $xml = ''
102
    )
103
    {
104
        $this->debugMode();
105
        $this->loadDoc($xml);
106
    }
107
108
    /**
109
     * Ativa ou desativa o modo debug
110
     * @param bool $activate
111
     * @return bool
112
     */
113
    private function debugMode($activate = null)
114
    {
115
        if (isset($activate) && is_bool($activate)) {
116
            $this->debugmode = $activate;
117
        }
118
        if ($this->debugmode) {
119
            error_reporting(E_ALL);
120
            ini_set('display_errors', 'On');
121
        } else {
122
            error_reporting(0);
123
            ini_set('display_errors', 'Off');
124
        }
125
        return $this->debugmode;
126
    }
127
128
    private function loadDoc($xml)
129
    {
130
        $this->xml = $xml;
131
        if (!empty($xml)) {
132
            $this->dom = new Dom();
133
            $this->dom->loadXML($this->xml);
134
            $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...
135
            if (empty($this->dom->getElementsByTagName("infCte")->item(0))) {
136
                throw new \Exception('Isso não é um CT-e.');
137
            }
138
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
139
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
140
            if ($this->getTagValue($this->ide, "mod") != '57') {
141
                throw new \Exception("O xml deve ser CT-e modelo 57.");
142
            }
143
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
144
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
145
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
146
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
147
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
148
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
149
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
150
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
151
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
152
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
153
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
154
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
155
            $this->infQ = $this->dom->getElementsByTagName("infQ");
156
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
157
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
158
            $this->aereo = $this->dom->getElementsByTagName("aereo")->item(0);
0 ignored issues
show
Bug introduced by
The property aereo 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...
159
            $this->lota = $this->getTagValue($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...
160
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
161
            $this->veic = $this->dom->getElementsByTagName("veic");
162
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
163
            // adicionar outros modais
164
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
165
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
166
            if ($this->tpCTe == 1) {
167
                $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chCTe");
168
            } else {
169
                $this->chaveCTeRef = $this->getTagValue($this->infCteAnu, "chCte");
170
            }
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);
179
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
180
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
181
            if (!empty($this->getTagValue($this->imp, "vTotTrib"))) {
182
                $textoAdic = number_format($this->getTagValue($this->imp, "vTotTrib"), 2, ",", ".");
183
                $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
184
                    . $textoAdic;
185
            }
186
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
187
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
188
            //Tag tomador é identificado por toma03 na versão 2.00
189
            if ($this->infCte->getAttribute("versao") == "2.00") {
190
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
191
            }
192
            //modal aquaviário
193
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
194
            $tomador = $this->getTagValue($this->toma03, "toma");
195
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
196
            switch ($tomador) {
197
                case '0':
198
                    $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...
199
                    $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...
200
                    break;
201
                case '1':
202
                    $this->toma = $this->exped;
203
                    $this->enderToma = $this->enderExped;
204
                    break;
205
                case '2':
206
                    $this->toma = $this->receb;
207
                    $this->enderToma = $this->enderReceb;
208
                    break;
209
                case '3':
210
                    $this->toma = $this->dest;
211
                    $this->enderToma = $this->enderDest;
212
                    break;
213
                default:
214
                    $this->toma = $this->toma4;
215
                    $this->enderToma = $this->getTagValue($this->toma4, "enderToma");
216
                    break;
217
            }
218
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
219
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
220
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
221
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
222
            $this->qrCodCTe = $this->dom->getElementsByTagName('qrCodCTe')->item(0) ?
223
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE';
224
            $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...
225
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
226
            $this->modal = $this->getTagValue($this->ide, "modal");
227
        }
228
    }
229
230
    /**
231
     * Dados brutos do PDF
232
     * @return string
233
     */
234
    public function render()
235
    {
236
        if (empty($this->pdf)) {
237
            $this->monta();
238
        }
239
        return $this->pdf->getPdf();
240
    }
241
242
    protected function cteDPEC()
243
    {
244
        return $this->numero_registro_dpec != '';
245
    }
246
247
    /**
248
     * montaDACTE
249
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
250
     * durante sua construção.
251
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
252
     * pelo conteúdo da funçao e podem ser modificados.
253
     *
254
     * @param  string $orientacao (Opcional) Estabelece a orientação da
255
     *                impressão (ex. P-retrato), se nada for fornecido será
256
     *                usado o padrão da NFe
257
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
258
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
259
     */
260
    public function monta(
261
        $logo = '',
262
        $orientacao = '',
263
        $papel = 'A4',
264
        $logoAlign = 'C'
265
    )
266
    {
267
        $this->pdf = '';
268
        $this->logomarca = $logo;
269
        //se a orientação estiver em branco utilizar o padrão estabelecido no CTe
270
        if ($orientacao == '') {
271
            if ($this->tpImp == '1') {
272
                $orientacao = 'P';
273
            } else {
274
                $orientacao = 'P';
275
            }
276
        }
277
        $this->orientacao = $orientacao;
278
        $this->papel = $papel;
279
        $this->logoAlign = $logoAlign;
280
        //instancia a classe pdf
281
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
282
        // verifica se foi passa a fonte a ser usada
283
        $this->formatPadrao = array(
284
            'font' => $this->fontePadrao,
285
            'size' => 6,
286
            'style' => '');
287
        $this->formatNegrito = array(
288
            'font' => $this->fontePadrao,
289
            'size' => 7,
290
            'style' => 'B');
291
        if ($this->orientacao == 'P') {
292
            // margens do PDF
293
            $margSup = 2;
294
            $margEsq = 2;
295
            $margDir = 2;
296
            // posição inicial do relatorio
297
            $xInic = 1;
298
            $yInic = 1;
299
            if ($papel == 'A4') {
300
                //A4 210x297mm
301
                $maxW = 210;
302
                $maxH = 297;
303
            }
304
        } else {
305
            // margens do PDF
306
            $margSup = 3;
307
            $margEsq = 3;
308
            $margDir = 3;
309
            // posição inicial do relatorio
310
            $xInic = 5;
311
            $yInic = 5;
312
            if ($papel == 'A4') {
313
                //A4 210x297mm
314
                $maxH = 210;
315
                $maxW = 297;
316
                $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...
317
            }
318
        }
319
        //total inicial de paginas
320
        $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...
321
        //largura imprimivel em mm
322
        $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...
323
        //comprimento imprimivel em mm
324
        $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...
325
        // estabelece contagem de paginas
326
        $this->pdf->aliasNbPages();
327
        // fixa as margens
328
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
329
        $this->pdf->setDrawColor(0, 0, 0);
330
        $this->pdf->setFillColor(255, 255, 255);
331
        // inicia o documento
332
        $this->pdf->Open();
333
        // adiciona a primeira página
334
        $this->pdf->addPage($this->orientacao, $this->papel);
335
        $this->pdf->setLineWidth(0.1);
336
        $this->pdf->setTextColor(0, 0, 0);
337
        //calculo do numero de páginas ???
338
        $totPag = 1;
339
        //montagem da primeira página
340
        $pag = 1;
341
        $x = $xInic;
342
        $y = $yInic;
343
        //coloca o cabeçalho
344
        $y = $this->canhoto($x, $y);
345
        $y += 24;
346
        $r = $this->cabecalho($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...
347
        $y += 70;
348
        $r = $this->remetente($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...
349
        $x = $this->wPrint * 0.5 + 2;
350
        $r = $this->destinatario($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...
351
        $y += 19;
352
        $x = $xInic;
353
        $r = $this->expedidor($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...
354
        $x = $this->wPrint * 0.5 + 2;
355
        $r = $this->recebedor($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...
356
        $y += 19;
357
        $x = $xInic;
358
        $r = $this->tomador($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...
359
        if ($this->tpCTe == '0') {
360
            //Normal
361
            $y += 10;
362
            $x = $xInic;
363
            $r = $this->descricaoCarga($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...
364
            $y += 17;
365
            $x = $xInic;
366
            $r = $this->compValorServ($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...
367
            $y += 25;
368
            $x = $xInic;
369
            $r = $this->impostos($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...
370
            $y += 13;
371
            $x = $xInic;
372
            $r = $this->docOrig($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...
373
            if ($this->modal == '1') {
374
                if ($this->lota == 1) {
375
                    //$y += 24.95;
376
                    $y += 35;
377
                } else {
378
                    $y += 53;
379
                }
380
            } elseif ($this->modal == '2') {
381
                $y += 53;
382
            } elseif ($this->modal == '3') {
383
                $y += 37.75;
384
            } else {
385
                $y += 24.95;
386
            }
387
            $x = $xInic;
388
            $r = $this->observacao($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...
389
            $y = $y - 6;
390
            switch ($this->modal) {
391
                case '1':
392
                    $y += 25.9;
393
                    $x = $xInic;
394
                    $r = $this->modalRod($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...
395
                    break;
396
                case '2':
397
                    $y += 25.9;
398
                    $x = $xInic;
399
                    $r = $this->modalAereo($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...
400
                    break;
401
                case '3':
402
                    $y += 17.9;
403
                    $x = $xInic;
404
                    $r = $this->modalAquaviario($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...
405
                    break;
406
                case '4':
407
                    $y += 17.9;
408
                    $x = $xInic;
409
                    $r = $this->modalFerr($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
410
                    break;
411
                case '5':
412
                    $y += 17.9;
413
                    $x = $xInic;
414
                    // TODO fmertins 31/10/14: este método não existe...
415
                    $r = $this->modalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method modalDutoviario() 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...
416
                    break;
417
            }
418
            if ($this->modal == '1') {
419
                if ($this->lota == 1) {
420
                    $y += 37;
421
                } else {
422
                    $y += 8.9;
423
                }
424
            } elseif ($this->modal == '2') {
425
                $y += 8.9;
426
            } elseif ($this->modal == '3') {
427
                $y += 24.15;
428
            } else {
429
                $y += 37;
430
            }
431
        } else {
432
            //$r = $this->cabecalho(1, 1, $pag, $totPag);
433
            //Complementado
434
            $y += 10;
435
            $x = $xInic;
436
            $r = $this->docCompl($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
437
            $y += 80;
438
            $x = $xInic;
439
            $r = $this->compValorServ($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...
440
            $y += 25;
441
            $x = $xInic;
442
            $r = $this->impostos($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...
443
            $y += 13;
444
            $x = $xInic;
445
            $r = $this->observacao($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
446
            $y += 15;
447
        }
448
        $x = $xInic;
449
        $r = $this->dadosAdic($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...
450
        //$y += 19;
451
        //$y += 11;
452
        //$y = $this->canhoto($x, $y);
453
        //coloca o rodapé da página
454
        if ($this->orientacao == 'P') {
455
            $this->rodape(2, $this->hPrint - 2);
456
        } else {
457
            $this->rodape($xInic, $this->hPrint + 2.3);
458
        }
459
        if ($this->flagDocOrigContinuacao == 1) {
460
            $this->docOrigContinuacao(1, 71);
461
        }
462
    }
463
464
    /**
465
     * cabecalho
466
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
467
     *
468
     * @param  number $x Posição horizontal inicial, canto esquerdo
469
     * @param  number $y Posição vertical inicial, canto superior
470
     * @param  number $pag Número da Página
471
     * @param  number $totPag Total de páginas
472
     * @return number Posição vertical final
473
     */
474
    protected function cabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
475
    {
476
        $oldX = $x;
477
        $oldY = $y;
478
        if ($this->orientacao == 'P') {
479
            $maxW = $this->wPrint;
480
        } else {
481
            if ($pag == 1) {
482
                // primeira página
483
                $maxW = $this->wPrint - $this->wCanhoto;
484
            } else {
485
                // páginas seguintes
486
                $maxW = $this->wPrint;
487
            }
488
        }
489
        //##################################################################
490
        //coluna esquerda identificação do emitente
491
        //$w = round($maxW * 0.42);
492
        $w = round($maxW * 0.32);
493
        if ($this->orientacao == 'P') {
494
            $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...
495
                'font' => $this->fontePadrao,
496
                'size' => 6,
497
                'style' => '');
498
        } else {
499
            $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...
500
        }
501
        $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...
502
        $h = 35;
503
        $oldY += $h;
504
        //desenha a caixa
505
        $this->pdf->textBox($x, $y, $w + 2, $h + 1);
506
        // coloca o logo
507
        if (!empty($this->logomarca)) {
508
            $logoInfo = getimagesize($this->logomarca);
509
            //largura da imagem em mm
510
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
511
            //altura da imagem em mm
512
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
513
            if ($this->logoAlign == 'L') {
514
                $nImgW = round($w / 3, 0);
515
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
516
                $xImg = $x + 1;
517
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
518
                //estabelecer posições do texto
519
                $x1 = round($xImg + $nImgW + 1, 0);
520
                $y1 = round($h / 3 + $y, 0);
521
                $tw = round(2 * $w / 3, 0);
522
            } elseif ($this->logoAlign == 'C') {
523
                $nImgH = round($h / 3, 0);
524
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
525
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
526
                $yImg = $y + 3;
527
                $x1 = $x;
528
                $y1 = round($yImg + $nImgH + 1, 0);
529
                $tw = $w;
530
            } elseif ($this->logoAlign == 'R') {
531
                $nImgW = round($w / 3, 0);
532
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
533
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
534
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
535
                $x1 = $x;
536
                $y1 = round($h / 3 + $y, 0);
537
                $tw = round(2 * $w / 3, 0);
538
            }
539
            $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...
540
        } else {
541
            $x1 = $x;
542
            $y1 = round($h / 3 + $y, 0);
543
            $tw = $w;
544
        }
545
        //Nome emitente
546
        $aFont = array(
547
            'font' => $this->fontePadrao,
548
            'size' => 9,
549
            'style' => 'B');
550
        $texto = $this->getTagValue($this->emit, "xNome");
551
        $this->pdf->textBox($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...
552
        //endereço
553
        $y1 = $y1 + 3;
554
        $aFont = array(
555
            'font' => $this->fontePadrao,
556
            'size' => 7,
557
            'style' => '');
558
        $fone = $this->getTagValue($this->enderEmit, "fone") != "" ? $this->formatFone($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...
559
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
560
        $nro = $this->getTagValue($this->enderEmit, "nro");
561
        $cpl = $this->getTagValue($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...
562
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
563
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
564
        $CEP = $this->formatField($CEP, "#####-###");
565
        $mun = $this->getTagValue($this->enderEmit, "xMun");
566
        $UF = $this->getTagValue($this->enderEmit, "UF");
567
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
568
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
569
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
570
            . "\n  Fone/Fax: " . $fone;
571
        $this->pdf->textBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
572
        //CNPJ/CPF IE
573
        $cpfCnpj = $this->formatCNPJCPF($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...
574
        $ie = $this->getTagValue($this->emit, "IE");
575
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
576
        $this->pdf->textBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
577
        //outra caixa
578
        $h1 = 17.5;
579
        $y1 = $y + $h + 1;
580
        $this->pdf->textBox($x, $y1, $w + 2, $h1);
581
        //TIPO DO CT-E
582
        $texto = 'TIPO DO CTE';
583
        //$wa = 37;
584
        $wa = 34;
585
        $aFont = array(
586
            'font' => $this->fontePadrao,
587
            'size' => 8,
588
            'style' => '');
589
        $this->pdf->textBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
590
        $tpCTe = $this->getTagValue($this->ide, "tpCTe");
591
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
592
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
593
        switch ($tpCTe) {
594
            case '0':
595
                $texto = 'Normal';
596
                break;
597
            case '1':
598
                $texto = 'Complemento de Valores';
599
                break;
600
            case '2':
601
                $texto = 'Anulação de Valores';
602
                break;
603
            case '3':
604
                $texto = 'Substituto';
605
                break;
606
            default:
607
                $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...
608
        }
609
        $aFont = $this->formatNegrito;
610
        $this->pdf->textBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
611
        //TIPO DO SERVIÇO
612
        $texto = 'TIPO DO SERVIÇO';
613
        $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...
614
        $aFont = array(
615
            'font' => $this->fontePadrao,
616
            'size' => 8,
617
            'style' => '');
618
        $this->pdf->textBox($x + $wa, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
619
        $tpServ = $this->getTagValue($this->ide, "tpServ");
620
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
621
        switch ($tpServ) {
622
            case '0':
623
                $texto = 'Normal';
624
                break;
625
            case '1':
626
                $texto = 'Subcontratação';
627
                break;
628
            case '2':
629
                $texto = 'Redespacho';
630
                break;
631
            case '3':
632
                $texto = 'Redespacho Intermediário';
633
                break;
634
            default:
635
                $texto = 'ERRO' . $tpServ;
636
        }
637
        $aFont = $this->formatNegrito;
638
        $this->pdf->textBox($x + $wa, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
639
        $this->pdf->line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
640
        //TOMADOR DO SERVIÇO
641
        $texto = 'IND.DO CT-E GLOBALIZADO';
642
        $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...
643
        $y2 = $y1 + 8;
644
        $aFont = array(
645
            'font' => $this->fontePadrao,
646
            'size' => 6,
647
            'style' => '');
648
        $this->pdf->textBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
649
        $this->pdf->line($x, $y1 + 8, $w + 3, $y1 + 8);
650
        $toma = $this->getTagValue($this->ide, "indGlobalizado");
651
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
652
        if ($toma == 1) {
653
            $aFont = array(
654
                'font' => $this->fontePadrao,
655
                'size' => 11,
656
                'style' => '');
657
            $this->pdf->textBox($x - 14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
658
        } else {
659
            $aFont = array(
660
                'font' => $this->fontePadrao,
661
                'size' => 11,
662
                'style' => '');
663
            $this->pdf->textBox($x + 3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
664
        }
665
        $aFont = $this->formatNegrito;
666
        $this->pdf->line($x + 3, $x + 71, $x + 3, $x + 75);
667
        $this->pdf->line($x + 8, $x + 71, $x + 8, $x + 75);
668
        $this->pdf->line($x + 3, $x + 71, $x + 8, $x + 71);
669
        $this->pdf->line($x + 3, $x + 75, $x + 8, $x + 75);
670
        $this->pdf->textBox($x - 6, $y2 + 1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
671
        $this->pdf->line($x + 18, $x + 71, $x + 18, $x + 75);
672
        $this->pdf->line($x + 23, $x + 71, $x + 23, $x + 75);
673
        $this->pdf->line($x + 18, $x + 71, $x + 23, $x + 71);
674
        $this->pdf->line($x + 18, $x + 75, $x + 23, $x + 75);
675
        $this->pdf->textBox($x + 9.8, $y2 + 1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
676
        //FORMA DE PAGAMENTO
677
        $texto = 'INF.DO CT-E GLOBALIZADO';
678
        $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...
679
        $aFont = array(
680
            'font' => $this->fontePadrao,
681
            'size' => 8,
682
            'style' => '');
683
        $this->pdf->textBox($x + $wa, $y2 - 0.5, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
684
        $forma = $this->getTagValue($this->ide, "forPag");
0 ignored issues
show
Unused Code introduced by
$forma is not used, you could remove the assignment.

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

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

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

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

Loading history...
685
        //##################################################################
686
        //coluna direita
687
        $x += $w + 2;
688
        $w = round($maxW * 0.212);
689
        $w1 = $w;
690
        $h = 11;
691
        $this->pdf->textBox($x, $y, $w + 48.5, $h + 1);
692
        $texto = "DACTE";
693
        $aFont = array(
694
            'font' => $this->fontePadrao,
695
            'size' => 10,
696
            'style' => 'B');
697
        $this->pdf->textBox($x + 25, $y + 2, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
698
        $aFont = array(
699
            'font' => $this->fontePadrao,
700
            'size' => 9,
701
            'style' => '');
702
        $texto = "Documento Auxiliar do Conhecimento de Transporte Eletrônico";
703
        $h = 10;
704
        $this->pdf->textBox($x + 5, $y + 6, $w + 40, $h, $texto, $aFont, 'T', 'C', 0, '', false);
705
        $x1 = $x + $w + 2;
706
        $w = round($maxW * 0.22, 0);
707
        $w2 = $w;
708
        $h = 11;
709
        $this->pdf->textBox($x1 + 46.5, $y, $w - 0.5, $h + 1);
710
        $texto = "MODAL";
711
        $aFont = array(
712
            'font' => $this->fontePadrao,
713
            'size' => 8,
714
            'style' => '');
715
        $this->pdf->textBox($x1 + 47, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
716
        switch ($this->modal) {
717
            case '1':
718
                $texto = 'Rodoviário';
719
                break;
720
            case '2':
721
                $texto = 'Aéreo';
722
                break;
723
            case '3':
724
                $texto = 'Aquaviário';
725
                break;
726
            case '4':
727
                $texto = 'Ferroviário';
728
                break;
729
            case '5':
730
                $texto = 'Dutoviário';
731
                break;
732
        }
733
        $aFont = array(
734
            'font' => $this->fontePadrao,
735
            'size' => 10,
736
            'style' => 'B');
737
        $this->pdf->textBox($x1 + 47, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
738
        //outra caixa
739
        $y += 12;
740
        $h = 9;
741
        $w = $w1 + $w2 + 2;
742
        $this->pdf->textBox($x, $y, $w + 0.5, $h + 1);
743
        //modelo
744
        $wa = 12;
745
        $xa = $x;
746
        $texto = 'MODELO';
747
        $aFont = array(
748
            'font' => $this->fontePadrao,
749
            'size' => 8,
750
            'style' => '');
751
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
752
        $texto = $this->getTagValue($this->ide, "mod");
753
        $aFont = $this->formatNegrito;
754
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
755
        $this->pdf->line($x + $wa, $y, $x + $wa, $y + $h + 1);
756
        //serie
757
        $wa = 11;
758
        $xa += $wa;
759
        $texto = 'SÉRIE';
760
        $aFont = array(
761
            'font' => $this->fontePadrao,
762
            'size' => 8,
763
            'style' => '');
764
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
765
        $texto = $this->getTagValue($this->ide, "serie");
766
        $aFont = $this->formatNegrito;
767
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
768
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
769
        //numero
770
        $xa += $wa;
771
        $wa = 14;
772
        $texto = 'NÚMERO';
773
        $aFont = array(
774
            'font' => $this->fontePadrao,
775
            'size' => 8,
776
            'style' => '');
777
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
778
        $texto = $this->getTagValue($this->ide, "nCT");
779
        $aFont = $this->formatNegrito;
780
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
781
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
782
        //folha
783
        $xa += $wa;
784
        $wa = 6;
785
        $texto = 'FL';
786
        $aFont = array(
787
            'font' => $this->fontePadrao,
788
            'size' => 8,
789
            'style' => '');
790
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
791
        //$texto = '1/1';
792
        $texto = $pag . "/" . $totPag;
793
        $aFont = $this->formatNegrito;
794
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
795
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
796
        //data  hora de emissão
797
        $xa += $wa;
798
        $wa = 28;
799
        $texto = 'DATA E HORA DE EMISSÃO';
800
        $aFont = array(
801
            'font' => $this->fontePadrao,
802
            'size' => 8,
803
            'style' => '');
804
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
805
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
806
            date('d/m/Y H:i:s', $this->convertTime($this->getTagValue($this->ide, "dhEmi"))) : '';
807
        $aFont = $this->formatNegrito;
808
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
809
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
810
        //ISUF
811
        $xa += $wa;
812
        $wa = 30;
813
        $texto = 'INSC.SUF.DO DEST';
814
        $aFont = $this->formatPadrao;
815
        $this->pdf->textBox($xa - 5, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
816
        $texto = $this->getTagValue($this->dest, "ISUF");
817
        $aFont = array(
818
            'font' => $this->fontePadrao,
819
            'size' => 7,
820
            'style' => 'B');
821
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
822
        //outra caixa
823
        $y += $h + 1;
824
        $h = 23;
825
        $h1 = 14;
826
        $this->pdf->textBox($x, $y, $w + 0.5, $h1);
827
        //CODIGO DE BARRAS
828
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
829
        $bW = 85;
830
        $bH = 10;
831
        //codigo de barras
832
        $this->pdf->setFillColor(0, 0, 0);
833
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
834
        $this->pdf->textBox($x, $y + $h1, $w + 0.5, $h1 - 6);
835
        $texto = 'CHAVE DE ACESSO';
836
        $aFont = $this->formatPadrao;
837
        $this->pdf->textBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
838
        $aFont = $this->formatNegrito;
839
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
840
        $this->pdf->textBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
841
        $this->pdf->textBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
842
        $texto = "Consulta em http://www.cte.fazenda.gov.br/portal";
843
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
844
            $texto = "";
845
            $this->pdf->setFillColor(0, 0, 0);
846
            if ($this->tpEmis == 5) {
847
                $chaveContingencia = $this->geraChaveAdicCont();
848
                $this->pdf->code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
849
            } else {
850
                $chaveContingencia = $this->getTagValue($this->protCTe, "nProt");
851
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
852
            }
853
            //codigo de barras
854
        }
855
        $aFont = array(
856
            'font' => $this->fontePadrao,
857
            'size' => 8,
858
            'style' => '');
859
        $this->pdf->textBox($x, $y + $h1 + 11, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
860
        //outra caixa
861
        $y += $h + 1;
862
        $h = 8.5;
863
        $wa = $w;
864
        $this->pdf->textBox($x, $y + 7.5, $w + 0.5, $h);
865
        if ($this->cteDPEC()) {
866
            $texto = 'NÚMERO DE REGISTRO DPEC';
867
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
868
            $texto = "DADOS DO CT-E";
869
        } else {
870
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
871
        }
872
        $aFont = $this->formatPadrao;
873
        $this->pdf->textBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
874
        if ($this->cteDPEC()) {
875
            $texto = $this->numero_registro_dpec;
876
        } elseif ($this->tpEmis == 5) {
877
            $chaveContingencia = $this->geraChaveAdicCont();
878
            $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...
879
                'font' => $this->fontePadrao,
880
                'size' => 8,
881
                'style' => 'B');
882
            $texto = $this->formatField($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
883
            $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...
884
        } else {
885
            $texto = $this->getTagValue($this->protCTe, "nProt") . " - ";
886
            if (!empty($this->protCTe)
887
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
888
            ) {
889
                $texto .= date(
890
                    'd/m/Y   H:i:s',
891
                    $this->convertTime($this->getTagValue($this->protCTe, "dhRecbto"))
892
                );
893
            }
894
            $texto = $this->getTagValue($this->protCTe, "nProt") == '' ? '' : $texto;
895
        }
896
        $aFont = $this->formatNegrito;
897
        $this->pdf->textBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
898
        if ($this->qrCodCTe !== null) {
899
            $this->qrCodeDacte($y - 27);
900
            $w = 45;
901
            $x += 92.5;
902
            $this->pdf->textBox($x, $y - 34, $w + 0.5, $h + 41.5);
903
        }
904
        //CFOP
905
        $x = $oldX;
906
        $h = 8.5;
907
        $w = round($maxW * 0.32);
908
        $y1 = $y + 7.5;
909
        $this->pdf->textBox($x, $y1, $w + 2, $h);
910
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
911
        $aFont = array(
912
            'font' => $this->fontePadrao,
913
            'size' => 8,
914
            'style' => '');
915
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
916
        $texto = $this->getTagValue($this->ide, "CFOP") . ' - ' . $this->getTagValue($this->ide, "natOp");
917
        $aFont = $this->formatNegrito;
918
        $this->pdf->textBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
919
        //ORIGEM DA PRESTAÇÃO
920
        $y += $h + 7.5;
921
        $x = $oldX;
922
        $h = 8;
923
        $w = ($maxW * 0.5);
924
        $this->pdf->textBox($x, $y, $w + 0.5, $h);
925
        $texto = 'INÍCIO DA PRESTAÇÃO';
926
        $aFont = array(
927
            'font' => $this->fontePadrao,
928
            'size' => 8,
929
            'style' => '');
930
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
931
        $texto = $this->getTagValue($this->ide, "xMunIni") . ' - ' . $this->getTagValue($this->ide, "UFIni");
932
        $aFont = $this->formatNegrito;
933
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
934
        //DESTINO DA PRESTAÇÃO
935
        $x = $oldX + $w + 1;
936
        $h = 8;
937
        $w = $w - 1.3;
938
        $this->pdf->textBox($x - 0.5, $y, $w + 0.5, $h);
939
        $texto = 'TÉRMINO DA PRESTAÇÃO';
940
        $aFont = array(
941
            'font' => $this->fontePadrao,
942
            'size' => 8,
943
            'style' => '');
944
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
945
        $texto = $this->getTagValue($this->ide, "xMunFim") . ' - ' . $this->getTagValue($this->ide, "UFFim");
946
        $aFont = $this->formatNegrito;
947
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
948
        //#########################################################################
949
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
950
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
951
        //indicar cancelamento
952
        $cStat = $this->getTagValue($this->cteProc, "cStat");
953
        if ($cStat == '101' || $cStat == '135') {
954
            //101 Cancelamento
955
            $x = 10;
956
            $y = $this->hPrint - 130;
957
            $h = 25;
958
            $w = $maxW - (2 * $x);
959
            $this->pdf->setTextColor(90, 90, 90);
960
            $texto = "CTe CANCELADO";
961
            $aFont = array(
962
                'font' => $this->fontePadrao,
963
                'size' => 48,
964
                'style' => 'B');
965
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
966
            $this->pdf->setTextColor(0, 0, 0);
967
        }
968
        $cStat = $this->getTagValue($this->cteProc, "cStat");
969
        if ($cStat == '110' ||
970
            $cStat == '301' ||
971
            $cStat == '302'
972
        ) {
973
            //110 Denegada
974
            $x = 10;
975
            $y = $this->hPrint - 130;
976
            $h = 25;
977
            $w = $maxW - (2 * $x);
978
            $this->pdf->setTextColor(90, 90, 90);
979
            $texto = "CTe USO DENEGADO";
980
            $aFont = array(
981
                'font' => $this->fontePadrao,
982
                'size' => 48,
983
                'style' => 'B');
984
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
985
            $y += $h;
986
            $h = 5;
987
            $w = $maxW - (2 * $x);
988
            $texto = "SEM VALOR FISCAL";
989
            $aFont = array(
990
                'font' => $this->fontePadrao,
991
                'size' => 48,
992
                'style' => 'B');
993
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
994
            $this->pdf->setTextColor(0, 0, 0);
995
        }
996
        //indicar sem valor
997
        if ($tpAmb != 1 && $this->preVisualizar == '0') { // caso não seja uma DA de produção
998
            $x = 10;
999
            if ($this->orientacao == 'P') {
1000
                $y = round($this->hPrint * 2 / 3, 0);
1001
            } else {
1002
                $y = round($this->hPrint / 2, 0);
1003
            }
1004
            $h = 5;
1005
            $w = $maxW - (2 * $x);
1006
            $this->pdf->setTextColor(90, 90, 90);
1007
            $texto = "SEM VALOR FISCAL";
1008
            $aFont = array(
1009
                'font' => $this->fontePadrao,
1010
                'size' => 48,
1011
                'style' => 'B');
1012
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1013
            $aFont = array(
1014
                'font' => $this->fontePadrao,
1015
                'size' => 30,
1016
                'style' => 'B');
1017
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1018
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1019
            $this->pdf->setTextColor(0, 0, 0);
1020
        } elseif ($this->preVisualizar == '1') { // caso seja uma DA de Pré-Visualização
1021
            $h = 5;
1022
            $w = $maxW - (2 * 10);
1023
            $x = 55;
1024
            $y = 240;
1025
            $this->pdf->setTextColor(255, 100, 100);
1026
            $aFont = array(
1027
                'font' => $this->fontePadrao,
1028
                'size' => 40,
1029
                'style' => 'B');
1030
            $texto = "Pré-visualização";
1031
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method pTextBox90() 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...
1032
            $this->pdf->setTextColor(255, 100, 100);
1033
            $aFont = array(
1034
                'font' => $this->fontePadrao,
1035
                'size' => 41,
1036
                'style' => 'B');
1037
            $texto = "Sem Validade Jurídica";
1038
            $this->pTextBox90($x + 20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method pTextBox90() 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...
1039
            $this->pdf->setTextColor(90, 90, 90);
1040
            $texto = "SEM VALOR FISCAL";
1041
            $aFont = array(
1042
                'font' => $this->fontePadrao,
1043
                'size' => 48,
1044
                'style' => 'B');
1045
            $this->pTextBox90($x + 40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The method pTextBox90() 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...
1046
            $this->pdf->setTextColor(0, 0, 0); // voltar a cor default
1047
        } else {
1048
            $x = 10;
1049
            if ($this->orientacao == 'P') {
1050
                $y = round($this->hPrint * 2 / 3, 0);
1051
            } else {
1052
                $y = round($this->hPrint / 2, 0);
1053
            } //fim orientacao
1054
            $h = 5;
1055
            $w = $maxW - (2 * $x);
1056
            $this->pdf->setTextColor(90, 90, 90);
1057
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1058
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->cteDPEC()) {
1059
                //Contingência
1060
                $texto = "DACTE Emitido em Contingência";
1061
                $aFont = array(
1062
                    'font' => $this->fontePadrao,
1063
                    'size' => 48,
1064
                    'style' => 'B');
1065
                $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1066
                $aFont = array(
1067
                    'font' => $this->fontePadrao,
1068
                    'size' => 30,
1069
                    'style' => 'B');
1070
                $texto = "devido à problemas técnicos";
1071
                $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1072
            } else {
1073
                if (!isset($this->protCTe)) {
1074
                    if (!$this->cteDPEC()) {
1075
                        $texto = "SEM VALOR FISCAL";
1076
                        $aFont = array(
1077
                            'font' => $this->fontePadrao,
1078
                            'size' => 48,
1079
                            'style' => 'B');
1080
                        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1081
                    }
1082
                    $aFont = array(
1083
                        'font' => $this->fontePadrao,
1084
                        'size' => 30,
1085
                        'style' => 'B');
1086
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1087
                    if (!$this->cteDPEC()) {
1088
                        $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1089
                    } else {
1090
                        $this->pdf->textBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1091
                    }
1092
                } //fim cteProc
1093
                if ($this->tpEmis == 4) {
1094
                    //DPEC
1095
                    $x = 10;
1096
                    $y = $this->hPrint - 130;
1097
                    $h = 25;
1098
                    $w = $maxW - (2 * $x);
1099
                    $this->pdf->setTextColor(200, 200, 200); // 90,90,90 é muito escuro
1100
                    $texto = "DACTE impresso em contingência -\n"
1101
                        . "DPEC regularmente recebido pela Receita\n"
1102
                        . "Federal do Brasil";
1103
                    $aFont = array(
1104
                        'font' => $this->fontePadrao,
1105
                        'size' => 48,
1106
                        'style' => 'B');
1107
                    $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1108
                    $this->pdf->setTextColor(0, 0, 0);
1109
                }
1110
            } //fim tpEmis
1111
            $this->pdf->setTextColor(0, 0, 0);
1112
        }
1113
        return $oldY;
1114
    }
1115
1116
    /**
1117
     * rodapeDACTE
1118
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1119
     *
1120
     * @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...
1121
     * @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...
1122
     */
1123
    protected function rodape($x, $y)
1124
    {
1125
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1126
        $w = $this->wPrint - 4;
1127
        $aFont = array(
1128
            'font' => $this->fontePadrao,
1129
            'size' => 6,
1130
            'style' => '');
1131
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1132
        $texto = $this->creditos .  "  Powered by NFePHP®";
1133
        $aFont = array(
1134
            'font' => $this->fontePadrao,
1135
            'size' => 6,
1136
            'style' => '');
1137
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', false, '');
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a integer.

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...
1138
    }
1139
1140
    /**
1141
     * remetente
1142
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1143
     *
1144
     * @param  number $x Posição horizontal canto esquerdo
1145
     * @param  number $y Posição vertical canto superior
1146
     * @return number Posição vertical final
1147
     */
1148
    protected function remetente($x = 0, $y = 0)
1149
    {
1150
        $oldX = $x;
1151
        $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...
1152
        if ($this->orientacao == 'P') {
1153
            $maxW = $this->wPrint;
1154
        } else {
1155
            $maxW = $this->wPrint - $this->wCanhoto;
1156
        }
1157
        $w = $maxW * 0.5 + 0.5;
1158
        $h = 19;
1159
        $x1 = $x + 16;
1160
        $texto = 'REMETENTE';
1161
        $aFont = $this->formatPadrao;
1162
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1163
        $aFont = $this->formatNegrito;
1164
        $texto = $this->getTagValue($this->rem, "xNome");
1165
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1166
        $y += 3;
1167
        $texto = 'ENDEREÇO';
1168
        $aFont = $this->formatPadrao;
1169
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1170
        $aFont = $this->formatNegrito;
1171
        $texto = $this->getTagValue($this->enderReme, "xLgr") . ',';
1172
        $texto .= $this->getTagValue($this->enderReme, "nro");
1173
        $texto .= ($this->getTagValue($this->enderReme, "xCpl") != "") ?
1174
            ' - ' . $this->getTagValue($this->enderReme, "xCpl") : '';
1175
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1176
        $y += 3;
1177
        $texto = $this->getTagValue($this->enderReme, "xBairro");
1178
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1179
        $y += 3;
1180
        $texto = 'MUNICÍPIO';
1181
        $aFont = $this->formatPadrao;
1182
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1183
        $texto = $this->getTagValue($this->enderReme, "xMun") . ' - ';
1184
        $texto .= $this->getTagValue($this->enderReme, "UF");
1185
        $aFont = $this->formatNegrito;
1186
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1187
        $x = $w - 18;
1188
        $texto = 'CEP';
1189
        $aFont = $this->formatPadrao;
1190
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1191
        $texto = $this->formatField($this->getTagValue($this->enderReme, "CEP"), "#####-###");
1192
        $aFont = $this->formatNegrito;
1193
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1194
        $x = $oldX;
1195
        $y += 3;
1196
        $texto = 'CNPJ/CPF';
1197
        $aFont = $this->formatPadrao;
1198
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1199
        $cpfCnpj = $this->formatCNPJCPF($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...
1200
        $aFont = $this->formatNegrito;
1201
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1202
        $x = $w - 45;
1203
        $texto = 'INSCRIÇÃO ESTADUAL';
1204
        $aFont = $this->formatPadrao;
1205
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1206
        $texto = $this->getTagValue($this->rem, "IE");
1207
        $aFont = $this->formatNegrito;
1208
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1209
        $x = $oldX;
1210
        $y += 3;
1211
        $texto = 'PAÍS';
1212
        $aFont = $this->formatPadrao;
1213
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1214
        $texto = $this->getTagValue($this->rem, "xPais") != "" ?
1215
            $this->getTagValue($this->rem, "xPais") : 'BRASIL';
1216
        $aFont = $this->formatNegrito;
1217
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1218
        $x = $w - 25;
1219
        $texto = 'FONE';
1220
        $aFont = $this->formatPadrao;
1221
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1222
        //$texto = $this->formatFone($this->rem);
1223
        $texto = $this->getTagValue($this->rem, "fone") != "" ? $this->formatFone($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...
1224
        $aFont = $this->formatNegrito;
1225
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1226
    }
1227
1228
    /**
1229
     * destinatario
1230
     * Monta o campo com os dados do destinatário na DACTE.
1231
     *
1232
     * @param  number $x Posição horizontal canto esquerdo
1233
     * @param  number $y Posição vertical canto superior
1234
     * @return number Posição vertical final
1235
     */
1236
    protected function destinatario($x = 0, $y = 0)
1237
    {
1238
        $oldX = $x;
1239
        $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...
1240
        if ($this->orientacao == 'P') {
1241
            $maxW = $this->wPrint;
1242
        } else {
1243
            $maxW = $this->wPrint - $this->wCanhoto;
1244
        }
1245
        $w = ($maxW * 0.5) - 0.7;
1246
        $h = 19;
1247
        $x1 = $x + 19;
1248
        $texto = 'DESTINATÁRIO';
1249
        $aFont = $this->formatPadrao;
1250
        $this->pdf->textBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1251
        $aFont = $this->formatNegrito;
1252
        $texto = $this->getTagValue($this->dest, "xNome");
1253
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1254
        $y += 3;
1255
        $texto = 'ENDEREÇO';
1256
        $aFont = $this->formatPadrao;
1257
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1258
        $aFont = $this->formatNegrito;
1259
        $texto = $this->getTagValue($this->enderDest, "xLgr") . ',';
1260
        $texto .= $this->getTagValue($this->enderDest, "nro");
1261
        $texto .= $this->getTagValue($this->enderDest, "xCpl") != "" ?
1262
            ' - ' . $this->getTagValue($this->enderDest, "xCpl") : '';
1263
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1264
        $y += 3;
1265
        $texto = $this->getTagValue($this->enderDest, "xBairro");
1266
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1267
        $y += 3;
1268
        $texto = 'MUNICÍPIO';
1269
        $aFont = $this->formatPadrao;
1270
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1271
        $texto = $this->getTagValue($this->enderDest, "xMun") . ' - ';
1272
        $texto .= $this->getTagValue($this->enderDest, "UF");
1273
        $aFont = $this->formatNegrito;
1274
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1275
        $x = $w - 19 + $oldX;
1276
        $texto = 'CEP';
1277
        $aFont = $this->formatPadrao;
1278
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1279
        $texto = $this->formatField($this->getTagValue($this->enderDest, "CEP"), "#####-###");
1280
        $aFont = $this->formatNegrito;
1281
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1282
        $x = $oldX;
1283
        $y += 3;
1284
        $texto = 'CNPJ/CPF';
1285
        $aFont = $this->formatPadrao;
1286
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1287
        $cpfCnpj = $this->formatCNPJCPF($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...
1288
        $aFont = $this->formatNegrito;
1289
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1290
        $x = $w - 47.5 + $oldX;
1291
        $texto = 'INSCRIÇÃO ESTADUAL';
1292
        $aFont = $this->formatPadrao;
1293
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1294
        $texto = $this->getTagValue($this->dest, "IE");
1295
        $aFont = $this->formatNegrito;
1296
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1297
        $x = $oldX;
1298
        $y += 3;
1299
        $texto = 'PAÍS';
1300
        $aFont = $this->formatPadrao;
1301
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1302
        $texto = $this->getTagValue($this->dest, "xPais");
1303
        $aFont = $this->formatNegrito;
1304
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1305
        $x = $w - 27 + $oldX;
1306
        $texto = 'FONE';
1307
        $aFont = $this->formatPadrao;
1308
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1309
        //$texto = $this->formatFone($this->dest);
1310
        $texto = $this->getTagValue($this->dest, "fone") != "" ? $this->formatFone($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...
1311
        $aFont = $this->formatNegrito;
1312
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1313
    }
1314
1315
    /**
1316
     * expedidor
1317
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1318
     *
1319
     * @param  number $x Posição horizontal canto esquerdo
1320
     * @param  number $y Posição vertical canto superior
1321
     * @return number Posição vertical final
1322
     */
1323
    protected function expedidor($x = 0, $y = 0)
1324
    {
1325
        $oldX = $x;
1326
        $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...
1327
        if ($this->orientacao == 'P') {
1328
            $maxW = $this->wPrint;
1329
        } else {
1330
            $maxW = $this->wPrint - $this->wCanhoto;
1331
        }
1332
        $w = $maxW * 0.5 + 0.5;
1333
        $h = 19;
1334
        $x1 = $x + 16;
1335
        $texto = 'EXPEDIDOR';
1336
        $aFont = $this->formatPadrao;
1337
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1338
        $aFont = $this->formatNegrito;
1339
        $texto = $this->getTagValue($this->exped, "xNome");
1340
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1341
        $y += 3;
1342
        $texto = 'ENDEREÇO';
1343
        $aFont = $this->formatPadrao;
1344
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1345
        $aFont = $this->formatNegrito;
1346
        if (isset($this->enderExped)) {
1347
            $texto = $this->getTagValue($this->enderExped, "xLgr") . ', ';
1348
            $texto .= $this->getTagValue($this->enderExped, "nro");
1349
            $texto .= $this->getTagValue($this->enderExped, "xCpl") != "" ?
1350
                ' - ' . $this->getTagValue($this->enderExped, "xCpl") :
1351
                '';
1352
        } else {
1353
            $texto = '';
1354
        }
1355
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1356
        $y += 3;
1357
        $texto = $this->getTagValue($this->enderExped, "xBairro");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, getTagValue() does not accept null, maybe add an additional type check?

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

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1358
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1359
        $y += 3;
1360
        $texto = 'MUNICÍPIO';
1361
        $aFont = $this->formatPadrao;
1362
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1363
        if (isset($this->enderExped)) {
1364
            $texto = $this->getTagValue($this->enderExped, "xMun") . ' - ';
1365
            $texto .= $this->getTagValue($this->enderExped, "UF");
1366
        } else {
1367
            $texto = '';
1368
        }
1369
        $aFont = $this->formatNegrito;
1370
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1371
        $x = $w - 18;
1372
        $texto = 'CEP';
1373
        $aFont = $this->formatPadrao;
1374
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1375
        $texto = $this->formatField($this->getTagValue($this->enderExped, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderExped can be null; however, getTagValue() does not accept null, maybe add an additional type check?

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

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1376
        $aFont = $this->formatNegrito;
1377
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1378
        $x = $oldX;
1379
        $y += 3;
1380
        $texto = 'CNPJ/CPF';
1381
        $aFont = $this->formatPadrao;
1382
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1383
        $cpfCnpj = $this->formatCNPJCPF($this->exped);
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1384
        $aFont = $this->formatNegrito;
1385
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1386
        $x = $w - 45;
1387
        $texto = 'INSCRIÇÃO ESTADUAL';
1388
        $aFont = $this->formatPadrao;
1389
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1390
        $texto = $this->getTagValue($this->exped, "IE");
1391
        $aFont = $this->formatNegrito;
1392
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1393
        $x = $oldX;
1394
        $y += 3;
1395
        $texto = 'PAÍS';
1396
        $aFont = $this->formatPadrao;
1397
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1398
        $texto = $this->getTagValue($this->exped, "xPais");
1399
        $aFont = $this->formatNegrito;
1400
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1401
        $x = $w - 25;
1402
        $texto = 'FONE';
1403
        $aFont = $this->formatPadrao;
1404
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1405
        if (isset($this->exped)) {
1406
            $texto = $this->getTagValue($this->exped, "fone") != "" ? $this->formatFone($this->exped) : '';
0 ignored issues
show
Documentation introduced by
$this->exped is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1455
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1456
        $y += 3;
1457
        $texto = 'MUNICÍPIO';
1458
        $aFont = $this->formatPadrao;
1459
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1460
        if (isset($this->enderReceb)) {
1461
            $texto = $this->getTagValue($this->enderReceb, "xMun") . ' - ';
1462
            $texto .= $this->getTagValue($this->enderReceb, "UF");
1463
        } else {
1464
            $texto = '';
1465
        }
1466
        $aFont = $this->formatNegrito;
1467
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1468
        $x = $w - 19 + $oldX;
1469
        $texto = 'CEP';
1470
        $aFont = $this->formatPadrao;
1471
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1472
        $texto = $this->formatField($this->getTagValue($this->enderReceb, "CEP"), "#####-###");
0 ignored issues
show
Bug introduced by
It seems like $this->enderReceb can be null; however, getTagValue() does not accept null, maybe add an additional type check?

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

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

function doesNotAcceptNull(stdClass $x) { }

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

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

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1473
        $aFont = $this->formatNegrito;
1474
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1475
        $x = $oldX;
1476
        $y += 3;
1477
        $texto = 'CNPJ/CPF';
1478
        $aFont = $this->formatPadrao;
1479
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1480
        $texto = $this->formatCNPJCPF($this->receb);
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1481
        $aFont = $this->formatNegrito;
1482
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1483
        $x = $w - 47 + $oldX;
1484
        $texto = 'INSCRIÇÃO ESTADUAL';
1485
        $aFont = $this->formatPadrao;
1486
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1487
        $texto = $this->getTagValue($this->receb, "IE");
1488
        $aFont = $this->formatNegrito;
1489
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1490
        $x = $oldX;
1491
        $y += 3;
1492
        $texto = 'PAÍS';
1493
        $aFont = $this->formatPadrao;
1494
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1495
        $texto = $this->getTagValue($this->receb, "xPais");
1496
        $aFont = $this->formatNegrito;
1497
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1498
        $x = $w - 27 + $oldX;
1499
        $texto = 'FONE';
1500
        $aFont = $this->formatPadrao;
1501
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1502
        if (isset($this->receb)) {
1503
            $texto = $this->getTagValue($this->receb, "fone") != "" ? $this->formatFone($this->receb) : '';
0 ignored issues
show
Documentation introduced by
$this->receb is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1504
            $aFont = $this->formatNegrito;
1505
            $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1506
        }
1507
    }
1508
1509
    /**
1510
     * tomador
1511
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1512
     *
1513
     * @param  number $x Posição horizontal canto esquerdo
1514
     * @param  number $y Posição vertical canto superior
1515
     * @return number Posição vertical final
1516
     */
1517
    protected function tomador($x = 0, $y = 0)
1518
    {
1519
        $oldX = $x;
1520
        $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...
1521
        if ($this->orientacao == 'P') {
1522
            $maxW = $this->wPrint;
1523
        } else {
1524
            $maxW = $this->wPrint - $this->wCanhoto;
1525
        }
1526
        $w = $maxW;
1527
        $h = 10;
1528
        $texto = 'TOMADOR DO SERVIÇO';
1529
        $aFont = $this->formatPadrao;
1530
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1531
        $aFont = $this->formatNegrito;
1532
        $texto = $this->getTagValue($this->toma, "xNome");
1533
        $this->pdf->textBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1534
        $x = $maxW * 0.60;
1535
        $texto = 'MUNICÍPIO';
1536
        $aFont = $this->formatPadrao;
1537
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1538
        $texto = $this->getTagValue($this->toma, "xMun");
1539
        $aFont = $this->formatNegrito;
1540
        $this->pdf->textBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1541
        $x = $maxW * 0.85;
1542
        $texto = 'UF';
1543
        $aFont = $this->formatPadrao;
1544
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1545
        $texto = $this->getTagValue($this->toma, "UF");
1546
        $aFont = $this->formatNegrito;
1547
        $this->pdf->textBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1548
        $x = $w - 18;
1549
        $texto = 'CEP';
1550
        $aFont = $this->formatPadrao;
1551
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1552
        $texto = $this->formatField($this->getTagValue($this->toma, "CEP"), "#####-###");
1553
        $aFont = $this->formatNegrito;
1554
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1555
        $y += 3;
1556
        $x = $oldX;
1557
        $texto = 'ENDEREÇO';
1558
        $aFont = $this->formatPadrao;
1559
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1560
        $aFont = $this->formatNegrito;
1561
        $texto = $this->getTagValue($this->toma, "xLgr") . ',';
1562
        $texto .= $this->getTagValue($this->toma, "nro");
1563
        $texto .= ($this->getTagValue($this->toma, "xCpl") != "") ?
1564
            ' - ' . $this->getTagValue($this->toma, "xCpl") : '';
1565
        $texto .= ' - ' . $this->getTagValue($this->toma, "xBairro");
1566
        $this->pdf->textBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1567
        $y += 3;
1568
        $texto = 'CNPJ/CPF';
1569
        $aFont = $this->formatPadrao;
1570
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1571
        $texto = $this->formatCNPJCPF($this->toma);
1572
        $aFont = $this->formatNegrito;
1573
        $this->pdf->textBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1574
        $x = $x + 65;
1575
        $texto = 'INSCRIÇÃO ESTADUAL';
1576
        $aFont = $this->formatPadrao;
1577
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1578
        $texto = $this->getTagValue($this->toma, "IE");
1579
        $aFont = $this->formatNegrito;
1580
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1581
        $x = $w * 0.75;
1582
        $texto = 'PAÍS';
1583
        $aFont = $this->formatPadrao;
1584
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1585
        $texto = $this->getTagValue($this->toma, "xPais") != "" ?
1586
            $this->getTagValue($this->toma, "xPais") : 'BRASIL';
1587
        $aFont = $this->formatNegrito;
1588
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1589
        $x = $w - 27;
1590
        $texto = 'FONE';
1591
        $aFont = $this->formatPadrao;
1592
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1593
        $texto = $this->getTagValue($this->toma, "fone") != "" ? $this->formatFone($this->toma) : '';
1594
        $aFont = $this->formatNegrito;
1595
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1596
    }
1597
1598
    /**
1599
     * descricaoCarga
1600
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1601
     *
1602
     * @param  number $x Posição horizontal canto esquerdo
1603
     * @param  number $y Posição vertical canto superior
1604
     * @return number Posição vertical final
1605
     */
1606
    protected function descricaoCarga($x = 0, $y = 0)
1607
    {
1608
        $oldX = $x;
1609
        $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...
1610
        if ($this->orientacao == 'P') {
1611
            $maxW = $this->wPrint;
1612
        } else {
1613
            $maxW = $this->wPrint - $this->wCanhoto;
1614
        }
1615
        $w = $maxW;
1616
        $h = 17;
1617
        $texto = 'PRODUTO PREDOMINANTE';
1618
        $aFont = array(
1619
            'font' => $this->fontePadrao,
1620
            'size' => 6,
1621
            'style' => '');
1622
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1623
        $texto = $this->getTagValue($this->infCarga, "proPred");
1624
        $aFont = $this->formatNegrito;
1625
        $this->pdf->textBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1626
        $x = $w * 0.56;
1627
        $this->pdf->line($x, $y, $x, $y + 8);
1628
        $aFont = $this->formatPadrao;
1629
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1630
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1631
        $texto = $this->getTagValue($this->infCarga, "xOutCat");
1632
        $aFont = $this->formatNegrito;
1633
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1634
        $x = $w * 0.8;
1635
        $this->pdf->line($x, $y, $x, $y + 8);
1636
        $aFont = $this->formatPadrao;
1637
        $texto = 'VALOR TOTAL DA CARGA';
1638
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1639
        $texto = $this->getTagValue($this->infCarga, "vCarga") == "" ?
1640
            $this->getTagValue($this->infCarga, "vMerc") : $this->getTagValue($this->infCarga, "vCarga");
1641
        $texto = number_format($texto, 2, ",", ".");
1642
        $aFont = $this->formatNegrito;
1643
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1644
        $y += 8;
1645
        $x = $oldX;
1646
        $this->pdf->line($x, $y, $w + 1, $y);
1647
        //Identifica código da unidade
1648
        //01 = KG (QUILOS)
1649
        $qCarga = 0;
1650
        foreach ($this->infQ as $infQ) {
1651
            if ($this->getTagValue($infQ, "cUnid") == '01') {
1652
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1653
            }
1654
        }
1655
        $texto = 'PESO BRUTO (KG)';
1656
        $aFont = array(
1657
            'font' => $this->fontePadrao,
1658
            'size' => 5,
1659
            'style' => '');
1660
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1661
        $texto = number_format($qCarga, 3, ",", ".");
1662
        $aFont = array(
1663
            'font' => $this->fontePadrao,
1664
            'size' => 7,
1665
            'style' => 'B');
1666
        $this->pdf->textBox($x + 2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1667
        $x = $w * 0.12;
1668
        $this->pdf->line($x + 13.5, $y, $x + 13.5, $y + 9);
1669
        $texto = 'PESO BASE CÁLCULO (KG)';
1670
        $aFont = array(
1671
            'font' => $this->fontePadrao,
1672
            'size' => 5,
1673
            'style' => '');
1674
        $this->pdf->textBox($x + 20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1675
        $texto = number_format($qCarga, 3, ",", ".");
1676
        $aFont = array(
1677
            'font' => $this->fontePadrao,
1678
            'size' => 7,
1679
            'style' => 'B');
1680
        $this->pdf->textBox($x + 17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1681
        $x = $w * 0.24;
1682
        $this->pdf->line($x + 25, $y, $x + 25, $y + 9);
1683
        $texto = 'PESO AFERIDO (KG)';
1684
        $aFont = array(
1685
            'font' => $this->fontePadrao,
1686
            'size' => 5,
1687
            'style' => '');
1688
        $this->pdf->textBox($x + 35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1689
        $texto = number_format($qCarga, 3, ",", ".");
1690
        $aFont = array(
1691
            'font' => $this->fontePadrao,
1692
            'size' => 7,
1693
            'style' => 'B');
1694
        $this->pdf->textBox($x + 28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1695
        $x = $w * 0.36;
1696
        $this->pdf->line($x + 41.3, $y, $x + 41.3, $y + 9);
1697
        $texto = 'CUBAGEM(M3)';
1698
        $aFont = $this->formatPadrao;
1699
        $this->pdf->textBox($x + 60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1700
        $qCarga = 0;
1701
        foreach ($this->infQ as $infQ) {
1702
            if ($this->getTagValue($infQ, "cUnid") == '00') {
1703
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1704
            }
1705
        }
1706
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1707
        $aFont = array(
1708
            'font' => $this->fontePadrao,
1709
            'size' => 7,
1710
            'style' => 'B');
1711
        $this->pdf->textBox($x + 50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1712
        $x = $w * 0.45;
1713
        //$this->pdf->line($x+37, $y, $x+37, $y + 9);
1714
        $texto = 'QTDE(VOL)';
1715
        $aFont = $this->formatPadrao;
1716
        $this->pdf->textBox($x + 85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1717
        $qCarga = 0;
1718
        foreach ($this->infQ as $infQ) {
1719
            if ($this->getTagValue($infQ, "cUnid") == '03') {
1720
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1721
            }
1722
        }
1723
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1724
        $aFont = array(
1725
            'font' => $this->fontePadrao,
1726
            'size' => 7,
1727
            'style' => 'B');
1728
        $this->pdf->textBox($x + 85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1729
        $x = $w * 0.53;
1730
        $this->pdf->line($x + 56, $y, $x + 56, $y + 9);
1731
        /*$texto = 'NOME DA SEGURADORA';
1732
        $aFont = $this->formatPadrao;
1733
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1734
        $texto = $this->getTagValue($this->seg, "xSeg");
1735
        $aFont = array(
1736
            'font' => $this->fontePadrao,
1737
            'size' => 7,
1738
            'style' => 'B');
1739
        $this->pdf->textBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1740
        $y += 3;
1741
        $this->pdf->line($x, $y, $w + 1, $y);
1742
        $texto = 'RESPONSÁVEL';
1743
        $aFont = $this->formatPadrao;
1744
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1745
        $texto = $this->respSeg;
1746
        $aFont = array(
1747
            'font' => $this->fontePadrao,
1748
            'size' => 7,
1749
            'style' => 'B');
1750
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1751
        $x = $w * 0.68;
1752
        $this->pdf->line($x, $y, $x, $y + 6);
1753
        $texto = 'NÚMERO DA APOLICE';
1754
        $aFont = $this->formatPadrao;
1755
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1756
        $texto = $this->getTagValue($this->seg, "nApol");
1757
        $aFont = array(
1758
            'font' => $this->fontePadrao,
1759
            'size' => 7,
1760
            'style' => 'B');
1761
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1762
        $x = $w * 0.85;
1763
        $this->pdf->line($x, $y, $x, $y + 6);
1764
        $texto = 'NÚMERO DA AVERBAÇÃO';
1765
        $aFont = $this->formatPadrao;
1766
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1767
        $texto = $this->getTagValue($this->seg, "nAver");
1768
        $aFont = array(
1769
            'font' => $this->fontePadrao,
1770
            'size' => 7,
1771
            'style' => 'B');
1772
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1773
    }
1774
1775
    /**
1776
     * compValorServ
1777
     * Monta o campo com os componentes da prestação de serviços.
1778
     *
1779
     * @param  number $x Posição horizontal canto esquerdo
1780
     * @param  number $y Posição vertical canto superior
1781
     * @return number Posição vertical final
1782
     */
1783
    protected function compValorServ($x = 0, $y = 0)
1784
    {
1785
        $oldX = $x;
1786
        $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...
1787
        if ($this->orientacao == 'P') {
1788
            $maxW = $this->wPrint;
1789
        } else {
1790
            $maxW = $this->wPrint - $this->wCanhoto;
1791
        }
1792
        $w = $maxW;
1793
        $h = 25;
1794
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1795
        $aFont = $this->formatPadrao;
1796
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1797
        $y += 3.4;
1798
        $this->pdf->line($x, $y, $w + 1, $y);
1799
        $texto = 'NOME';
1800
        $aFont = $this->formatPadrao;
1801
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1802
        $yIniDados = $y;
1803
        $x = $w * 0.14;
1804
        $texto = 'VALOR';
1805
        $aFont = $this->formatPadrao;
1806
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1807
        $x = $w * 0.28;
1808
        $this->pdf->line($x, $y, $x, $y + 21.5);
1809
        $texto = 'NOME';
1810
        $aFont = $this->formatPadrao;
1811
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1812
        $x = $w * 0.42;
1813
        $texto = 'VALOR';
1814
        $aFont = $this->formatPadrao;
1815
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1816
        $x = $w * 0.56;
1817
        $this->pdf->line($x, $y, $x, $y + 21.5);
1818
        $texto = 'NOME';
1819
        $aFont = $this->formatPadrao;
1820
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1821
        $x = $w * 0.70;
1822
        $texto = 'VALOR';
1823
        $aFont = $this->formatPadrao;
1824
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1825
        $x = $w * 0.86;
1826
        $this->pdf->line($x, $y, $x, $y + 21.5);
1827
        $y += 1;
1828
        $texto = 'VALOR TOTAL DO SERVIÇO';
1829
        $aFont = $this->formatPadrao;
1830
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1831
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1832
        $aFont = array(
1833
            'font' => $this->fontePadrao,
1834
            'size' => 9,
1835
            'style' => 'B');
1836
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1837
        $y += 10;
1838
        $this->pdf->line($x, $y, $w + 1, $y);
1839
        $y += 1;
1840
        $texto = 'VALOR A RECEBER';
1841
        $aFont = $this->formatPadrao;
1842
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1843
        $texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
1844
        $aFont = array(
1845
            'font' => $this->fontePadrao,
1846
            'size' => 9,
1847
            'style' => 'B');
1848
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1849
        $auxX = $oldX;
1850
        $yIniDados += 4;
1851
        foreach ($this->Comp as $k => $d) {
1852
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1853
            $valor = number_format(
1854
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1855
                2,
1856
                ",",
1857
                "."
1858
            );
1859
            if ($auxX > $w * 0.60) {
1860
                $yIniDados = $yIniDados + 4;
1861
                $auxX = $oldX;
1862
            }
1863
            $texto = $nome;
1864
            $aFont = $this->formatPadrao;
1865
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1866
            $auxX += $w * 0.14;
1867
            $texto = $valor;
1868
            $aFont = $this->formatPadrao;
1869
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1870
            $auxX += $w * 0.14;
1871
        }
1872
    }
1873
1874
    /**
1875
     * impostos
1876
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1877
     *
1878
     * @param  number $x Posição horizontal canto esquerdo
1879
     * @param  number $y Posição vertical canto superior
1880
     * @return number Posição vertical final
1881
     */
1882
    protected function impostos($x = 0, $y = 0)
1883
    {
1884
        $oldX = $x;
1885
        $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...
1886
        if ($this->orientacao == 'P') {
1887
            $maxW = $this->wPrint;
1888
        } else {
1889
            $maxW = $this->wPrint - $this->wCanhoto;
1890
        }
1891
        $w = $maxW;
1892
        $h = 13;
1893
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1894
        $aFont = $this->formatPadrao;
1895
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1896
        $y += 3.4;
1897
        $this->pdf->line($x, $y, $w + 1, $y);
1898
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1899
        $aFont = $this->formatPadrao;
1900
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1901
        $x += $w * 0.26;
1902
        $this->pdf->line($x, $y, $x, $y + 9.5);
1903
        $texto = 'BASE DE CALCULO';
1904
        $aFont = $this->formatPadrao;
1905
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1906
        $wCol02 = 0.15;
1907
        $x += $w * $wCol02;
1908
        $this->pdf->line($x, $y, $x, $y + 9.5);
1909
        $texto = 'ALÍQ ICMS';
1910
        $aFont = $this->formatPadrao;
1911
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1912
        $x += $w * $wCol02;
1913
        $this->pdf->line($x, $y, $x, $y + 9.5);
1914
        $texto = 'VALOR ICMS';
1915
        $aFont = $this->formatPadrao;
1916
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1917
        $x += $w * $wCol02;
1918
        $this->pdf->line($x, $y, $x, $y + 9.5);
1919
        $texto = '% RED. BC ICMS';
1920
        $aFont = $this->formatPadrao;
1921
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1922
        $x += $w * $wCol02;
1923
        $this->pdf->line($x, $y, $x, $y + 9.5);
1924
        $texto = 'VALOR ICMS ST';
1925
        $aFont = $this->formatPadrao;
1926
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1927
        /*$x += $w * 0.14;
1928
        $this->pdf->line($x, $y, $x, $y + 9.5);
1929
        $texto = 'ICMS ST';
1930
        $aFont = $this->formatPadrao;
1931
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1932
         * */
1933
        $x = $oldX;
1934
        $y = $y + 4;
1935
        $texto = $this->getTagValue($this->ICMS, "CST");
1936
        switch ($texto) {
1937
            case '00':
1938
                $texto = "00 - Tributação normal ICMS";
1939
                break;
1940
            case '20':
1941
                $texto = "20 - Tributação com BC reduzida do ICMS";
1942
                break;
1943
            case '40':
1944
                $texto = "40 - ICMS isenção";
1945
                break;
1946
            case '41':
1947
                $texto = "41 - ICMS não tributada";
1948
                break;
1949
            case '51':
1950
                $texto = "51 - ICMS diferido";
1951
                break;
1952
            case '60':
1953
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
1954
                break;
1955
            case '90':
1956
                if ($this->ICMSOutraUF) {
1957
                    $texto = "90 - ICMS Outra UF";
1958
                } else {
1959
                    $texto = "90 - ICMS Outros";
1960
                }
1961
                break;
1962
        }
1963
        if ($this->getTagValue($this->ICMS, "CST") == '60') {
1964
            $aFont = $this->formatNegrito;
1965
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1966
            $x += $w * 0.26;
1967
            $texto = !empty($this->ICMS->getElementsByTagName("vBCSTRet")->item(0)->nodeValue) ?
1968
                number_format($this->getTagValue($this->ICMS, "vBCSTRet"), 2, ",", ".") : (
1969
                !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
1970
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
1971
                );
1972
            $aFont = $this->formatNegrito;
1973
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1974
            $x += $w * $wCol02;
1975
            $texto = !empty($this->ICMS->getElementsByTagName("pICMSSTRet")->item(0)->nodeValue) ?
1976
                number_format($this->getTagValue($this->ICMS, "pICMSSTRet"), 2, ",", ".") : (
1977
                !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
1978
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
1979
                );
1980
            $aFont = $this->formatNegrito;
1981
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1982
            $x += $w * $wCol02;
1983
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
1984
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
1985
                !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
1986
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
1987
                );
1988
            $aFont = $this->formatNegrito;
1989
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1990
            $x += $w * $wCol02;
1991
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
1992
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
1993
                !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
1994
                    number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
1995
                );
1996
            $aFont = $this->formatNegrito;
1997
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1998
            $x += $w * $wCol02;
1999
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2000
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2001
            $aFont = $this->formatNegrito;
2002
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2003
        } else {
2004
            $texto = $this->getTagValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
2005
            $aFont = $this->formatNegrito;
2006
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2007
            $x += $w * 0.26;
2008
            $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2009
                number_format($this->getTagValue($this->ICMS, "vBC"), 2, ",", ".") : (
2010
                !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2011
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2012
                );
2013
            $aFont = $this->formatNegrito;
2014
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2015
            $x += $w * $wCol02;
2016
            $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2017
                number_format($this->getTagValue($this->ICMS, "pICMS"), 2, ",", ".") : (
2018
                !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2019
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2020
                );
2021
            $aFont = $this->formatNegrito;
2022
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2023
            $x += $w * $wCol02;
2024
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2025
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2026
                !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2027
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2028
                );
2029
            $aFont = $this->formatNegrito;
2030
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2031
            $x += $w * $wCol02;
2032
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2033
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2034
                !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2035
                    number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2036
                );
2037
            $aFont = $this->formatNegrito;
2038
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2039
            $x += $w * $wCol02;
2040
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2041
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2042
            $aFont = $this->formatNegrito;
2043
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2044
        }
2045
        /*$x += $w * 0.14;
2046
        $texto = '';
2047
        $aFont = $this->formatNegrito;
2048
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2049
    }
2050
2051
    /**
2052
     * geraChaveAdicCont
2053
     *
2054
     * @return string chave
2055
     */
2056
    protected function geraChaveAdicCont()
2057
    {
2058
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2059
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
2060
        $forma = "%02d%d%s%014d%01d%01d%02d";
2061
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2062
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2063
        $CNPJ = substr($CNPJ, -14);
2064
        $vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
2065
        $ICMS_CST = $this->getTagValue($this->ICMS, "CST");
2066
        switch ($ICMS_CST) {
2067
            case '00':
2068
            case '20':
2069
                $ICMSp = '1';
2070
                $ICMSs = '2';
2071
                break;
2072
            case '40':
2073
            case '41':
2074
            case '51':
2075
            case '90':
2076
                $ICMSp = '2';
2077
                $ICMSs = '2';
2078
                break;
2079
            case '60':
2080
                $ICMSp = '2';
2081
                $ICMSs = '1';
2082
                break;
2083
        }
2084
        $dd = $this->ide->getElementsByTagName('dhEmi')->item(0)->nodeValue;
2085
        $rpos = strrpos($dd, '-');
2086
        $dd = substr($dd, $rpos + 1);
2087
        $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...
2088
        $chave = $chave . $this->modulo11($chave);
2089
        return $chave;
2090
    }
2091
2092
    /**
2093
     * docOrig
2094
     * Monta o campo com os documentos originarios.
2095
     *
2096
     * @param  number $x Posição horizontal canto esquerdo
2097
     * @param  number $y Posição vertical canto superior
2098
     * @return number Posição vertical final
2099
     */
2100
    protected function docOrig($x = 0, $y = 0)
2101
    {
2102
        $oldX = $x;
2103
        $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...
2104
        if ($this->orientacao == 'P') {
2105
            $maxW = $this->wPrint;
2106
        } else {
2107
            $maxW = $this->wPrint - $this->wCanhoto;
2108
        }
2109
        $w = $maxW;
2110
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2111
        if ($this->modal == '1') {
2112
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2113
            // ou combinação veicular, e por viagem
2114
            $h = $this->lota == 1 ? 35 : 53;
2115
        } elseif ($this->modal == '2') {
2116
            $h = 53;
2117
        } elseif ($this->modal == '3') {
2118
            $h = 37.6;
2119
        } else {
2120
            $h = 35;
2121
        }
2122
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2123
        $aFont = $this->formatPadrao;
2124
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2125
        $descr1 = 'TIPO DOC';
2126
        $descr2 = 'CNPJ/CHAVE/OBS';
2127
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2128
        $y += 3.4;
2129
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2130
        $texto = $descr1;
2131
        $aFont = $this->formatPadrao;
2132
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2133
        $yIniDados = $y;
2134
        $x += $w * 0.07;
2135
        $texto = $descr2;
2136
        $aFont = $this->formatPadrao;
2137
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2138
        $x += $w * 0.28;
2139
        $texto = $descr3;
2140
        $aFont = $this->formatPadrao;
2141
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2142
        $x += $w * 0.14;
2143
        if ($this->modal == '1') {
2144
            if ($this->lota == 1) {
2145
                $this->pdf->line($x, $y, $x, $y + 31.5); // TESTE
2146
            } else {
2147
                $this->pdf->line($x, $y, $x, $y + 49.5); // TESTE
2148
            }
2149
        } elseif ($this->modal == '2') {
2150
            $this->pdf->line($x, $y, $x, $y + 49.5);
2151
        } elseif ($this->modal == '3') {
2152
            $this->pdf->line($x, $y, $x, $y + 34.1);
2153
        } else {
2154
            $this->pdf->line($x, $y, $x, $y + 21.5);
2155
        }
2156
        $texto = $descr1;
2157
        $aFont = $this->formatPadrao;
2158
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2159
        $x += $w * 0.08;
2160
        $texto = $descr2;
2161
        $aFont = $this->formatPadrao;
2162
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2163
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2164
        $texto = $descr3;
2165
        $aFont = $this->formatPadrao;
2166
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2167
        $auxX = $oldX;
2168
        $yIniDados += 3;
2169
        foreach ($this->infNF as $k => $d) {
2170
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2171
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2172
            $cnpj = $this->formatCNPJCPF($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...
2173
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2174
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2175
            if ($auxX > $w * 0.90) {
2176
                $yIniDados = $yIniDados + 3;
2177
                $auxX = $oldX;
2178
            }
2179
            $texto = $tp;
2180
            $aFont = array(
2181
                'font' => $this->fontePadrao,
2182
                'size' => 8,
2183
                'style' => '');
2184
            //$this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2185
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2186
            //$auxX += $w * 0.09;
2187
            $auxX += $w * 0.07;
2188
            $texto = $cnpj;
2189
            $aFont = array(
2190
                'font' => $this->fontePadrao,
2191
                'size' => 8,
2192
                'style' => '');
2193
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2194
            $auxX += $w * 0.28;
2195
            $texto = $doc;
2196
            $aFont = array(
2197
                'font' => $this->fontePadrao,
2198
                'size' => 8,
2199
                'style' => '');
2200
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2201
            $auxX += $w * 0.15;
2202
        }
2203
        foreach ($this->infNFe as $k => $d) {
2204
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2205
            $this->arrayNFe[] = $chaveNFe;
2206
        }
2207
        $qtdeNFe = 1;
2208
        if (count($this->arrayNFe) > 15) {
2209
            $this->flagDocOrigContinuacao = 1;
2210
            $qtdeNFe = count($this->arrayNFe);
2211
        }
2212
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
2213
        switch ($qtdeNFe) {
2214
            default:
2215
                $this->totPag = 1;
2216
            case ($qtdeNFe >= 1044):
2217
                $this->totPag = 11;
2218
                break;
2219
            case ($qtdeNFe > 928):
2220
                $this->totPag = 10;
2221
                break;
2222
            case ($qtdeNFe > 812):
2223
                $this->totPag = 9;
2224
                break;
2225
            case ($qtdeNFe > 696):
2226
                $this->totPag = 8;
2227
                break;
2228
            case ($qtdeNFe > 580):
2229
                $this->totPag = 7;
2230
                break;
2231
            case ($qtdeNFe > 464):
2232
                $this->totPag = 6;
2233
                break;
2234
            case ($qtdeNFe > 348):
2235
                $this->totPag = 5;
2236
                break;
2237
            case ($qtdeNFe > 232):
2238
                $this->totPag = 4;
2239
                break;
2240
            case ($qtdeNFe > 116):
2241
                $this->totPag = 3;
2242
                break;
2243
            case ($qtdeNFe > 16):
2244
                $this->totPag = 2;
2245
                break;
2246
            case ($qtdeNFe <= 16):
2247
                $this->totPag = 1;
2248
                break;
2249
        }
2250
        //$r = $this->cabecalho(1, 1, '1', $this->totPag);
2251
        $contador = 0;
2252
        while ($contador < count($this->arrayNFe)) {
2253
            if ($contador == 15) {
2254
                break;
2255
            }
2256
            $tp = 'NF-e';
2257
            $chaveNFe = $this->arrayNFe[$contador];
2258
            $numNFe = substr($chaveNFe, 25, 9);
2259
            $serieNFe = substr($chaveNFe, 22, 3);
2260
            $doc = $serieNFe . '/' . $numNFe;
2261
            if ($auxX > $w * 0.90) {
2262
                $yIniDados = $yIniDados + 3.5;
2263
                $auxX = $oldX;
2264
            }
2265
            $texto = $tp;
2266
            $aFont = array(
2267
                'font' => $this->fontePadrao,
2268
                'size' => 7,
2269
                'style' => '');
2270
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2271
            $auxX += $w * 0.07;
2272
            $texto = $chaveNFe;
2273
            $aFont = array(
2274
                'font' => $this->fontePadrao,
2275
                'size' => 7,
2276
                'style' => '');
2277
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2278
            $auxX += $w * 0.28;
2279
            $texto = $doc;
2280
            $aFont = array(
2281
                'font' => $this->fontePadrao,
2282
                'size' => 7,
2283
                'style' => '');
2284
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2285
            $auxX += $w * 0.15;
2286
            $contador++;
2287
        }
2288
        foreach ($this->infOutros as $k => $d) {
2289
            $temp = $this->infOutros->item($k);
2290
            $tpDoc = $this->getTagValue($temp, "tpDoc");
2291
            $descOutros = $this->getTagValue($temp, "descOutros");
2292
            $nDoc = $this->getTagValue($temp, "nDoc");
2293
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
0 ignored issues
show
Bug introduced by
The method pSimpleGetDate() 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...
2294
            $vDocFisc = $this->getTagValue($temp, "vDocFisc", "Valor: ");
2295
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
0 ignored issues
show
Bug introduced by
The method pSimpleGetDate() 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...
2296
            switch ($tpDoc) {
2297
                case "00":
2298
                    $tpDoc = "00 - Declaração";
2299
                    break;
2300
                case "10":
2301
                    $tpDoc = "10 - Dutoviário";
2302
                    break;
2303
                case "99":
2304
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2305
                    break;
2306
                default:
2307
                    break;
2308
            }
2309
            $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...
2310
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2311
            if ($auxX > $w * 0.90) {
2312
                $yIniDados = $yIniDados + 4;
2313
                $auxX = $oldX;
2314
            }
2315
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2316
            $auxX += $w * 0.09;
2317
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2318
            $auxX += $w * 0.28;
2319
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2320
            $auxX += $w * 0.14;
2321
        }
2322
        foreach ($this->idDocAntEle as $k => $d) {
2323
            $tp = 'CT-e';
2324
            $chaveCTe = $this->idDocAntEle->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The method item cannot be called on $this->idDocAntEle (of type array).

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

Loading history...
2325
            $numCTe = substr($chaveCTe, 25, 9);
2326
            $serieCTe = substr($chaveCTe, 22, 3);
2327
            $doc = $serieCTe . '/' . $numCTe;
2328
            if ($auxX > $w * 0.90) {
2329
                $yIniDados = $yIniDados + 4;
2330
                $auxX = $oldX;
2331
            }
2332
            $texto = $tp;
2333
            $aFont = array(
2334
                'font' => $this->fontePadrao,
2335
                'size' => 8,
2336
                'style' => '');
2337
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2338
            $auxX += $w * 0.09;
2339
            $texto = $chaveCTe;
2340
            $aFont = array(
2341
                'font' => $this->fontePadrao,
2342
                'size' => 8,
2343
                'style' => '');
2344
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2345
            $auxX += $w * 0.28;
2346
            $texto = $doc;
2347
            $aFont = array(
2348
                'font' => $this->fontePadrao,
2349
                'size' => 8,
2350
                'style' => '');
2351
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2352
            $auxX += $w * 0.14;
2353
        }
2354
    }
2355
2356
    /**
2357
     * docOrigContinuacao
2358
     * Monta o campo com os documentos originarios.
2359
     *
2360
     * @param  number $x Posição horizontal canto esquerdo
2361
     * @param  number $y Posição vertical canto superior
2362
     * @return number Posição vertical final
2363
     */
2364
    protected function docOrigContinuacao($x = 0, $y = 0)
2365
    {
2366
        $x2 = $x;
2367
        $y2 = $y;
2368
        $contador = 16;
2369
        for ($i = 2; $i <= $this->totPag; $i++) {
2370
            $x = $x2;
2371
            $y = $y2;
2372
            $this->pdf->AddPage($this->orientacao, $this->papel);
2373
            $r = $this->cabecalho(1, 1, $i, $this->totPag);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
2374
            $oldX = $x;
2375
            $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...
2376
            if ($this->orientacao == 'P') {
2377
                $maxW = $this->wPrint;
2378
            } else {
2379
                $maxW = $this->wPrint - $this->wCanhoto;
2380
            }
2381
            $w = $maxW;
2382
            //$h = 6; // de sub-titulo
2383
            //$h = 6 + 3; // de altura do texto (primeira linha
2384
            //$h = 9 + 3.5 ;// segunda linha
2385
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
2386
            $h = (((count($this->arrayNFe) / 2) - 9) * 3.5) + 9;
2387
            if (count($this->arrayNFe) % 2 != 0) {
2388
                $h = $h + 3.5;
2389
            } // Caso tenha apenas 1 registro na ultima linha
2390
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2391
            $aFont = $this->formatPadrao;
2392
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2393
            $descr1 = 'TIPO DOC';
2394
            $descr2 = 'CNPJ/CHAVE/OBS';
2395
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2396
            $y += 3.4;
2397
            $this->pdf->line($x, $y, $w + 1, $y);
2398
            $texto = $descr1;
2399
            $aFont = $this->formatPadrao;
2400
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2401
            $yIniDados = $y;
2402
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2403
            $texto = $descr2;
2404
            $aFont = $this->formatPadrao;
2405
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2406
            $x += $w * 0.28;
2407
            $texto = $descr3;
2408
            $aFont = $this->formatPadrao;
2409
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2410
            $x += $w * 0.14;
2411
            if ($this->modal == '1') {
2412
                if ($this->lota == 1) {
2413
                    $this->pdf->line($x, $y, $x, $y + 31.5);
2414
                } else {
2415
                    $this->pdf->line($x, $y, $x, $y + 49.5);
2416
                }
2417
            } elseif ($this->modal == '2') {
2418
                $this->pdf->line($x, $y, $x, $y + 49.5);
2419
            } elseif ($this->modal == '3') {
2420
                $this->pdf->line($x, $y, $x, $y + 34.1);
2421
            } else {
2422
                $this->pdf->line($x, $y, $x, $y + 21.5);
2423
            }
2424
            $texto = $descr1;
2425
            $aFont = $this->formatPadrao;
2426
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2427
            $x += $w * 0.08;
2428
            $texto = $descr2;
2429
            $aFont = $this->formatPadrao;
2430
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2431
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2432
            $texto = $descr3;
2433
            $aFont = $this->formatPadrao;
2434
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2435
            $auxX = $oldX;
2436
            $yIniDados += 3;
2437
            while ($contador < (count($this->arrayNFe))) {
2438
                if ($contador % (116 * ($i - 1)) == 0) {
2439
//                    $contador++;
2440
                    break;
2441
                }
2442
                $tp = 'NF-e';
2443
                $chaveNFe = $this->arrayNFe[$contador];
2444
                $numNFe = substr($chaveNFe, 25, 9);
2445
                $serieNFe = substr($chaveNFe, 22, 3);
2446
                $doc = $serieNFe . '/' . $numNFe;
2447
                if ($auxX > $w * 0.90) {
2448
                    $yIniDados = $yIniDados + 3.5;
2449
                    $auxX = $oldX;
2450
                }
2451
                $texto = $tp;
2452
                $aFont = array(
2453
                    'font' => $this->fontePadrao,
2454
                    'size' => 7,
2455
                    'style' => '');
2456
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2457
                $auxX += $w * 0.07;
2458
                $texto = $chaveNFe;
2459
                $aFont = array(
2460
                    'font' => $this->fontePadrao,
2461
                    'size' => 7,
2462
                    'style' => '');
2463
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2464
                $auxX += $w * 0.28;
2465
                $texto = $doc;
2466
                $aFont = array(
2467
                    'font' => $this->fontePadrao,
2468
                    'size' => 7,
2469
                    'style' => '');
2470
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2471
                $auxX += $w * 0.15;
2472
                $contador++;
2473
            }
2474
        }
2475
    }
2476
2477
    /**
2478
     * docCompl
2479
     * Monta o campo com os dados do remetente na DACTE.
2480
     *
2481
     * @param number $x Posição horizontal canto esquerdo
2482
     * @param number $y Posição vertical canto superior
2483
     * @return number Posição vertical final
2484
     */
2485
    protected function docCompl($x = 0, $y = 0)
2486
    {
2487
        $oldX = $x;
2488
        $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...
2489
        if ($this->orientacao == 'P') {
2490
            $maxW = $this->wPrint;
2491
        } else {
2492
            $maxW = $this->wPrint - $this->wCanhoto;
2493
        }
2494
        $w = $maxW;
2495
        $h = 80;
2496
        if ($this->tpCTe == 1) {
2497
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2498
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2499
            $descr2 = 'VALOR COMPLEMENTADO';
2500
        } else {
2501
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2502
            $descr1 = 'CHAVE DO CT-E ANULADO';
2503
            $descr2 = 'VALOR ANULADO';
2504
        }
2505
        $aFont = $this->formatPadrao;
2506
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2507
        $y += 3.4;
2508
        $this->pdf->line($x, $y, $w + 1, $y);
2509
        $texto = $descr1;
2510
        $aFont = $this->formatPadrao;
2511
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2512
        $yIniDados = $y;
2513
        $x += $w * 0.37;
2514
        $texto = $descr2;
2515
        $aFont = $this->formatPadrao;
2516
        $this->pdf->textBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2517
        $x += $w * 0.13;
2518
        $this->pdf->line($x, $y, $x, $y + 76.5);
2519
        $texto = $descr1;
2520
        $aFont = $this->formatPadrao;
2521
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2522
        $x += $w * 0.3;
2523
        $texto = $descr2;
2524
        $aFont = $this->formatPadrao;
2525
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2526
        $auxX = $oldX;
2527
        $yIniDados += 4;
2528
        if ($auxX > $w * 0.90) {
2529
            $yIniDados = $yIniDados + 4;
2530
            $auxX = $oldX;
2531
        }
2532
        $texto = $this->chaveCTeRef;
2533
        $aFont = array(
2534
            'font' => $this->fontePadrao,
2535
            'size' => 8,
2536
            'style' => '');
2537
        $this->pdf->textBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2538
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
2539
        $aFont = array(
2540
            'font' => $this->fontePadrao,
2541
            'size' => 8,
2542
            'style' => '');
2543
        $this->pdf->textBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2544
    }
2545
2546
    /**
2547
     * observacao
2548
     * Monta o campo com os dados do remetente na DACTE.
2549
     *
2550
     * @param  number $x Posição horizontal canto esquerdo
2551
     * @param  number $y Posição vertical canto superior
2552
     * @return number Posição vertical final
2553
     */
2554
    protected function observacao($x = 0, $y = 0)
2555
    {
2556
        $oldX = $x;
2557
        $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...
2558
        if ($this->orientacao == 'P') {
2559
            $maxW = $this->wPrint;
2560
        } else {
2561
            $maxW = $this->wPrint - $this->wCanhoto;
2562
        }
2563
        $w = $maxW;
2564
        //$h = 18;
2565
        $h = 18.8;
2566
        $texto = 'OBSERVAÇÕES';
2567
        $aFont = $this->formatPadrao;
2568
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2569
        $y += 3.4;
2570
        $this->pdf->line($x, $y, $w + 1, $y);
2571
        $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...
2572
        $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...
2573
        $texto = '';
2574
        foreach ($this->compl as $k => $d) {
2575
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
2576
            $texto .= $xObs;
2577
        }
2578
        $textoObs = explode("Motorista:", $texto);
2579
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: " . $textoObs[1] : '';
2580
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
2581
        $aFont = array(
2582
            'font' => $this->fontePadrao,
2583
            'size' => 7.5,
2584
            'style' => '');
2585
        $this->pdf->textBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2586
        $this->pdf->textBox($x, $y + 11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2587
    }
2588
2589
    /**
2590
     * modalRod
2591
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2592
     *
2593
     * @param  number $x Posição horizontal canto esquerdo
2594
     * @param  number $y Posição vertical canto superior
2595
     * @return number Posição vertical final
2596
     */
2597
    protected function modalRod($x = 0, $y = 0)
2598
    {
2599
        $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...
2600
        $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...
2601
        $lotacao = '';
0 ignored issues
show
Unused Code introduced by
$lotacao is not used, you could remove the assignment.

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

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

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

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

Loading history...
2602
        if ($this->orientacao == 'P') {
2603
            $maxW = $this->wPrint;
2604
        } else {
2605
            $maxW = $this->wPrint - $this->wCanhoto;
2606
        }
2607
        $w = $maxW;
2608
        $h = 3;
2609
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2610
        $aFont = $this->formatPadrao;
2611
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2612
        if ($this->lota == 1) {
2613
            $this->pdf->line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2614
        }
2615
        $y += 3.4;
2616
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2617
        $texto = 'RNTRC DA EMPRESA';
2618
        $aFont = $this->formatPadrao;
2619
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2620
        $texto = $this->getTagValue($this->rodo, "RNTRC");
2621
        $aFont = $this->formatNegrito;
2622
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2623
        $x += $w * 0.23;
2624
        $this->pdf->line($x - 20, $y, $x - 20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2625
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2626
        $aFont = $this->formatPadrao;
2627
        $this->pdf->textBox($x - 20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2628
    }
2629
2630
    /**
2631
     * modalAereo
2632
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2633
     *
2634
     * @param  number $x Posição horizontal canto esquerdo
2635
     * @param  number $y Posição vertical canto superior
2636
     * @return number Posição vertical final
2637
     */
2638
    protected function modalAereo($x = 0, $y = 0)
2639
    {
2640
        $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...
2641
        $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...
2642
        $lotacao = '';
0 ignored issues
show
Unused Code introduced by
$lotacao is not used, you could remove the assignment.

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

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

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

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

Loading history...
2643
        if ($this->orientacao == 'P') {
2644
            $maxW = $this->wPrint;
2645
        } else {
2646
            $maxW = $this->wPrint - $this->wCanhoto;
2647
        }
2648
        $w = $maxW;
2649
        $h = 3;
2650
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2651
        $aFont = $this->formatPadrao;
2652
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2653
        $y += 3.4;
2654
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2655
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2656
        $aFont = $this->formatPadrao;
2657
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2658
        $texto = 'CLASSE DA TARIFA';
2659
        $aFont = $this->formatPadrao;
2660
        $this->pdf->textBox($x + 50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2661
        $texto = 'CÓDIGO DA TARIFA';
2662
        $aFont = $this->formatPadrao;
2663
        $this->pdf->textBox($x + 80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2664
        $texto = 'VALOR DA TARIFA';
2665
        $aFont = $this->formatPadrao;
2666
        $this->pdf->textBox($x + 110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2667
        $texto = $this->getTagValue($this->aereo, "nOCA");
2668
        $aFont = $this->formatNegrito;
2669
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2670
        $x += $w * 0.23;
2671
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2672
        $texto = $this->getTagValue($this->aereo, "CL");
2673
        $aFont = $this->formatNegrito;
2674
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2675
        $x += 30;
2676
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2677
        $texto = $this->getTagValue($this->aereo, "cTar");
2678
        $aFont = $this->formatNegrito;
2679
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2680
        $x += 30;
2681
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2682
        $texto = $this->getTagValue($this->aereo, "vTar");
2683
        $aFont = $this->formatNegrito;
2684
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2685
    }
2686
2687
    /**
2688
     * modalAquaviario
2689
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2690
     *
2691
     * @param  number $x Posição horizontal canto esquerdo
2692
     * @param  number $y Posição vertical canto superior
2693
     * @return number Posição vertical final
2694
     */
2695
    protected function modalAquaviario($x = 0, $y = 0)
2696
    {
2697
        $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...
2698
        $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...
2699
        if ($this->orientacao == 'P') {
2700
            $maxW = $this->wPrint;
2701
        } else {
2702
            $maxW = $this->wPrint - $this->wCanhoto;
2703
        }
2704
        $w = $maxW;
2705
        $h = 8.5;
2706
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2707
        $aFont = $this->formatPadrao;
2708
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2709
        $y += 3.4;
2710
        $this->pdf->line($x, $y, $w + 1, $y);
2711
        $texto = 'PORTO DE EMBARQUE';
2712
        $aFont = $this->formatPadrao;
2713
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2714
        $texto = $this->getTagValue($this->aquav, "prtEmb");
2715
        $aFont = $this->formatNegrito;
2716
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2717
        $x += $w * 0.50;
2718
        $this->pdf->line($x, $y, $x, $y + 7.7);
2719
        $texto = 'PORTO DE DESTINO';
2720
        $aFont = $this->formatPadrao;
2721
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2722
        $texto = $this->getTagValue($this->aquav, "prtDest");
2723
        $aFont = $this->formatNegrito;
2724
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2725
        $y += 8;
2726
        $this->pdf->line(208, $y, 1, $y);
2727
        $x = 1;
2728
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2729
        $aFont = $this->formatPadrao;
2730
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2731
        $texto = $this->getTagValue($this->aquav, "xNavio");
2732
        $aFont = $this->formatNegrito;
2733
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2734
        $x += $w * 0.50;
2735
        $this->pdf->line($x, $y, $x, $y + 7.7);
2736
        $texto = 'VR DA B. DE CALC. AFRMM';
2737
        $aFont = $this->formatPadrao;
2738
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2739
        $texto = $this->getTagValue($this->aquav, "vPrest");
2740
        $aFont = $this->formatNegrito;
2741
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2742
        $x += $w * 0.17;
2743
        $this->pdf->line($x, $y, $x, $y + 7.7);
2744
        $texto = 'VALOR DO AFRMM';
2745
        $aFont = $this->formatPadrao;
2746
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2747
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
2748
        $aFont = $this->formatNegrito;
2749
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2750
        $x += $w * 0.12;
2751
        $this->pdf->line($x, $y, $x, $y + 7.7);
2752
        $texto = 'TIPO DE NAVEGAÇÃO';
2753
        $aFont = $this->formatPadrao;
2754
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2755
        $texto = $this->getTagValue($this->aquav, "tpNav");
2756
        switch ($texto) {
2757
            case '0':
2758
                $texto = 'INTERIOR';
2759
                break;
2760
            case '1':
2761
                $texto = 'CABOTAGEM';
2762
                break;
2763
        }
2764
        $aFont = $this->formatNegrito;
2765
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2766
        $x += $w * 0.14;
2767
        $this->pdf->line($x, $y, $x, $y + 7.7);
2768
        $texto = 'DIREÇÃO';
2769
        $aFont = $this->formatPadrao;
2770
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2771
        $texto = $this->getTagValue($this->aquav, "direc");
2772
        switch ($texto) {
2773
            case 'N':
2774
                $texto = 'NORTE';
2775
                break;
2776
            case 'L':
2777
                $texto = 'LESTE';
2778
                break;
2779
            case 'S':
2780
                $texto = 'SUL';
2781
                break;
2782
            case 'O':
2783
                $texto = 'OESTE';
2784
                break;
2785
        }
2786
        $aFont = $this->formatNegrito;
2787
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2788
        $y += 8;
2789
        $this->pdf->line(208, $y, 1, $y);
2790
        $x = 1;
2791
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2792
        $aFont = $this->formatPadrao;
2793
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2794
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2795
            $texto = $this->infNF
2796
                ->item(0)
2797
                ->getElementsByTagName('infUnidCarga')
2798
                ->item(0)
2799
                ->getElementsByTagName('idUnidCarga')
2800
                ->item(0)->nodeValue;
2801
        } elseif ($this->infNFe->item(0) !== null
2802
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2803
        ) {
2804
            $texto = $this->infNFe
2805
                ->item(0)
2806
                ->getElementsByTagName('infUnidCarga')
2807
                ->item(0)
2808
                ->getElementsByTagName('idUnidCarga')
2809
                ->item(0)
2810
                ->nodeValue;
2811
        } elseif ($this->infOutros->item(0) !== null
2812
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2813
        ) {
2814
            $texto = $this->infOutros
2815
                ->item(0)
2816
                ->getElementsByTagName('infUnidCarga')
2817
                ->item(0)
2818
                ->getElementsByTagName('idUnidCarga')
2819
                ->item(0)
2820
                ->nodeValue;
2821
        } else {
2822
            $texto = '';
2823
        }
2824
        $aFont = $this->formatNegrito;
2825
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2826
        $x += $w * 0.50;
2827
        $this->pdf->line($x, $y, $x, $y + 7.7);
2828
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2829
        $aFont = $this->formatPadrao;
2830
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2831
        $texto = '';
2832
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
2833
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2834
                if ($k == 0) {
2835
                    $texto = $this->aquav
2836
                        ->getElementsByTagName('balsa')
2837
                        ->item($k)
2838
                        ->getElementsByTagName('xBalsa')
2839
                        ->item(0)
2840
                        ->nodeValue;
2841
                } else {
2842
                    $texto = $texto
2843
                        . ' / '
2844
                        . $this->aquav
2845
                            ->getElementsByTagName('balsa')
2846
                            ->item($k)
2847
                            ->getElementsByTagName('xBalsa')
2848
                            ->item(0)
2849
                            ->nodeValue;
2850
                }
2851
            }
2852
        }
2853
        $aFont = $this->formatNegrito;
2854
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2855
    }
2856
2857
    /**
2858
     * modalFerr
2859
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2860
     *
2861
     * @param  number $x Posição horizontal canto esquerdo
2862
     * @param  number $y Posição vertical canto superior
2863
     * @return number Posição vertical final
2864
     */
2865
    protected function modalFerr($x = 0, $y = 0)
2866
    {
2867
        $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...
2868
        $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...
2869
        if ($this->orientacao == 'P') {
2870
            $maxW = $this->wPrint;
2871
        } else {
2872
            $maxW = $this->wPrint - $this->wCanhoto;
2873
        }
2874
        $w = $maxW;
2875
        $h = 19.6;
2876
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2877
        $aFont = $this->formatPadrao;
2878
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2879
        $y += 3.4;
2880
        $this->pdf->line($x, $y, $w + 1, $y);
2881
        $texto = 'DCL';
2882
        $aFont = array(
2883
            'font' => $this->fontePadrao,
2884
            'size' => 7,
2885
            'style' => 'B');
2886
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2887
        $this->pdf->line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2888
        $texto = 'VAGÕES';
2889
        $aFont = array(
2890
            'font' => $this->fontePadrao,
2891
            'size' => 7,
2892
            'style' => 'B');
2893
        $this->pdf->textBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2894
        $y += 3.4;
2895
        $this->pdf->line($x, $y, $w + 1, $y);
2896
        // DCL
2897
        $texto = 'ID TREM';
2898
        $aFont = array(
2899
            'font' => $this->fontePadrao,
2900
            'size' => 6,
2901
            'style' => '');
2902
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2903
        $texto = $this->getTagValue($this->ferrov, "idTrem");
2904
        $aFont = array(
2905
            'font' => $this->fontePadrao,
2906
            'size' => 6,
2907
            'style' => 'B');
2908
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2909
        $x += $w * 0.06;
2910
        $y1 = $y + 12.5;
2911
        $this->pdf->line($x, $y, $x, $y1);
2912
        $texto = 'NUM';
2913
        $aFont = array(
2914
            'font' => $this->fontePadrao,
2915
            'size' => 6,
2916
            'style' => '');
2917
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2918
        $texto = $this->getTagValue($this->rem, "nDoc");
2919
        $aFont = array(
2920
            'font' => $this->fontePadrao,
2921
            'size' => 6,
2922
            'style' => 'B');
2923
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2924
        $x += $w * 0.06;
2925
        $this->pdf->line($x, $y, $x, $y1);
2926
        $texto = 'SÉRIE';
2927
        $aFont = array(
2928
            'font' => $this->fontePadrao,
2929
            'size' => 6,
2930
            'style' => '');
2931
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2932
        $texto = $this->getTagValue($this->rem, "serie");
2933
        $aFont = array(
2934
            'font' => $this->fontePadrao,
2935
            'size' => 6,
2936
            'style' => 'B');
2937
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2938
        $x += $w * 0.06;
2939
        $this->pdf->line($x, $y, $x, $y1);
2940
        $texto = 'EMISSÃO';
2941
        $aFont = array(
2942
            'font' => $this->fontePadrao,
2943
            'size' => 6,
2944
            'style' => '');
2945
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2946
        $texto = $this->ymdTodmy($this->getTagValue($this->rem, "dEmi"));
2947
        $aFont = array(
2948
            'font' => $this->fontePadrao,
2949
            'size' => 6,
2950
            'style' => 'B');
2951
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2952
        // VAGOES
2953
        $x += $w * 0.06;
2954
        $this->pdf->line($x, $y, $x, $y1);
2955
        $texto = 'NUM';
2956
        $aFont = array(
2957
            'font' => $this->fontePadrao,
2958
            'size' => 6,
2959
            'style' => '');
2960
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2961
        $texto = $this->getTagValue($this->ferrov, "nVag");
2962
        $aFont = array(
2963
            'font' => $this->fontePadrao,
2964
            'size' => 6,
2965
            'style' => 'B');
2966
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2967
        $x += $w * 0.06;
2968
        $this->pdf->line($x, $y, $x, $y1);
2969
        $texto = 'TIPO';
2970
        $aFont = array(
2971
            'font' => $this->fontePadrao,
2972
            'size' => 6,
2973
            'style' => '');
2974
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2975
        $texto = $this->getTagValue($this->ferrov, "tpVag");
2976
        $aFont = array(
2977
            'font' => $this->fontePadrao,
2978
            'size' => 6,
2979
            'style' => 'B');
2980
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2981
        $x += $w * 0.06;
2982
        $this->pdf->line($x, $y, $x, $y1);
2983
        $texto = 'CAPACIDADE';
2984
        $aFont = array(
2985
            'font' => $this->fontePadrao,
2986
            'size' => 6,
2987
            'style' => '');
2988
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2989
        $texto = $this->getTagValue($this->ferrov, "cap");
2990
        $aFont = array(
2991
            'font' => $this->fontePadrao,
2992
            'size' => 6,
2993
            'style' => 'B');
2994
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2995
        $x += $w * 0.08;
2996
        $this->pdf->line($x, $y, $x, $y1);
2997
        $texto = 'PESO REAL/TON';
2998
        $aFont = array(
2999
            'font' => $this->fontePadrao,
3000
            'size' => 6,
3001
            'style' => '');
3002
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3003
        $texto = $this->getTagValue($this->ferrov, "pesoR");
3004
        $aFont = array(
3005
            'font' => $this->fontePadrao,
3006
            'size' => 6,
3007
            'style' => 'B');
3008
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3009
        $x += $w * 0.09;
3010
        $this->pdf->line($x, $y, $x, $y1);
3011
        $texto = 'PESO BRUTO/TON';
3012
        $aFont = array(
3013
            'font' => $this->fontePadrao,
3014
            'size' => 6,
3015
            'style' => '');
3016
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3017
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
3018
        $aFont = array(
3019
            'font' => $this->fontePadrao,
3020
            'size' => 6,
3021
            'style' => 'B');
3022
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3023
        $x += $w * 0.1;
3024
        $this->pdf->line($x, $y, $x, $y1);
3025
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3026
        $aFont = array(
3027
            'font' => $this->fontePadrao,
3028
            'size' => 6,
3029
            'style' => '');
3030
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3031
        $texto = $this->getTagValue($this->ferrov, "nCont");
3032
        $aFont = array(
3033
            'font' => $this->fontePadrao,
3034
            'size' => 6,
3035
            'style' => 'B');
3036
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3037
        // FLUXO
3038
        $x = 1;
3039
        $y += 12.9;
3040
        $h1 = $h * 0.5 + 0.27;
3041
        $wa = round($w * 0.103) + 0.5;
3042
        $texto = 'FLUXO FERROVIARIO';
3043
        $aFont = $this->formatPadrao;
3044
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3045
        $texto = $this->getTagValue($this->ferrov, "fluxo");
3046
        $aFont = array(
3047
            'font' => $this->fontePadrao,
3048
            'size' => 7,
3049
            'style' => 'B');
3050
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3051
        $y += 10;
3052
        $texto = 'TIPO DE TRÁFEGO';
3053
        $aFont = $this->formatPadrao;
3054
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3055
        $texto = $this->convertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
3056
        $aFont = array(
3057
            'font' => $this->fontePadrao,
3058
            'size' => 7,
3059
            'style' => 'B');
3060
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3061
        // Novo Box Relativo a Modal Ferroviário
3062
        $x = 22.5;
3063
        $y += -10.2;
3064
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3065
        $aFont = $this->formatPadrao;
3066
        $this->pdf->textBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3067
        $y += 3.4;
3068
        $this->pdf->line($x, $y, $w + 1, $y);
3069
        $w = $w * 0.2;
3070
        $h = $h * 1.04;
3071
        $texto = 'CÓDIGO INTERNO';
3072
        $aFont = array(
3073
            'font' => $this->fontePadrao,
3074
            'size' => 6,
3075
            'style' => '');
3076
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3077
        $texto = $this->getTagValue($this->ferrov, "cInt");
3078
        $aFont = array(
3079
            'font' => $this->fontePadrao,
3080
            'size' => 6,
3081
            'style' => 'B');
3082
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3083
        $texto = 'CNPJ';
3084
        $aFont = array(
3085
            'font' => $this->fontePadrao,
3086
            'size' => 6,
3087
            'style' => '');
3088
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3089
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
3090
        $aFont = array(
3091
            'font' => $this->fontePadrao,
3092
            'size' => 6,
3093
            'style' => 'B');
3094
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3095
        $x += 50;
3096
        $texto = 'NOME';
3097
        $aFont = array(
3098
            'font' => $this->fontePadrao,
3099
            'size' => 6,
3100
            'style' => '');
3101
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3102
        $texto = $this->getTagValue($this->ferrov, "xNome");
3103
        $aFont = array(
3104
            'font' => $this->fontePadrao,
3105
            'size' => 6,
3106
            'style' => 'B');
3107
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3108
        $texto = 'INSCRICAO ESTADUAL';
3109
        $aFont = array(
3110
            'font' => $this->fontePadrao,
3111
            'size' => 6,
3112
            'style' => '');
3113
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3114
        $texto = $this->getTagValue($this->ferrov, "IE");
3115
        $aFont = array(
3116
            'font' => $this->fontePadrao,
3117
            'size' => 6,
3118
            'style' => 'B');
3119
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3120
        $x += 50;
3121
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3122
        $aFont = array(
3123
            'font' => $this->fontePadrao,
3124
            'size' => 6,
3125
            'style' => '');
3126
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3127
        $texto = '';
3128
        $aFont = array(
3129
            'font' => $this->fontePadrao,
3130
            'size' => 6,
3131
            'style' => 'B');
3132
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3133
    }
3134
3135
    /**
3136
     * canhoto
3137
     * Monta o campo com os dados do remetente na DACTE.
3138
     *
3139
     * @param  number $x Posição horizontal canto esquerdo
3140
     * @param  number $y Posição vertical canto superior
3141
     * @return number Posição vertical final
3142
     */
3143
    protected function canhoto($x = 0, $y = 0)
3144
    {
3145
        $oldX = $x;
3146
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY is not used, you could remove the assignment.

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

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

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

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

Loading history...
3147
        if ($this->orientacao == 'P') {
3148
            $maxW = $this->wPrint;
3149
        } else {
3150
            $maxW = $this->wPrint - $this->wCanhoto;
3151
        }
3152
        $w = $maxW - 1;
3153
        $h = 20;
3154
        $y = $y + 1;
3155
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3156
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3157
        $aFont = $this->formatPadrao;
3158
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3159
        $y += 3.4;
3160
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3161
        $texto = 'NOME';
3162
        $aFont = array(
3163
            'font' => $this->fontePadrao,
3164
            'size' => 6,
3165
            'style' => '');
3166
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3167
        $x += $w * 0.25;
3168
        $this->pdf->line($x, $y, $x, $y + 16.5);
3169
        $texto = 'ASSINATURA / CARIMBO';
3170
        $aFont = array(
3171
            'font' => $this->fontePadrao,
3172
            'size' => 6,
3173
            'style' => '');
3174
        $this->pdf->textBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3175
        $x += $w * 0.25;
3176
        $this->pdf->line($x, $y, $x, $y + 16.5);
3177
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n" . "\r\n";
3178
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3179
        $aFont = array(
3180
            'font' => $this->fontePadrao,
3181
            'size' => 6,
3182
            'style' => '');
3183
        $this->pdf->textBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3184
        $x = $oldX;
3185
        $y = $y + 5;
3186
        $this->pdf->line($x, $y + 3, $w * 0.255, $y + 3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3187
        $texto = 'RG';
3188
        $aFont = array(
3189
            'font' => $this->fontePadrao,
3190
            'size' => 6,
3191
            'style' => '');
3192
        $this->pdf->textBox($x, $y + 3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3193
        $x += $w * 0.85;
3194
        $this->pdf->line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3195
        $texto = "CT-E";
3196
        $aFont = $this->formatNegrito;
3197
        $this->pdf->textBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3198
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
3199
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
3200
        $aFont = array(
3201
            'font' => $this->fontePadrao,
3202
            'size' => 6,
3203
            'style' => '');
3204
        $this->pdf->textBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3205
        $x = $oldX;
3206
        $this->pdf->dashedHLine($x, $y + 12.7, $this->wPrint, 0.1, 80);
3207
    }
3208
3209
    /**
3210
     * dadosAdic
3211
     * Coloca o grupo de dados adicionais da DACTE.
3212
     *
3213
     * @param  number $x Posição horizontal canto esquerdo
3214
     * @param  number $y Posição vertical canto superior
3215
     * @param  number $h altura do campo
3216
     * @return number Posição vertical final
3217
     */
3218
    protected function dadosAdic($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...
3219
    {
3220
        $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...
3221
        //###########################################################################
3222
        //DADOS ADICIONAIS DACTE
3223
        if ($this->orientacao == 'P') {
3224
            $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...
3225
        } else {
3226
            $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...
3227
        }
3228
        //INFORMAÇÕES COMPLEMENTARES
3229
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3230
        $y += 3;
3231
        $w = $this->wAdic;
3232
        $h = 8; //mudar
3233
        $aFont = array(
3234
            'font' => $this->fontePadrao,
3235
            'size' => 6,
3236
            'style' => '');
3237
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3238
        //$this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3239
        $this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3240
        //o texto com os dados adicionais foi obtido na função xxxxxx
3241
        //e carregado em uma propriedade privada da classe
3242
        //$this->wAdic com a largura do campo
3243
        //$this->textoAdic com o texto completo do campo
3244
        $y += 1;
3245
        $aFont = $this->formatPadrao;
3246
        $this->pdf->textBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3247
        //RESERVADO AO FISCO
3248
        $texto = "RESERVADO AO FISCO";
3249
        $x += $w;
3250
        $y -= 1;
3251
        if ($this->orientacao == 'P') {
3252
            $w = $this->wPrint - $w;
3253
        } else {
3254
            $w = $this->wPrint - $w - $this->wCanhoto;
3255
        }
3256
        $aFont = array(
3257
            'font' => $this->fontePadrao,
3258
            'size' => 6,
3259
            'style' => '');
3260
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3261
        //inserir texto informando caso de contingência
3262
        //1 – Normal – emissão normal;
3263
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3264
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3265
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3266
        //Emissão em Contingência – DPEC;
3267
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3268
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3269
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3270
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3271
        $texto = '';
3272
        switch ($this->tpEmis) {
3273
            case 2:
3274
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3275
                break;
3276
            case 3:
3277
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3278
                break;
3279
            case 4:
3280
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3281
                break;
3282
            case 5:
3283
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3284
                break;
3285
        }
3286
        $y += 2;
3287
        $aFont = $this->formatPadrao;
3288
        $this->pdf->textBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3289
        return $y + $h;
3290
    }
3291
3292
    /**
3293
     * formatCNPJCPF
3294
     * Formata campo CnpjCpf contida na CTe
3295
     *
3296
     * @param  string $field campo cnpjCpf da CT-e
3297
     * @return string
3298
     */
3299
    protected function formatCNPJCPF($field)
3300
    {
3301
        if (!isset($field)) {
3302
            return '';
3303
        }
3304
        $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...
3305
            $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...
3306
        if ($cnpj != "" && $cnpj != "00000000000000") {
3307
            $cnpj = $this->formatField($cnpj, '###.###.###/####-##');
3308
        } else {
3309
            $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...
3310
                $this->formatField($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...
3311
        }
3312
        return $cnpj;
3313
    }
3314
3315
    /**
3316
     * formatFone
3317
     * Formata campo fone contida na CTe
3318
     *
3319
     * @param  string $field campo fone da CT-e
3320
     * @return string
3321
     */
3322
    protected function formatFone($field)
3323
    {
3324
        try {
3325
            $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...
3326
                $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...
3327
            $foneLen = strlen($fone);
3328
            if ($foneLen > 0) {
3329
                $fone2 = substr($fone, 0, $foneLen - 4);
3330
                $fone1 = substr($fone, 0, $foneLen - 8);
3331
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3332
            } else {
3333
                $fone = '';
3334
            }
3335
            return $fone;
3336
        } catch (Exception $exc) {
3337
            return '';
3338
        }
3339
    }
3340
3341
    /**
3342
     * unidade
3343
     * Converte a imformação de peso contida na CTe
3344
     *
3345
     * @param  string $c unidade de trafego extraida da CTe
3346
     * @return string
3347
     */
3348
    protected function unidade($c = '')
3349
    {
3350
        switch ($c) {
3351
            case '00':
3352
                $r = 'M3';
3353
                break;
3354
            case '01':
3355
                $r = 'KG';
3356
                break;
3357
            case '02':
3358
                $r = 'TON';
3359
                break;
3360
            case '03':
3361
                $r = 'UN';
3362
                break;
3363
            case '04':
3364
                $r = 'LT';
3365
                break;
3366
            case '05':
3367
                $r = 'MMBTU';
3368
                break;
3369
            default:
3370
                $r = '';
3371
        }
3372
        return $r;
3373
    }
3374
3375
    /**
3376
     * convertUnidTrafego
3377
     * Converte a imformação de peso contida na CTe
3378
     *
3379
     * @param  string $U Informação de trafego extraida da CTe
3380
     * @return string
3381
     */
3382
    protected function convertUnidTrafego($U = '')
3383
    {
3384
        if ($U) {
3385
            switch ($U) {
3386
                case '0':
3387
                    $stringU = 'Próprio';
3388
                    break;
3389
                case '1':
3390
                    $stringU = 'Mútuo';
3391
                    break;
3392
                case '2':
3393
                    $stringU = 'Rodoferroviário';
3394
                    break;
3395
                case '3':
3396
                    $stringU = 'Rodoviário';
3397
                    break;
3398
            }
3399
            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...
3400
        }
3401
    }
3402
3403
    /**
3404
     * multiUniPeso
3405
     * Fornece a imformação multiplicação de peso contida na CTe
3406
     *
3407
     * @param  interger $U Informação de peso extraida da CTe
3408
     * @return interger
3409
     */
3410
    protected function multiUniPeso($U = '')
3411
    {
3412
        if ($U === "01") {
3413
            // tonelada
3414
            //return 1000;
3415
            return 1;
3416
        }
3417
        return 1; // M3, KG, Unidade, litros, mmbtu
3418
    }
3419
3420
    protected function qrCodeDacte($y = 0)
3421
    {
3422
        $margemInterna = $this->margemInterna;
3423
        $barcode = new Barcode();
3424
        $bobj = $barcode->getBarcodeObj(
3425
            'QRCODE,M',
3426
            $this->qrCodCTe,
3427
            -4,
3428
            -4,
3429
            'black',
3430
            array(-2, -2, -2, -2)
3431
        )->setBackgroundColor('white');
3432
        $qrcode = $bobj->getPngData();
3433
        $wQr = 36;
3434
        $hQr = 36;
3435
        $yQr = ($y + $margemInterna);
3436
        if ($this->orientacao == 'P') {
3437
            $xQr = 170;
3438
        } else {
3439
            $xQr = 250;
3440
        }
3441
        // prepare a base64 encoded "data url"
3442
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
3443
        $this->pdf->image($pic, $xQr - 3, $yQr, $wQr, $hQr, 'PNG');
3444
    }
3445
3446
    /**
3447
     * Add the credits to the integrator in the footer message
3448
     * @param string $message
3449
     */
3450
    public function creditsIntegratorFooter($message = '')
3451
    {
3452
        $this->creditos = trim($message);
3453
    }
3454
3455
}
3456