Passed
Push — master ( 7b04d5...4ba447 )
by Roberto
45s queued 11s
created

DacteV3::zFormatCNPJCPF()   A

Complexity

Conditions 6
Paths 7

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
nc 7
nop 1
dl 0
loc 15
ccs 0
cts 15
cp 0
crap 42
rs 9.2222
c 0
b 0
f 0
1
<?php
2
namespace NFePHP\DA\CTe;
3
4
/**
5
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
6
 * estabelecidas pela SEFAZ.
7
 *
8
 * @category  Library
9
 * @package   nfephp-org/sped-da
10
 * @name      Dacte .php
11
 * @copyright 2009-2016 NFePHP
12
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
13
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
14
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
15
 */
16
use Com\Tecnick\Barcode\Barcode;
17
use Exception;
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Legacy\Common;
21
22
class DacteV3 extends Common
23
{
24
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
25
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
26
    const SIT_DPEC = 3;
27
    protected $logoAlign = 'C';
28
    protected $yDados = 0;
29
    protected $situacao_externa = 0;
30
    protected $numero_registro_dpec = '';
31
    protected $pdf;
32
    protected $xml;
33
    protected $logomarca = '';
34
    protected $errMsg = '';
35
    protected $errStatus = false;
36
    protected $orientacao = 'P';
37
    protected $papel = 'A4';
38
    protected $destino = 'I';
39
    protected $pdfDir = '';
40
    protected $fontePadrao = 'Times';
41
    protected $version = '1.3.0';
42
    protected $wPrint;
43
    protected $hPrint;
44
    protected $dom;
45
    protected $infCte;
46
    protected $infCteComp;
47
    protected $infCteAnu;
48
    protected $chaveCTeRef;
49
    protected $tpCTe;
50
    protected $ide;
51
    protected $emit;
52
    protected $enderEmit;
53
    protected $rem;
54
    protected $enderReme;
55
    protected $dest;
56
    protected $enderDest;
57
    protected $exped;
58
    protected $enderExped;
59
    protected $receb;
60
    protected $enderReceb;
61
    protected $infCarga;
62
    protected $infQ;
63
    protected $seg;
64
    protected $modal;
65
    protected $rodo;
66
    protected $moto;
67
    protected $veic;
68
    protected $ferrov;
69
    protected $Comp;
70
    protected $infNF;
71
    protected $infNFe;
72
    protected $compl;
73
    protected $ICMS;
74
    protected $ICMSSN;
75
    protected $ICMSOutraUF;
76
    protected $imp;
77
    protected $toma4;
78
    protected $toma03;
79
    protected $tpEmis;
80
    protected $tpImp;
81
    protected $tpAmb;
82
    protected $vPrest;
83
    protected $wAdic = 150;
84
    protected $textoAdic = '';
85
    protected $debugMode = 2;
86
    protected $formatPadrao;
87
    protected $formatNegrito;
88
    protected $aquav;
89
    protected $preVisualizar;
90
    protected $flagDocOrigContinuacao;
91
    protected $arrayNFe = array();
92
    protected $siteDesenvolvedor;
93
    protected $nomeDesenvolvedor;
94
    protected $totPag;
95
    protected $idDocAntEle = [];
96
    protected $qrCodCTe;
97
    protected $margemInterna = 0;
98
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
99
100
    /**
101
     * __construct
102
     *
103
     * @param string $docXML Arquivo XML da CTe
104
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
105
     * @param string $sPapel Tamanho do papel (Ex. A4)
106
     * @param string $sPathLogo Caminho para o arquivo do logo
107
     * @param string $sDestino Estabelece a direção do envio do documento PDF
108
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
109
     * @param string $fonteDACTE Nome da fonte a ser utilizada
110
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
111
     * @param string $preVisualizar 0-Não 1-Sim
112
     * @param string $nomeDesenvolvedor Nome do desenvolvedor
113
     * @param string $siteDesenvolvedor Site do desenvolvedor
114
     */
115
    public function __construct(
116
        $docXML = '',
117
        $sOrientacao = '',
118
        $sPapel = '',
119
        $sPathLogo = '',
120
        $sDestino = 'I',
121
        $sDirPDF = '',
122
        $fonteDACTE = '',
123
        $mododebug = 2,
124
        $preVisualizar = false,
125
        $nomeDesenvolvedor = 'Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org',
126
        $siteDesenvolvedor = 'http://www.nfephp.org'
127
    ) {
128
        if (is_numeric($mododebug)) {
129
            $this->debugMode = $mododebug;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mododebug can also be of type double or string. However, the property $debugMode is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
130
        }
131
        if ($mododebug == 1) {
132
            //ativar modo debug
133
            error_reporting(E_ALL);
134
            ini_set('display_errors', 'On');
135
        } elseif ($mododebug == 0) {
136
            //desativar modo debug
137
            error_reporting(0);
138
            ini_set('display_errors', 'Off');
139
        }
140
        $this->orientacao = $sOrientacao;
141
        $this->papel = $sPapel;
142
        $this->pdf = '';
143
        $this->xml = $docXML;
144
        $this->logomarca = $sPathLogo;
145
        $this->destino = $sDestino;
146
        $this->pdfDir = $sDirPDF;
147
        $this->preVisualizar = $preVisualizar;
148
        $this->siteDesenvolvedor = $siteDesenvolvedor;
149
        $this->nomeDesenvolvedor = $nomeDesenvolvedor;
150
        // verifica se foi passa a fonte a ser usada
151
        if (!empty($fonteDACTE)) {
152
            $this->fontePadrao = $fonteDACTE;
153
        }
154
        $this->formatPadrao = array(
155
            'font' => $this->fontePadrao,
156
            'size' => 6,
157
            'style' => '');
158
        $this->formatNegrito = array(
159
            'font' => $this->fontePadrao,
160
            'size' => 7,
161
            'style' => 'B');
162
        //se for passado o xml
163
        if (!empty($this->xml)) {
164
            $this->dom = new Dom();
165
            $this->dom->loadXML($this->xml);
166
            $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...
167
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
168
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
169
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
170
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
171
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
172
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
173
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
174
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
175
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
176
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
177
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
178
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
179
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
180
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
181
            $this->infQ = $this->dom->getElementsByTagName("infQ");
182
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
183
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
184
            $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...
185
            $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...
186
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
187
            $this->veic = $this->dom->getElementsByTagName("veic");
188
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
189
            // adicionar outros modais
190
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
191
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
192
            if ($this->tpCTe == 1) {
193
                $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chCTe");
194
            } else {
195
                $this->chaveCTeRef = $this->getTagValue($this->infCteAnu, "chCte");
196
            }
197
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
198
            $this->Comp = $this->dom->getElementsByTagName("Comp");
199
            $this->infNF = $this->dom->getElementsByTagName("infNF");
200
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
201
            $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...
202
            $this->compl = $this->dom->getElementsByTagName("compl");
203
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
204
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
205
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
206
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
207
            if (!empty($this->getTagValue($this->imp, "vTotTrib"))) {
208
                $textoAdic = number_format($this->getTagValue($this->imp, "vTotTrib"), 2, ",", ".");
209
                $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
210
                        .$textoAdic;
211
            }
212
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
213
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
214
            //Tag tomador é identificado por toma03 na versão 2.00
215
            if ($this->infCte->getAttribute("versao")=="2.00") {
216
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
217
            }
218
            //modal aquaviário
219
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
220
            $tomador = $this->getTagValue($this->toma03, "toma");
221
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
222
            switch ($tomador) {
223
                case '0':
224
                    $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...
225
                    $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...
226
                    break;
227
                case '1':
228
                    $this->toma = $this->exped;
229
                    $this->enderToma = $this->enderExped;
230
                    break;
231
                case '2':
232
                    $this->toma = $this->receb;
233
                    $this->enderToma = $this->enderReceb;
234
                    break;
235
                case '3':
236
                    $this->toma = $this->dest;
237
                    $this->enderToma = $this->enderDest;
238
                    break;
239
                default:
240
                    $this->toma = $this->toma4;
241
                    $this->enderToma = $this->getTagValue($this->toma4, "enderToma");
242
                    break;
243
            }
244
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
245
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
246
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
247
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
248
            $this->qrCodCTe = $this->dom->getElementsByTagName('qrCodCTe')->item(0) ?
249
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : null;
250
            $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...
251
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
252
            $this->modal = $this->getTagValue($this->ide, "modal");
253
        }
254
    }
255
256
    /**
257
     * monta
258
     * @param string $orientacao L ou P
259
     * @param string $papel A4
260
     * @param string $logoAlign C, L ou R
261
     * @param Pdf $classPDF
262
     * @return string montagem
263
     */
264
    public function monta(
265
        $orientacao = '',
266
        $papel = 'A4',
267
        $logoAlign = 'C',
268
        $classPDF = false
269
    ) {
270
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 268 can also be of type object<NFePHP\DA\Legacy\Pdf>; however, NFePHP\DA\CTe\DacteV3::montaDACTE() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
271
    }
272
273
    /**
274
     * printDocument
275
     * @param string $nome
276
     * @param string $destino
277
     * @param string $printer
278
     * @return
279
     */
280
    public function printDocument($nome = '', $destino = 'I', $printer = '')
281
    {
282
        return $this->printDACTE($nome, $destino, $printer);
283
    }
284
285
    /**
286
     * Dados brutos do PDF
287
     * @return string
288
     */
289
    public function render()
290
    {
291
        return $this->pdf->getPdf();
292
    }
293
    protected function zCteDPEC()
294
    {
295
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
296
    }
297
298
    /**
299
     * montaDACTE
300
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
301
     * durante sua construção.
302
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
303
     * pelo conteúdo da funçao e podem ser modificados.
304
     *
305
     * @param  string $orientacao (Opcional) Estabelece a orientação da
306
     *                impressão (ex. P-retrato), se nada for fornecido será
307
     *                usado o padrão da NFe
308
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
309
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
310
     */
311
    public function montaDACTE(
312
        $orientacao = '',
313
        $papel = 'A4',
314
        $logoAlign = 'C',
315
        $classPDF = false
316
    ) {
317
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
318
        if ($orientacao == '') {
319
            if ($this->tpImp == '1') {
320
                $orientacao = 'P';
321
            } else {
322
                $orientacao = 'P';
323
            }
324
        }
325
        $this->orientacao = $orientacao;
326
        $this->papel = $papel;
327
        $this->logoAlign = $logoAlign;
328
        //$this->situacao_externa = $situacao_externa;
329
        //instancia a classe pdf
330
        if ($classPDF !== false) {
331
            $this->pdf = $classPDF;
332
        } else {
333
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
334
        }
335
        if ($this->orientacao == 'P') {
336
            // margens do PDF
337
            $margSup = 2;
338
            $margEsq = 2;
339
            $margDir = 2;
340
            // posição inicial do relatorio
341
            $xInic = 1;
342
            $yInic = 1;
343
            if ($papel == 'A4') {
344
                //A4 210x297mm
345
                $maxW = 210;
346
                $maxH = 297;
347
            }
348
        } else {
349
            // margens do PDF
350
            $margSup = 3;
351
            $margEsq = 3;
352
            $margDir = 3;
353
            // posição inicial do relatorio
354
            $xInic = 5;
355
            $yInic = 5;
356
            if ($papel == 'A4') {
357
                //A4 210x297mm
358
                $maxH = 210;
359
                $maxW = 297;
360
                $this->wCanhoto = 25;
0 ignored issues
show
Bug introduced by
The property wCanhoto does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
361
            }
362
        }
363
        //total inicial de paginas
364
        $totPag = 1;
0 ignored issues
show
Unused Code introduced by
$totPag is not used, you could remove the assignment.

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

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

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

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

Loading history...
365
        //largura imprimivel em mm
366
        $this->wPrint = $maxW - ($margEsq + $xInic);
0 ignored issues
show
Bug introduced by
The variable $maxW does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
367
        //comprimento imprimivel em mm
368
        $this->hPrint = $maxH - ($margSup + $yInic);
0 ignored issues
show
Bug introduced by
The variable $maxH does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
369
        // estabelece contagem de paginas
370
        $this->pdf->AliasNbPages();
371
        // fixa as margens
372
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
373
        $this->pdf->SetDrawColor(0, 0, 0);
374
        $this->pdf->SetFillColor(255, 255, 255);
375
        // inicia o documento
376
        $this->pdf->Open();
377
        // adiciona a primeira página
378
        $this->pdf->AddPage($this->orientacao, $this->papel);
379
        $this->pdf->SetLineWidth(0.1);
380
        $this->pdf->SetTextColor(0, 0, 0);
381
        //calculo do numero de páginas ???
382
        $totPag = 1;
383
        //montagem da primeira página
384
        $pag = 1;
385
        $x = $xInic;
386
        $y = $yInic;
387
        //coloca o cabeçalho
388
        $y = $this->zCanhoto($x, $y);
389
        $y += 24;
390
        $r = $this->zCabecalho($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
391
        $y += 70;
392
        $r = $this->zRemetente($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
393
        $x = $this->wPrint * 0.5 + 2;
394
        $r = $this->zDestinatario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
395
        $y += 19;
396
        $x = $xInic;
397
        $r = $this->zExpedidor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
398
        $x = $this->wPrint * 0.5 + 2;
399
        $r = $this->zRecebedor($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
400
        $y += 19;
401
        $x = $xInic;
402
        $r = $this->zTomador($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
403
        if ($this->tpCTe == '0') {
404
            //Normal
405
            $y += 10;
406
            $x = $xInic;
407
            $r = $this->zDescricaoCarga($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
408
            $y += 17;
409
            $x = $xInic;
410
            $r = $this->zCompValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
411
            $y += 25;
412
            $x = $xInic;
413
            $r = $this->zImpostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
414
            $y += 13;
415
            $x = $xInic;
416
            $r = $this->zDocOrig($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
417
            if ($this->modal == '1') {
418
                if ($this->lota == 1) {
419
                    //$y += 24.95;
420
                    $y += 35;
421
                } else {
422
                    $y += 53;
423
                }
424
            } elseif ($this->modal == '2') {
425
                $y += 53;
426
            } elseif ($this->modal == '3') {
427
                $y += 37.75;
428
            } else {
429
                $y += 24.95;
430
            }
431
            $x = $xInic;
432
            $r = $this->zObs($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
433
            $y = $y-6;
434
            switch ($this->modal) {
435
                case '1':
436
                    $y += 25.9;
437
                    $x = $xInic;
438
                    $r = $this->zModalRod($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
439
                    break;
440
                case '2':
441
                    $y += 25.9;
442
                    $x = $xInic;
443
                    $r = $this->zModalAereo($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...
444
                    break;
445
                case '3':
446
                    $y += 17.9;
447
                    $x = $xInic;
448
                    $r = $this->zModalAquaviario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
449
                    break;
450
                case '4':
451
                    $y += 17.9;
452
                    $x = $xInic;
453
                    $r = $this->zModalFerr($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
454
                    break;
455
                case '5':
456
                    $y += 17.9;
457
                    $x = $xInic;
458
                    // TODO fmertins 31/10/14: este método não existe...
459
                    $r = $this->zModalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalDutoviario() does not seem to exist on object<NFePHP\DA\CTe\DacteV3>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
460
                    break;
461
            }
462
            if ($this->modal == '1') {
463
                if ($this->lota == 1) {
464
                    $y += 37;
465
                } else {
466
                    $y += 8.9;
467
                }
468
            } elseif ($this->modal == '2') {
469
                $y += 8.9;
470
            } elseif ($this->modal == '3') {
471
                $y += 24.15;
472
            } else {
473
                $y += 37;
474
            }
475
        } else {
476
            //$r = $this->zCabecalho(1, 1, $pag, $totPag);
477
            //Complementado
478
            $y += 10;
479
            $x = $xInic;
480
            $r = $this->zDocCompl($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
481
            $y += 80;
482
            $x = $xInic;
483
            $r = $this->zCompValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
484
            $y += 25;
485
            $x = $xInic;
486
            $r = $this->zImpostos($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
487
            $y += 13;
488
            $x = $xInic;
489
            $r = $this->zObs($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
490
            $y += 15;
491
        }
492
        $x = $xInic;
493
        $r = $this->zDadosAdic($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
494
        //$y += 19;
495
        //$y += 11;
496
        //$y = $this->zCanhoto($x, $y);
497
        //coloca o rodapé da página
498
        if ($this->orientacao == 'P') {
499
            $this->zRodape(2, $this->hPrint - 2);
500
        } else {
501
            $this->zRodape($xInic, $this->hPrint + 2.3);
502
        }
503
        if ($this->flagDocOrigContinuacao == 1) {
504
            $this->zdocOrigContinuacao(1, 71);
505
        }
506
        //retorna o ID na CTe
507
        if ($classPDF !== false) {
508
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
509
            return $aR;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $aR; (array) is incompatible with the return type documented by NFePHP\DA\CTe\DacteV3::montaDACTE of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
510
        } else {
511
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
512
        }
513
    }
514
515
    /**
516
     * printDACTE
517
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
518
     * O destino da impressão pode ser :
519
     * I-browser
520
     * D-browser com download
521
     * F-salva em um arquivo local com o nome informado
522
     * S-retorna o documento como uma string e o nome é ignorado.
523
     * Para enviar o pdf diretamente para uma impressora indique o
524
     * nome da impressora e o destino deve ser 'S'.
525
     *
526
     * @param  string $nome Path completo com o nome do arquivo pdf
527
     * @param  string $destino Direção do envio do PDF
528
     * @param  string $printer Identificação da impressora no sistema
529
     * @return string Caso o destino seja S o pdf é retornado como uma string
530
     * @todo Rotina de impressão direta do arquivo pdf criado
531
     */
532
    public function printDACTE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
533
    {
534
        $arq = $this->pdf->Output($nome, $destino);
535
        if ($destino == 'S') {
536
            //aqui pode entrar a rotina de impressão direta
537
        }
538
        return $arq;
539
    }
540
541
    /**
542
     * zCabecalho
543
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
544
     *
545
     * @param  number $x Posição horizontal inicial, canto esquerdo
546
     * @param  number $y Posição vertical inicial, canto superior
547
     * @param  number $pag Número da Página
548
     * @param  number $totPag Total de páginas
549
     * @return number Posição vertical final
550
     */
551
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
552
    {
553
        $oldX = $x;
554
        $oldY = $y;
555
        if ($this->orientacao == 'P') {
556
            $maxW = $this->wPrint;
557
        } else {
558
            if ($pag == 1) {
559
                // primeira página
560
                $maxW = $this->wPrint - $this->wCanhoto;
561
            } else {
562
                // páginas seguintes
563
                $maxW = $this->wPrint;
564
            }
565
        }
566
        //##################################################################
567
        //coluna esquerda identificação do emitente
568
        //$w = round($maxW * 0.42);
569
        $w = round($maxW * 0.32);
570
        if ($this->orientacao == 'P') {
571
            $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...
572
                'font' => $this->fontePadrao,
573
                'size' => 6,
574
                'style' => '');
575
        } else {
576
            $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...
577
        }
578
        $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...
579
        $h = 35;
580
        $oldY += $h;
581
        //desenha a caixa
582
        $this->pTextBox($x, $y, $w + 2, $h + 1);
583
        // coloca o logo
584
        if (is_file($this->logomarca)) {
585
            $logoInfo = getimagesize($this->logomarca);
586
            //largura da imagem em mm
587
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
588
            //altura da imagem em mm
589
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
590
            if ($this->logoAlign == 'L') {
591
                $nImgW = round($w / 3, 0);
592
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
593
                $xImg = $x + 1;
594
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
595
                //estabelecer posições do texto
596
                $x1 = round($xImg + $nImgW + 1, 0);
597
                $y1 = round($h / 3 + $y, 0);
598
                $tw = round(2 * $w / 3, 0);
599
            } elseif ($this->logoAlign == 'C') {
600
                $nImgH = round($h / 3, 0);
601
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
602
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
603
                $yImg = $y + 3;
604
                $x1 = $x;
605
                $y1 = round($yImg + $nImgH + 1, 0);
606
                $tw = $w;
607
            } elseif ($this->logoAlign == 'R') {
608
                $nImgW = round($w / 3, 0);
609
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
610
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
611
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
612
                $x1 = $x;
613
                $y1 = round($h / 3 + $y, 0);
614
                $tw = round(2 * $w / 3, 0);
615
            }
616
            $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...
617
        } else {
618
            $x1 = $x;
619
            $y1 = round($h / 3 + $y, 0);
620
            $tw = $w;
621
        }
622
        //Nome emitente
623
        $aFont = array(
624
            'font' => $this->fontePadrao,
625
            'size' => 9,
626
            'style' => 'B');
627
        $texto = $this->getTagValue($this->emit, "xNome");
628
        $this->pTextBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $y1 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $tw does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
629
        //endereço
630
        $y1 = $y1 + 3;
631
        $aFont = array(
632
            'font' => $this->fontePadrao,
633
            'size' => 7,
634
            'style' => '');
635
        $fone = $this->getTagValue($this->enderEmit, "fone")!=""? $this->zFormatFone($this->enderEmit):'';
0 ignored issues
show
Documentation introduced by
$this->enderEmit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
636
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
637
        $nro = $this->getTagValue($this->enderEmit, "nro");
638
        $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...
639
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
640
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
641
        $CEP = $this->pFormat($CEP, "#####-###");
642
        $mun = $this->getTagValue($this->enderEmit, "xMun");
643
        $UF = $this->getTagValue($this->enderEmit, "UF");
644
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
645
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
646
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
647
            . "\n  Fone/Fax: " . $fone;
648
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
649
        //CNPJ/CPF IE
650
        $cpfCnpj = $this->zFormatCNPJCPF($this->emit);
0 ignored issues
show
Documentation introduced by
$this->emit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1278
        $aFont = $this->formatNegrito;
1279
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1280
        $x = $w - 45;
1281
        $texto = 'INSCRIÇÃO ESTADUAL';
1282
        $aFont = $this->formatPadrao;
1283
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1284
        $texto = $this->getTagValue($this->rem, "IE");
1285
        $aFont = $this->formatNegrito;
1286
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1287
        $x = $oldX;
1288
        $y += 3;
1289
        $texto = 'PAÍS';
1290
        $aFont = $this->formatPadrao;
1291
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1292
        $texto = $this->getTagValue($this->rem, "xPais") != "" ?
1293
            $this->getTagValue($this->rem, "xPais") : 'BRASIL';
1294
        $aFont = $this->formatNegrito;
1295
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1296
        $x = $w - 25;
1297
        $texto = 'FONE';
1298
        $aFont = $this->formatPadrao;
1299
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1300
        //$texto = $this->zFormatFone($this->rem);
1301
        $texto = $this->getTagValue($this->rem, "fone")!=""? $this->zFormatFone($this->rem):'';
0 ignored issues
show
Documentation introduced by
$this->rem is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1302
        $aFont = $this->formatNegrito;
1303
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1304
    }
1305
1306
    /**
1307
     * zDestinatario
1308
     * Monta o campo com os dados do destinatário na DACTE.
1309
     *
1310
     * @param  number $x Posição horizontal canto esquerdo
1311
     * @param  number $y Posição vertical canto superior
1312
     * @return number Posição vertical final
1313
     */
1314
    protected function zDestinatario($x = 0, $y = 0)
1315
    {
1316
        $oldX = $x;
1317
        $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...
1318
        if ($this->orientacao == 'P') {
1319
            $maxW = $this->wPrint;
1320
        } else {
1321
            $maxW = $this->wPrint - $this->wCanhoto;
1322
        }
1323
        $w = ($maxW * 0.5) - 0.7;
1324
        $h = 19;
1325
        $x1 = $x + 19;
1326
        $texto = 'DESTINATÁRIO';
1327
        $aFont = $this->formatPadrao;
1328
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1329
        $aFont = $this->formatNegrito;
1330
        $texto = $this->getTagValue($this->dest, "xNome");
1331
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1332
        $y += 3;
1333
        $texto = 'ENDEREÇO';
1334
        $aFont = $this->formatPadrao;
1335
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1336
        $aFont = $this->formatNegrito;
1337
        $texto = $this->getTagValue($this->enderDest, "xLgr") . ',';
1338
        $texto .= $this->getTagValue($this->enderDest, "nro");
1339
        $texto .= $this->getTagValue($this->enderDest, "xCpl") != "" ?
1340
            ' - ' . $this->getTagValue($this->enderDest, "xCpl") : '';
1341
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1342
        $y += 3;
1343
        $texto = $this->getTagValue($this->enderDest, "xBairro");
1344
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1345
        $y += 3;
1346
        $texto = 'MUNICÍPIO';
1347
        $aFont = $this->formatPadrao;
1348
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1349
        $texto = $this->getTagValue($this->enderDest, "xMun") . ' - ';
1350
        $texto .= $this->getTagValue($this->enderDest, "UF");
1351
        $aFont = $this->formatNegrito;
1352
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1353
        $x = $w - 19 + $oldX;
1354
        $texto = 'CEP';
1355
        $aFont = $this->formatPadrao;
1356
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1357
        $texto = $this->pFormat($this->getTagValue($this->enderDest, "CEP"), "#####-###");
1358
        $aFont = $this->formatNegrito;
1359
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1360
        $x = $oldX;
1361
        $y += 3;
1362
        $texto = 'CNPJ/CPF';
1363
        $aFont = $this->formatPadrao;
1364
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1365
        $cpfCnpj = $this->zFormatCNPJCPF($this->dest);
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1366
        $aFont = $this->formatNegrito;
1367
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1368
        $x = $w - 47.5 + $oldX;
1369
        $texto = 'INSCRIÇÃO ESTADUAL';
1370
        $aFont = $this->formatPadrao;
1371
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1372
        $texto = $this->getTagValue($this->dest, "IE");
1373
        $aFont = $this->formatNegrito;
1374
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1375
        $x = $oldX;
1376
        $y += 3;
1377
        $texto = 'PAÍS';
1378
        $aFont = $this->formatPadrao;
1379
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1380
        $texto = $this->getTagValue($this->dest, "xPais");
1381
        $aFont = $this->formatNegrito;
1382
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1383
        $x = $w - 27 + $oldX;
1384
        $texto = 'FONE';
1385
        $aFont = $this->formatPadrao;
1386
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1387
        //$texto = $this->zFormatFone($this->dest);
1388
        $texto = $this->getTagValue($this->dest, "fone")!=""? $this->zFormatFone($this->dest):'';
0 ignored issues
show
Documentation introduced by
$this->dest is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
2252
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2253
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2254
            if ($auxX > $w * 0.90) {
2255
                $yIniDados = $yIniDados + 3;
2256
                $auxX = $oldX;
2257
            }
2258
            $texto = $tp;
2259
            $aFont = array(
2260
                'font' => $this->fontePadrao,
2261
                'size' => 8,
2262
                'style' => '');
2263
            //$this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2264
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2265
            //$auxX += $w * 0.09;
2266
            $auxX += $w * 0.07;
2267
            $texto = $cnpj;
2268
            $aFont = array(
2269
                'font' => $this->fontePadrao,
2270
                'size' => 8,
2271
                'style' => '');
2272
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2273
            $auxX += $w * 0.28;
2274
            $texto = $doc;
2275
            $aFont = array(
2276
                'font' => $this->fontePadrao,
2277
                'size' => 8,
2278
                'style' => '');
2279
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2280
            $auxX += $w * 0.15;
2281
        }
2282
        foreach ($this->infNFe as $k => $d) {
2283
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2284
            $this->arrayNFe[] = $chaveNFe;
2285
        }
2286
        $qtdeNFe = 1;
2287
        if (count($this->arrayNFe) >15) {
2288
            $this->flagDocOrigContinuacao = 1;
2289
            $qtdeNFe = count($this->arrayNFe);
2290
        }
2291
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
2292
        switch ($qtdeNFe) {
2293
            default:
2294
                $this->totPag = 1;
2295
            case ($qtdeNFe >= 1044):
2296
                $this->totPag = 11;
2297
                break;
2298
            case ($qtdeNFe > 928):
2299
                $this->totPag = 10;
2300
                break;
2301
            case ($qtdeNFe > 812):
2302
                $this->totPag = 9;
2303
                break;
2304
            case ($qtdeNFe > 696):
2305
                $this->totPag = 8;
2306
                break;
2307
            case ($qtdeNFe > 580):
2308
                $this->totPag = 7;
2309
                break;
2310
            case ($qtdeNFe > 464):
2311
                $this->totPag = 6;
2312
                break;
2313
            case ($qtdeNFe > 348):
2314
                $this->totPag = 5;
2315
                break;
2316
            case ($qtdeNFe > 232):
2317
                $this->totPag = 4;
2318
                break;
2319
            case ($qtdeNFe > 116):
2320
                $this->totPag = 3;
2321
                break;
2322
            case ($qtdeNFe > 16):
2323
                $this->totPag = 2;
2324
                break;
2325
            case ($qtdeNFe <= 16):
2326
                $this->totPag = 1;
2327
                break;
2328
        }
2329
        //$r = $this->zCabecalho(1, 1, '1', $this->totPag);
2330
        $contador = 0;
2331
        while ($contador < count($this->arrayNFe)) {
2332
            if ($contador == 15) {
2333
                break;
2334
            }
2335
            $tp = 'NF-e';
2336
            $chaveNFe = $this->arrayNFe[$contador];
2337
            $numNFe = substr($chaveNFe, 25, 9);
2338
            $serieNFe = substr($chaveNFe, 22, 3);
2339
            $doc = $serieNFe . '/' . $numNFe;
2340
            if ($auxX > $w * 0.90) {
2341
                $yIniDados = $yIniDados + 3.5;
2342
                $auxX = $oldX;
2343
            }
2344
            $texto = $tp;
2345
            $aFont = array(
2346
                'font' => $this->fontePadrao,
2347
                'size' => 7,
2348
                'style' => '');
2349
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2350
            $auxX += $w * 0.07;
2351
            $texto = $chaveNFe;
2352
            $aFont = array(
2353
                'font' => $this->fontePadrao,
2354
                'size' => 7,
2355
                'style' => '');
2356
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2357
            $auxX += $w * 0.28;
2358
            $texto = $doc;
2359
            $aFont = array(
2360
                'font' => $this->fontePadrao,
2361
                'size' => 7,
2362
                'style' => '');
2363
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2364
            $auxX += $w * 0.15;
2365
            $contador++;
2366
        }
2367
        foreach ($this->infOutros as $k => $d) {
2368
            $temp = $this->infOutros->item($k);
2369
            $tpDoc = $this->getTagValue($temp, "tpDoc");
2370
            $descOutros = $this->getTagValue($temp, "descOutros");
2371
            $nDoc = $this->getTagValue($temp, "nDoc");
2372
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2373
            $vDocFisc = $this->getTagValue($temp, "vDocFisc", "Valor: ");
2374
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2375
            switch ($tpDoc) {
2376
                case "00":
2377
                    $tpDoc = "00 - Declaração";
2378
                    break;
2379
                case "10":
2380
                    $tpDoc = "10 - Dutoviário";
2381
                    break;
2382
                case "99":
2383
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2384
                    break;
2385
                default:
2386
                    break;
2387
            }
2388
            $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...
2389
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2390
            if ($auxX > $w * 0.90) {
2391
                $yIniDados = $yIniDados + 4;
2392
                $auxX = $oldX;
2393
            }
2394
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2395
            $auxX += $w * 0.09;
2396
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2397
            $auxX += $w * 0.28;
2398
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2399
            $auxX += $w * 0.14;
2400
        }
2401
        foreach ($this->idDocAntEle as $k => $d) {
2402
            $tp = 'CT-e';
2403
            $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...
2404
            $numCTe = substr($chaveCTe, 25, 9);
2405
            $serieCTe = substr($chaveCTe, 22, 3);
2406
            $doc = $serieCTe . '/' . $numCTe;
2407
            if ($auxX > $w * 0.90) {
2408
                $yIniDados = $yIniDados + 4;
2409
                $auxX = $oldX;
2410
            }
2411
            $texto = $tp;
2412
            $aFont = array(
2413
                'font' => $this->fontePadrao,
2414
                'size' => 8,
2415
                'style' => '');
2416
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2417
            $auxX += $w * 0.09;
2418
            $texto = $chaveCTe;
2419
            $aFont = array(
2420
                'font' => $this->fontePadrao,
2421
                'size' => 8,
2422
                'style' => '');
2423
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2424
            $auxX += $w * 0.28;
2425
            $texto = $doc;
2426
            $aFont = array(
2427
                'font' => $this->fontePadrao,
2428
                'size' => 8,
2429
                'style' => '');
2430
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2431
            $auxX += $w * 0.14;
2432
        }
2433
    }
2434
2435
    /**
2436
     * zDocOrigContinuacao
2437
     * Monta o campo com os documentos originarios.
2438
     *
2439
     * @param  number $x Posição horizontal canto esquerdo
2440
     * @param  number $y Posição vertical canto superior
2441
     * @return number Posição vertical final
2442
     */
2443
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2444
    {
2445
        $x2 = $x;
2446
        $y2 = $y;
2447
        $contador = 16;
2448
        for ($i = 2; $i <= $this->totPag; $i++) {
2449
            $x = $x2;
2450
            $y = $y2;
2451
            $this->pdf->AddPage($this->orientacao, $this->papel);
2452
            $r = $this->zCabecalho(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...
2453
            $oldX = $x;
2454
            $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...
2455
            if ($this->orientacao == 'P') {
2456
                $maxW = $this->wPrint;
2457
            } else {
2458
                $maxW = $this->wPrint - $this->wCanhoto;
2459
            }
2460
            $w = $maxW;
2461
            //$h = 6; // de sub-titulo
2462
            //$h = 6 + 3; // de altura do texto (primeira linha
2463
            //$h = 9 + 3.5 ;// segunda linha
2464
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
2465
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2466
            if (count($this->arrayNFe)%2 !=0) {
2467
                $h = $h+3.5;
2468
            } // Caso tenha apenas 1 registro na ultima linha
2469
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2470
            $aFont = $this->formatPadrao;
2471
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2472
            $descr1 = 'TIPO DOC';
2473
            $descr2 = 'CNPJ/CHAVE/OBS';
2474
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2475
            $y += 3.4;
2476
            $this->pdf->Line($x, $y, $w + 1, $y);
2477
            $texto = $descr1;
2478
            $aFont = $this->formatPadrao;
2479
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2480
            $yIniDados = $y;
2481
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2482
            $texto = $descr2;
2483
            $aFont = $this->formatPadrao;
2484
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2485
            $x += $w * 0.28;
2486
            $texto = $descr3;
2487
            $aFont = $this->formatPadrao;
2488
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2489
            $x += $w * 0.14;
2490
            if ($this->modal == '1') {
2491
                if ($this->lota == 1) {
2492
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2493
                } else {
2494
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2495
                }
2496
            } elseif ($this->modal == '2') {
2497
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2498
            } elseif ($this->modal == '3') {
2499
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2500
            } else {
2501
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2502
            }
2503
            $texto = $descr1;
2504
            $aFont = $this->formatPadrao;
2505
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2506
            $x += $w * 0.08;
2507
            $texto = $descr2;
2508
            $aFont = $this->formatPadrao;
2509
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2510
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2511
            $texto = $descr3;
2512
            $aFont = $this->formatPadrao;
2513
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2514
            $auxX = $oldX;
2515
            $yIniDados += 3;
2516
            while ($contador < (count($this->arrayNFe))) {
2517
                if ($contador%(116*($i-1)) == 0) {
2518
//                    $contador++;
2519
                    break;
2520
                }
2521
                $tp = 'NF-e';
2522
                $chaveNFe = $this->arrayNFe[$contador];
2523
                $numNFe = substr($chaveNFe, 25, 9);
2524
                $serieNFe = substr($chaveNFe, 22, 3);
2525
                $doc = $serieNFe . '/' . $numNFe;
2526
                if ($auxX > $w * 0.90) {
2527
                    $yIniDados = $yIniDados + 3.5;
2528
                    $auxX = $oldX;
2529
                }
2530
                $texto = $tp;
2531
                $aFont = array(
2532
                    'font' => $this->fontePadrao,
2533
                    'size' => 7,
2534
                    'style' => '');
2535
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2536
                $auxX += $w * 0.07;
2537
                $texto = $chaveNFe;
2538
                $aFont = array(
2539
                    'font' => $this->fontePadrao,
2540
                    'size' => 7,
2541
                    'style' => '');
2542
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2543
                $auxX += $w * 0.28;
2544
                $texto = $doc;
2545
                $aFont = array(
2546
                    'font' => $this->fontePadrao,
2547
                    'size' => 7,
2548
                    'style' => '');
2549
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2550
                $auxX += $w * 0.15;
2551
                $contador++;
2552
            }
2553
        }
2554
    }
2555
2556
    /**
2557
     * zDocCompl
2558
     * Monta o campo com os dados do remetente na DACTE.
2559
     *
2560
     * @param number $x Posição horizontal canto esquerdo
2561
     * @param number $y Posição vertical canto superior
2562
     * @return number Posição vertical final
2563
     */
2564
    protected function zDocCompl($x = 0, $y = 0)
2565
    {
2566
        $oldX = $x;
2567
        $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...
2568
        if ($this->orientacao == 'P') {
2569
            $maxW = $this->wPrint;
2570
        } else {
2571
            $maxW = $this->wPrint - $this->wCanhoto;
2572
        }
2573
        $w = $maxW;
2574
        $h = 80;
2575
        if ($this->tpCTe == 1) {
2576
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2577
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2578
            $descr2 = 'VALOR COMPLEMENTADO';
2579
        } else {
2580
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2581
            $descr1 = 'CHAVE DO CT-E ANULADO';
2582
            $descr2 = 'VALOR ANULADO';
2583
        }
2584
        $aFont = $this->formatPadrao;
2585
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2586
        $y += 3.4;
2587
        $this->pdf->Line($x, $y, $w + 1, $y);
2588
        $texto = $descr1;
2589
        $aFont = $this->formatPadrao;
2590
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2591
        $yIniDados = $y;
2592
        $x += $w * 0.37;
2593
        $texto = $descr2;
2594
        $aFont = $this->formatPadrao;
2595
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2596
        $x += $w * 0.13;
2597
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2598
        $texto = $descr1;
2599
        $aFont = $this->formatPadrao;
2600
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2601
        $x += $w * 0.3;
2602
        $texto = $descr2;
2603
        $aFont = $this->formatPadrao;
2604
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2605
        $auxX = $oldX;
2606
        $yIniDados += 4;
2607
        if ($auxX > $w * 0.90) {
2608
            $yIniDados = $yIniDados + 4;
2609
            $auxX = $oldX;
2610
        }
2611
        $texto = $this->chaveCTeRef;
2612
        $aFont = array(
2613
            'font' => $this->fontePadrao,
2614
            'size' => 8,
2615
            'style' => '');
2616
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2617
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
2618
        $aFont = array(
2619
            'font' => $this->fontePadrao,
2620
            'size' => 8,
2621
            'style' => '');
2622
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2623
    }
2624
2625
    /**
2626
     * zObs
2627
     * Monta o campo com os dados do remetente na DACTE.
2628
     *
2629
     * @param  number $x Posição horizontal canto esquerdo
2630
     * @param  number $y Posição vertical canto superior
2631
     * @return number Posição vertical final
2632
     */
2633
    protected function zObs($x = 0, $y = 0)
2634
    {
2635
        $oldX = $x;
2636
        $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...
2637
        if ($this->orientacao == 'P') {
2638
            $maxW = $this->wPrint;
2639
        } else {
2640
            $maxW = $this->wPrint - $this->wCanhoto;
2641
        }
2642
        $w = $maxW;
2643
        //$h = 18;
2644
        $h = 18.8;
2645
        $texto = 'OBSERVAÇÕES';
2646
        $aFont = $this->formatPadrao;
2647
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2648
        $y += 3.4;
2649
        $this->pdf->Line($x, $y, $w + 1, $y);
2650
        $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...
2651
        $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...
2652
        $texto = '';
2653
        foreach ($this->compl as $k => $d) {
2654
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
2655
            $texto .= $xObs;
2656
        }
2657
        $textoObs = explode("Motorista:", $texto);
2658
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2659
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
2660
        $aFont = array(
2661
            'font' => $this->fontePadrao,
2662
            'size' => 7.5,
2663
            'style' => '');
2664
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2665
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2666
    }
2667
2668
    /**
2669
     * zModalRod
2670
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2671
     *
2672
     * @param  number $x Posição horizontal canto esquerdo
2673
     * @param  number $y Posição vertical canto superior
2674
     * @return number Posição vertical final
2675
     */
2676
    protected function zModalRod($x = 0, $y = 0)
2677
    {
2678
        $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...
2679
        $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...
2680
        $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...
2681
        if ($this->orientacao == 'P') {
2682
            $maxW = $this->wPrint;
2683
        } else {
2684
            $maxW = $this->wPrint - $this->wCanhoto;
2685
        }
2686
        $w = $maxW;
2687
        $h = 3;
2688
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2689
        $aFont = $this->formatPadrao;
2690
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2691
        if ($this->lota == 1) {
2692
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2693
        }
2694
        $y += 3.4;
2695
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2696
        $texto = 'RNTRC DA EMPRESA';
2697
        $aFont = $this->formatPadrao;
2698
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2699
        $texto = $this->getTagValue($this->rodo, "RNTRC");
2700
        $aFont = $this->formatNegrito;
2701
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2702
        $x += $w * 0.23;
2703
        $this->pdf->Line($x-20, $y, $x-20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2704
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2705
        $aFont = $this->formatPadrao;
2706
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2707
    }
2708
2709
    /**
2710
     * zModalAereo
2711
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2712
     *
2713
     * @param  number $x Posição horizontal canto esquerdo
2714
     * @param  number $y Posição vertical canto superior
2715
     * @return number Posição vertical final
2716
     */
2717
    protected function zModalAereo($x = 0, $y = 0)
2718
    {
2719
        $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...
2720
        $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...
2721
        $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...
2722
        if ($this->orientacao == 'P') {
2723
            $maxW = $this->wPrint;
2724
        } else {
2725
            $maxW = $this->wPrint - $this->wCanhoto;
2726
        }
2727
        $w = $maxW;
2728
        $h = 3;
2729
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2730
        $aFont = $this->formatPadrao;
2731
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2732
        $y += 3.4;
2733
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2734
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2735
        $aFont = $this->formatPadrao;
2736
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2737
        $texto = 'CLASSE DA TARIFA';
2738
        $aFont = $this->formatPadrao;
2739
        $this->pTextBox($x+50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2740
        $texto = 'CÓDIGO DA TARIFA';
2741
        $aFont = $this->formatPadrao;
2742
        $this->pTextBox($x+80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2743
        $texto = 'VALOR DA TARIFA';
2744
        $aFont = $this->formatPadrao;
2745
        $this->pTextBox($x+110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2746
        $texto = $this->getTagValue($this->aereo, "nOCA");
2747
        $aFont = $this->formatNegrito;
2748
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2749
        $x += $w * 0.23;
2750
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2751
        $texto = $this->getTagValue($this->aereo, "CL");
2752
        $aFont = $this->formatNegrito;
2753
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2754
        $x += 30;
2755
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2756
        $texto = $this->getTagValue($this->aereo, "cTar");
2757
        $aFont = $this->formatNegrito;
2758
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2759
        $x += 30;
2760
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2761
        $texto = $this->getTagValue($this->aereo, "vTar");
2762
        $aFont = $this->formatNegrito;
2763
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2764
    }
2765
2766
    /**
2767
     * zModalAquaviario
2768
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2769
     *
2770
     * @param  number $x Posição horizontal canto esquerdo
2771
     * @param  number $y Posição vertical canto superior
2772
     * @return number Posição vertical final
2773
     */
2774
    protected function zModalAquaviario($x = 0, $y = 0)
2775
    {
2776
        $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...
2777
        $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...
2778
        if ($this->orientacao == 'P') {
2779
            $maxW = $this->wPrint;
2780
        } else {
2781
            $maxW = $this->wPrint - $this->wCanhoto;
2782
        }
2783
        $w = $maxW;
2784
        $h = 8.5;
2785
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2786
        $aFont = $this->formatPadrao;
2787
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2788
        $y += 3.4;
2789
        $this->pdf->Line($x, $y, $w + 1, $y);
2790
        $texto = 'PORTO DE EMBARQUE';
2791
        $aFont = $this->formatPadrao;
2792
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2793
        $texto = $this->getTagValue($this->aquav, "prtEmb");
2794
        $aFont = $this->formatNegrito;
2795
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2796
        $x += $w * 0.50;
2797
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2798
        $texto = 'PORTO DE DESTINO';
2799
        $aFont = $this->formatPadrao;
2800
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2801
        $texto = $this->getTagValue($this->aquav, "prtDest");
2802
        $aFont = $this->formatNegrito;
2803
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2804
        $y += 8;
2805
        $this->pdf->Line(208, $y, 1, $y);
2806
        $x = 1;
2807
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2808
        $aFont = $this->formatPadrao;
2809
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2810
        $texto = $this->getTagValue($this->aquav, "xNavio");
2811
        $aFont = $this->formatNegrito;
2812
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2813
        $x += $w * 0.50;
2814
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2815
        $texto = 'VR DA B. DE CALC. AFRMM';
2816
        $aFont = $this->formatPadrao;
2817
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2818
        $texto = $this->getTagValue($this->aquav, "vPrest");
2819
        $aFont = $this->formatNegrito;
2820
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2821
        $x += $w * 0.17;
2822
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2823
        $texto = 'VALOR DO AFRMM';
2824
        $aFont = $this->formatPadrao;
2825
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2826
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
2827
        $aFont = $this->formatNegrito;
2828
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2829
        $x += $w * 0.12;
2830
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2831
        $texto = 'TIPO DE NAVEGAÇÃO';
2832
        $aFont = $this->formatPadrao;
2833
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2834
        $texto = $this->getTagValue($this->aquav, "tpNav");
2835
        switch ($texto) {
2836
            case '0':
2837
                $texto = 'INTERIOR';
2838
                break;
2839
            case '1':
2840
                $texto = 'CABOTAGEM';
2841
                break;
2842
        }
2843
        $aFont = $this->formatNegrito;
2844
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2845
        $x += $w * 0.14;
2846
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2847
        $texto = 'DIREÇÃO';
2848
        $aFont = $this->formatPadrao;
2849
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2850
        $texto = $this->getTagValue($this->aquav, "direc");
2851
        switch ($texto) {
2852
            case 'N':
2853
                $texto = 'NORTE';
2854
                break;
2855
            case 'L':
2856
                $texto = 'LESTE';
2857
                break;
2858
            case 'S':
2859
                $texto = 'SUL';
2860
                break;
2861
            case 'O':
2862
                $texto = 'OESTE';
2863
                break;
2864
        }
2865
        $aFont = $this->formatNegrito;
2866
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2867
        $y += 8;
2868
        $this->pdf->Line(208, $y, 1, $y);
2869
        $x = 1;
2870
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2871
        $aFont = $this->formatPadrao;
2872
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2873
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2874
            $texto = $this->infNF
2875
                ->item(0)
2876
                ->getElementsByTagName('infUnidCarga')
2877
                ->item(0)
2878
                ->getElementsByTagName('idUnidCarga')
2879
                ->item(0)->nodeValue;
2880
        } elseif ($this->infNFe->item(0) !== null
2881
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2882
        ) {
2883
            $texto = $this->infNFe
2884
                ->item(0)
2885
                ->getElementsByTagName('infUnidCarga')
2886
                ->item(0)
2887
                ->getElementsByTagName('idUnidCarga')
2888
                ->item(0)
2889
                ->nodeValue;
2890
        } elseif ($this->infOutros->item(0) !== null
2891
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2892
        ) {
2893
            $texto = $this->infOutros
2894
                ->item(0)
2895
                ->getElementsByTagName('infUnidCarga')
2896
                ->item(0)
2897
                ->getElementsByTagName('idUnidCarga')
2898
                ->item(0)
2899
                ->nodeValue;
2900
        } else {
2901
            $texto = '';
2902
        }
2903
        $aFont = $this->formatNegrito;
2904
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2905
        $x += $w * 0.50;
2906
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2907
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2908
        $aFont = $this->formatPadrao;
2909
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2910
        $texto = '';
2911
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
2912
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2913
                if ($k == 0) {
2914
                    $texto = $this->aquav
2915
                        ->getElementsByTagName('balsa')
2916
                        ->item($k)
2917
                        ->getElementsByTagName('xBalsa')
2918
                        ->item(0)
2919
                        ->nodeValue;
2920
                } else {
2921
                    $texto = $texto
2922
                        . ' / '
2923
                        . $this->aquav
2924
                            ->getElementsByTagName('balsa')
2925
                            ->item($k)
2926
                            ->getElementsByTagName('xBalsa')
2927
                            ->item(0)
2928
                            ->nodeValue;
2929
                }
2930
            }
2931
        }
2932
        $aFont = $this->formatNegrito;
2933
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2934
    }
2935
2936
    /**
2937
     * zModalFerr
2938
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2939
     *
2940
     * @param  number $x Posição horizontal canto esquerdo
2941
     * @param  number $y Posição vertical canto superior
2942
     * @return number Posição vertical final
2943
     */
2944
    protected function zModalFerr($x = 0, $y = 0)
2945
    {
2946
        $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...
2947
        $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...
2948
        if ($this->orientacao == 'P') {
2949
            $maxW = $this->wPrint;
2950
        } else {
2951
            $maxW = $this->wPrint - $this->wCanhoto;
2952
        }
2953
        $w = $maxW;
2954
        $h = 19.6;
2955
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2956
        $aFont = $this->formatPadrao;
2957
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2958
        $y += 3.4;
2959
        $this->pdf->Line($x, $y, $w + 1, $y);
2960
        $texto = 'DCL';
2961
        $aFont = array(
2962
            'font' => $this->fontePadrao,
2963
            'size' => 7,
2964
            'style' => 'B');
2965
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2966
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2967
        $texto = 'VAGÕES';
2968
        $aFont = array(
2969
            'font' => $this->fontePadrao,
2970
            'size' => 7,
2971
            'style' => 'B');
2972
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2973
        $y += 3.4;
2974
        $this->pdf->Line($x, $y, $w + 1, $y);
2975
        // DCL
2976
        $texto = 'ID TREM';
2977
        $aFont = array(
2978
            'font' => $this->fontePadrao,
2979
            'size' => 6,
2980
            'style' => '');
2981
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2982
        $texto = $this->getTagValue($this->ferrov, "idTrem");
2983
        $aFont = array(
2984
            'font' => $this->fontePadrao,
2985
            'size' => 6,
2986
            'style' => 'B');
2987
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2988
        $x += $w * 0.06;
2989
        $y1 = $y + 12.5;
2990
        $this->pdf->Line($x, $y, $x, $y1);
2991
        $texto = 'NUM';
2992
        $aFont = array(
2993
            'font' => $this->fontePadrao,
2994
            'size' => 6,
2995
            'style' => '');
2996
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2997
        $texto = $this->getTagValue($this->rem, "nDoc");
2998
        $aFont = array(
2999
            'font' => $this->fontePadrao,
3000
            'size' => 6,
3001
            'style' => 'B');
3002
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3003
        $x += $w * 0.06;
3004
        $this->pdf->Line($x, $y, $x, $y1);
3005
        $texto = 'SÉRIE';
3006
        $aFont = array(
3007
            'font' => $this->fontePadrao,
3008
            'size' => 6,
3009
            'style' => '');
3010
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3011
        $texto = $this->getTagValue($this->rem, "serie");
3012
        $aFont = array(
3013
            'font' => $this->fontePadrao,
3014
            'size' => 6,
3015
            'style' => 'B');
3016
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3017
        $x += $w * 0.06;
3018
        $this->pdf->Line($x, $y, $x, $y1);
3019
        $texto = 'EMISSÃO';
3020
        $aFont = array(
3021
            'font' => $this->fontePadrao,
3022
            'size' => 6,
3023
            'style' => '');
3024
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3025
        $texto = $this->pYmd2dmy($this->getTagValue($this->rem, "dEmi"));
3026
        $aFont = array(
3027
            'font' => $this->fontePadrao,
3028
            'size' => 6,
3029
            'style' => 'B');
3030
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3031
        // VAGOES
3032
        $x += $w * 0.06;
3033
        $this->pdf->Line($x, $y, $x, $y1);
3034
        $texto = 'NUM';
3035
        $aFont = array(
3036
            'font' => $this->fontePadrao,
3037
            'size' => 6,
3038
            'style' => '');
3039
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3040
        $texto = $this->getTagValue($this->ferrov, "nVag");
3041
        $aFont = array(
3042
            'font' => $this->fontePadrao,
3043
            'size' => 6,
3044
            'style' => 'B');
3045
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3046
        $x += $w * 0.06;
3047
        $this->pdf->Line($x, $y, $x, $y1);
3048
        $texto = 'TIPO';
3049
        $aFont = array(
3050
            'font' => $this->fontePadrao,
3051
            'size' => 6,
3052
            'style' => '');
3053
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3054
        $texto = $this->getTagValue($this->ferrov, "tpVag");
3055
        $aFont = array(
3056
            'font' => $this->fontePadrao,
3057
            'size' => 6,
3058
            'style' => 'B');
3059
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3060
        $x += $w * 0.06;
3061
        $this->pdf->Line($x, $y, $x, $y1);
3062
        $texto = 'CAPACIDADE';
3063
        $aFont = array(
3064
            'font' => $this->fontePadrao,
3065
            'size' => 6,
3066
            'style' => '');
3067
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3068
        $texto = $this->getTagValue($this->ferrov, "cap");
3069
        $aFont = array(
3070
            'font' => $this->fontePadrao,
3071
            'size' => 6,
3072
            'style' => 'B');
3073
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3074
        $x += $w * 0.08;
3075
        $this->pdf->Line($x, $y, $x, $y1);
3076
        $texto = 'PESO REAL/TON';
3077
        $aFont = array(
3078
            'font' => $this->fontePadrao,
3079
            'size' => 6,
3080
            'style' => '');
3081
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3082
        $texto = $this->getTagValue($this->ferrov, "pesoR");
3083
        $aFont = array(
3084
            'font' => $this->fontePadrao,
3085
            'size' => 6,
3086
            'style' => 'B');
3087
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3088
        $x += $w * 0.09;
3089
        $this->pdf->Line($x, $y, $x, $y1);
3090
        $texto = 'PESO BRUTO/TON';
3091
        $aFont = array(
3092
            'font' => $this->fontePadrao,
3093
            'size' => 6,
3094
            'style' => '');
3095
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3096
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
3097
        $aFont = array(
3098
            'font' => $this->fontePadrao,
3099
            'size' => 6,
3100
            'style' => 'B');
3101
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3102
        $x += $w * 0.1;
3103
        $this->pdf->Line($x, $y, $x, $y1);
3104
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3105
        $aFont = array(
3106
            'font' => $this->fontePadrao,
3107
            'size' => 6,
3108
            'style' => '');
3109
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3110
        $texto = $this->getTagValue($this->ferrov, "nCont");
3111
        $aFont = array(
3112
            'font' => $this->fontePadrao,
3113
            'size' => 6,
3114
            'style' => 'B');
3115
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3116
        // FLUXO
3117
        $x = 1;
3118
        $y += 12.9;
3119
        $h1 = $h * 0.5 + 0.27;
3120
        $wa = round($w * 0.103) + 0.5;
3121
        $texto = 'FLUXO FERROVIARIO';
3122
        $aFont = $this->formatPadrao;
3123
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3124
        $texto = $this->getTagValue($this->ferrov, "fluxo");
3125
        $aFont = array(
3126
            'font' => $this->fontePadrao,
3127
            'size' => 7,
3128
            'style' => 'B');
3129
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3130
        $y += 10;
3131
        $texto = 'TIPO DE TRÁFEGO';
3132
        $aFont = $this->formatPadrao;
3133
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3134
        $texto = $this->zConvertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
3135
        $aFont = array(
3136
            'font' => $this->fontePadrao,
3137
            'size' => 7,
3138
            'style' => 'B');
3139
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3140
        // Novo Box Relativo a Modal Ferroviário
3141
        $x = 22.5;
3142
        $y += -10.2;
3143
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3144
        $aFont = $this->formatPadrao;
3145
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3146
        $y += 3.4;
3147
        $this->pdf->Line($x, $y, $w + 1, $y);
3148
        $w = $w * 0.2;
3149
        $h = $h * 1.04;
3150
        $texto = 'CÓDIGO INTERNO';
3151
        $aFont = array(
3152
            'font' => $this->fontePadrao,
3153
            'size' => 6,
3154
            'style' => '');
3155
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3156
        $texto = $this->getTagValue($this->ferrov, "cInt");
3157
        $aFont = array(
3158
            'font' => $this->fontePadrao,
3159
            'size' => 6,
3160
            'style' => 'B');
3161
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3162
        $texto = 'CNPJ';
3163
        $aFont = array(
3164
            'font' => $this->fontePadrao,
3165
            'size' => 6,
3166
            'style' => '');
3167
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3168
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
3169
        $aFont = array(
3170
            'font' => $this->fontePadrao,
3171
            'size' => 6,
3172
            'style' => 'B');
3173
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3174
        $x += 50;
3175
        $texto = 'NOME';
3176
        $aFont = array(
3177
            'font' => $this->fontePadrao,
3178
            'size' => 6,
3179
            'style' => '');
3180
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3181
        $texto = $this->getTagValue($this->ferrov, "xNome");
3182
        $aFont = array(
3183
            'font' => $this->fontePadrao,
3184
            'size' => 6,
3185
            'style' => 'B');
3186
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3187
        $texto = 'INSCRICAO ESTADUAL';
3188
        $aFont = array(
3189
            'font' => $this->fontePadrao,
3190
            'size' => 6,
3191
            'style' => '');
3192
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3193
        $texto = $this->getTagValue($this->ferrov, "IE");
3194
        $aFont = array(
3195
            'font' => $this->fontePadrao,
3196
            'size' => 6,
3197
            'style' => 'B');
3198
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3199
        $x += 50;
3200
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3201
        $aFont = array(
3202
            'font' => $this->fontePadrao,
3203
            'size' => 6,
3204
            'style' => '');
3205
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3206
        $texto = '';
3207
        $aFont = array(
3208
            'font' => $this->fontePadrao,
3209
            'size' => 6,
3210
            'style' => 'B');
3211
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3212
    }
3213
3214
    /**
3215
     * zCanhoto
3216
     * Monta o campo com os dados do remetente na DACTE.
3217
     *
3218
     * @param  number $x Posição horizontal canto esquerdo
3219
     * @param  number $y Posição vertical canto superior
3220
     * @return number Posição vertical final
3221
     */
3222
    protected function zCanhoto($x = 0, $y = 0)
3223
    {
3224
        //$this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3225
        //$y = $y + 2;
3226
        $oldX = $x;
3227
        $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...
3228
        if ($this->orientacao == 'P') {
3229
            $maxW = $this->wPrint;
3230
        } else {
3231
            $maxW = $this->wPrint - $this->wCanhoto;
3232
        }
3233
        $w = $maxW - 1;
3234
        $h = 20;
3235
        $y = $y + 1;
3236
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3237
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3238
        $aFont = $this->formatPadrao;
3239
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3240
        $y += 3.4;
3241
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3242
        $texto = 'NOME';
3243
        $aFont = array(
3244
            'font' => $this->fontePadrao,
3245
            'size' => 6,
3246
            'style' => '');
3247
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3248
        $x += $w * 0.25;
3249
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3250
        $texto = 'ASSINATURA / CARIMBO';
3251
        $aFont = array(
3252
            'font' => $this->fontePadrao,
3253
            'size' => 6,
3254
            'style' => '');
3255
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3256
        $x += $w * 0.25;
3257
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3258
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3259
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3260
        $aFont = array(
3261
            'font' => $this->fontePadrao,
3262
            'size' => 6,
3263
            'style' => '');
3264
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3265
        $x = $oldX;
3266
        $y = $y + 5;
3267
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3268
        $texto = 'RG';
3269
        $aFont = array(
3270
            'font' => $this->fontePadrao,
3271
            'size' => 6,
3272
            'style' => '');
3273
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3274
        $x += $w * 0.85;
3275
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3276
        $texto = "CT-E";
3277
        $aFont = $this->formatNegrito;
3278
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3279
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
3280
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
3281
        $aFont = array(
3282
            'font' => $this->fontePadrao,
3283
            'size' => 6,
3284
            'style' => '');
3285
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3286
        $x = $oldX;
3287
        $this->zhDashedLine($x, $y + 12.7, $this->wPrint, 0.1, 80);
3288
    }
3289
3290
    /**
3291
     * zDadosAdic
3292
     * Coloca o grupo de dados adicionais da DACTE.
3293
     *
3294
     * @param  number $x Posição horizontal canto esquerdo
3295
     * @param  number $y Posição vertical canto superior
3296
     * @param  number $h altura do campo
3297
     * @return number Posição vertical final
3298
     */
3299
    protected function zDadosAdic($x, $y, $pag, $h)
0 ignored issues
show
Unused Code introduced by
The parameter $pag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $h is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
3300
    {
3301
        $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...
3302
        //###########################################################################
3303
        //DADOS ADICIONAIS DACTE
3304
        if ($this->orientacao == 'P') {
3305
            $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...
3306
        } else {
3307
            $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...
3308
        }
3309
        //INFORMAÇÕES COMPLEMENTARES
3310
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3311
        $y += 3;
3312
        $w = $this->wAdic;
3313
        $h = 8; //mudar
3314
        $aFont = array(
3315
            'font' => $this->fontePadrao,
3316
            'size' => 6,
3317
            'style' => '');
3318
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3319
        //$this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3320
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3321
        //o texto com os dados adicionais foi obtido na função xxxxxx
3322
        //e carregado em uma propriedade privada da classe
3323
        //$this->wAdic com a largura do campo
3324
        //$this->textoAdic com o texto completo do campo
3325
        $y += 1;
3326
        $aFont = $this->formatPadrao;
3327
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3328
        //RESERVADO AO FISCO
3329
        $texto = "RESERVADO AO FISCO";
3330
        $x += $w;
3331
        $y -= 1;
3332
        if ($this->orientacao == 'P') {
3333
            $w = $this->wPrint - $w;
3334
        } else {
3335
            $w = $this->wPrint - $w - $this->wCanhoto;
3336
        }
3337
        $aFont = array(
3338
            'font' => $this->fontePadrao,
3339
            'size' => 6,
3340
            'style' => '');
3341
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3342
        //inserir texto informando caso de contingência
3343
        //1 – Normal – emissão normal;
3344
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3345
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3346
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3347
        //Emissão em Contingência – DPEC;
3348
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3349
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3350
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3351
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3352
        $texto = '';
3353
        switch ($this->tpEmis) {
3354
            case 2:
3355
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3356
                break;
3357
            case 3:
3358
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3359
                break;
3360
            case 4:
3361
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3362
                break;
3363
            case 5:
3364
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3365
                break;
3366
        }
3367
        $y += 2;
3368
        $aFont = $this->formatPadrao;
3369
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3370
        return $y + $h;
3371
    }
3372
3373
    /**
3374
     * zhDashedLine
3375
     * Desenha uma linha horizontal tracejada com o FPDF
3376
     *
3377
     * @param  number $x Posição horizontal inicial, em mm
3378
     * @param  number $y Posição vertical inicial, em mm
3379
     * @param  number $w Comprimento da linha, em mm
3380
     * @param  number $h Espessura da linha, em mm
3381
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3382
     * @return none
3383
     */
3384
    protected function zhDashedLine($x, $y, $w, $h, $n)
3385
    {
3386
        $this->pdf->SetLineWidth($h);
3387
        $wDash = ($w / $n) / 2; // comprimento dos traços
3388
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3389
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3390
                if ($j <= ($x + $w - 1)) {
3391
                    $this->pdf->Line($j, $y, $j + 1, $y);
3392
                }
3393
            }
3394
        }
3395
    }
3396
3397
    /**
3398
     * zhDashedVerticalLine
3399
     * Desenha uma linha vertical tracejada com o FPDF
3400
     *
3401
     * @param  number $x Posição horizontal inicial, em mm
3402
     * @param  number $y Posição vertical inicial, em mm
3403
     * @param  number $w Comprimento da linha, em mm
3404
     * @param  number $yfinal Espessura da linha, em mm
3405
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3406
     * @return none
3407
     */
3408
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3409
    {
3410
        $this->pdf->SetLineWidth($w);
3411
        /* Organizando valores */
3412
        if ($y > $yfinal) {
3413
            $aux = $yfinal;
3414
            $yfinal = $y;
3415
            $y = $aux;
3416
        }
3417
        while ($y < $yfinal && $n > 0) {
3418
            $this->pdf->Line($x, $y, $x, $y + 1);
3419
            $y += 3;
3420
            $n--;
3421
        }
3422
    }
3423
3424
    /**
3425
     * zFormatCNPJCPF
3426
     * Formata campo CnpjCpf contida na CTe
3427
     *
3428
     * @param  string $field campo cnpjCpf da CT-e
3429
     * @return string
3430
     */
3431
    protected function zFormatCNPJCPF($field)
3432
    {
3433
        if (!isset($field)) {
3434
            return '';
3435
        }
3436
        $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...
3437
            $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...
3438
        if ($cnpj != "" && $cnpj != "00000000000000") {
3439
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3440
        } else {
3441
            $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...
3442
                $this->pFormat($field->getElementsByTagName("CPF")->item(0)->nodeValue, '###.###.###.###-##') : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

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

Loading history...
3443
        }
3444
        return $cnpj;
3445
    }
3446
3447
    /**
3448
     * zFormatFone
3449
     * Formata campo fone contida na CTe
3450
     *
3451
     * @param  string $field campo fone da CT-e
3452
     * @return string
3453
     */
3454
    protected function zFormatFone($field)
3455
    {
3456
        try {
3457
            $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...
3458
            $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...
3459
            $foneLen = strlen($fone);
3460
            if ($foneLen > 0) {
3461
                $fone2 = substr($fone, 0, $foneLen - 4);
3462
                $fone1 = substr($fone, 0, $foneLen - 8);
3463
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3464
            } else {
3465
                $fone = '';
3466
            }
3467
            return $fone;
3468
        } catch (Exception $exc) {
3469
            return '';
3470
        }
3471
    }
3472
3473
    /**
3474
     * zUnidade
3475
     * Converte a imformação de peso contida na CTe
3476
     *
3477
     * @param  string $c unidade de trafego extraida da CTe
3478
     * @return string
3479
     */
3480
    protected function zUnidade($c = '')
3481
    {
3482
        switch ($c) {
3483
            case '00':
3484
                $r = 'M3';
3485
                break;
3486
            case '01':
3487
                $r = 'KG';
3488
                break;
3489
            case '02':
3490
                $r = 'TON';
3491
                break;
3492
            case '03':
3493
                $r = 'UN';
3494
                break;
3495
            case '04':
3496
                $r = 'LT';
3497
                break;
3498
            case '05':
3499
                $r = 'MMBTU';
3500
                break;
3501
            default:
3502
                $r = '';
3503
        }
3504
        return $r;
3505
    }
3506
3507
    /**
3508
     * zConvertUnidTrafego
3509
     * Converte a imformação de peso contida na CTe
3510
     *
3511
     * @param  string $U Informação de trafego extraida da CTe
3512
     * @return string
3513
     */
3514
    protected function zConvertUnidTrafego($U = '')
3515
    {
3516
        if ($U) {
3517
            switch ($U) {
3518
                case '0':
3519
                    $stringU = 'Próprio';
3520
                    break;
3521
                case '1':
3522
                    $stringU = 'Mútuo';
3523
                    break;
3524
                case '2':
3525
                    $stringU = 'Rodoferroviário';
3526
                    break;
3527
                case '3':
3528
                    $stringU = 'Rodoviário';
3529
                    break;
3530
            }
3531
            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...
3532
        }
3533
    }
3534
3535
    /**
3536
     * zMultiUniPeso
3537
     * Fornece a imformação multiplicação de peso contida na CTe
3538
     *
3539
     * @param  interger $U Informação de peso extraida da CTe
3540
     * @return interger
3541
     */
3542
    protected function zMultiUniPeso($U = '')
3543
    {
3544
        if ($U === "01") {
3545
            // tonelada
3546
            //return 1000;
3547
            return 1;
3548
        }
3549
        return 1; // M3, KG, Unidade, litros, mmbtu
3550
    }
3551
3552
    protected function pQRDACTE($y = 0)
3553
    {
3554
        $margemInterna = $this->margemInterna;
3555
        $barcode = new Barcode();
3556
        $bobj = $barcode->getBarcodeObj(
3557
            'QRCODE,M',
3558
            $this->qrCodCTe,
3559
            -4,
3560
            -4,
3561
            'black',
3562
            array(-2, -2, -2, -2)
3563
        )->setBackgroundColor('white');
3564
        $qrcode = $bobj->getPngData();
3565
        $wQr = 36;
3566
        $hQr = 36;
3567
        $yQr = ($y + $margemInterna);
3568
        if ($this->orientacao == 'P') {
3569
            $xQr = 170;
3570
        } else {
3571
            $xQr = 250;
3572
        }
3573
        // prepare a base64 encoded "data url"
3574
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
3575
        $this->pdf->image($pic, $xQr - 3, $yQr, $wQr, $hQr, 'PNG');
3576
    }
3577
}
3578