Passed
Push — master ( f8305a...b6c7f7 )
by Roberto
03:01 queued 11s
created

Dacte::debugMode()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 14
ccs 0
cts 14
cp 0
crap 20
rs 9.7998
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\Common\DaCommon;
23
24
class Dacte extends DaCommon
25
{
26
27
    protected $logoAlign = 'C';
28
    protected $yDados = 0;
29
    protected $numero_registro_dpec = '';
30
    protected $pdf;
31
    protected $xml;
32
    protected $errMsg = '';
33
    protected $errStatus = false;
34
    protected $orientacao = 'P';
35
    protected $papel = 'A4';
36
    protected $fontePadrao = 'Times';
37
    protected $wPrint;
38
    protected $hPrint;
39
    protected $dom;
40
    protected $infCte;
41
    protected $infCteComp;
42
    protected $infCteAnu;
43
    protected $chaveCTeRef;
44
    protected $tpCTe;
45
    protected $ide;
46
    protected $emit;
47
    protected $enderEmit;
48
    protected $rem;
49
    protected $enderReme;
50
    protected $dest;
51
    protected $enderDest;
52
    protected $exped;
53
    protected $enderExped;
54
    protected $receb;
55
    protected $enderReceb;
56
    protected $infCarga;
57
    protected $infQ;
58
    protected $seg;
59
    protected $modal;
60
    protected $rodo;
61
    protected $moto;
62
    protected $veic;
63
    protected $ferrov;
64
    protected $Comp;
65
    protected $infNF;
66
    protected $infNFe;
67
    protected $compl;
68
    protected $ICMS;
69
    protected $ICMSSN;
70
    protected $ICMSOutraUF;
71
    protected $imp;
72
    protected $toma4;
73
    protected $toma03;
74
    protected $tpEmis;
75
    protected $tpImp;
76
    protected $tpAmb;
77
    protected $vPrest;
78
    protected $wAdic = 150;
79
    protected $textoAdic = '';
80
    protected $debugmode = false;
81
    protected $formatPadrao;
82
    protected $formatNegrito;
83
    protected $aquav;
84
    protected $preVisualizar;
85
    protected $flagDocOrigContinuacao;
86
    protected $arrayNFe = array();
87
    protected $totPag;
88
    protected $idDocAntEle = [];
89
    protected $qrCodCTe;
90
    protected $margemInterna = 0;
91
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
92
    protected $infCTeMultimodal = [];
93
    protected $creditos;
94
95
    /**
96
     * __construct
97
     *
98
     * @param string $xml Arquivo XML da CTe
99
     */
100
    public function __construct(
101
        $xml = ''
102
    ) {
103
        $this->loadDoc($xml);
104
    }
105
106
107
    private function loadDoc($xml)
108
    {
109
        $this->xml = $xml;
110
        if (!empty($xml)) {
111
            $this->dom = new Dom();
112
            $this->dom->loadXML($this->xml);
113
            $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...
114
            if (empty($this->dom->getElementsByTagName("infCte")->item(0))) {
115
                throw new \Exception('Isso não é um CT-e.');
116
            }
117
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
118
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
119
            if ($this->getTagValue($this->ide, "mod") != '57') {
120
                throw new \Exception("O xml deve ser CT-e modelo 57.");
121
            }
122
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
123
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
124
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
125
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
126
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
127
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
128
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
129
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
130
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
131
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
132
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
133
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
134
            $this->infQ = $this->dom->getElementsByTagName("infQ");
135
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
136
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
137
            $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...
138
            $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...
139
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
140
            $this->veic = $this->dom->getElementsByTagName("veic");
141
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
142
            // adicionar outros modais
143
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
144
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
145
            if ($this->tpCTe == 1) {
146
                $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chCTe");
147
            } else {
148
                $this->chaveCTeRef = $this->getTagValue($this->infCteAnu, "chCte");
149
            }
150
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
151
            $this->Comp = $this->dom->getElementsByTagName("Comp");
152
            $this->infNF = $this->dom->getElementsByTagName("infNF");
153
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
154
            $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...
155
            $this->infCTeMultimodal = $this->dom->getElementsByTagName("infCTeMultimodal");
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->dom->getElementsB...ame('infCTeMultimodal') of type object<DOMNodeList> is incompatible with the declared type array of property $infCTeMultimodal.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
156
            $this->compl = $this->dom->getElementsByTagName("compl");
157
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
158
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
159
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
160
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
161
            if (!empty($this->getTagValue($this->imp, "vTotTrib"))) {
162
                $textoAdic = number_format($this->getTagValue($this->imp, "vTotTrib"), 2, ",", ".");
163
                $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
164
                    . $textoAdic;
165
            }
166
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
167
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
168
            //Tag tomador é identificado por toma03 na versão 2.00
169
            if ($this->infCte->getAttribute("versao") == "2.00") {
170
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
171
            }
172
            //modal aquaviário
173
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
174
            $tomador = $this->getTagValue($this->toma03, "toma");
175
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
176
            switch ($tomador) {
177
                case '0':
178
                    $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...
179
                    $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...
180
                    break;
181
                case '1':
182
                    $this->toma = $this->exped;
183
                    $this->enderToma = $this->enderExped;
184
                    break;
185
                case '2':
186
                    $this->toma = $this->receb;
187
                    $this->enderToma = $this->enderReceb;
188
                    break;
189
                case '3':
190
                    $this->toma = $this->dest;
191
                    $this->enderToma = $this->enderDest;
192
                    break;
193
                default:
194
                    $this->toma = $this->toma4;
195
                    $this->enderToma = $this->getTagValue($this->toma4, "enderToma");
196
                    break;
197
            }
198
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
199
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
200
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
201
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
202
            $this->qrCodCTe = $this->dom->getElementsByTagName('qrCodCTe')->item(0) ?
203
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE';
204
            $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...
205
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
206
            $this->modal = $this->getTagValue($this->ide, "modal");
207
        }
208
    }
209
210
    protected function cteDPEC()
211
    {
212
        return $this->numero_registro_dpec != '';
213
    }
214
215
    /**
216
     * montaDACTE
217
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
218
     * durante sua construção.
219
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
220
     * pelo conteúdo da funçao e podem ser modificados.
221
     *
222
     * @param  string $orientacao (Opcional) Estabelece a orientação da
223
     *                impressão (ex. P-retrato), se nada for fornecido será
224
     *                usado o padrão da NFe
225
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
226
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
227
     */
228
    public function monta(
229
        $logo = '',
230
        $orientacao = '',
231
        $papel = 'A4',
232
        $logoAlign = 'C'
233
    ) {
234
        $this->pdf = '';
235
        $this->logomarca = $this->adjustImage($logo);
236
        //se a orientação estiver em branco utilizar o padrão estabelecido no CTe
237
        if ($orientacao == '') {
238
            if ($this->tpImp == '1') {
239
                $orientacao = 'P';
240
            } else {
241
                $orientacao = 'P';
242
            }
243
        }
244
        $this->orientacao = $orientacao;
245
        $this->papel = $papel;
246
        $this->logoAlign = $logoAlign;
247
        //instancia a classe pdf
248
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
249
        // verifica se foi passa a fonte a ser usada
250
        $this->formatPadrao = array(
251
            'font' => $this->fontePadrao,
252
            'size' => 6,
253
            'style' => '');
254
        $this->formatNegrito = array(
255
            'font' => $this->fontePadrao,
256
            'size' => 7,
257
            'style' => 'B');
258
        if ($this->orientacao == 'P') {
259
            // margens do PDF
260
            $margSup = 2;
261
            $margEsq = 2;
262
            $margDir = 2;
263
            // posição inicial do relatorio
264
            $xInic = 1;
265
            $yInic = 1;
266
            if ($papel == 'A4') {
267
                //A4 210x297mm
268
                $maxW = 210;
269
                $maxH = 297;
270
            }
271
        } else {
272
            // margens do PDF
273
            $margSup = 3;
274
            $margEsq = 3;
275
            $margDir = 3;
276
            // posição inicial do relatorio
277
            $xInic = 5;
278
            $yInic = 5;
279
            if ($papel == 'A4') {
280
                //A4 210x297mm
281
                $maxH = 210;
282
                $maxW = 297;
283
                $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...
284
            }
285
        }
286
        //total inicial de paginas
287
        $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...
288
        //largura imprimivel em mm
289
        $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...
290
        //comprimento imprimivel em mm
291
        $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...
292
        // estabelece contagem de paginas
293
        $this->pdf->aliasNbPages();
294
        // fixa as margens
295
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
296
        $this->pdf->setDrawColor(0, 0, 0);
297
        $this->pdf->setFillColor(255, 255, 255);
298
        // inicia o documento
299
        $this->pdf->Open();
300
        // adiciona a primeira página
301
        $this->pdf->addPage($this->orientacao, $this->papel);
302
        $this->pdf->setLineWidth(0.1);
303
        $this->pdf->setTextColor(0, 0, 0);
304
        //calculo do numero de páginas ???
305
        $totPag = 1;
306
        //montagem da primeira página
307
        $pag = 1;
308
        $x = $xInic;
309
        $y = $yInic;
310
        //coloca o cabeçalho
311
        $y = $this->canhoto($x, $y);
312
        $y += 24;
313
        $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...
314
        $y += 70;
315
        $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...
316
        $x = $this->wPrint * 0.5 + 2;
317
        $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...
318
        $y += 19;
319
        $x = $xInic;
320
        $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...
321
        $x = $this->wPrint * 0.5 + 2;
322
        $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...
323
        $y += 19;
324
        $x = $xInic;
325
        $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...
326
        if ($this->tpCTe == '0') {
327
            //Normal
328
            $y += 10;
329
            $x = $xInic;
330
            $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...
331
            $y += 17;
332
            $x = $xInic;
333
            $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...
334
            $y += 25;
335
            $x = $xInic;
336
            $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...
337
            $y += 13;
338
            $x = $xInic;
339
            $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...
340
            if ($this->modal == '1') {
341
                if ($this->lota == 1) {
342
                    //$y += 24.95;
343
                    $y += 35;
344
                } else {
345
                    $y += 53;
346
                }
347
            } elseif ($this->modal == '2') {
348
                $y += 53;
349
            } elseif ($this->modal == '3') {
350
                $y += 37.75;
351
            } else {
352
                $y += 24.95;
353
            }
354
            $x = $xInic;
355
            $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...
356
            $y = $y - 6;
357
            switch ($this->modal) {
358
                case '1':
359
                    $y += 25.9;
360
                    $x = $xInic;
361
                    $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...
362
                    break;
363
                case '2':
364
                    $y += 25.9;
365
                    $x = $xInic;
366
                    $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...
367
                    break;
368
                case '3':
369
                    $y += 17.9;
370
                    $x = $xInic;
371
                    $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...
372
                    break;
373
                case '4':
374
                    $y += 17.9;
375
                    $x = $xInic;
376
                    $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...
377
                    break;
378
                case '5':
379
                    $y += 17.9;
380
                    $x = $xInic;
381
                    // TODO fmertins 31/10/14: este método não existe...
382
                    $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...
383
                    break;
384
            }
385
            if ($this->modal == '1') {
386
                if ($this->lota == 1) {
387
                    $y += 37;
388
                } else {
389
                    $y += 8.9;
390
                }
391
            } elseif ($this->modal == '2') {
392
                $y += 8.9;
393
            } elseif ($this->modal == '3') {
394
                $y += 24.15;
395
            } else {
396
                $y += 37;
397
            }
398
        } else {
399
            //$r = $this->cabecalho(1, 1, $pag, $totPag);
400
            //Complementado
401
            $y += 10;
402
            $x = $xInic;
403
            $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...
404
            $y += 80;
405
            $x = $xInic;
406
            $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...
407
            $y += 25;
408
            $x = $xInic;
409
            $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...
410
            $y += 13;
411
            $x = $xInic;
412
            $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...
413
            $y += 15;
414
        }
415
        $x = $xInic;
416
        $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...
417
        //$y += 19;
418
        //$y += 11;
419
        //$y = $this->canhoto($x, $y);
420
        //coloca o rodapé da página
421
        if ($this->orientacao == 'P') {
422
            $this->rodape(2, $this->hPrint - 2);
423
        } else {
424
            $this->rodape($xInic, $this->hPrint + 2.3);
425
        }
426
        if ($this->flagDocOrigContinuacao == 1) {
427
            $this->docOrigContinuacao(1, 71);
428
        }
429
    }
430
431
    /**
432
     * cabecalho
433
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
434
     *
435
     * @param  number $x Posição horizontal inicial, canto esquerdo
436
     * @param  number $y Posição vertical inicial, canto superior
437
     * @param  number $pag Número da Página
438
     * @param  number $totPag Total de páginas
439
     * @return number Posição vertical final
440
     */
441
    protected function cabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
442
    {
443
        $oldX = $x;
444
        $oldY = $y;
445
        if ($this->orientacao == 'P') {
446
            $maxW = $this->wPrint;
447
        } else {
448
            if ($pag == 1) {
449
                // primeira página
450
                $maxW = $this->wPrint - $this->wCanhoto;
451
            } else {
452
                // páginas seguintes
453
                $maxW = $this->wPrint;
454
            }
455
        }
456
        //##################################################################
457
        //coluna esquerda identificação do emitente
458
        //$w = round($maxW * 0.42);
459
        $w = round($maxW * 0.32);
460
        if ($this->orientacao == 'P') {
461
            $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...
462
                'font' => $this->fontePadrao,
463
                'size' => 6,
464
                'style' => '');
465
        } else {
466
            $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...
467
        }
468
        $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...
469
        $h = 35;
470
        $oldY += $h;
471
        //desenha a caixa
472
        $this->pdf->textBox($x, $y, $w + 2, $h + 1);
473
        // coloca o logo
474
        if (!empty($this->logomarca)) {
475
            $logoInfo = getimagesize($this->logomarca);
476
            //largura da imagem em mm
477
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
478
            //altura da imagem em mm
479
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
480
            if ($this->logoAlign == 'L') {
481
                $nImgW = round($w / 3, 0);
482
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
483
                $xImg = $x + 1;
484
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
485
                //estabelecer posições do texto
486
                $x1 = round($xImg + $nImgW + 1, 0);
487
                $y1 = round($h / 3 + $y, 0);
488
                $tw = round(2 * $w / 3, 0);
489
            } elseif ($this->logoAlign == 'C') {
490
                $nImgH = round($h / 3, 0);
491
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
492
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
493
                $yImg = $y + 3;
494
                $x1 = $x;
495
                $y1 = round($yImg + $nImgH + 1, 0);
496
                $tw = $w;
497
            } elseif ($this->logoAlign == 'R') {
498
                $nImgW = round($w / 3, 0);
499
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
500
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
501
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
502
                $x1 = $x;
503
                $y1 = round($h / 3 + $y, 0);
504
                $tw = round(2 * $w / 3, 0);
505
            }
506
            $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...
507
        } else {
508
            $x1 = $x;
509
            $y1 = round($h / 3 + $y, 0);
510
            $tw = $w;
511
        }
512
        //Nome emitente
513
        $aFont = array(
514
            'font' => $this->fontePadrao,
515
            'size' => 9,
516
            'style' => 'B');
517
        $texto = $this->getTagValue($this->emit, "xNome");
518
        $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...
519
        //endereço
520
        $y1 = $y1 + 3;
521
        $aFont = array(
522
            'font' => $this->fontePadrao,
523
            'size' => 7,
524
            'style' => '');
525
        $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...
526
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
527
        $nro = $this->getTagValue($this->enderEmit, "nro");
528
        $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...
529
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
530
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
531
        $CEP = $this->formatField($CEP, "#####-###");
532
        $mun = $this->getTagValue($this->enderEmit, "xMun");
533
        $UF = $this->getTagValue($this->enderEmit, "UF");
534
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
535
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
536
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
537
            . "\n  Fone/Fax: " . $fone;
538
        $this->pdf->textBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
539
        //CNPJ/CPF IE
540
        $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...
541
        $ie = $this->getTagValue($this->emit, "IE");
542
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
543
        $this->pdf->textBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
544
        //outra caixa
545
        $h1 = 17.5;
546
        $y1 = $y + $h + 1;
547
        $this->pdf->textBox($x, $y1, $w + 2, $h1);
548
        //TIPO DO CT-E
549
        $texto = 'TIPO DO CTE';
550
        //$wa = 37;
551
        $wa = 34;
552
        $aFont = array(
553
            'font' => $this->fontePadrao,
554
            'size' => 8,
555
            'style' => '');
556
        $this->pdf->textBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
557
        $tpCTe = $this->getTagValue($this->ide, "tpCTe");
558
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
559
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
560
        switch ($tpCTe) {
561
            case '0':
562
                $texto = 'Normal';
563
                break;
564
            case '1':
565
                $texto = 'Complemento de Valores';
566
                break;
567
            case '2':
568
                $texto = 'Anulação de Valores';
569
                break;
570
            case '3':
571
                $texto = 'Substituto';
572
                break;
573
            default:
574
                $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...
575
        }
576
        $aFont = $this->formatNegrito;
577
        $this->pdf->textBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
578
        //TIPO DO SERVIÇO
579
        $texto = 'TIPO DO SERVIÇO';
580
        $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...
581
        $aFont = array(
582
            'font' => $this->fontePadrao,
583
            'size' => 8,
584
            'style' => '');
585
        $this->pdf->textBox($x + $wa, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
586
        $tpServ = $this->getTagValue($this->ide, "tpServ");
587
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
588
        switch ($tpServ) {
589
            case '0':
590
                $texto = 'Normal';
591
                break;
592
            case '1':
593
                $texto = 'Subcontratação';
594
                break;
595
            case '2':
596
                $texto = 'Redespacho';
597
                break;
598
            case '3':
599
                $texto = 'Redespacho Intermediário';
600
                break;
601
            case '4':
602
                $texto = 'Serviço Vinculado a Multimodal';
603
                break;
604
            default:
605
                $texto = 'ERRO' . $tpServ;
606
        }
607
        $aFont = $this->formatNegrito;
608
        $this->pdf->textBox($x + $wa, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
609
        $this->pdf->line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
610
        //TOMADOR DO SERVIÇO
611
        $texto = 'IND.DO CT-E GLOBALIZADO';
612
        $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...
613
        $y2 = $y1 + 8;
614
        $aFont = array(
615
            'font' => $this->fontePadrao,
616
            'size' => 6,
617
            'style' => '');
618
        $this->pdf->textBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
619
        $this->pdf->line($x, $y1 + 8, $w + 3, $y1 + 8);
620
        $toma = $this->getTagValue($this->ide, "indGlobalizado");
621
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
622
        if ($toma == 1) {
623
            $aFont = array(
624
                'font' => $this->fontePadrao,
625
                'size' => 11,
626
                'style' => '');
627
            $this->pdf->textBox($x - 14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
628
        } else {
629
            $aFont = array(
630
                'font' => $this->fontePadrao,
631
                'size' => 11,
632
                'style' => '');
633
            $this->pdf->textBox($x + 3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
634
        }
635
        $aFont = $this->formatNegrito;
636
        $this->pdf->line($x + 3, $x + 71, $x + 3, $x + 75);
637
        $this->pdf->line($x + 8, $x + 71, $x + 8, $x + 75);
638
        $this->pdf->line($x + 3, $x + 71, $x + 8, $x + 71);
639
        $this->pdf->line($x + 3, $x + 75, $x + 8, $x + 75);
640
        $this->pdf->textBox($x - 6, $y2 + 1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
641
        $this->pdf->line($x + 18, $x + 71, $x + 18, $x + 75);
642
        $this->pdf->line($x + 23, $x + 71, $x + 23, $x + 75);
643
        $this->pdf->line($x + 18, $x + 71, $x + 23, $x + 71);
644
        $this->pdf->line($x + 18, $x + 75, $x + 23, $x + 75);
645
        $this->pdf->textBox($x + 9.8, $y2 + 1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
646
        //FORMA DE PAGAMENTO
647
        $texto = 'INF.DO CT-E GLOBALIZADO';
648
        $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...
649
        $aFont = array(
650
            'font' => $this->fontePadrao,
651
            'size' => 8,
652
            'style' => '');
653
        $this->pdf->textBox($x + $wa, $y2 - 0.5, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
654
        $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...
655
        //##################################################################
656
        //coluna direita
657
        $x += $w + 2;
658
        $w = round($maxW * 0.212);
659
        $w1 = $w;
660
        $h = 11;
661
        $this->pdf->textBox($x, $y, $w + 48.5, $h + 1);
662
        $texto = "DACTE";
663
        $aFont = array(
664
            'font' => $this->fontePadrao,
665
            'size' => 10,
666
            'style' => 'B');
667
        $this->pdf->textBox($x + 25, $y + 2, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
668
        $aFont = array(
669
            'font' => $this->fontePadrao,
670
            'size' => 9,
671
            'style' => '');
672
        $texto = "Documento Auxiliar do Conhecimento de Transporte Eletrônico";
673
        $h = 10;
674
        $this->pdf->textBox($x + 5, $y + 6, $w + 40, $h, $texto, $aFont, 'T', 'C', 0, '', false);
675
        $x1 = $x + $w + 2;
676
        $w = round($maxW * 0.22, 0);
677
        $w2 = $w;
678
        $h = 11;
679
        $this->pdf->textBox($x1 + 46.5, $y, $w - 0.5, $h + 1);
680
        $texto = "MODAL";
681
        $aFont = array(
682
            'font' => $this->fontePadrao,
683
            'size' => 8,
684
            'style' => '');
685
        $this->pdf->textBox($x1 + 47, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
686
        switch ($this->modal) {
687
            case '1':
688
                $texto = 'Rodoviário';
689
                break;
690
            case '2':
691
                $texto = 'Aéreo';
692
                break;
693
            case '3':
694
                $texto = 'Aquaviário';
695
                break;
696
            case '4':
697
                $texto = 'Ferroviário';
698
                break;
699
            case '5':
700
                $texto = 'Dutoviário';
701
                break;
702
        }
703
        $aFont = array(
704
            'font' => $this->fontePadrao,
705
            'size' => 10,
706
            'style' => 'B');
707
        $this->pdf->textBox($x1 + 47, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
708
        //outra caixa
709
        $y += 12;
710
        $h = 9;
711
        $w = $w1 + $w2 + 2;
712
        $this->pdf->textBox($x, $y, $w + 0.5, $h + 1);
713
        //modelo
714
        $wa = 12;
715
        $xa = $x;
716
        $texto = 'MODELO';
717
        $aFont = array(
718
            'font' => $this->fontePadrao,
719
            'size' => 8,
720
            'style' => '');
721
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
722
        $texto = $this->getTagValue($this->ide, "mod");
723
        $aFont = $this->formatNegrito;
724
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
725
        $this->pdf->line($x + $wa, $y, $x + $wa, $y + $h + 1);
726
        //serie
727
        $wa = 11;
728
        $xa += $wa;
729
        $texto = 'SÉRIE';
730
        $aFont = array(
731
            'font' => $this->fontePadrao,
732
            'size' => 8,
733
            'style' => '');
734
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
735
        $texto = $this->getTagValue($this->ide, "serie");
736
        $aFont = $this->formatNegrito;
737
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
738
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
739
        //numero
740
        $xa += $wa;
741
        $wa = 14;
742
        $texto = 'NÚMERO';
743
        $aFont = array(
744
            'font' => $this->fontePadrao,
745
            'size' => 8,
746
            'style' => '');
747
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
748
        $texto = $this->getTagValue($this->ide, "nCT");
749
        $aFont = $this->formatNegrito;
750
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
751
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
752
        //folha
753
        $xa += $wa;
754
        $wa = 6;
755
        $texto = 'FL';
756
        $aFont = array(
757
            'font' => $this->fontePadrao,
758
            'size' => 8,
759
            'style' => '');
760
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
761
        //$texto = '1/1';
762
        $texto = $pag . "/" . $totPag;
763
        $aFont = $this->formatNegrito;
764
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
765
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
766
        //data  hora de emissão
767
        $xa += $wa;
768
        $wa = 28;
769
        $texto = 'DATA E HORA DE EMISSÃO';
770
        $aFont = array(
771
            'font' => $this->fontePadrao,
772
            'size' => 8,
773
            'style' => '');
774
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
775
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
776
            date('d/m/Y H:i:s', $this->toTimestamp($this->getTagValue($this->ide, "dhEmi"))) : '';
777
        $aFont = $this->formatNegrito;
778
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
779
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
780
        //ISUF
781
        $xa += $wa;
782
        $wa = 30;
783
        $texto = 'INSC.SUF.DO DEST';
784
        $aFont = $this->formatPadrao;
785
        $this->pdf->textBox($xa - 5, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
786
        $texto = $this->getTagValue($this->dest, "ISUF");
787
        $aFont = array(
788
            'font' => $this->fontePadrao,
789
            'size' => 7,
790
            'style' => 'B');
791
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
792
        //outra caixa
793
        $y += $h + 1;
794
        $h = 23;
795
        $h1 = 14;
796
        $this->pdf->textBox($x, $y, $w + 0.5, $h1);
797
        //CODIGO DE BARRAS
798
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
799
        $bW = 85;
800
        $bH = 10;
801
        //codigo de barras
802
        $this->pdf->setFillColor(0, 0, 0);
803
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
804
        $this->pdf->textBox($x, $y + $h1, $w + 0.5, $h1 - 6);
805
        $texto = 'CHAVE DE ACESSO';
806
        $aFont = $this->formatPadrao;
807
        $this->pdf->textBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
808
        $aFont = $this->formatNegrito;
809
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
810
        $this->pdf->textBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
811
        $this->pdf->textBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
812
        $texto = "Consulta em http://www.cte.fazenda.gov.br/portal";
813
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
814
            $texto = "";
815
            $this->pdf->setFillColor(0, 0, 0);
816
            if ($this->tpEmis == 5) {
817
                $chaveContingencia = $this->geraChaveAdicCont();
818
                $this->pdf->code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
819
            } else {
820
                $chaveContingencia = $this->getTagValue($this->protCTe, "nProt");
821
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
822
            }
823
            //codigo de barras
824
        }
825
        $aFont = array(
826
            'font' => $this->fontePadrao,
827
            'size' => 8,
828
            'style' => '');
829
        $this->pdf->textBox($x, $y + $h1 + 11, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
830
        //outra caixa
831
        $y += $h + 1;
832
        $h = 8.5;
833
        $wa = $w;
834
        $this->pdf->textBox($x, $y + 7.5, $w + 0.5, $h);
835
        if ($this->cteDPEC()) {
836
            $texto = 'NÚMERO DE REGISTRO DPEC';
837
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
838
            $texto = "DADOS DO CT-E";
839
        } else {
840
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
841
        }
842
        $aFont = $this->formatPadrao;
843
        $this->pdf->textBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
844
        if ($this->cteDPEC()) {
845
            $texto = $this->numero_registro_dpec;
846
        } elseif ($this->tpEmis == 5) {
847
            $chaveContingencia = $this->geraChaveAdicCont();
848
            $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...
849
                'font' => $this->fontePadrao,
850
                'size' => 8,
851
                'style' => 'B');
852
            $texto = $this->formatField($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
853
            $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...
854
        } else {
855
            $texto = $this->getTagValue($this->protCTe, "nProt") . " - ";
856
            if (!empty($this->protCTe)
857
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
858
            ) {
859
                $texto .= date(
860
                    'd/m/Y   H:i:s',
861
                    $this->toTimestamp($this->getTagValue($this->protCTe, "dhRecbto"))
862
                );
863
            }
864
            $texto = $this->getTagValue($this->protCTe, "nProt") == '' ? '' : $texto;
865
        }
866
        $aFont = $this->formatNegrito;
867
        $this->pdf->textBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
868
        if ($this->qrCodCTe !== null) {
869
            $this->qrCodeDacte($y - 27);
870
            $w = 45;
871
            $x += 92.5;
872
            $this->pdf->textBox($x, $y - 34, $w + 0.5, $h + 41.5);
873
        }
874
        //CFOP
875
        $x = $oldX;
876
        $h = 8.5;
877
        $w = round($maxW * 0.32);
878
        $y1 = $y + 7.5;
879
        $this->pdf->textBox($x, $y1, $w + 2, $h);
880
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
881
        $aFont = array(
882
            'font' => $this->fontePadrao,
883
            'size' => 8,
884
            'style' => '');
885
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
886
        $texto = $this->getTagValue($this->ide, "CFOP") . ' - ' . $this->getTagValue($this->ide, "natOp");
887
        $aFont = $this->formatNegrito;
888
        $this->pdf->textBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
889
        //ORIGEM DA PRESTAÇÃO
890
        $y += $h + 7.5;
891
        $x = $oldX;
892
        $h = 8;
893
        $w = ($maxW * 0.5);
894
        $this->pdf->textBox($x, $y, $w + 0.5, $h);
895
        $texto = 'INÍCIO DA PRESTAÇÃO';
896
        $aFont = array(
897
            'font' => $this->fontePadrao,
898
            'size' => 8,
899
            'style' => '');
900
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
901
        $texto = $this->getTagValue($this->ide, "xMunIni") . ' - ' . $this->getTagValue($this->ide, "UFIni");
902
        $aFont = $this->formatNegrito;
903
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
904
        //DESTINO DA PRESTAÇÃO
905
        $x = $oldX + $w + 1;
906
        $h = 8;
907
        $w = $w - 1.3;
908
        $this->pdf->textBox($x - 0.5, $y, $w + 0.5, $h);
909
        $texto = 'TÉRMINO DA PRESTAÇÃO';
910
        $aFont = array(
911
            'font' => $this->fontePadrao,
912
            'size' => 8,
913
            'style' => '');
914
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
915
        $texto = $this->getTagValue($this->ide, "xMunFim") . ' - ' . $this->getTagValue($this->ide, "UFFim");
916
        $aFont = $this->formatNegrito;
917
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
918
        //#########################################################################
919
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
920
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
921
        //indicar cancelamento
922
        $cStat = $this->getTagValue($this->cteProc, "cStat");
923
        if ($cStat == '101' || $cStat == '135') {
924
            //101 Cancelamento
925
            $x = 10;
926
            $y = $this->hPrint - 130;
927
            $h = 25;
928
            $w = $maxW - (2 * $x);
929
            $this->pdf->setTextColor(90, 90, 90);
930
            $texto = "CTe CANCELADO";
931
            $aFont = array(
932
                'font' => $this->fontePadrao,
933
                'size' => 48,
934
                'style' => 'B');
935
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
936
            $this->pdf->setTextColor(0, 0, 0);
937
        }
938
        $cStat = $this->getTagValue($this->cteProc, "cStat");
939
        if ($cStat == '110' ||
940
            $cStat == '301' ||
941
            $cStat == '302'
942
        ) {
943
            //110 Denegada
944
            $x = 10;
945
            $y = $this->hPrint - 130;
946
            $h = 25;
947
            $w = $maxW - (2 * $x);
948
            $this->pdf->setTextColor(90, 90, 90);
949
            $texto = "CTe USO DENEGADO";
950
            $aFont = array(
951
                'font' => $this->fontePadrao,
952
                'size' => 48,
953
                'style' => 'B');
954
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
955
            $y += $h;
956
            $h = 5;
957
            $w = $maxW - (2 * $x);
958
            $texto = "SEM VALOR FISCAL";
959
            $aFont = array(
960
                'font' => $this->fontePadrao,
961
                'size' => 48,
962
                'style' => 'B');
963
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
964
            $this->pdf->setTextColor(0, 0, 0);
965
        }
966
        //indicar sem valor
967
        if ($tpAmb != 1 && $this->preVisualizar == '0') { // caso não seja uma DA de produção
968
            $x = 10;
969
            if ($this->orientacao == 'P') {
970
                $y = round($this->hPrint * 2 / 3, 0);
971
            } else {
972
                $y = round($this->hPrint / 2, 0);
973
            }
974
            $h = 5;
975
            $w = $maxW - (2 * $x);
976
            $this->pdf->setTextColor(90, 90, 90);
977
            $texto = "SEM VALOR FISCAL";
978
            $aFont = array(
979
                'font' => $this->fontePadrao,
980
                'size' => 48,
981
                'style' => 'B');
982
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
983
            $aFont = array(
984
                'font' => $this->fontePadrao,
985
                'size' => 30,
986
                'style' => 'B');
987
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
988
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
989
            $this->pdf->setTextColor(0, 0, 0);
990
        } elseif ($this->preVisualizar == '1') { // caso seja uma DA de Pré-Visualização
991
            $h = 5;
992
            $w = $maxW - (2 * 10);
993
            $x = 55;
994
            $y = 240;
995
            $this->pdf->setTextColor(255, 100, 100);
996
            $aFont = array(
997
                'font' => $this->fontePadrao,
998
                'size' => 40,
999
                'style' => 'B');
1000
            $texto = "Pré-visualização";
1001
            $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...
1002
            $this->pdf->setTextColor(255, 100, 100);
1003
            $aFont = array(
1004
                'font' => $this->fontePadrao,
1005
                'size' => 41,
1006
                'style' => 'B');
1007
            $texto = "Sem Validade Jurídica";
1008
            $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...
1009
            $this->pdf->setTextColor(90, 90, 90);
1010
            $texto = "SEM VALOR FISCAL";
1011
            $aFont = array(
1012
                'font' => $this->fontePadrao,
1013
                'size' => 48,
1014
                'style' => 'B');
1015
            $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...
1016
            $this->pdf->setTextColor(0, 0, 0); // voltar a cor default
1017
        } else {
1018
            $x = 10;
1019
            if ($this->orientacao == 'P') {
1020
                $y = round($this->hPrint * 2 / 3, 0);
1021
            } else {
1022
                $y = round($this->hPrint / 2, 0);
1023
            } //fim orientacao
1024
            $h = 5;
1025
            $w = $maxW - (2 * $x);
1026
            $this->pdf->setTextColor(90, 90, 90);
1027
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1028
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->cteDPEC()) {
1029
                //Contingência
1030
                $texto = "DACTE Emitido em Contingência";
1031
                $aFont = array(
1032
                    'font' => $this->fontePadrao,
1033
                    'size' => 48,
1034
                    'style' => 'B');
1035
                $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1036
                $aFont = array(
1037
                    'font' => $this->fontePadrao,
1038
                    'size' => 30,
1039
                    'style' => 'B');
1040
                $texto = "devido à problemas técnicos";
1041
                $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1042
            } else {
1043
                if (!isset($this->protCTe)) {
1044
                    if (!$this->cteDPEC()) {
1045
                        $texto = "SEM VALOR FISCAL";
1046
                        $aFont = array(
1047
                            'font' => $this->fontePadrao,
1048
                            'size' => 48,
1049
                            'style' => 'B');
1050
                        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1051
                    }
1052
                    $aFont = array(
1053
                        'font' => $this->fontePadrao,
1054
                        'size' => 30,
1055
                        'style' => 'B');
1056
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1057
                    if (!$this->cteDPEC()) {
1058
                        $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1059
                    } else {
1060
                        $this->pdf->textBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1061
                    }
1062
                } //fim cteProc
1063
                if ($this->tpEmis == 4) {
1064
                    //DPEC
1065
                    $x = 10;
1066
                    $y = $this->hPrint - 130;
1067
                    $h = 25;
1068
                    $w = $maxW - (2 * $x);
1069
                    $this->pdf->setTextColor(200, 200, 200); // 90,90,90 é muito escuro
1070
                    $texto = "DACTE impresso em contingência -\n"
1071
                        . "DPEC regularmente recebido pela Receita\n"
1072
                        . "Federal do Brasil";
1073
                    $aFont = array(
1074
                        'font' => $this->fontePadrao,
1075
                        'size' => 48,
1076
                        'style' => 'B');
1077
                    $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1078
                    $this->pdf->setTextColor(0, 0, 0);
1079
                }
1080
            } //fim tpEmis
1081
            $this->pdf->setTextColor(0, 0, 0);
1082
        }
1083
        return $oldY;
1084
    }
1085
1086
    /**
1087
     * rodapeDACTE
1088
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1089
     *
1090
     * @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...
1091
     * @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...
1092
     */
1093
    protected function rodape($x, $y)
1094
    {
1095
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1096
        $w = $this->wPrint - 4;
1097
        $aFont = array(
1098
            'font' => $this->fontePadrao,
1099
            'size' => 6,
1100
            'style' => '');
1101
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1102
        $texto = $this->creditos .  "  Powered by NFePHP®";
1103
        $aFont = array(
1104
            'font' => $this->fontePadrao,
1105
            'size' => 6,
1106
            'style' => '');
1107
        $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...
1108
    }
1109
1110
    /**
1111
     * remetente
1112
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1113
     *
1114
     * @param  number $x Posição horizontal canto esquerdo
1115
     * @param  number $y Posição vertical canto superior
1116
     * @return number Posição vertical final
1117
     */
1118
    protected function remetente($x = 0, $y = 0)
1119
    {
1120
        $oldX = $x;
1121
        $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...
1122
        if ($this->orientacao == 'P') {
1123
            $maxW = $this->wPrint;
1124
        } else {
1125
            $maxW = $this->wPrint - $this->wCanhoto;
1126
        }
1127
        $w = $maxW * 0.5 + 0.5;
1128
        $h = 19;
1129
        $x1 = $x + 16;
1130
        $texto = 'REMETENTE';
1131
        $aFont = $this->formatPadrao;
1132
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1133
        $aFont = $this->formatNegrito;
1134
        $texto = $this->getTagValue($this->rem, "xNome");
1135
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1136
        $y += 3;
1137
        $texto = 'ENDEREÇO';
1138
        $aFont = $this->formatPadrao;
1139
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1140
        $aFont = $this->formatNegrito;
1141
        $texto = $this->getTagValue($this->enderReme, "xLgr") . ',';
1142
        $texto .= $this->getTagValue($this->enderReme, "nro");
1143
        $texto .= ($this->getTagValue($this->enderReme, "xCpl") != "") ?
1144
            ' - ' . $this->getTagValue($this->enderReme, "xCpl") : '';
1145
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1146
        $y += 3;
1147
        $texto = $this->getTagValue($this->enderReme, "xBairro");
1148
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1149
        $y += 3;
1150
        $texto = 'MUNICÍPIO';
1151
        $aFont = $this->formatPadrao;
1152
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1153
        $texto = $this->getTagValue($this->enderReme, "xMun") . ' - ';
1154
        $texto .= $this->getTagValue($this->enderReme, "UF");
1155
        $aFont = $this->formatNegrito;
1156
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1157
        $x = $w - 18;
1158
        $texto = 'CEP';
1159
        $aFont = $this->formatPadrao;
1160
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1161
        $texto = $this->formatField($this->getTagValue($this->enderReme, "CEP"), "#####-###");
1162
        $aFont = $this->formatNegrito;
1163
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1164
        $x = $oldX;
1165
        $y += 3;
1166
        $texto = 'CNPJ/CPF';
1167
        $aFont = $this->formatPadrao;
1168
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1169
        $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...
1170
        $aFont = $this->formatNegrito;
1171
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1172
        $x = $w - 45;
1173
        $texto = 'INSCRIÇÃO ESTADUAL';
1174
        $aFont = $this->formatPadrao;
1175
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1176
        $texto = $this->getTagValue($this->rem, "IE");
1177
        $aFont = $this->formatNegrito;
1178
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1179
        $x = $oldX;
1180
        $y += 3;
1181
        $texto = 'PAÍS';
1182
        $aFont = $this->formatPadrao;
1183
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1184
        $texto = $this->getTagValue($this->rem, "xPais") != "" ?
1185
            $this->getTagValue($this->rem, "xPais") : 'BRASIL';
1186
        $aFont = $this->formatNegrito;
1187
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1188
        $x = $w - 25;
1189
        $texto = 'FONE';
1190
        $aFont = $this->formatPadrao;
1191
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1192
        //$texto = $this->formatFone($this->rem);
1193
        $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...
1194
        $aFont = $this->formatNegrito;
1195
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1196
    }
1197
1198
    /**
1199
     * destinatario
1200
     * Monta o campo com os dados do destinatário na DACTE.
1201
     *
1202
     * @param  number $x Posição horizontal canto esquerdo
1203
     * @param  number $y Posição vertical canto superior
1204
     * @return number Posição vertical final
1205
     */
1206
    protected function destinatario($x = 0, $y = 0)
1207
    {
1208
        $oldX = $x;
1209
        $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...
1210
        if ($this->orientacao == 'P') {
1211
            $maxW = $this->wPrint;
1212
        } else {
1213
            $maxW = $this->wPrint - $this->wCanhoto;
1214
        }
1215
        $w = ($maxW * 0.5) - 0.7;
1216
        $h = 19;
1217
        $x1 = $x + 19;
1218
        $texto = 'DESTINATÁRIO';
1219
        $aFont = $this->formatPadrao;
1220
        $this->pdf->textBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1221
        $aFont = $this->formatNegrito;
1222
        $texto = $this->getTagValue($this->dest, "xNome");
1223
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1224
        $y += 3;
1225
        $texto = 'ENDEREÇO';
1226
        $aFont = $this->formatPadrao;
1227
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1228
        $aFont = $this->formatNegrito;
1229
        $texto = $this->getTagValue($this->enderDest, "xLgr") . ',';
1230
        $texto .= $this->getTagValue($this->enderDest, "nro");
1231
        $texto .= $this->getTagValue($this->enderDest, "xCpl") != "" ?
1232
            ' - ' . $this->getTagValue($this->enderDest, "xCpl") : '';
1233
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1234
        $y += 3;
1235
        $texto = $this->getTagValue($this->enderDest, "xBairro");
1236
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1237
        $y += 3;
1238
        $texto = 'MUNICÍPIO';
1239
        $aFont = $this->formatPadrao;
1240
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1241
        $texto = $this->getTagValue($this->enderDest, "xMun") . ' - ';
1242
        $texto .= $this->getTagValue($this->enderDest, "UF");
1243
        $aFont = $this->formatNegrito;
1244
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1245
        $x = $w - 19 + $oldX;
1246
        $texto = 'CEP';
1247
        $aFont = $this->formatPadrao;
1248
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1249
        $texto = $this->formatField($this->getTagValue($this->enderDest, "CEP"), "#####-###");
1250
        $aFont = $this->formatNegrito;
1251
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1252
        $x = $oldX;
1253
        $y += 3;
1254
        $texto = 'CNPJ/CPF';
1255
        $aFont = $this->formatPadrao;
1256
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1257
        $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...
1258
        $aFont = $this->formatNegrito;
1259
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1260
        $x = $w - 47.5 + $oldX;
1261
        $texto = 'INSCRIÇÃO ESTADUAL';
1262
        $aFont = $this->formatPadrao;
1263
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1264
        $texto = $this->getTagValue($this->dest, "IE");
1265
        $aFont = $this->formatNegrito;
1266
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1267
        $x = $oldX;
1268
        $y += 3;
1269
        $texto = 'PAÍS';
1270
        $aFont = $this->formatPadrao;
1271
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1272
        $texto = $this->getTagValue($this->dest, "xPais");
1273
        $aFont = $this->formatNegrito;
1274
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1275
        $x = $w - 27 + $oldX;
1276
        $texto = 'FONE';
1277
        $aFont = $this->formatPadrao;
1278
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1279
        //$texto = $this->formatFone($this->dest);
1280
        $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...
1281
        $aFont = $this->formatNegrito;
1282
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1283
    }
1284
1285
    /**
1286
     * expedidor
1287
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1288
     *
1289
     * @param  number $x Posição horizontal canto esquerdo
1290
     * @param  number $y Posição vertical canto superior
1291
     * @return number Posição vertical final
1292
     */
1293
    protected function expedidor($x = 0, $y = 0)
1294
    {
1295
        $oldX = $x;
1296
        $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...
1297
        if ($this->orientacao == 'P') {
1298
            $maxW = $this->wPrint;
1299
        } else {
1300
            $maxW = $this->wPrint - $this->wCanhoto;
1301
        }
1302
        $w = $maxW * 0.5 + 0.5;
1303
        $h = 19;
1304
        $x1 = $x + 16;
1305
        $texto = 'EXPEDIDOR';
1306
        $aFont = $this->formatPadrao;
1307
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1308
        $aFont = $this->formatNegrito;
1309
        $texto = $this->getTagValue($this->exped, "xNome");
1310
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1311
        $y += 3;
1312
        $texto = 'ENDEREÇO';
1313
        $aFont = $this->formatPadrao;
1314
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1315
        $aFont = $this->formatNegrito;
1316
        if (isset($this->enderExped)) {
1317
            $texto = $this->getTagValue($this->enderExped, "xLgr") . ', ';
1318
            $texto .= $this->getTagValue($this->enderExped, "nro");
1319
            $texto .= $this->getTagValue($this->enderExped, "xCpl") != "" ?
1320
                ' - ' . $this->getTagValue($this->enderExped, "xCpl") :
1321
                '';
1322
        } else {
1323
            $texto = '';
1324
        }
1325
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1326
        $y += 3;
1327
        $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...
1328
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1329
        $y += 3;
1330
        $texto = 'MUNICÍPIO';
1331
        $aFont = $this->formatPadrao;
1332
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1333
        if (isset($this->enderExped)) {
1334
            $texto = $this->getTagValue($this->enderExped, "xMun") . ' - ';
1335
            $texto .= $this->getTagValue($this->enderExped, "UF");
1336
        } else {
1337
            $texto = '';
1338
        }
1339
        $aFont = $this->formatNegrito;
1340
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1341
        $x = $w - 18;
1342
        $texto = 'CEP';
1343
        $aFont = $this->formatPadrao;
1344
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1345
        $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...
1346
        $aFont = $this->formatNegrito;
1347
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1348
        $x = $oldX;
1349
        $y += 3;
1350
        $texto = 'CNPJ/CPF';
1351
        $aFont = $this->formatPadrao;
1352
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1353
        $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...
1354
        $aFont = $this->formatNegrito;
1355
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1356
        $x = $w - 45;
1357
        $texto = 'INSCRIÇÃO ESTADUAL';
1358
        $aFont = $this->formatPadrao;
1359
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1360
        $texto = $this->getTagValue($this->exped, "IE");
1361
        $aFont = $this->formatNegrito;
1362
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1363
        $x = $oldX;
1364
        $y += 3;
1365
        $texto = 'PAÍS';
1366
        $aFont = $this->formatPadrao;
1367
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1368
        $texto = $this->getTagValue($this->exped, "xPais");
1369
        $aFont = $this->formatNegrito;
1370
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1371
        $x = $w - 25;
1372
        $texto = 'FONE';
1373
        $aFont = $this->formatPadrao;
1374
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1375
        if (isset($this->exped)) {
1376
            $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...
1377
            $aFont = $this->formatNegrito;
1378
            $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1379
        }
1380
    }
1381
1382
    /**
1383
     * recebedor
1384
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1385
     *
1386
     * @param  number $x Posição horizontal canto esquerdo
1387
     * @param  number $y Posição vertical canto superior
1388
     * @return number Posição vertical final
1389
     */
1390
    protected function recebedor($x = 0, $y = 0)
1391
    {
1392
        $oldX = $x;
1393
        $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...
1394
        if ($this->orientacao == 'P') {
1395
            $maxW = $this->wPrint;
1396
        } else {
1397
            $maxW = $this->wPrint - $this->wCanhoto;
1398
        }
1399
        $w = ($maxW * 0.5) - 0.7;
1400
        $h = 19;
1401
        $x1 = $x + 19;
1402
        $texto = 'RECEBEDOR';
1403
        $aFont = $this->formatPadrao;
1404
        $this->pdf->textBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1405
        $aFont = $this->formatNegrito;
1406
        $texto = $this->getTagValue($this->receb, "xNome");
1407
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1408
        $y += 3;
1409
        $texto = 'ENDEREÇO';
1410
        $aFont = $this->formatPadrao;
1411
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1412
        $aFont = $this->formatNegrito;
1413
        if (isset($this->enderReceb)) {
1414
            $texto = $this->getTagValue($this->enderReceb, "xLgr") . ', ';
1415
            $texto .= $this->getTagValue($this->enderReceb, "nro");
1416
            $texto .= ($this->getTagValue($this->enderReceb, "xCpl") != "") ?
1417
                ' - ' . $this->getTagValue($this->enderReceb, "xCpl") :
1418
                '';
1419
        } else {
1420
            $texto = '';
1421
        }
1422
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1423
        $y += 3;
1424
        $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...
1425
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1426
        $y += 3;
1427
        $texto = 'MUNICÍPIO';
1428
        $aFont = $this->formatPadrao;
1429
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1430
        if (isset($this->enderReceb)) {
1431
            $texto = $this->getTagValue($this->enderReceb, "xMun") . ' - ';
1432
            $texto .= $this->getTagValue($this->enderReceb, "UF");
1433
        } else {
1434
            $texto = '';
1435
        }
1436
        $aFont = $this->formatNegrito;
1437
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1438
        $x = $w - 19 + $oldX;
1439
        $texto = 'CEP';
1440
        $aFont = $this->formatPadrao;
1441
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1442
        $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...
1443
        $aFont = $this->formatNegrito;
1444
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1445
        $x = $oldX;
1446
        $y += 3;
1447
        $texto = 'CNPJ/CPF';
1448
        $aFont = $this->formatPadrao;
1449
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1450
        $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...
1451
        $aFont = $this->formatNegrito;
1452
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1453
        $x = $w - 47 + $oldX;
1454
        $texto = 'INSCRIÇÃO ESTADUAL';
1455
        $aFont = $this->formatPadrao;
1456
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1457
        $texto = $this->getTagValue($this->receb, "IE");
1458
        $aFont = $this->formatNegrito;
1459
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1460
        $x = $oldX;
1461
        $y += 3;
1462
        $texto = 'PAÍS';
1463
        $aFont = $this->formatPadrao;
1464
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1465
        $texto = $this->getTagValue($this->receb, "xPais");
1466
        $aFont = $this->formatNegrito;
1467
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1468
        $x = $w - 27 + $oldX;
1469
        $texto = 'FONE';
1470
        $aFont = $this->formatPadrao;
1471
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1472
        if (isset($this->receb)) {
1473
            $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...
1474
            $aFont = $this->formatNegrito;
1475
            $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1476
        }
1477
    }
1478
1479
    /**
1480
     * tomador
1481
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1482
     *
1483
     * @param  number $x Posição horizontal canto esquerdo
1484
     * @param  number $y Posição vertical canto superior
1485
     * @return number Posição vertical final
1486
     */
1487
    protected function tomador($x = 0, $y = 0)
1488
    {
1489
        $oldX = $x;
1490
        $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...
1491
        if ($this->orientacao == 'P') {
1492
            $maxW = $this->wPrint;
1493
        } else {
1494
            $maxW = $this->wPrint - $this->wCanhoto;
1495
        }
1496
        $w = $maxW;
1497
        $h = 10;
1498
        $texto = 'TOMADOR DO SERVIÇO';
1499
        $aFont = $this->formatPadrao;
1500
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1501
        $aFont = $this->formatNegrito;
1502
        $texto = $this->getTagValue($this->toma, "xNome");
1503
        $this->pdf->textBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1504
        $x = $maxW * 0.60;
1505
        $texto = 'MUNICÍPIO';
1506
        $aFont = $this->formatPadrao;
1507
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1508
        $texto = $this->getTagValue($this->toma, "xMun");
1509
        $aFont = $this->formatNegrito;
1510
        $this->pdf->textBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1511
        $x = $maxW * 0.85;
1512
        $texto = 'UF';
1513
        $aFont = $this->formatPadrao;
1514
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1515
        $texto = $this->getTagValue($this->toma, "UF");
1516
        $aFont = $this->formatNegrito;
1517
        $this->pdf->textBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1518
        $x = $w - 18;
1519
        $texto = 'CEP';
1520
        $aFont = $this->formatPadrao;
1521
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1522
        $texto = $this->formatField($this->getTagValue($this->toma, "CEP"), "#####-###");
1523
        $aFont = $this->formatNegrito;
1524
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1525
        $y += 3;
1526
        $x = $oldX;
1527
        $texto = 'ENDEREÇO';
1528
        $aFont = $this->formatPadrao;
1529
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1530
        $aFont = $this->formatNegrito;
1531
        $texto = $this->getTagValue($this->toma, "xLgr") . ',';
1532
        $texto .= $this->getTagValue($this->toma, "nro");
1533
        $texto .= ($this->getTagValue($this->toma, "xCpl") != "") ?
1534
            ' - ' . $this->getTagValue($this->toma, "xCpl") : '';
1535
        $texto .= ' - ' . $this->getTagValue($this->toma, "xBairro");
1536
        $this->pdf->textBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1537
        $y += 3;
1538
        $texto = 'CNPJ/CPF';
1539
        $aFont = $this->formatPadrao;
1540
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1541
        $texto = $this->formatCNPJCPF($this->toma);
1542
        $aFont = $this->formatNegrito;
1543
        $this->pdf->textBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1544
        $x = $x + 65;
1545
        $texto = 'INSCRIÇÃO ESTADUAL';
1546
        $aFont = $this->formatPadrao;
1547
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1548
        $texto = $this->getTagValue($this->toma, "IE");
1549
        $aFont = $this->formatNegrito;
1550
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1551
        $x = $w * 0.75;
1552
        $texto = 'PAÍS';
1553
        $aFont = $this->formatPadrao;
1554
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1555
        $texto = $this->getTagValue($this->toma, "xPais") != "" ?
1556
            $this->getTagValue($this->toma, "xPais") : 'BRASIL';
1557
        $aFont = $this->formatNegrito;
1558
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1559
        $x = $w - 27;
1560
        $texto = 'FONE';
1561
        $aFont = $this->formatPadrao;
1562
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1563
        $texto = $this->getTagValue($this->toma, "fone") != "" ? $this->formatFone($this->toma) : '';
1564
        $aFont = $this->formatNegrito;
1565
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1566
    }
1567
1568
    /**
1569
     * descricaoCarga
1570
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1571
     *
1572
     * @param  number $x Posição horizontal canto esquerdo
1573
     * @param  number $y Posição vertical canto superior
1574
     * @return number Posição vertical final
1575
     */
1576
    protected function descricaoCarga($x = 0, $y = 0)
1577
    {
1578
        $oldX = $x;
1579
        $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...
1580
        if ($this->orientacao == 'P') {
1581
            $maxW = $this->wPrint;
1582
        } else {
1583
            $maxW = $this->wPrint - $this->wCanhoto;
1584
        }
1585
        $w = $maxW;
1586
        $h = 17;
1587
        $texto = 'PRODUTO PREDOMINANTE';
1588
        $aFont = array(
1589
            'font' => $this->fontePadrao,
1590
            'size' => 6,
1591
            'style' => '');
1592
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1593
        $texto = $this->getTagValue($this->infCarga, "proPred");
1594
        $aFont = $this->formatNegrito;
1595
        $this->pdf->textBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1596
        $x = $w * 0.56;
1597
        $this->pdf->line($x, $y, $x, $y + 8);
1598
        $aFont = $this->formatPadrao;
1599
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1600
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1601
        $texto = $this->getTagValue($this->infCarga, "xOutCat");
1602
        $aFont = $this->formatNegrito;
1603
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1604
        $x = $w * 0.8;
1605
        $this->pdf->line($x, $y, $x, $y + 8);
1606
        $aFont = $this->formatPadrao;
1607
        $texto = 'VALOR TOTAL DA CARGA';
1608
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1609
        $texto = $this->getTagValue($this->infCarga, "vCarga") == "" ?
1610
            $this->getTagValue($this->infCarga, "vMerc") : $this->getTagValue($this->infCarga, "vCarga");
1611
        $texto = number_format($texto, 2, ",", ".");
1612
        $aFont = $this->formatNegrito;
1613
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1614
        $y += 8;
1615
        $x = $oldX;
1616
        $this->pdf->line($x, $y, $w + 1, $y);
1617
        //Identifica código da unidade
1618
        //01 = KG (QUILOS)
1619
        $qCarga = 0;
1620
        foreach ($this->infQ as $infQ) {
1621
            if (in_array($this->getTagValue($infQ, "cUnid"), array('01', '02'))) {
1622
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1623
            }
1624
        }
1625
        $texto = 'PESO BRUTO (KG)';
1626
        $aFont = array(
1627
            'font' => $this->fontePadrao,
1628
            'size' => 5,
1629
            'style' => '');
1630
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1631
        $texto = number_format($qCarga, 3, ",", ".");
1632
        $aFont = array(
1633
            'font' => $this->fontePadrao,
1634
            'size' => 7,
1635
            'style' => 'B');
1636
        $this->pdf->textBox($x + 2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1637
        $x = $w * 0.12;
1638
        $this->pdf->line($x + 13.5, $y, $x + 13.5, $y + 9);
1639
        $texto = 'PESO BASE CÁLCULO (KG)';
1640
        $aFont = array(
1641
            'font' => $this->fontePadrao,
1642
            'size' => 5,
1643
            'style' => '');
1644
        $this->pdf->textBox($x + 20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1645
        $texto = number_format($qCarga, 3, ",", ".");
1646
        $aFont = array(
1647
            'font' => $this->fontePadrao,
1648
            'size' => 7,
1649
            'style' => 'B');
1650
        $this->pdf->textBox($x + 17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1651
        $x = $w * 0.24;
1652
        $this->pdf->line($x + 25, $y, $x + 25, $y + 9);
1653
        $texto = 'PESO AFERIDO (KG)';
1654
        $aFont = array(
1655
            'font' => $this->fontePadrao,
1656
            'size' => 5,
1657
            'style' => '');
1658
        $this->pdf->textBox($x + 35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1659
        $texto = number_format($qCarga, 3, ",", ".");
1660
        $aFont = array(
1661
            'font' => $this->fontePadrao,
1662
            'size' => 7,
1663
            'style' => 'B');
1664
        $this->pdf->textBox($x + 28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1665
        $x = $w * 0.36;
1666
        $this->pdf->line($x + 41.3, $y, $x + 41.3, $y + 9);
1667
        $texto = 'CUBAGEM(M3)';
1668
        $aFont = $this->formatPadrao;
1669
        $this->pdf->textBox($x + 60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1670
        $qCarga = 0;
1671
        foreach ($this->infQ as $infQ) {
1672
            if ($this->getTagValue($infQ, "cUnid") == '00') {
1673
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1674
            }
1675
        }
1676
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1677
        $aFont = array(
1678
            'font' => $this->fontePadrao,
1679
            'size' => 7,
1680
            'style' => 'B');
1681
        $this->pdf->textBox($x + 50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1682
        $x = $w * 0.45;
1683
        //$this->pdf->line($x+37, $y, $x+37, $y + 9);
1684
        $texto = 'QTDE(VOL)';
1685
        $aFont = $this->formatPadrao;
1686
        $this->pdf->textBox($x + 85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1687
        $qCarga = 0;
1688
        foreach ($this->infQ as $infQ) {
1689
            if ($this->getTagValue($infQ, "cUnid") == '03') {
1690
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1691
            }
1692
        }
1693
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1694
        $aFont = array(
1695
            'font' => $this->fontePadrao,
1696
            'size' => 7,
1697
            'style' => 'B');
1698
        $this->pdf->textBox($x + 85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1699
        $x = $w * 0.53;
1700
        $this->pdf->line($x + 56, $y, $x + 56, $y + 9);
1701
        /*$texto = 'NOME DA SEGURADORA';
1702
        $aFont = $this->formatPadrao;
1703
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1704
        $texto = $this->getTagValue($this->seg, "xSeg");
1705
        $aFont = array(
1706
            'font' => $this->fontePadrao,
1707
            'size' => 7,
1708
            'style' => 'B');
1709
        $this->pdf->textBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1710
        $y += 3;
1711
        $this->pdf->line($x, $y, $w + 1, $y);
1712
        $texto = 'RESPONSÁVEL';
1713
        $aFont = $this->formatPadrao;
1714
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1715
        $texto = $this->respSeg;
1716
        $aFont = array(
1717
            'font' => $this->fontePadrao,
1718
            'size' => 7,
1719
            'style' => 'B');
1720
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1721
        $x = $w * 0.68;
1722
        $this->pdf->line($x, $y, $x, $y + 6);
1723
        $texto = 'NÚMERO DA APOLICE';
1724
        $aFont = $this->formatPadrao;
1725
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1726
        $texto = $this->getTagValue($this->seg, "nApol");
1727
        $aFont = array(
1728
            'font' => $this->fontePadrao,
1729
            'size' => 7,
1730
            'style' => 'B');
1731
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1732
        $x = $w * 0.85;
1733
        $this->pdf->line($x, $y, $x, $y + 6);
1734
        $texto = 'NÚMERO DA AVERBAÇÃO';
1735
        $aFont = $this->formatPadrao;
1736
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1737
        $texto = $this->getTagValue($this->seg, "nAver");
1738
        $aFont = array(
1739
            'font' => $this->fontePadrao,
1740
            'size' => 7,
1741
            'style' => 'B');
1742
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1743
    }
1744
1745
    /**
1746
     * compValorServ
1747
     * Monta o campo com os componentes da prestação de serviços.
1748
     *
1749
     * @param  number $x Posição horizontal canto esquerdo
1750
     * @param  number $y Posição vertical canto superior
1751
     * @return number Posição vertical final
1752
     */
1753
    protected function compValorServ($x = 0, $y = 0)
1754
    {
1755
        $oldX = $x;
1756
        $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...
1757
        if ($this->orientacao == 'P') {
1758
            $maxW = $this->wPrint;
1759
        } else {
1760
            $maxW = $this->wPrint - $this->wCanhoto;
1761
        }
1762
        $w = $maxW;
1763
        $h = 25;
1764
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1765
        $aFont = $this->formatPadrao;
1766
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1767
        $y += 3.4;
1768
        $this->pdf->line($x, $y, $w + 1, $y);
1769
        $texto = 'NOME';
1770
        $aFont = $this->formatPadrao;
1771
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1772
        $yIniDados = $y;
1773
        $x = $w * 0.14;
1774
        $texto = 'VALOR';
1775
        $aFont = $this->formatPadrao;
1776
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1777
        $x = $w * 0.28;
1778
        $this->pdf->line($x, $y, $x, $y + 21.5);
1779
        $texto = 'NOME';
1780
        $aFont = $this->formatPadrao;
1781
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1782
        $x = $w * 0.42;
1783
        $texto = 'VALOR';
1784
        $aFont = $this->formatPadrao;
1785
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1786
        $x = $w * 0.56;
1787
        $this->pdf->line($x, $y, $x, $y + 21.5);
1788
        $texto = 'NOME';
1789
        $aFont = $this->formatPadrao;
1790
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1791
        $x = $w * 0.70;
1792
        $texto = 'VALOR';
1793
        $aFont = $this->formatPadrao;
1794
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1795
        $x = $w * 0.86;
1796
        $this->pdf->line($x, $y, $x, $y + 21.5);
1797
        $y += 1;
1798
        $texto = 'VALOR TOTAL DO SERVIÇO';
1799
        $aFont = $this->formatPadrao;
1800
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1801
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1802
        $aFont = array(
1803
            'font' => $this->fontePadrao,
1804
            'size' => 9,
1805
            'style' => 'B');
1806
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1807
        $y += 10;
1808
        $this->pdf->line($x, $y, $w + 1, $y);
1809
        $y += 1;
1810
        $texto = 'VALOR A RECEBER';
1811
        $aFont = $this->formatPadrao;
1812
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1813
        $texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
1814
        $aFont = array(
1815
            'font' => $this->fontePadrao,
1816
            'size' => 9,
1817
            'style' => 'B');
1818
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1819
        $auxX = $oldX;
1820
        $yIniDados += 4;
1821
        foreach ($this->Comp as $k => $d) {
1822
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1823
            $valor = number_format(
1824
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1825
                2,
1826
                ",",
1827
                "."
1828
            );
1829
            if ($auxX > $w * 0.60) {
1830
                $yIniDados = $yIniDados + 4;
1831
                $auxX = $oldX;
1832
            }
1833
            $texto = $nome;
1834
            $aFont = $this->formatPadrao;
1835
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1836
            $auxX += $w * 0.14;
1837
            $texto = $valor;
1838
            $aFont = $this->formatPadrao;
1839
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1840
            $auxX += $w * 0.14;
1841
        }
1842
    }
1843
1844
    /**
1845
     * impostos
1846
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1847
     *
1848
     * @param  number $x Posição horizontal canto esquerdo
1849
     * @param  number $y Posição vertical canto superior
1850
     * @return number Posição vertical final
1851
     */
1852
    protected function impostos($x = 0, $y = 0)
1853
    {
1854
        $oldX = $x;
1855
        $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...
1856
        if ($this->orientacao == 'P') {
1857
            $maxW = $this->wPrint;
1858
        } else {
1859
            $maxW = $this->wPrint - $this->wCanhoto;
1860
        }
1861
        $w = $maxW;
1862
        $h = 13;
1863
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1864
        $aFont = $this->formatPadrao;
1865
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1866
        $y += 3.4;
1867
        $this->pdf->line($x, $y, $w + 1, $y);
1868
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1869
        $aFont = $this->formatPadrao;
1870
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1871
        $x += $w * 0.26;
1872
        $this->pdf->line($x, $y, $x, $y + 9.5);
1873
        $texto = 'BASE DE CALCULO';
1874
        $aFont = $this->formatPadrao;
1875
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1876
        $wCol02 = 0.15;
1877
        $x += $w * $wCol02;
1878
        $this->pdf->line($x, $y, $x, $y + 9.5);
1879
        $texto = 'ALÍQ ICMS';
1880
        $aFont = $this->formatPadrao;
1881
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1882
        $x += $w * $wCol02;
1883
        $this->pdf->line($x, $y, $x, $y + 9.5);
1884
        $texto = 'VALOR ICMS';
1885
        $aFont = $this->formatPadrao;
1886
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1887
        $x += $w * $wCol02;
1888
        $this->pdf->line($x, $y, $x, $y + 9.5);
1889
        $texto = '% RED. BC ICMS';
1890
        $aFont = $this->formatPadrao;
1891
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1892
        $x += $w * $wCol02;
1893
        $this->pdf->line($x, $y, $x, $y + 9.5);
1894
        $texto = 'VALOR ICMS ST';
1895
        $aFont = $this->formatPadrao;
1896
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1897
        /*$x += $w * 0.14;
1898
        $this->pdf->line($x, $y, $x, $y + 9.5);
1899
        $texto = 'ICMS ST';
1900
        $aFont = $this->formatPadrao;
1901
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1902
         * */
1903
        $x = $oldX;
1904
        $y = $y + 4;
1905
        $texto = $this->getTagValue($this->ICMS, "CST");
1906
        switch ($texto) {
1907
            case '00':
1908
                $texto = "00 - Tributação normal ICMS";
1909
                break;
1910
            case '20':
1911
                $texto = "20 - Tributação com BC reduzida do ICMS";
1912
                break;
1913
            case '40':
1914
                $texto = "40 - ICMS isenção";
1915
                break;
1916
            case '41':
1917
                $texto = "41 - ICMS não tributada";
1918
                break;
1919
            case '51':
1920
                $texto = "51 - ICMS diferido";
1921
                break;
1922
            case '60':
1923
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
1924
                break;
1925
            case '90':
1926
                if ($this->ICMSOutraUF) {
1927
                    $texto = "90 - ICMS Outra UF";
1928
                } else {
1929
                    $texto = "90 - ICMS Outros";
1930
                }
1931
                break;
1932
        }
1933
        if ($this->getTagValue($this->ICMS, "CST") == '60') {
1934
            $aFont = $this->formatNegrito;
1935
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1936
            $x += $w * 0.26;
1937
            $texto = !empty($this->ICMS->getElementsByTagName("vBCSTRet")->item(0)->nodeValue) ?
1938
                number_format($this->getTagValue($this->ICMS, "vBCSTRet"), 2, ",", ".") : (
1939
                !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
1940
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
1941
                );
1942
            $aFont = $this->formatNegrito;
1943
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1944
            $x += $w * $wCol02;
1945
            $texto = !empty($this->ICMS->getElementsByTagName("pICMSSTRet")->item(0)->nodeValue) ?
1946
                number_format($this->getTagValue($this->ICMS, "pICMSSTRet"), 2, ",", ".") : (
1947
                !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
1948
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
1949
                );
1950
            $aFont = $this->formatNegrito;
1951
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1952
            $x += $w * $wCol02;
1953
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
1954
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
1955
                !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
1956
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
1957
                );
1958
            $aFont = $this->formatNegrito;
1959
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1960
            $x += $w * $wCol02;
1961
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
1962
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
1963
                !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
1964
                    number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
1965
                );
1966
            $aFont = $this->formatNegrito;
1967
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1968
            $x += $w * $wCol02;
1969
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
1970
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
1971
            $aFont = $this->formatNegrito;
1972
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1973
        } else {
1974
            $texto = $this->getTagValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
1975
            $aFont = $this->formatNegrito;
1976
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1977
            $x += $w * 0.26;
1978
            $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
1979
                number_format($this->getTagValue($this->ICMS, "vBC"), 2, ",", ".") : (
1980
                !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
1981
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
1982
                );
1983
            $aFont = $this->formatNegrito;
1984
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1985
            $x += $w * $wCol02;
1986
            $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
1987
                number_format($this->getTagValue($this->ICMS, "pICMS"), 2, ",", ".") : (
1988
                !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
1989
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
1990
                );
1991
            $aFont = $this->formatNegrito;
1992
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1993
            $x += $w * $wCol02;
1994
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
1995
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
1996
                !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
1997
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
1998
                );
1999
            $aFont = $this->formatNegrito;
2000
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2001
            $x += $w * $wCol02;
2002
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2003
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2004
                !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2005
                    number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2006
                );
2007
            $aFont = $this->formatNegrito;
2008
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2009
            $x += $w * $wCol02;
2010
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2011
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2012
            $aFont = $this->formatNegrito;
2013
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2014
        }
2015
        /*$x += $w * 0.14;
2016
        $texto = '';
2017
        $aFont = $this->formatNegrito;
2018
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2019
    }
2020
2021
    /**
2022
     * geraChaveAdicCont
2023
     *
2024
     * @return string chave
2025
     */
2026
    protected function geraChaveAdicCont()
2027
    {
2028
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2029
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
2030
        $forma = "%02d%d%s%014d%01d%01d%02d";
2031
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2032
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2033
        $CNPJ = substr($CNPJ, -14);
2034
        $vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
2035
        $ICMS_CST = $this->getTagValue($this->ICMS, "CST");
2036
        switch ($ICMS_CST) {
2037
            case '00':
2038
            case '20':
2039
                $ICMSp = '1';
2040
                $ICMSs = '2';
2041
                break;
2042
            case '40':
2043
            case '41':
2044
            case '51':
2045
            case '90':
2046
                $ICMSp = '2';
2047
                $ICMSs = '2';
2048
                break;
2049
            case '60':
2050
                $ICMSp = '2';
2051
                $ICMSs = '1';
2052
                break;
2053
        }
2054
        $dd = $this->ide->getElementsByTagName('dhEmi')->item(0)->nodeValue;
2055
        $rpos = strrpos($dd, '-');
2056
        $dd = substr($dd, $rpos + 1);
2057
        $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...
2058
        $chave = $chave . $this->modulo11($chave);
2059
        return $chave;
2060
    }
2061
2062
    /**
2063
     * docOrig
2064
     * Monta o campo com os documentos originarios.
2065
     *
2066
     * @param  number $x Posição horizontal canto esquerdo
2067
     * @param  number $y Posição vertical canto superior
2068
     * @return number Posição vertical final
2069
     */
2070
    protected function docOrig($x = 0, $y = 0)
2071
    {
2072
        $oldX = $x;
2073
        $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...
2074
        if ($this->orientacao == 'P') {
2075
            $maxW = $this->wPrint;
2076
        } else {
2077
            $maxW = $this->wPrint - $this->wCanhoto;
2078
        }
2079
        $w = $maxW;
2080
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2081
        if ($this->modal == '1') {
2082
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2083
            // ou combinação veicular, e por viagem
2084
            $h = $this->lota == 1 ? 35 : 53;
2085
        } elseif ($this->modal == '2') {
2086
            $h = 53;
2087
        } elseif ($this->modal == '3') {
2088
            $h = 37.6;
2089
        } else {
2090
            $h = 35;
2091
        }
2092
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2093
        $aFont = $this->formatPadrao;
2094
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2095
        $descr1 = 'TIPO DOC';
2096
        $descr2 = 'CNPJ/CHAVE/OBS';
2097
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2098
        $y += 3.4;
2099
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2100
        $texto = $descr1;
2101
        $aFont = $this->formatPadrao;
2102
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2103
        $yIniDados = $y;
2104
        $x += $w * 0.07;
2105
        $texto = $descr2;
2106
        $aFont = $this->formatPadrao;
2107
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2108
        $x += $w * 0.28;
2109
        $texto = $descr3;
2110
        $aFont = $this->formatPadrao;
2111
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2112
        $x += $w * 0.14;
2113
        if ($this->modal == '1') {
2114
            if ($this->lota == 1) {
2115
                $this->pdf->line($x, $y, $x, $y + 31.5); // TESTE
2116
            } else {
2117
                $this->pdf->line($x, $y, $x, $y + 49.5); // TESTE
2118
            }
2119
        } elseif ($this->modal == '2') {
2120
            $this->pdf->line($x, $y, $x, $y + 49.5);
2121
        } elseif ($this->modal == '3') {
2122
            $this->pdf->line($x, $y, $x, $y + 34.1);
2123
        } else {
2124
            $this->pdf->line($x, $y, $x, $y + 21.5);
2125
        }
2126
        $texto = $descr1;
2127
        $aFont = $this->formatPadrao;
2128
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2129
        $x += $w * 0.08;
2130
        $texto = $descr2;
2131
        $aFont = $this->formatPadrao;
2132
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2133
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2134
        $texto = $descr3;
2135
        $aFont = $this->formatPadrao;
2136
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2137
        $auxX = $oldX;
2138
        $yIniDados += 3;
2139
        foreach ($this->infNF as $k => $d) {
2140
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2141
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2142
            $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...
2143
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2144
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2145
            if ($auxX > $w * 0.90) {
2146
                $yIniDados = $yIniDados + 3;
2147
                $auxX = $oldX;
2148
            }
2149
            $texto = $tp;
2150
            $aFont = array(
2151
                'font' => $this->fontePadrao,
2152
                'size' => 8,
2153
                'style' => '');
2154
            //$this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2155
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2156
            //$auxX += $w * 0.09;
2157
            $auxX += $w * 0.07;
2158
            $texto = $cnpj;
2159
            $aFont = array(
2160
                'font' => $this->fontePadrao,
2161
                'size' => 8,
2162
                'style' => '');
2163
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2164
            $auxX += $w * 0.28;
2165
            $texto = $doc;
2166
            $aFont = array(
2167
                'font' => $this->fontePadrao,
2168
                'size' => 8,
2169
                'style' => '');
2170
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2171
            $auxX += $w * 0.15;
2172
        }
2173
        foreach ($this->infNFe as $k => $d) {
2174
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2175
            $this->arrayNFe[] = $chaveNFe;
2176
        }
2177
        $qtdeNFe = 1;
2178
        if (count($this->arrayNFe) > 15) {
2179
            $this->flagDocOrigContinuacao = 1;
2180
            $qtdeNFe = count($this->arrayNFe);
2181
        }
2182
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
2183
        switch ($qtdeNFe) {
2184
            default:
2185
                $this->totPag = 1;
2186
            case ($qtdeNFe >= 1044):
2187
                $this->totPag = 11;
2188
                break;
2189
            case ($qtdeNFe > 928):
2190
                $this->totPag = 10;
2191
                break;
2192
            case ($qtdeNFe > 812):
2193
                $this->totPag = 9;
2194
                break;
2195
            case ($qtdeNFe > 696):
2196
                $this->totPag = 8;
2197
                break;
2198
            case ($qtdeNFe > 580):
2199
                $this->totPag = 7;
2200
                break;
2201
            case ($qtdeNFe > 464):
2202
                $this->totPag = 6;
2203
                break;
2204
            case ($qtdeNFe > 348):
2205
                $this->totPag = 5;
2206
                break;
2207
            case ($qtdeNFe > 232):
2208
                $this->totPag = 4;
2209
                break;
2210
            case ($qtdeNFe > 116):
2211
                $this->totPag = 3;
2212
                break;
2213
            case ($qtdeNFe > 16):
2214
                $this->totPag = 2;
2215
                break;
2216
            case ($qtdeNFe <= 16):
2217
                $this->totPag = 1;
2218
                break;
2219
        }
2220
        //$r = $this->cabecalho(1, 1, '1', $this->totPag);
2221
        $contador = 0;
2222
        while ($contador < count($this->arrayNFe)) {
2223
            if ($contador == 16) {
2224
                break;
2225
            }
2226
            $tp = 'NF-e';
2227
            $chaveNFe = $this->arrayNFe[$contador];
2228
            $numNFe = substr($chaveNFe, 25, 9);
2229
            $serieNFe = substr($chaveNFe, 22, 3);
2230
            $doc = $serieNFe . '/' . $numNFe;
2231
            if ($auxX > $w * 0.90) {
2232
                $yIniDados = $yIniDados + 3.5;
2233
                $auxX = $oldX;
2234
            }
2235
            $texto = $tp;
2236
            $aFont = array(
2237
                'font' => $this->fontePadrao,
2238
                'size' => 7,
2239
                'style' => '');
2240
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2241
            $auxX += $w * 0.07;
2242
            $texto = $chaveNFe;
2243
            $aFont = array(
2244
                'font' => $this->fontePadrao,
2245
                'size' => 7,
2246
                'style' => '');
2247
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2248
            $auxX += $w * 0.28;
2249
            $texto = $doc;
2250
            $aFont = array(
2251
                'font' => $this->fontePadrao,
2252
                'size' => 7,
2253
                'style' => '');
2254
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2255
            $auxX += $w * 0.15;
2256
            $contador++;
2257
        }
2258
        foreach ($this->infOutros as $k => $d) {
2259
            $temp = $this->infOutros->item($k);
2260
            $tpDoc = $this->getTagValue($temp, "tpDoc");
2261
            $descOutros = $this->getTagValue($temp, "descOutros");
2262
            $nDoc = $this->getTagValue($temp, "nDoc");
2263
            $dEmi = "Emissão: " . date('d/m/Y', strtotime($this->getTagValue($temp, "dEmi")));
2264
            $vDocFisc = $this->getTagValue($temp, "vDocFisc", "Valor: ");
2265
            $dPrev = "Entrega: " . date('d/m/Y', strtotime($this->getTagValue($temp, "dPrev")));
2266
            switch ($tpDoc) {
2267
                case "00":
2268
                    $tpDoc = "00 - Declaração";
2269
                    break;
2270
                case "10":
2271
                    $tpDoc = "10 - Dutoviário";
2272
                    break;
2273
                case "99":
2274
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2275
                    break;
2276
                default:
2277
                    break;
2278
            }
2279
            $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...
2280
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2281
            if ($auxX > $w * 0.90) {
2282
                $yIniDados = $yIniDados + 4;
2283
                $auxX = $oldX;
2284
            }
2285
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2286
            $auxX += $w * 0.09;
2287
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2288
            $auxX += $w * 0.28;
2289
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2290
            $auxX += $w * 0.14;
2291
        }
2292
        foreach ($this->idDocAntEle as $k => $d) {
2293
            $tp = 'CT-e';
2294
            $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...
2295
            $numCTe = substr($chaveCTe, 25, 9);
2296
            $serieCTe = substr($chaveCTe, 22, 3);
2297
            $doc = $serieCTe . '/' . $numCTe;
2298
            if ($auxX > $w * 0.90) {
2299
                $yIniDados = $yIniDados + 4;
2300
                $auxX = $oldX;
2301
            }
2302
            $texto = $tp;
2303
            $aFont = array(
2304
                'font' => $this->fontePadrao,
2305
                'size' => 8,
2306
                'style' => '');
2307
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2308
            $auxX += $w * 0.09;
2309
            $texto = $chaveCTe;
2310
            $aFont = array(
2311
                'font' => $this->fontePadrao,
2312
                'size' => 8,
2313
                'style' => '');
2314
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2315
            $auxX += $w * 0.28;
2316
            $texto = $doc;
2317
            $aFont = array(
2318
                'font' => $this->fontePadrao,
2319
                'size' => 8,
2320
                'style' => '');
2321
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2322
            $auxX += $w * 0.14;
2323
        }
2324
        foreach ($this->infCTeMultimodal as $k => $d) {
2325
            $tp = 'CT-e';
2326
            $chaveCTe = $this->infCTeMultimodal->item($k)->getElementsByTagName('chCTeMultimodal')->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The method item cannot be called on $this->infCTeMultimodal (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...
2327
            $numCTe = substr($chaveCTe, 25, 9);
2328
            $serieCTe = substr($chaveCTe, 22, 3);
2329
            $doc = $serieCTe . '/' . $numCTe;
2330
            if ($auxX > $w * 0.90) {
2331
                $yIniDados = $yIniDados + 4;
2332
                $auxX = $oldX;
2333
            }
2334
            $texto = $tp;
2335
            $aFont = array(
2336
                'font' => $this->fontePadrao,
2337
                'size' => 8,
2338
                'style' => '');
2339
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2340
            $auxX += $w * 0.09;
2341
            $texto = $chaveCTe;
2342
            $aFont = array(
2343
                'font' => $this->fontePadrao,
2344
                'size' => 8,
2345
                'style' => '');
2346
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2347
            $auxX += $w * 0.28;
2348
            $texto = $doc;
2349
            $aFont = array(
2350
                'font' => $this->fontePadrao,
2351
                'size' => 8,
2352
                'style' => '');
2353
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2354
            $auxX += $w * 0.14;
2355
        }
2356
    }
2357
2358
    /**
2359
     * docOrigContinuacao
2360
     * Monta o campo com os documentos originarios.
2361
     *
2362
     * @param  number $x Posição horizontal canto esquerdo
2363
     * @param  number $y Posição vertical canto superior
2364
     * @return number Posição vertical final
2365
     */
2366
    protected function docOrigContinuacao($x = 0, $y = 0)
2367
    {
2368
        $x2 = $x;
2369
        $y2 = $y;
2370
        $contador = 16;
2371
        for ($i = 2; $i <= $this->totPag; $i++) {
2372
            $x = $x2;
2373
            $y = $y2;
2374
            $this->pdf->AddPage($this->orientacao, $this->papel);
2375
            $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...
2376
            $oldX = $x;
2377
            $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...
2378
            if ($this->orientacao == 'P') {
2379
                $maxW = $this->wPrint;
2380
            } else {
2381
                $maxW = $this->wPrint - $this->wCanhoto;
2382
            }
2383
            $w = $maxW;
2384
            //$h = 6; // de sub-titulo
2385
            //$h = 6 + 3; // de altura do texto (primeira linha
2386
            //$h = 9 + 3.5 ;// segunda linha
2387
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
2388
            $h = (((count($this->arrayNFe) / 2) - 9) * 3.5) + 9;
2389
            if (count($this->arrayNFe) % 2 != 0) {
2390
                $h = $h + 3.5;
2391
            } // Caso tenha apenas 1 registro na ultima linha
2392
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2393
            $aFont = $this->formatPadrao;
2394
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2395
            $descr1 = 'TIPO DOC';
2396
            $descr2 = 'CNPJ/CHAVE/OBS';
2397
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2398
            $y += 3.4;
2399
            $this->pdf->line($x, $y, $w + 1, $y);
2400
            $texto = $descr1;
2401
            $aFont = $this->formatPadrao;
2402
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2403
            $yIniDados = $y;
2404
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2405
            $texto = $descr2;
2406
            $aFont = $this->formatPadrao;
2407
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2408
            $x += $w * 0.28;
2409
            $texto = $descr3;
2410
            $aFont = $this->formatPadrao;
2411
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2412
            $x += $w * 0.14;
2413
            if ($this->modal == '1') {
2414
                if ($this->lota == 1) {
2415
                    $this->pdf->line($x, $y, $x, $y + 31.5);
2416
                } else {
2417
                    $this->pdf->line($x, $y, $x, $y + 49.5);
2418
                }
2419
            } elseif ($this->modal == '2') {
2420
                $this->pdf->line($x, $y, $x, $y + 49.5);
2421
            } elseif ($this->modal == '3') {
2422
                $this->pdf->line($x, $y, $x, $y + 34.1);
2423
            } else {
2424
                $this->pdf->line($x, $y, $x, $y + 21.5);
2425
            }
2426
            $texto = $descr1;
2427
            $aFont = $this->formatPadrao;
2428
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2429
            $x += $w * 0.08;
2430
            $texto = $descr2;
2431
            $aFont = $this->formatPadrao;
2432
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2433
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2434
            $texto = $descr3;
2435
            $aFont = $this->formatPadrao;
2436
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2437
            $auxX = $oldX;
2438
            $yIniDados += 3;
2439
            while ($contador < (count($this->arrayNFe))) {
2440
                if ($contador % (116 * ($i - 1)) == 0) {
2441
//                    $contador++;
2442
                    break;
2443
                }
2444
                $tp = 'NF-e';
2445
                $chaveNFe = $this->arrayNFe[$contador];
2446
                $numNFe = substr($chaveNFe, 25, 9);
2447
                $serieNFe = substr($chaveNFe, 22, 3);
2448
                $doc = $serieNFe . '/' . $numNFe;
2449
                if ($auxX > $w * 0.90) {
2450
                    $yIniDados = $yIniDados + 3.5;
2451
                    $auxX = $oldX;
2452
                }
2453
                $texto = $tp;
2454
                $aFont = array(
2455
                    'font' => $this->fontePadrao,
2456
                    'size' => 7,
2457
                    'style' => '');
2458
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2459
                $auxX += $w * 0.07;
2460
                $texto = $chaveNFe;
2461
                $aFont = array(
2462
                    'font' => $this->fontePadrao,
2463
                    'size' => 7,
2464
                    'style' => '');
2465
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2466
                $auxX += $w * 0.28;
2467
                $texto = $doc;
2468
                $aFont = array(
2469
                    'font' => $this->fontePadrao,
2470
                    'size' => 7,
2471
                    'style' => '');
2472
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2473
                $auxX += $w * 0.15;
2474
                $contador++;
2475
            }
2476
        }
2477
    }
2478
2479
    /**
2480
     * docCompl
2481
     * Monta o campo com os dados do remetente na DACTE.
2482
     *
2483
     * @param number $x Posição horizontal canto esquerdo
2484
     * @param number $y Posição vertical canto superior
2485
     * @return number Posição vertical final
2486
     */
2487
    protected function docCompl($x = 0, $y = 0)
2488
    {
2489
        $oldX = $x;
2490
        $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...
2491
        if ($this->orientacao == 'P') {
2492
            $maxW = $this->wPrint;
2493
        } else {
2494
            $maxW = $this->wPrint - $this->wCanhoto;
2495
        }
2496
        $w = $maxW;
2497
        $h = 80;
2498
        if ($this->tpCTe == 1) {
2499
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2500
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2501
            $descr2 = 'VALOR COMPLEMENTADO';
2502
        } else {
2503
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2504
            $descr1 = 'CHAVE DO CT-E ANULADO';
2505
            $descr2 = 'VALOR ANULADO';
2506
        }
2507
        $aFont = $this->formatPadrao;
2508
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2509
        $y += 3.4;
2510
        $this->pdf->line($x, $y, $w + 1, $y);
2511
        $texto = $descr1;
2512
        $aFont = $this->formatPadrao;
2513
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2514
        $yIniDados = $y;
2515
        $x += $w * 0.37;
2516
        $texto = $descr2;
2517
        $aFont = $this->formatPadrao;
2518
        $this->pdf->textBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2519
        $x += $w * 0.13;
2520
        $this->pdf->line($x, $y, $x, $y + 76.5);
2521
        $texto = $descr1;
2522
        $aFont = $this->formatPadrao;
2523
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2524
        $x += $w * 0.3;
2525
        $texto = $descr2;
2526
        $aFont = $this->formatPadrao;
2527
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2528
        $auxX = $oldX;
2529
        $yIniDados += 4;
2530
        if ($auxX > $w * 0.90) {
2531
            $yIniDados = $yIniDados + 4;
2532
            $auxX = $oldX;
2533
        }
2534
        $texto = $this->chaveCTeRef;
2535
        $aFont = array(
2536
            'font' => $this->fontePadrao,
2537
            'size' => 8,
2538
            'style' => '');
2539
        $this->pdf->textBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2540
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
2541
        $aFont = array(
2542
            'font' => $this->fontePadrao,
2543
            'size' => 8,
2544
            'style' => '');
2545
        $this->pdf->textBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2546
    }
2547
2548
    /**
2549
     * observacao
2550
     * Monta o campo com os dados do remetente na DACTE.
2551
     *
2552
     * @param  number $x Posição horizontal canto esquerdo
2553
     * @param  number $y Posição vertical canto superior
2554
     * @return number Posição vertical final
2555
     */
2556
    protected function observacao($x = 0, $y = 0)
2557
    {
2558
        $oldX = $x;
2559
        $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...
2560
        if ($this->orientacao == 'P') {
2561
            $maxW = $this->wPrint;
2562
        } else {
2563
            $maxW = $this->wPrint - $this->wCanhoto;
2564
        }
2565
        $w = $maxW;
2566
        //$h = 18;
2567
        $h = 18.8;
2568
        $texto = 'OBSERVAÇÕES';
2569
        $aFont = $this->formatPadrao;
2570
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2571
        $y += 3.4;
2572
        $this->pdf->line($x, $y, $w + 1, $y);
2573
        $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...
2574
        $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...
2575
        $texto = '';
2576
        foreach ($this->compl as $k => $d) {
2577
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
2578
            $texto .= $xObs;
2579
        }
2580
        $textoObs = explode("Motorista:", $texto);
2581
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: " . $textoObs[1] : '';
2582
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
2583
        $aFont = array(
2584
            'font' => $this->fontePadrao,
2585
            'size' => 7.5,
2586
            'style' => '');
2587
        $this->pdf->textBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2588
        $this->pdf->textBox($x, $y + 11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2589
    }
2590
2591
    /**
2592
     * modalRod
2593
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2594
     *
2595
     * @param  number $x Posição horizontal canto esquerdo
2596
     * @param  number $y Posição vertical canto superior
2597
     * @return number Posição vertical final
2598
     */
2599
    protected function modalRod($x = 0, $y = 0)
2600
    {
2601
        $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...
2602
        $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...
2603
        $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...
2604
        if ($this->orientacao == 'P') {
2605
            $maxW = $this->wPrint;
2606
        } else {
2607
            $maxW = $this->wPrint - $this->wCanhoto;
2608
        }
2609
        $w = $maxW;
2610
        $h = 3;
2611
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2612
        $aFont = $this->formatPadrao;
2613
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2614
        if ($this->lota == 1) {
2615
            $this->pdf->line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2616
        }
2617
        $y += 3.4;
2618
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2619
        $texto = 'RNTRC DA EMPRESA';
2620
        $aFont = $this->formatPadrao;
2621
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2622
        $texto = $this->getTagValue($this->rodo, "RNTRC");
2623
        $aFont = $this->formatNegrito;
2624
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2625
        $x += $w * 0.23;
2626
        $this->pdf->line($x - 20, $y, $x - 20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2627
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2628
        $aFont = $this->formatPadrao;
2629
        $this->pdf->textBox($x - 20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2630
    }
2631
2632
    /**
2633
     * modalAereo
2634
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2635
     *
2636
     * @param  number $x Posição horizontal canto esquerdo
2637
     * @param  number $y Posição vertical canto superior
2638
     * @return number Posição vertical final
2639
     */
2640
    protected function modalAereo($x = 0, $y = 0)
2641
    {
2642
        $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...
2643
        $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...
2644
        $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...
2645
        if ($this->orientacao == 'P') {
2646
            $maxW = $this->wPrint;
2647
        } else {
2648
            $maxW = $this->wPrint - $this->wCanhoto;
2649
        }
2650
        $w = $maxW;
2651
        $h = 3;
2652
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2653
        $aFont = $this->formatPadrao;
2654
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2655
        $y += 3.4;
2656
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2657
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2658
        $aFont = $this->formatPadrao;
2659
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2660
        $texto = 'CLASSE DA TARIFA';
2661
        $aFont = $this->formatPadrao;
2662
        $this->pdf->textBox($x + 50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2663
        $texto = 'CÓDIGO DA TARIFA';
2664
        $aFont = $this->formatPadrao;
2665
        $this->pdf->textBox($x + 80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2666
        $texto = 'VALOR DA TARIFA';
2667
        $aFont = $this->formatPadrao;
2668
        $this->pdf->textBox($x + 110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2669
        $texto = $this->getTagValue($this->aereo, "nOCA");
2670
        $aFont = $this->formatNegrito;
2671
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2672
        $x += $w * 0.23;
2673
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2674
        $texto = $this->getTagValue($this->aereo, "CL");
2675
        $aFont = $this->formatNegrito;
2676
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2677
        $x += 30;
2678
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2679
        $texto = $this->getTagValue($this->aereo, "cTar");
2680
        $aFont = $this->formatNegrito;
2681
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2682
        $x += 30;
2683
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2684
        $texto = $this->getTagValue($this->aereo, "vTar");
2685
        $aFont = $this->formatNegrito;
2686
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2687
    }
2688
2689
    /**
2690
     * modalAquaviario
2691
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2692
     *
2693
     * @param  number $x Posição horizontal canto esquerdo
2694
     * @param  number $y Posição vertical canto superior
2695
     * @return number Posição vertical final
2696
     */
2697
    protected function modalAquaviario($x = 0, $y = 0)
2698
    {
2699
        $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...
2700
        $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...
2701
        if ($this->orientacao == 'P') {
2702
            $maxW = $this->wPrint;
2703
        } else {
2704
            $maxW = $this->wPrint - $this->wCanhoto;
2705
        }
2706
        $w = $maxW;
2707
        $h = 8.5;
2708
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2709
        $aFont = $this->formatPadrao;
2710
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2711
        $y += 3.4;
2712
        $this->pdf->line($x, $y, $w + 1, $y);
2713
        $texto = 'PORTO DE EMBARQUE';
2714
        $aFont = $this->formatPadrao;
2715
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2716
        $texto = $this->getTagValue($this->aquav, "prtEmb");
2717
        $aFont = $this->formatNegrito;
2718
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2719
        $x += $w * 0.50;
2720
        $this->pdf->line($x, $y, $x, $y + 7.7);
2721
        $texto = 'PORTO DE DESTINO';
2722
        $aFont = $this->formatPadrao;
2723
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2724
        $texto = $this->getTagValue($this->aquav, "prtDest");
2725
        $aFont = $this->formatNegrito;
2726
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2727
        $y += 8;
2728
        $this->pdf->line(208, $y, 1, $y);
2729
        $x = 1;
2730
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2731
        $aFont = $this->formatPadrao;
2732
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2733
        $texto = $this->getTagValue($this->aquav, "xNavio");
2734
        $aFont = $this->formatNegrito;
2735
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2736
        $x += $w * 0.50;
2737
        $this->pdf->line($x, $y, $x, $y + 7.7);
2738
        $texto = 'VR DA B. DE CALC. AFRMM';
2739
        $aFont = $this->formatPadrao;
2740
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2741
        $texto = $this->getTagValue($this->aquav, "vPrest");
2742
        $aFont = $this->formatNegrito;
2743
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2744
        $x += $w * 0.17;
2745
        $this->pdf->line($x, $y, $x, $y + 7.7);
2746
        $texto = 'VALOR DO AFRMM';
2747
        $aFont = $this->formatPadrao;
2748
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2749
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
2750
        $aFont = $this->formatNegrito;
2751
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2752
        $x += $w * 0.12;
2753
        $this->pdf->line($x, $y, $x, $y + 7.7);
2754
        $texto = 'TIPO DE NAVEGAÇÃO';
2755
        $aFont = $this->formatPadrao;
2756
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2757
        $texto = $this->getTagValue($this->aquav, "tpNav");
2758
        switch ($texto) {
2759
            case '0':
2760
                $texto = 'INTERIOR';
2761
                break;
2762
            case '1':
2763
                $texto = 'CABOTAGEM';
2764
                break;
2765
        }
2766
        $aFont = $this->formatNegrito;
2767
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2768
        $x += $w * 0.14;
2769
        $this->pdf->line($x, $y, $x, $y + 7.7);
2770
        $texto = 'DIREÇÃO';
2771
        $aFont = $this->formatPadrao;
2772
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2773
        $texto = $this->getTagValue($this->aquav, "direc");
2774
        switch ($texto) {
2775
            case 'N':
2776
                $texto = 'NORTE';
2777
                break;
2778
            case 'L':
2779
                $texto = 'LESTE';
2780
                break;
2781
            case 'S':
2782
                $texto = 'SUL';
2783
                break;
2784
            case 'O':
2785
                $texto = 'OESTE';
2786
                break;
2787
        }
2788
        $aFont = $this->formatNegrito;
2789
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2790
        $y += 8;
2791
        $this->pdf->line(208, $y, 1, $y);
2792
        $x = 1;
2793
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2794
        $aFont = $this->formatPadrao;
2795
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2796
        if (($this->infNF->item(0) !== null)
2797
            && ($this->infNF->item(0)->getElementsByTagName('infUnidCarga')->item(0)->nodeValue !== null)) {
2798
            $texto = $this->infNF
2799
                ->item(0)
2800
                ->getElementsByTagName('infUnidCarga')
2801
                ->item(0)
2802
                ->getElementsByTagName('idUnidCarga')
2803
                ->item(0)->nodeValue;
2804
        } elseif (($this->infNFe->item(0) !== null)
2805
            && ($this->infNFe->item(0)->getElementsByTagName('infUnidCarga')->item(0)->nodeValue !== null)) {
2806
            $texto = $this->infNFe
2807
                ->item(0)
2808
                ->getElementsByTagName('infUnidCarga')
2809
                ->item(0)
2810
                ->getElementsByTagName('idUnidCarga')
2811
                ->item(0)
2812
                ->nodeValue;
2813
        } elseif (($this->infOutros->item(0) !== null)
2814
            && ($this->infOutros->item(0)->getElementsByTagName('infUnidCarga')->item(0)->nodeValue !== null)) {
2815
            $texto = $this->infOutros
2816
                ->item(0)
2817
                ->getElementsByTagName('infUnidCarga')
2818
                ->item(0)
2819
                ->getElementsByTagName('idUnidCarga')
2820
                ->item(0)
2821
                ->nodeValue;
2822
        } else {
2823
            $texto = '';
2824
        }
2825
        $aFont = $this->formatNegrito;
2826
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2827
        $x += $w * 0.50;
2828
        $this->pdf->line($x, $y, $x, $y + 7.7);
2829
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2830
        $aFont = $this->formatPadrao;
2831
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2832
        $texto = '';
2833
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
2834
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2835
                if ($k == 0) {
2836
                    $texto = $this->aquav
2837
                        ->getElementsByTagName('balsa')
2838
                        ->item($k)
2839
                        ->getElementsByTagName('xBalsa')
2840
                        ->item(0)
2841
                        ->nodeValue;
2842
                } else {
2843
                    $texto = $texto
2844
                        . ' / '
2845
                        . $this->aquav
2846
                            ->getElementsByTagName('balsa')
2847
                            ->item($k)
2848
                            ->getElementsByTagName('xBalsa')
2849
                            ->item(0)
2850
                            ->nodeValue;
2851
                }
2852
            }
2853
        }
2854
        $aFont = $this->formatNegrito;
2855
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2856
    }
2857
2858
    /**
2859
     * modalFerr
2860
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2861
     *
2862
     * @param  number $x Posição horizontal canto esquerdo
2863
     * @param  number $y Posição vertical canto superior
2864
     * @return number Posição vertical final
2865
     */
2866
    protected function modalFerr($x = 0, $y = 0)
2867
    {
2868
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX is not used, you could remove the assignment.

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

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

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

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

Loading history...
2869
        $oldY = $y;
0 ignored issues
show
Unused Code introduced by
$oldY is not used, you could remove the assignment.

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

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

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

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

Loading history...
2870
        if ($this->orientacao == 'P') {
2871
            $maxW = $this->wPrint;
2872
        } else {
2873
            $maxW = $this->wPrint - $this->wCanhoto;
2874
        }
2875
        $w = $maxW;
2876
        $h = 19.6;
2877
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2878
        $aFont = $this->formatPadrao;
2879
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2880
        $y += 3.4;
2881
        $this->pdf->line($x, $y, $w + 1, $y);
2882
        $texto = 'DCL';
2883
        $aFont = array(
2884
            'font' => $this->fontePadrao,
2885
            'size' => 7,
2886
            'style' => 'B');
2887
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2888
        $this->pdf->line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2889
        $texto = 'VAGÕES';
2890
        $aFont = array(
2891
            'font' => $this->fontePadrao,
2892
            'size' => 7,
2893
            'style' => 'B');
2894
        $this->pdf->textBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2895
        $y += 3.4;
2896
        $this->pdf->line($x, $y, $w + 1, $y);
2897
        // DCL
2898
        $texto = 'ID TREM';
2899
        $aFont = array(
2900
            'font' => $this->fontePadrao,
2901
            'size' => 6,
2902
            'style' => '');
2903
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2904
        $texto = $this->getTagValue($this->ferrov, "idTrem");
2905
        $aFont = array(
2906
            'font' => $this->fontePadrao,
2907
            'size' => 6,
2908
            'style' => 'B');
2909
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2910
        $x += $w * 0.06;
2911
        $y1 = $y + 12.5;
2912
        $this->pdf->line($x, $y, $x, $y1);
2913
        $texto = 'NUM';
2914
        $aFont = array(
2915
            'font' => $this->fontePadrao,
2916
            'size' => 6,
2917
            'style' => '');
2918
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2919
        $texto = $this->getTagValue($this->rem, "nDoc");
2920
        $aFont = array(
2921
            'font' => $this->fontePadrao,
2922
            'size' => 6,
2923
            'style' => 'B');
2924
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2925
        $x += $w * 0.06;
2926
        $this->pdf->line($x, $y, $x, $y1);
2927
        $texto = 'SÉRIE';
2928
        $aFont = array(
2929
            'font' => $this->fontePadrao,
2930
            'size' => 6,
2931
            'style' => '');
2932
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2933
        $texto = $this->getTagValue($this->rem, "serie");
2934
        $aFont = array(
2935
            'font' => $this->fontePadrao,
2936
            'size' => 6,
2937
            'style' => 'B');
2938
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2939
        $x += $w * 0.06;
2940
        $this->pdf->line($x, $y, $x, $y1);
2941
        $texto = 'EMISSÃO';
2942
        $aFont = array(
2943
            'font' => $this->fontePadrao,
2944
            'size' => 6,
2945
            'style' => '');
2946
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2947
        $texto = $this->ymdTodmy($this->getTagValue($this->rem, "dEmi"));
2948
        $aFont = array(
2949
            'font' => $this->fontePadrao,
2950
            'size' => 6,
2951
            'style' => 'B');
2952
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2953
        // VAGOES
2954
        $x += $w * 0.06;
2955
        $this->pdf->line($x, $y, $x, $y1);
2956
        $texto = 'NUM';
2957
        $aFont = array(
2958
            'font' => $this->fontePadrao,
2959
            'size' => 6,
2960
            'style' => '');
2961
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2962
        $texto = $this->getTagValue($this->ferrov, "nVag");
2963
        $aFont = array(
2964
            'font' => $this->fontePadrao,
2965
            'size' => 6,
2966
            'style' => 'B');
2967
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2968
        $x += $w * 0.06;
2969
        $this->pdf->line($x, $y, $x, $y1);
2970
        $texto = 'TIPO';
2971
        $aFont = array(
2972
            'font' => $this->fontePadrao,
2973
            'size' => 6,
2974
            'style' => '');
2975
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2976
        $texto = $this->getTagValue($this->ferrov, "tpVag");
2977
        $aFont = array(
2978
            'font' => $this->fontePadrao,
2979
            'size' => 6,
2980
            'style' => 'B');
2981
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2982
        $x += $w * 0.06;
2983
        $this->pdf->line($x, $y, $x, $y1);
2984
        $texto = 'CAPACIDADE';
2985
        $aFont = array(
2986
            'font' => $this->fontePadrao,
2987
            'size' => 6,
2988
            'style' => '');
2989
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2990
        $texto = $this->getTagValue($this->ferrov, "cap");
2991
        $aFont = array(
2992
            'font' => $this->fontePadrao,
2993
            'size' => 6,
2994
            'style' => 'B');
2995
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2996
        $x += $w * 0.08;
2997
        $this->pdf->line($x, $y, $x, $y1);
2998
        $texto = 'PESO REAL/TON';
2999
        $aFont = array(
3000
            'font' => $this->fontePadrao,
3001
            'size' => 6,
3002
            'style' => '');
3003
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3004
        $texto = $this->getTagValue($this->ferrov, "pesoR");
3005
        $aFont = array(
3006
            'font' => $this->fontePadrao,
3007
            'size' => 6,
3008
            'style' => 'B');
3009
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3010
        $x += $w * 0.09;
3011
        $this->pdf->line($x, $y, $x, $y1);
3012
        $texto = 'PESO BRUTO/TON';
3013
        $aFont = array(
3014
            'font' => $this->fontePadrao,
3015
            'size' => 6,
3016
            'style' => '');
3017
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3018
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
3019
        $aFont = array(
3020
            'font' => $this->fontePadrao,
3021
            'size' => 6,
3022
            'style' => 'B');
3023
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3024
        $x += $w * 0.1;
3025
        $this->pdf->line($x, $y, $x, $y1);
3026
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3027
        $aFont = array(
3028
            'font' => $this->fontePadrao,
3029
            'size' => 6,
3030
            'style' => '');
3031
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3032
        $texto = $this->getTagValue($this->ferrov, "nCont");
3033
        $aFont = array(
3034
            'font' => $this->fontePadrao,
3035
            'size' => 6,
3036
            'style' => 'B');
3037
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3038
        // FLUXO
3039
        $x = 1;
3040
        $y += 12.9;
3041
        $h1 = $h * 0.5 + 0.27;
3042
        $wa = round($w * 0.103) + 0.5;
3043
        $texto = 'FLUXO FERROVIARIO';
3044
        $aFont = $this->formatPadrao;
3045
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3046
        $texto = $this->getTagValue($this->ferrov, "fluxo");
3047
        $aFont = array(
3048
            'font' => $this->fontePadrao,
3049
            'size' => 7,
3050
            'style' => 'B');
3051
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3052
        $y += 10;
3053
        $texto = 'TIPO DE TRÁFEGO';
3054
        $aFont = $this->formatPadrao;
3055
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3056
        $texto = $this->convertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
3057
        $aFont = array(
3058
            'font' => $this->fontePadrao,
3059
            'size' => 7,
3060
            'style' => 'B');
3061
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3062
        // Novo Box Relativo a Modal Ferroviário
3063
        $x = 22.5;
3064
        $y += -10.2;
3065
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3066
        $aFont = $this->formatPadrao;
3067
        $this->pdf->textBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3068
        $y += 3.4;
3069
        $this->pdf->line($x, $y, $w + 1, $y);
3070
        $w = $w * 0.2;
3071
        $h = $h * 1.04;
3072
        $texto = 'CÓDIGO INTERNO';
3073
        $aFont = array(
3074
            'font' => $this->fontePadrao,
3075
            'size' => 6,
3076
            'style' => '');
3077
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3078
        $texto = $this->getTagValue($this->ferrov, "cInt");
3079
        $aFont = array(
3080
            'font' => $this->fontePadrao,
3081
            'size' => 6,
3082
            'style' => 'B');
3083
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3084
        $texto = 'CNPJ';
3085
        $aFont = array(
3086
            'font' => $this->fontePadrao,
3087
            'size' => 6,
3088
            'style' => '');
3089
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3090
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
3091
        $aFont = array(
3092
            'font' => $this->fontePadrao,
3093
            'size' => 6,
3094
            'style' => 'B');
3095
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3096
        $x += 50;
3097
        $texto = 'NOME';
3098
        $aFont = array(
3099
            'font' => $this->fontePadrao,
3100
            'size' => 6,
3101
            'style' => '');
3102
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3103
        $texto = $this->getTagValue($this->ferrov, "xNome");
3104
        $aFont = array(
3105
            'font' => $this->fontePadrao,
3106
            'size' => 6,
3107
            'style' => 'B');
3108
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3109
        $texto = 'INSCRICAO ESTADUAL';
3110
        $aFont = array(
3111
            'font' => $this->fontePadrao,
3112
            'size' => 6,
3113
            'style' => '');
3114
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3115
        $texto = $this->getTagValue($this->ferrov, "IE");
3116
        $aFont = array(
3117
            'font' => $this->fontePadrao,
3118
            'size' => 6,
3119
            'style' => 'B');
3120
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3121
        $x += 50;
3122
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3123
        $aFont = array(
3124
            'font' => $this->fontePadrao,
3125
            'size' => 6,
3126
            'style' => '');
3127
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3128
        $texto = '';
3129
        $aFont = array(
3130
            'font' => $this->fontePadrao,
3131
            'size' => 6,
3132
            'style' => 'B');
3133
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3134
    }
3135
3136
    /**
3137
     * canhoto
3138
     * Monta o campo com os dados do remetente na DACTE.
3139
     *
3140
     * @param  number $x Posição horizontal canto esquerdo
3141
     * @param  number $y Posição vertical canto superior
3142
     * @return number Posição vertical final
3143
     */
3144
    protected function canhoto($x = 0, $y = 0)
3145
    {
3146
        $oldX = $x;
3147
        $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...
3148
        if ($this->orientacao == 'P') {
3149
            $maxW = $this->wPrint;
3150
        } else {
3151
            $maxW = $this->wPrint - $this->wCanhoto;
3152
        }
3153
        $w = $maxW - 1;
3154
        $h = 20;
3155
        $y = $y + 1;
3156
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3157
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3158
        $aFont = $this->formatPadrao;
3159
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3160
        $y += 3.4;
3161
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3162
        $texto = 'NOME';
3163
        $aFont = array(
3164
            'font' => $this->fontePadrao,
3165
            'size' => 6,
3166
            'style' => '');
3167
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3168
        $x += $w * 0.25;
3169
        $this->pdf->line($x, $y, $x, $y + 16.5);
3170
        $texto = 'ASSINATURA / CARIMBO';
3171
        $aFont = array(
3172
            'font' => $this->fontePadrao,
3173
            'size' => 6,
3174
            'style' => '');
3175
        $this->pdf->textBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3176
        $x += $w * 0.25;
3177
        $this->pdf->line($x, $y, $x, $y + 16.5);
3178
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n" . "\r\n";
3179
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3180
        $aFont = array(
3181
            'font' => $this->fontePadrao,
3182
            'size' => 6,
3183
            'style' => '');
3184
        $this->pdf->textBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3185
        $x = $oldX;
3186
        $y = $y + 5;
3187
        $this->pdf->line($x, $y + 3, $w * 0.255, $y + 3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3188
        $texto = 'RG';
3189
        $aFont = array(
3190
            'font' => $this->fontePadrao,
3191
            'size' => 6,
3192
            'style' => '');
3193
        $this->pdf->textBox($x, $y + 3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3194
        $x += $w * 0.85;
3195
        $this->pdf->line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3196
        $texto = "CT-E";
3197
        $aFont = $this->formatNegrito;
3198
        $this->pdf->textBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3199
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
3200
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
3201
        $aFont = array(
3202
            'font' => $this->fontePadrao,
3203
            'size' => 6,
3204
            'style' => '');
3205
        $this->pdf->textBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3206
        $x = $oldX;
3207
        $this->pdf->dashedHLine($x, $y + 12.7, $this->wPrint, 0.1, 80);
3208
    }
3209
3210
    /**
3211
     * dadosAdic
3212
     * Coloca o grupo de dados adicionais da DACTE.
3213
     *
3214
     * @param  number $x Posição horizontal canto esquerdo
3215
     * @param  number $y Posição vertical canto superior
3216
     * @param  number $h altura do campo
3217
     * @return number Posição vertical final
3218
     */
3219
    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...
3220
    {
3221
        $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...
3222
        //###########################################################################
3223
        //DADOS ADICIONAIS DACTE
3224
        if ($this->orientacao == 'P') {
3225
            $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...
3226
        } else {
3227
            $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...
3228
        }
3229
        //INFORMAÇÕES COMPLEMENTARES
3230
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3231
        $y += 3;
3232
        $w = $this->wAdic;
3233
        $h = 8; //mudar
3234
        $aFont = array(
3235
            'font' => $this->fontePadrao,
3236
            'size' => 6,
3237
            'style' => '');
3238
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3239
        //$this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3240
        $this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3241
        //o texto com os dados adicionais foi obtido na função xxxxxx
3242
        //e carregado em uma propriedade privada da classe
3243
        //$this->wAdic com a largura do campo
3244
        //$this->textoAdic com o texto completo do campo
3245
        $y += 1;
3246
        $aFont = $this->formatPadrao;
3247
        $this->pdf->textBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3248
        //RESERVADO AO FISCO
3249
        $texto = "RESERVADO AO FISCO";
3250
        $x += $w;
3251
        $y -= 1;
3252
        if ($this->orientacao == 'P') {
3253
            $w = $this->wPrint - $w;
3254
        } else {
3255
            $w = $this->wPrint - $w - $this->wCanhoto;
3256
        }
3257
        $aFont = array(
3258
            'font' => $this->fontePadrao,
3259
            'size' => 6,
3260
            'style' => '');
3261
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3262
        //inserir texto informando caso de contingência
3263
        //1 – Normal – emissão normal;
3264
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3265
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3266
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3267
        //Emissão em Contingência – DPEC;
3268
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3269
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3270
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3271
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3272
        $texto = '';
3273
        switch ($this->tpEmis) {
3274
            case 2:
3275
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3276
                break;
3277
            case 3:
3278
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3279
                break;
3280
            case 4:
3281
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3282
                break;
3283
            case 5:
3284
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3285
                break;
3286
        }
3287
        $y += 2;
3288
        $aFont = $this->formatPadrao;
3289
        $this->pdf->textBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3290
        return $y + $h;
3291
    }
3292
3293
    /**
3294
     * formatCNPJCPF
3295
     * Formata campo CnpjCpf contida na CTe
3296
     *
3297
     * @param  string $field campo cnpjCpf da CT-e
3298
     * @return string
3299
     */
3300
    protected function formatCNPJCPF($field)
3301
    {
3302
        if (!isset($field)) {
3303
            return '';
3304
        }
3305
        $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...
3306
            $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...
3307
        if ($cnpj != "" && $cnpj != "00000000000000") {
3308
            $cnpj = $this->formatField($cnpj, '###.###.###/####-##');
3309
        } else {
3310
            $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...
3311
                $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...
3312
        }
3313
        return $cnpj;
3314
    }
3315
3316
    /**
3317
     * formatFone
3318
     * Formata campo fone contida na CTe
3319
     *
3320
     * @param  string $field campo fone da CT-e
3321
     * @return string
3322
     */
3323
    protected function formatFone($field)
3324
    {
3325
        try {
3326
            $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...
3327
                $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...
3328
            $foneLen = strlen($fone);
3329
            if ($foneLen > 0) {
3330
                $fone2 = substr($fone, 0, $foneLen - 4);
3331
                $fone1 = substr($fone, 0, $foneLen - 8);
3332
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3333
            } else {
3334
                $fone = '';
3335
            }
3336
            return $fone;
3337
        } catch (Exception $exc) {
3338
            return '';
3339
        }
3340
    }
3341
3342
    /**
3343
     * unidade
3344
     * Converte a imformação de peso contida na CTe
3345
     *
3346
     * @param  string $c unidade de trafego extraida da CTe
3347
     * @return string
3348
     */
3349
    protected function unidade($c = '')
3350
    {
3351
        switch ($c) {
3352
            case '00':
3353
                $r = 'M3';
3354
                break;
3355
            case '01':
3356
                $r = 'KG';
3357
                break;
3358
            case '02':
3359
                $r = 'TON';
3360
                break;
3361
            case '03':
3362
                $r = 'UN';
3363
                break;
3364
            case '04':
3365
                $r = 'LT';
3366
                break;
3367
            case '05':
3368
                $r = 'MMBTU';
3369
                break;
3370
            default:
3371
                $r = '';
3372
        }
3373
        return $r;
3374
    }
3375
3376
    /**
3377
     * convertUnidTrafego
3378
     * Converte a imformação de peso contida na CTe
3379
     *
3380
     * @param  string $U Informação de trafego extraida da CTe
3381
     * @return string
3382
     */
3383
    protected function convertUnidTrafego($U = '')
3384
    {
3385
        if ($U) {
3386
            switch ($U) {
3387
                case '0':
3388
                    $stringU = 'Próprio';
3389
                    break;
3390
                case '1':
3391
                    $stringU = 'Mútuo';
3392
                    break;
3393
                case '2':
3394
                    $stringU = 'Rodoferroviário';
3395
                    break;
3396
                case '3':
3397
                    $stringU = 'Rodoviário';
3398
                    break;
3399
            }
3400
            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...
3401
        }
3402
    }
3403
3404
    /**
3405
     * multiUniPeso
3406
     * Fornece a imformação multiplicação de peso contida na CTe
3407
     *
3408
     * @param  interger $U Informação de peso extraida da CTe
3409
     * @return interger
3410
     */
3411
    protected function multiUniPeso($U = '')
3412
    {
3413
        if ($U === "01") {
3414
            // tonelada
3415
            //return 1000;
3416
            return 1;
3417
        }
3418
        return 1; // M3, KG, Unidade, litros, mmbtu
3419
    }
3420
3421
    protected function qrCodeDacte($y = 0)
3422
    {
3423
        $margemInterna = $this->margemInterna;
3424
        $barcode = new Barcode();
3425
        $bobj = $barcode->getBarcodeObj(
3426
            'QRCODE,M',
3427
            $this->qrCodCTe,
3428
            -4,
3429
            -4,
3430
            'black',
3431
            array(-2, -2, -2, -2)
3432
        )->setBackgroundColor('white');
3433
        $qrcode = $bobj->getPngData();
3434
        $wQr = 36;
3435
        $hQr = 36;
3436
        $yQr = ($y + $margemInterna);
3437
        if ($this->orientacao == 'P') {
3438
            $xQr = 170;
3439
        } else {
3440
            $xQr = 250;
3441
        }
3442
        // prepare a base64 encoded "data url"
3443
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
3444
        $this->pdf->image($pic, $xQr - 3, $yQr, $wQr, $hQr, 'PNG');
3445
    }
3446
3447
    /**
3448
     * Add the credits to the integrator in the footer message
3449
     * @param string $message
3450
     */
3451
    public function creditsIntegratorFooter($message = '')
3452
    {
3453
        $this->creditos = trim($message);
3454
    }
3455
}
3456