Passed
Pull Request — master (#228)
by Roberto
03:23
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 $qrCodMDFe;
97
    protected $margemInterna = 2;
98
    
99
    /**
100
     * __construct
101
     *
102
     * @param string $docXML Arquivo XML da CTe
103
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
104
     * @param string $sPapel Tamanho do papel (Ex. A4)
105
     * @param string $sPathLogo Caminho para o arquivo do logo
106
     * @param string $sDestino Estabelece a direção do envio do documento PDF
107
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
108
     * @param string $fonteDACTE Nome da fonte a ser utilizada
109
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
110
     * @param string $preVisualizar 0-Não 1-Sim
111
     * @param string $nomeDesenvolvedor Nome do desenvolvedor
112
     * @param string $siteDesenvolvedor Site do desenvolvedor
113
     */
114
    public function __construct(
115
        $docXML = '',
116
        $sOrientacao = '',
117
        $sPapel = '',
118
        $sPathLogo = '',
119
        $sDestino = 'I',
120
        $sDirPDF = '',
121
        $fonteDACTE = '',
122
        $mododebug = 2,
123
        $preVisualizar = false,
124
        $nomeDesenvolvedor = 'Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org',
125
        $siteDesenvolvedor = 'http://www.nfephp.org'
126
    ) {
127
        if (is_numeric($mododebug)) {
128
            $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...
129
        }
130
        if ($mododebug == 1) {
131
            //ativar modo debug
132
            error_reporting(E_ALL);
133
            ini_set('display_errors', 'On');
134
        } elseif ($mododebug == 0) {
135
            //desativar modo debug
136
            error_reporting(0);
137
            ini_set('display_errors', 'Off');
138
        }
139
        $this->orientacao = $sOrientacao;
140
        $this->papel = $sPapel;
141
        $this->pdf = '';
142
        $this->xml = $docXML;
143
        $this->logomarca = $sPathLogo;
144
        $this->destino = $sDestino;
145
        $this->pdfDir = $sDirPDF;
146
        $this->preVisualizar = $preVisualizar;
147
        $this->siteDesenvolvedor = $siteDesenvolvedor;
148
        $this->nomeDesenvolvedor = $nomeDesenvolvedor;
149
        // verifica se foi passa a fonte a ser usada
150
        if (!empty($fonteDACTE)) {
151
            $this->fontePadrao = $fonteDACTE;
152
        }
153
        $this->formatPadrao = array(
154
            'font' => $this->fontePadrao,
155
            'size' => 6,
156
            'style' => '');
157
        $this->formatNegrito = array(
158
            'font' => $this->fontePadrao,
159
            'size' => 7,
160
            'style' => 'B');
161
        //se for passado o xml
162
        if (!empty($this->xml)) {
163
            $this->dom = new Dom();
164
            $this->dom->loadXML($this->xml);
165
            $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...
166
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
167
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
168
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
169
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
170
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
171
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
172
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
173
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
174
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
175
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
176
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
177
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
178
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
179
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
180
            $this->infQ = $this->dom->getElementsByTagName("infQ");
181
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
182
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
183
            $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...
184
            $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...
185
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
186
            $this->veic = $this->dom->getElementsByTagName("veic");
187
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
188
            // adicionar outros modais
189
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
190
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
191
            if ($this->tpCTe == 1) {
192
                $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chCTe");
193
            } else {
194
                $this->chaveCTeRef = $this->getTagValue($this->infCteAnu, "chCte");
195
            }
196
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
197
            $this->Comp = $this->dom->getElementsByTagName("Comp");
198
            $this->infNF = $this->dom->getElementsByTagName("infNF");
199
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
200
            $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...
201
            $this->compl = $this->dom->getElementsByTagName("compl");
202
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
203
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
204
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
205
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
206
            if (!empty($this->getTagValue($this->imp, "vTotTrib"))) {
207
                $textoAdic = number_format($this->getTagValue($this->imp, "vTotTrib"), 2, ",", ".");
208
                $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
209
                        .$textoAdic;
210
            }
211
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
212
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
213
            //Tag tomador é identificado por toma03 na versão 2.00
214
            if ($this->infCte->getAttribute("versao")=="2.00") {
215
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
216
            }
217
            //modal aquaviário
218
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
219
            $tomador = $this->getTagValue($this->toma03, "toma");
220
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
221
            switch ($tomador) {
222
                case '0':
223
                    $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...
224
                    $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...
225
                    break;
226
                case '1':
227
                    $this->toma = $this->exped;
228
                    $this->enderToma = $this->enderExped;
229
                    break;
230
                case '2':
231
                    $this->toma = $this->receb;
232
                    $this->enderToma = $this->enderReceb;
233
                    break;
234
                case '3':
235
                    $this->toma = $this->dest;
236
                    $this->enderToma = $this->enderDest;
237
                    break;
238
                default:
239
                    $this->toma = $this->toma4;
240
                    $this->enderToma = $this->getTagValue($this->toma4, "enderToma");
241
                    break;
242
            }
243
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
244
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
245
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
246
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
247
            $this->qrCodMDFe = $this->dom->getElementsByTagName('qrCodCTe')->item(0) ?
248
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : null;
249
            $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...
250
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
251
            $this->modal = $this->getTagValue($this->ide, "modal");
252
        }
253
    }
254
    
255
    /**
256
     * monta
257
     * @param string $orientacao L ou P
258
     * @param string $papel A4
259
     * @param string $logoAlign C, L ou R
260
     * @param Pdf $classPDF
261
     * @return string montagem
262
     */
263
    public function monta(
264
        $orientacao = '',
265
        $papel = 'A4',
266
        $logoAlign = 'C',
267
        $classPDF = false
268
    ) {
269
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 267 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...
270
    }
271
    
272
    /**
273
     * printDocument
274
     * @param string $nome
275
     * @param string $destino
276
     * @param string $printer
277
     * @return
278
     */
279
    public function printDocument($nome = '', $destino = 'I', $printer = '')
280
    {
281
        return $this->printDACTE($nome, $destino, $printer);
282
    }
283
    
284
    /**
285
     * Dados brutos do PDF
286
     * @return string
287
     */
288
    public function render()
289
    {
290
        return $this->pdf->getPdf();
291
    }
292
    protected function zCteDPEC()
293
    {
294
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
295
    }
296
    
297
    /**
298
     * montaDACTE
299
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
300
     * durante sua construção.
301
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
302
     * pelo conteúdo da funçao e podem ser modificados.
303
     *
304
     * @param  string $orientacao (Opcional) Estabelece a orientação da
305
     *                impressão (ex. P-retrato), se nada for fornecido será
306
     *                usado o padrão da NFe
307
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
308
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
309
     */
310
    public function montaDACTE(
311
        $orientacao = '',
312
        $papel = 'A4',
313
        $logoAlign = 'C',
314
        $classPDF = false
315
    ) {
316
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
317
        if ($orientacao == '') {
318
            if ($this->tpImp == '1') {
319
                $orientacao = 'P';
320
            } else {
321
                $orientacao = 'P';
322
            }
323
        }
324
        $this->orientacao = $orientacao;
325
        $this->papel = $papel;
326
        $this->logoAlign = $logoAlign;
327
        //$this->situacao_externa = $situacao_externa;
328
        //instancia a classe pdf
329
        if ($classPDF !== false) {
330
            $this->pdf = $classPDF;
331
        } else {
332
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
333
        }
334
        if ($this->orientacao == 'P') {
335
            // margens do PDF
336
            $margSup = 2;
337
            $margEsq = 2;
338
            $margDir = 2;
339
            // posição inicial do relatorio
340
            $xInic = 1;
341
            $yInic = 1;
342
            if ($papel == 'A4') {
343
                //A4 210x297mm
344
                $maxW = 210;
345
                $maxH = 297;
346
            }
347
        } else {
348
            // margens do PDF
349
            $margSup = 3;
350
            $margEsq = 3;
351
            $margDir = 3;
352
            // posição inicial do relatorio
353
            $xInic = 5;
354
            $yInic = 5;
355
            if ($papel == 'A4') {
356
                //A4 210x297mm
357
                $maxH = 210;
358
                $maxW = 297;
359
                $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...
360
            }
361
        }
362
        //total inicial de paginas
363
        $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...
364
        //largura imprimivel em mm
365
        $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...
366
        //comprimento imprimivel em mm
367
        $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...
368
        // estabelece contagem de paginas
369
        $this->pdf->AliasNbPages();
370
        // fixa as margens
371
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
372
        $this->pdf->SetDrawColor(0, 0, 0);
373
        $this->pdf->SetFillColor(255, 255, 255);
374
        // inicia o documento
375
        $this->pdf->Open();
376
        // adiciona a primeira página
377
        $this->pdf->AddPage($this->orientacao, $this->papel);
378
        $this->pdf->SetLineWidth(0.1);
379
        $this->pdf->SetTextColor(0, 0, 0);
380
        //calculo do numero de páginas ???
381
        $totPag = 1;
382
        //montagem da primeira página
383
        $pag = 1;
384
        $x = $xInic;
385
        $y = $yInic;
386
        //coloca o cabeçalho
387
        $y = $this->zCanhoto($x, $y);
388
        $y += 24;
389
        $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...
390
        $y += 70;
391
        $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...
392
        $x = $this->wPrint * 0.5 + 2;
393
        $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...
394
        $y += 19;
395
        $x = $xInic;
396
        $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...
397
        $x = $this->wPrint * 0.5 + 2;
398
        $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...
399
        $y += 19;
400
        $x = $xInic;
401
        $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...
402
        if ($this->tpCTe == '0') {
403
            //Normal
404
            $y += 10;
405
            $x = $xInic;
406
            $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...
407
            $y += 17;
408
            $x = $xInic;
409
            $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...
410
            $y += 25;
411
            $x = $xInic;
412
            $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...
413
            $y += 13;
414
            $x = $xInic;
415
            $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...
416
            if ($this->modal == '1') {
417
                if ($this->lota == 1) {
418
                    //$y += 24.95;
419
                    $y += 35;
420
                } else {
421
                    $y += 53;
422
                }
423
            } elseif ($this->modal == '2') {
424
                $y += 53;
425
            } elseif ($this->modal == '3') {
426
                $y += 37.75;
427
            } else {
428
                $y += 24.95;
429
            }
430
            $x = $xInic;
431
            $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...
432
            $y = $y-6;
433
            switch ($this->modal) {
434
                case '1':
435
                    $y += 25.9;
436
                    $x = $xInic;
437
                    $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...
438
                    break;
439
                case '2':
440
                    $y += 25.9;
441
                    $x = $xInic;
442
                    $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...
443
                    break;
444
                case '3':
445
                    $y += 17.9;
446
                    $x = $xInic;
447
                    $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...
448
                    break;
449
                case '4':
450
                    $y += 17.9;
451
                    $x = $xInic;
452
                    $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...
453
                    break;
454
                case '5':
455
                    $y += 17.9;
456
                    $x = $xInic;
457
                    // TODO fmertins 31/10/14: este método não existe...
458
                    $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...
459
                    break;
460
            }
461
            if ($this->modal == '1') {
462
                if ($this->lota == 1) {
463
                    $y += 37;
464
                } else {
465
                    $y += 8.9;
466
                }
467
            } elseif ($this->modal == '2') {
468
                $y += 8.9;
469
            } elseif ($this->modal == '3') {
470
                $y += 24.15;
471
            } else {
472
                $y += 37;
473
            }
474
        } else {
475
            //$r = $this->zCabecalho(1, 1, $pag, $totPag);
476
            //Complementado
477
            $y += 10;
478
            $x = $xInic;
479
            $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...
480
            $y += 80;
481
            $x = $xInic;
482
            $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...
483
            $y += 25;
484
            $x = $xInic;
485
            $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...
486
            $y += 13;
487
            $x = $xInic;
488
            $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...
489
            $y += 15;
490
        }
491
        $x = $xInic;
492
        $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...
493
        //$y += 19;
494
        //$y += 11;
495
        //$y = $this->zCanhoto($x, $y);
496
        //coloca o rodapé da página
497
        if ($this->orientacao == 'P') {
498
            $this->zRodape(2, $this->hPrint - 2);
499
        } else {
500
            $this->zRodape($xInic, $this->hPrint + 2.3);
501
        }
502
        if ($this->flagDocOrigContinuacao == 1) {
503
            $this->zdocOrigContinuacao(1, 71);
504
        }
505
        //retorna o ID na CTe
506
        if ($classPDF !== false) {
507
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
508
            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...
509
        } else {
510
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
511
        }
512
    }
513
    
514
    /**
515
     * printDACTE
516
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
517
     * O destino da impressão pode ser :
518
     * I-browser
519
     * D-browser com download
520
     * F-salva em um arquivo local com o nome informado
521
     * S-retorna o documento como uma string e o nome é ignorado.
522
     * Para enviar o pdf diretamente para uma impressora indique o
523
     * nome da impressora e o destino deve ser 'S'.
524
     *
525
     * @param  string $nome Path completo com o nome do arquivo pdf
526
     * @param  string $destino Direção do envio do PDF
527
     * @param  string $printer Identificação da impressora no sistema
528
     * @return string Caso o destino seja S o pdf é retornado como uma string
529
     * @todo Rotina de impressão direta do arquivo pdf criado
530
     */
531
    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...
532
    {
533
        $arq = $this->pdf->Output($nome, $destino);
534
        if ($destino == 'S') {
535
            //aqui pode entrar a rotina de impressão direta
536
        }
537
        return $arq;
538
    }
539
    
540
    /**
541
     * zCabecalho
542
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
543
     *
544
     * @param  number $x Posição horizontal inicial, canto esquerdo
545
     * @param  number $y Posição vertical inicial, canto superior
546
     * @param  number $pag Número da Página
547
     * @param  number $totPag Total de páginas
548
     * @return number Posição vertical final
549
     */
550
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
551
    {
552
        $oldX = $x;
553
        $oldY = $y;
554
        if ($this->orientacao == 'P') {
555
            $maxW = $this->wPrint;
556
        } else {
557
            if ($pag == 1) {
558
                // primeira página
559
                $maxW = $this->wPrint - $this->wCanhoto;
560
            } else {
561
                // páginas seguintes
562
                $maxW = $this->wPrint;
563
            }
564
        }
565
        //##################################################################
566
        //coluna esquerda identificação do emitente
567
        //$w = round($maxW * 0.42);
568
        $w = round($maxW * 0.32);
569
        if ($this->orientacao == 'P') {
570
            $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...
571
                'font' => $this->fontePadrao,
572
                'size' => 6,
573
                'style' => '');
574
        } else {
575
            $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...
576
        }
577
        $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...
578
        $h = 35;
579
        $oldY += $h;
580
        //desenha a caixa
581
        $this->pTextBox($x, $y, $w + 2, $h + 1);
582
        // coloca o logo
583
        if (is_file($this->logomarca)) {
584
            $logoInfo = getimagesize($this->logomarca);
585
            //largura da imagem em mm
586
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
587
            //altura da imagem em mm
588
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
589
            if ($this->logoAlign == 'L') {
590
                $nImgW = round($w / 3, 0);
591
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
592
                $xImg = $x + 1;
593
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
594
                //estabelecer posições do texto
595
                $x1 = round($xImg + $nImgW + 1, 0);
596
                $y1 = round($h / 3 + $y, 0);
597
                $tw = round(2 * $w / 3, 0);
598
            } elseif ($this->logoAlign == 'C') {
599
                $nImgH = round($h / 3, 0);
600
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
601
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
602
                $yImg = $y + 3;
603
                $x1 = $x;
604
                $y1 = round($yImg + $nImgH + 1, 0);
605
                $tw = $w;
606
            } elseif ($this->logoAlign == 'R') {
607
                $nImgW = round($w / 3, 0);
608
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
609
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
610
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
611
                $x1 = $x;
612
                $y1 = round($h / 3 + $y, 0);
613
                $tw = round(2 * $w / 3, 0);
614
            }
615
            $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...
616
        } else {
617
            $x1 = $x;
618
            $y1 = round($h / 3 + $y, 0);
619
            $tw = $w;
620
        }
621
        //Nome emitente
622
        $aFont = array(
623
            'font' => $this->fontePadrao,
624
            'size' => 9,
625
            'style' => 'B');
626
        $texto = $this->getTagValue($this->emit, "xNome");
627
        $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...
628
        //endereço
629
        $y1 = $y1 + 3;
630
        $aFont = array(
631
            'font' => $this->fontePadrao,
632
            'size' => 7,
633
            'style' => '');
634
        $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...
635
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
636
        $nro = $this->getTagValue($this->enderEmit, "nro");
637
        $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...
638
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
639
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
640
        $CEP = $this->pFormat($CEP, "#####-###");
641
        $mun = $this->getTagValue($this->enderEmit, "xMun");
642
        $UF = $this->getTagValue($this->enderEmit, "UF");
643
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
644
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
645
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
646
            . "\n  Fone/Fax: " . $fone;
647
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
648
        //CNPJ/CPF IE
649
        $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...
650
        $ie = $this->getTagValue($this->emit, "IE");
651
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
652
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
653
        //outra caixa
654
        $h1 = 17.5;
655
        $y1 = $y + $h + 1;
656
        $this->pTextBox($x, $y1, $w + 2, $h1);
657
        //TIPO DO CT-E
658
        $texto = 'TIPO DO CTE';
659
        //$wa = 37;
660
        $wa = 34;
661
        $aFont = array(
662
            'font' => $this->fontePadrao,
663
            'size' => 8,
664
            'style' => '');
665
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
666
        $tpCTe = $this->getTagValue($this->ide, "tpCTe");
667
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
668
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
669
        switch ($tpCTe) {
670
            case '0':
671
                $texto = 'Normal';
672
                break;
673
            case '1':
674
                $texto = 'Complemento de Valores';
675
                break;
676
            case '2':
677
                $texto = 'Anulação de Valores';
678
                break;
679
            case '3':
680
                $texto = 'Substituto';
681
                break;
682
            default:
683
                $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...
684
        }
685
        $aFont = $this->formatNegrito;
686
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
687
        //TIPO DO SERVIÇO
688
        $texto = 'TIPO DO SERVIÇO';
689
        $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...
690
        $aFont = array(
691
            'font' => $this->fontePadrao,
692
            'size' => 8,
693
            'style' => '');
694
        $this->pTextBox($x + $wa, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
695
        $tpServ = $this->getTagValue($this->ide, "tpServ");
696
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
697
        switch ($tpServ) {
698
            case '0':
699
                $texto = 'Normal';
700
                break;
701
            case '1':
702
                $texto = 'Subcontratação';
703
                break;
704
            case '2':
705
                $texto = 'Redespacho';
706
                break;
707
            case '3':
708
                $texto = 'Redespacho Intermediário';
709
                break;
710
            default:
711
                $texto = 'ERRO' . $tpServ;
712
        }
713
        $aFont = $this->formatNegrito;
714
        $this->pTextBox($x + $wa, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
715
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
716
        //TOMADOR DO SERVIÇO
717
        $texto = 'IND.DO CT-E GLOBALIZADO';
718
        $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...
719
        $y2 = $y1 + 8;
720
        $aFont = array(
721
            'font' => $this->fontePadrao,
722
            'size' => 6,
723
            'style' => '');
724
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
725
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
726
        $toma = $this->getTagValue($this->ide, "indGlobalizado");
727
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
728
        if ($toma==1) {
729
            $aFont = array(
730
            'font' => $this->fontePadrao,
731
            'size' => 11,
732
            'style' => '');
733
            $this->pTextBox($x-14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
734
        } else {
735
            $aFont = array(
736
            'font' => $this->fontePadrao,
737
            'size' => 11,
738
            'style' => '');
739
            $this->pTextBox($x+3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
740
        }
741
        $aFont = $this->formatNegrito;
742
        $this->pdf->Line($x+3, $x+71, $x+3, $x+75);
743
        $this->pdf->Line($x+8, $x+71, $x+8, $x+75);
744
        $this->pdf->Line($x+3, $x+71, $x+8, $x+71);
745
        $this->pdf->Line($x+3, $x+75, $x+8, $x+75);
746
        $this->pTextBox($x-6, $y2+1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
747
        $this->pdf->Line($x+18, $x+71, $x+18, $x+75);
748
        $this->pdf->Line($x+23, $x+71, $x+23, $x+75);
749
        $this->pdf->Line($x+18, $x+71, $x+23, $x+71);
750
        $this->pdf->Line($x+18, $x+75, $x+23, $x+75);
751
        $this->pTextBox($x+9.8, $y2+1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
752
        //FORMA DE PAGAMENTO
753
        $texto = 'INF.DO CT-E GLOBALIZADO';
754
        $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...
755
        $aFont = array(
756
            'font' => $this->fontePadrao,
757
            'size' => 8,
758
            'style' => '');
759
        $this->pTextBox($x + $wa, $y2-0.5, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
760
        $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...
761
        //##################################################################
762
        //coluna direita
763
        $x += $w + 2;
764
        $w = round($maxW * 0.212);
765
        $w1 = $w;
766
        $h = 11;
767
        $this->pTextBox($x, $y, $w + 2, $h + 1);
768
        $texto = "DACTE";
769
        $aFont = array(
770
            'font' => $this->fontePadrao,
771
            'size' => 10,
772
            'style' => 'B');
773
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
774
        $aFont = array(
775
            'font' => $this->fontePadrao,
776
            'size' => 8,
777
            'style' => '');
778
        $texto = "Documento Auxiliar do Conhecimento de\nTransporte Eletrônico";
779
        $h = 10;
780
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
781
        $x1 = $x + $w + 2;
782
        $w = round($maxW * 0.212, 0);
783
        $w2 = $w;
784
        $h = 11;
785
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
786
        $texto = "MODAL";
787
        $aFont = array(
788
            'font' => $this->fontePadrao,
789
            'size' => 8,
790
            'style' => '');
791
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
792
        switch ($this->modal) {
793
            case '1':
794
                $texto = 'Rodoviário';
795
                break;
796
            case '2':
797
                $texto = 'Aéreo';
798
                break;
799
            case '3':
800
                $texto = 'Aquaviário';
801
                break;
802
            case '4':
803
                $texto = 'Ferroviário';
804
                break;
805
            case '5':
806
                $texto = 'Dutoviário';
807
                break;
808
        }
809
        $aFont = array(
810
            'font' => $this->fontePadrao,
811
            'size' => 10,
812
            'style' => 'B');
813
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
814
        //outra caixa
815
        $y += 12;
816
        $h = 9;
817
        $w = $w1 + $w2 + 2;
818
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
819
        //modelo
820
        $wa = 12;
821
        $xa = $x;
822
        $texto = 'MODELO';
823
        $aFont = array(
824
            'font' => $this->fontePadrao,
825
            'size' => 8,
826
            'style' => '');
827
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
828
        $texto = $this->getTagValue($this->ide, "mod");
829
        $aFont = $this->formatNegrito;
830
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
831
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
832
        //serie
833
        $wa = 11;
834
        $xa += $wa;
835
        $texto = 'SÉRIE';
836
        $aFont = array(
837
            'font' => $this->fontePadrao,
838
            'size' => 8,
839
            'style' => '');
840
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
841
        $texto = $this->getTagValue($this->ide, "serie");
842
        $aFont = $this->formatNegrito;
843
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
844
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
845
        //numero
846
        $xa += $wa;
847
        $wa = 14;
848
        $texto = 'NÚMERO';
849
        $aFont = array(
850
            'font' => $this->fontePadrao,
851
            'size' => 8,
852
            'style' => '');
853
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
854
        $texto = $this->getTagValue($this->ide, "nCT");
855
        $aFont = $this->formatNegrito;
856
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
857
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
858
        //folha
859
        $xa += $wa;
860
        $wa = 6;
861
        $texto = 'FL';
862
        $aFont = array(
863
            'font' => $this->fontePadrao,
864
            'size' => 8,
865
            'style' => '');
866
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
867
        //$texto = '1/1';
868
        $texto = $pag."/".$totPag;
869
        $aFont = $this->formatNegrito;
870
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
871
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
872
        //data  hora de emissão
873
        $xa += $wa;
874
        $wa = 28;
875
        $texto = 'DATA E HORA DE EMISSÃO';
876
        $aFont = array(
877
            'font' => $this->fontePadrao,
878
            'size' => 8,
879
            'style' => '');
880
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
881
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
882
            date('d/m/Y H:i:s', $this->pConvertTime($this->getTagValue($this->ide, "dhEmi"))) : '';
883
        $aFont = $this->formatNegrito;
884
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
885
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
886
        //ISUF
887
        $xa += $wa;
888
        $wa = 30;
889
        $texto = 'INSC.SUF.DO DEST';
890
        $aFont = $this->formatPadrao;
891
        $this->pTextBox($xa-5, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
892
        $texto = $this->getTagValue($this->dest, "ISUF");
893
        $aFont = array(
894
            'font' => $this->fontePadrao,
895
            'size' => 7,
896
            'style' => 'B');
897
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
898
        //outra caixa
899
        $y += $h + 1;
900
        $h = 23;
901
        $h1 = 14;
902
        $this->pTextBox($x, $y, $w + 0.5, $h1);
903
        //CODIGO DE BARRAS
904
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
905
        $bW = 85;
906
        $bH = 10;
907
        //codigo de barras
908
        $this->pdf->SetFillColor(0, 0, 0);
909
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
910
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
911
        $texto = 'CHAVE DE ACESSO';
912
        $aFont = $this->formatPadrao;
913
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
914
        $aFont = $this->formatNegrito;
915
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
916
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
917
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
918
        $texto = "Consulta em http://www.cte.fazenda.gov.br/portal";
919
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
920
            $texto = "";
921
            $this->pdf->SetFillColor(0, 0, 0);
922
            if ($this->tpEmis == 5) {
923
                $chaveContingencia = $this->zGeraChaveAdicCont();
924
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
925
            } else {
926
                $chaveContingencia = $this->getTagValue($this->protCTe, "nProt");
927
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
928
            }
929
            //codigo de barras
930
        }
931
        $aFont = array(
932
            'font' => $this->fontePadrao,
933
            'size' => 8,
934
            'style' => '');
935
        $this->pTextBox($x, $y + $h1 + 11, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
936
        //outra caixa
937
        $y += $h + 1;
938
        $h = 8.5;
939
        $wa = $w;
940
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
941
        if ($this->zCteDPEC()) {
942
            $texto = 'NÚMERO DE REGISTRO DPEC';
943
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
944
            $texto = "DADOS DO CT-E";
945
        } else {
946
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
947
        }
948
        $aFont = $this->formatPadrao;
949
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
950
        if ($this->zCteDPEC()) {
951
            $texto = $this->numero_registro_dpec;
952
        } elseif ($this->tpEmis == 5) {
953
            $chaveContingencia = $this->zGeraChaveAdicCont();
954
            $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...
955
                'font' => $this->fontePadrao,
956
                'size' => 8,
957
                'style' => 'B');
958
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
959
            $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...
960
        } else {
961
            $texto = $this->getTagValue($this->protCTe, "nProt") . " - ";
962
            if (!empty($this->protCTe)
963
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
964
            ) {
965
                $texto .= date(
966
                    'd/m/Y   H:i:s',
967
                    $this->pConvertTime($this->getTagValue($this->protCTe, "dhRecbto"))
968
                );
969
            }
970
            $texto = $this->getTagValue($this->protCTe, "nProt") == '' ? '' : $texto;
971
        }
972
        $aFont = $this->formatNegrito;
973
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
974
        if ($this->qrCodMDFe !== null) {
975
            $this->pQRDAMDFE($y-32);
976
        }
977
        //CFOP
978
        $x = $oldX;
979
        $h = 8.5;
980
        $w = round($maxW * 0.32);
981
        $y1 = $y + 7.5;
982
        $this->pTextBox($x, $y1, $w + 2, $h);
983
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
984
        $aFont = array(
985
            'font' => $this->fontePadrao,
986
            'size' => 8,
987
            'style' => '');
988
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
989
        $texto = $this->getTagValue($this->ide, "CFOP") . ' - ' . $this->getTagValue($this->ide, "natOp");
990
        $aFont = $this->formatNegrito;
991
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
992
        //ORIGEM DA PRESTAÇÃO
993
        $y += $h + 7.5;
994
        $x = $oldX;
995
        $h = 8;
996
        $w = ($maxW * 0.5);
997
        $this->pTextBox($x, $y, $w + 0.5, $h);
998
        $texto = 'INÍCIO DA PRESTAÇÃO';
999
        $aFont = array(
1000
            'font' => $this->fontePadrao,
1001
            'size' => 8,
1002
            'style' => '');
1003
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1004
        $texto = $this->getTagValue($this->ide, "xMunIni") . ' - ' . $this->getTagValue($this->ide, "UFIni");
1005
        $aFont = $this->formatNegrito;
1006
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1007
        //DESTINO DA PRESTAÇÃO
1008
        $x = $oldX + $w + 1;
1009
        $h = 8;
1010
        $w = $w - 1.3;
1011
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1012
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1013
        $aFont = array(
1014
            'font' => $this->fontePadrao,
1015
            'size' => 8,
1016
            'style' => '');
1017
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1018
        $texto = $this->getTagValue($this->ide, "xMunFim") . ' - ' . $this->getTagValue($this->ide, "UFFim");
1019
        $aFont = $this->formatNegrito;
1020
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1021
        //#########################################################################
1022
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1023
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1024
        //indicar cancelamento
1025
        $cStat = $this->getTagValue($this->cteProc, "cStat");
1026
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1027
            //101 Cancelamento
1028
            $x = 10;
1029
            $y = $this->hPrint - 130;
1030
            $h = 25;
1031
            $w = $maxW - (2 * $x);
1032
            $this->pdf->SetTextColor(90, 90, 90);
1033
            $texto = "CTe CANCELADO";
1034
            $aFont = array(
1035
                'font' => $this->fontePadrao,
1036
                'size' => 48,
1037
                'style' => 'B');
1038
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1039
            $this->pdf->SetTextColor(0, 0, 0);
1040
        }
1041
        $cStat = $this->getTagValue($this->cteProc, "cStat");
1042
        if ($cStat == '110' ||
1043
            $cStat == '301' ||
1044
            $cStat == '302' ||
1045
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1046
        ) {
1047
            //110 Denegada
1048
            $x = 10;
1049
            $y = $this->hPrint - 130;
1050
            $h = 25;
1051
            $w = $maxW - (2 * $x);
1052
            $this->pdf->SetTextColor(90, 90, 90);
1053
            $texto = "CTe USO DENEGADO";
1054
            $aFont = array(
1055
                'font' => $this->fontePadrao,
1056
                'size' => 48,
1057
                'style' => 'B');
1058
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1059
            $y += $h;
1060
            $h = 5;
1061
            $w = $maxW - (2 * $x);
1062
            $texto = "SEM VALOR FISCAL";
1063
            $aFont = array(
1064
                'font' => $this->fontePadrao,
1065
                'size' => 48,
1066
                'style' => 'B');
1067
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1068
            $this->pdf->SetTextColor(0, 0, 0);
1069
        }
1070
        //indicar sem valor
1071
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1072
            $x = 10;
1073
            if ($this->orientacao == 'P') {
1074
                $y = round($this->hPrint * 2 / 3, 0);
1075
            } else {
1076
                $y = round($this->hPrint / 2, 0);
1077
            }
1078
            $h = 5;
1079
            $w = $maxW - (2 * $x);
1080
            $this->pdf->SetTextColor(90, 90, 90);
1081
            $texto = "SEM VALOR FISCAL";
1082
            $aFont = array(
1083
                'font' => $this->fontePadrao,
1084
                'size' => 48,
1085
                'style' => 'B');
1086
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1087
            $aFont = array(
1088
                'font' => $this->fontePadrao,
1089
                'size' => 30,
1090
                'style' => 'B');
1091
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1092
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1093
            $this->pdf->SetTextColor(0, 0, 0);
1094
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1095
            $h = 5;
1096
            $w = $maxW - (2 * 10);
1097
            $x = 55;
1098
            $y = 240;
1099
            $this->pdf->SetTextColor(255, 100, 100);
1100
            $aFont = array(
1101
                'font' => $this->fontePadrao,
1102
                'size' => 40,
1103
                'style' => 'B');
1104
            $texto = "Pré-visualização";
1105
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1106
            $this->pdf->SetTextColor(255, 100, 100);
1107
            $aFont = array(
1108
                'font' => $this->fontePadrao,
1109
                'size' => 41,
1110
                'style' => 'B');
1111
            $texto = "Sem Validade Jurídica";
1112
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1113
            $this->pdf->SetTextColor(90, 90, 90);
1114
            $texto = "SEM VALOR FISCAL";
1115
            $aFont = array(
1116
                'font' => $this->fontePadrao,
1117
                'size' => 48,
1118
                'style' => 'B');
1119
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1120
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1121
        } else {
1122
            $x = 10;
1123
            if ($this->orientacao == 'P') {
1124
                $y = round($this->hPrint * 2 / 3, 0);
1125
            } else {
1126
                $y = round($this->hPrint / 2, 0);
1127
            } //fim orientacao
1128
            $h = 5;
1129
            $w = $maxW - (2 * $x);
1130
            $this->pdf->SetTextColor(90, 90, 90);
1131
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1132
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1133
                //Contingência
1134
                $texto = "DACTE Emitido em Contingência";
1135
                $aFont = array(
1136
                    'font' => $this->fontePadrao,
1137
                    'size' => 48,
1138
                    'style' => 'B');
1139
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1140
                $aFont = array(
1141
                    'font' => $this->fontePadrao,
1142
                    'size' => 30,
1143
                    'style' => 'B');
1144
                $texto = "devido à problemas técnicos";
1145
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1146
            } else {
1147
                if (!isset($this->protCTe)) {
1148
                    if (!$this->zCteDPEC()) {
1149
                        $texto = "SEM VALOR FISCAL";
1150
                        $aFont = array(
1151
                            'font' => $this->fontePadrao,
1152
                            'size' => 48,
1153
                            'style' => 'B');
1154
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1155
                    }
1156
                    $aFont = array(
1157
                        'font' => $this->fontePadrao,
1158
                        'size' => 30,
1159
                        'style' => 'B');
1160
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1161
                    if (!$this->zCteDPEC()) {
1162
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1163
                    } else {
1164
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1165
                    }
1166
                } //fim cteProc
1167
                if ($this->tpEmis == 4) {
1168
                    //DPEC
1169
                    $x = 10;
1170
                    $y = $this->hPrint - 130;
1171
                    $h = 25;
1172
                    $w = $maxW - (2 * $x);
1173
                    $this->pdf->SetTextColor(200, 200, 200); // 90,90,90 é muito escuro
1174
                    $texto = "DACTE impresso em contingência -\n"
1175
                        . "DPEC regularmente recebido pela Receita\n"
1176
                        . "Federal do Brasil";
1177
                    $aFont = array(
1178
                        'font' => $this->fontePadrao,
1179
                        'size' => 48,
1180
                        'style' => 'B');
1181
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1182
                    $this->pdf->SetTextColor(0, 0, 0);
1183
                }
1184
            } //fim tpEmis
1185
            $this->pdf->SetTextColor(0, 0, 0);
1186
        }
1187
        return $oldY;
1188
    }
1189
    
1190
    /**
1191
     * rodapeDACTE
1192
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1193
     *
1194
     * @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...
1195
     * @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...
1196
     */
1197
    protected function zRodape($x, $y)
1198
    {
1199
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1200
        $w = $this->wPrint - 4;
1201
        $aFont = array(
1202
            'font' => $this->fontePadrao,
1203
            'size' => 6,
1204
            'style' => '');
1205
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1206
        $texto = 'Desenvolvido por '.$this->nomeDesenvolvedor . ' - '. $this->siteDesenvolvedor;
1207
        $aFont = array(
1208
            'font' => $this->fontePadrao,
1209
            'size' => 6,
1210
            'style' => '');
1211
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, $this->siteDesenvolvedor);
1212
    }
1213
    
1214
    /**
1215
     * zRemetente
1216
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1217
     *
1218
     * @param  number $x Posição horizontal canto esquerdo
1219
     * @param  number $y Posição vertical canto superior
1220
     * @return number Posição vertical final
1221
     */
1222
    protected function zRemetente($x = 0, $y = 0)
1223
    {
1224
        $oldX = $x;
1225
        $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...
1226
        if ($this->orientacao == 'P') {
1227
            $maxW = $this->wPrint;
1228
        } else {
1229
            $maxW = $this->wPrint - $this->wCanhoto;
1230
        }
1231
        $w = $maxW * 0.5 + 0.5;
1232
        $h = 19;
1233
        $x1 = $x + 16;
1234
        $texto = 'REMETENTE';
1235
        $aFont = $this->formatPadrao;
1236
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1237
        $aFont = $this->formatNegrito;
1238
        $texto = $this->getTagValue($this->rem, "xNome");
1239
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1240
        $y += 3;
1241
        $texto = 'ENDEREÇO';
1242
        $aFont = $this->formatPadrao;
1243
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1244
        $aFont = $this->formatNegrito;
1245
        $texto = $this->getTagValue($this->enderReme, "xLgr") . ',';
1246
        $texto .= $this->getTagValue($this->enderReme, "nro");
1247
        $texto .= ($this->getTagValue($this->enderReme, "xCpl") != "") ?
1248
            ' - ' . $this->getTagValue($this->enderReme, "xCpl") : '';
1249
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1250
        $y += 3;
1251
        $texto = $this->getTagValue($this->enderReme, "xBairro");
1252
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1253
        $y += 3;
1254
        $texto = 'MUNICÍPIO';
1255
        $aFont = $this->formatPadrao;
1256
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1257
        $texto = $this->getTagValue($this->enderReme, "xMun") . ' - ';
1258
        $texto .= $this->getTagValue($this->enderReme, "UF");
1259
        $aFont = $this->formatNegrito;
1260
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1261
        $x = $w - 18;
1262
        $texto = 'CEP';
1263
        $aFont = $this->formatPadrao;
1264
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1265
        $texto = $this->pFormat($this->getTagValue($this->enderReme, "CEP"), "#####-###");
1266
        $aFont = $this->formatNegrito;
1267
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1268
        $x = $oldX;
1269
        $y += 3;
1270
        $texto = 'CNPJ/CPF';
1271
        $aFont = $this->formatPadrao;
1272
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1273
        $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...
1274
        $aFont = $this->formatNegrito;
1275
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1276
        $x = $w - 45;
1277
        $texto = 'INSCRIÇÃO ESTADUAL';
1278
        $aFont = $this->formatPadrao;
1279
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1280
        $texto = $this->getTagValue($this->rem, "IE");
1281
        $aFont = $this->formatNegrito;
1282
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1283
        $x = $oldX;
1284
        $y += 3;
1285
        $texto = 'PAÍS';
1286
        $aFont = $this->formatPadrao;
1287
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1288
        $texto = $this->getTagValue($this->rem, "xPais") != "" ?
1289
            $this->getTagValue($this->rem, "xPais") : 'BRASIL';
1290
        $aFont = $this->formatNegrito;
1291
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1292
        $x = $w - 25;
1293
        $texto = 'FONE';
1294
        $aFont = $this->formatPadrao;
1295
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1296
        //$texto = $this->zFormatFone($this->rem);
1297
        $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...
1298
        $aFont = $this->formatNegrito;
1299
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1300
    }
1301
    
1302
    /**
1303
     * zDestinatario
1304
     * Monta o campo com os dados do destinatário na DACTE.
1305
     *
1306
     * @param  number $x Posição horizontal canto esquerdo
1307
     * @param  number $y Posição vertical canto superior
1308
     * @return number Posição vertical final
1309
     */
1310
    protected function zDestinatario($x = 0, $y = 0)
1311
    {
1312
        $oldX = $x;
1313
        $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...
1314
        if ($this->orientacao == 'P') {
1315
            $maxW = $this->wPrint;
1316
        } else {
1317
            $maxW = $this->wPrint - $this->wCanhoto;
1318
        }
1319
        $w = ($maxW * 0.5) - 0.7;
1320
        $h = 19;
1321
        $x1 = $x + 19;
1322
        $texto = 'DESTINATÁRIO';
1323
        $aFont = $this->formatPadrao;
1324
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1325
        $aFont = $this->formatNegrito;
1326
        $texto = $this->getTagValue($this->dest, "xNome");
1327
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1328
        $y += 3;
1329
        $texto = 'ENDEREÇO';
1330
        $aFont = $this->formatPadrao;
1331
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1332
        $aFont = $this->formatNegrito;
1333
        $texto = $this->getTagValue($this->enderDest, "xLgr") . ',';
1334
        $texto .= $this->getTagValue($this->enderDest, "nro");
1335
        $texto .= $this->getTagValue($this->enderDest, "xCpl") != "" ?
1336
            ' - ' . $this->getTagValue($this->enderDest, "xCpl") : '';
1337
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1338
        $y += 3;
1339
        $texto = $this->getTagValue($this->enderDest, "xBairro");
1340
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1341
        $y += 3;
1342
        $texto = 'MUNICÍPIO';
1343
        $aFont = $this->formatPadrao;
1344
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1345
        $texto = $this->getTagValue($this->enderDest, "xMun") . ' - ';
1346
        $texto .= $this->getTagValue($this->enderDest, "UF");
1347
        $aFont = $this->formatNegrito;
1348
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1349
        $x = $w - 19 + $oldX;
1350
        $texto = 'CEP';
1351
        $aFont = $this->formatPadrao;
1352
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1353
        $texto = $this->pFormat($this->getTagValue($this->enderDest, "CEP"), "#####-###");
1354
        $aFont = $this->formatNegrito;
1355
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1356
        $x = $oldX;
1357
        $y += 3;
1358
        $texto = 'CNPJ/CPF';
1359
        $aFont = $this->formatPadrao;
1360
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1361
        $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...
1362
        $aFont = $this->formatNegrito;
1363
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1364
        $x = $w - 47.5 + $oldX;
1365
        $texto = 'INSCRIÇÃO ESTADUAL';
1366
        $aFont = $this->formatPadrao;
1367
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1368
        $texto = $this->getTagValue($this->dest, "IE");
1369
        $aFont = $this->formatNegrito;
1370
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1371
        $x = $oldX;
1372
        $y += 3;
1373
        $texto = 'PAÍS';
1374
        $aFont = $this->formatPadrao;
1375
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1376
        $texto = $this->getTagValue($this->dest, "xPais");
1377
        $aFont = $this->formatNegrito;
1378
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1379
        $x = $w - 27 + $oldX;
1380
        $texto = 'FONE';
1381
        $aFont = $this->formatPadrao;
1382
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1383
        //$texto = $this->zFormatFone($this->dest);
1384
        $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...
1385
        $aFont = $this->formatNegrito;
1386
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1387
    }
1388
    
1389
    /**
1390
     * zExpedidor
1391
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1392
     *
1393
     * @param  number $x Posição horizontal canto esquerdo
1394
     * @param  number $y Posição vertical canto superior
1395
     * @return number Posição vertical final
1396
     */
1397
    protected function zExpedidor($x = 0, $y = 0)
1398
    {
1399
        $oldX = $x;
1400
        $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...
1401
        if ($this->orientacao == 'P') {
1402
            $maxW = $this->wPrint;
1403
        } else {
1404
            $maxW = $this->wPrint - $this->wCanhoto;
1405
        }
1406
        $w = $maxW * 0.5 + 0.5;
1407
        $h = 19;
1408
        $x1 = $x + 16;
1409
        $texto = 'EXPEDIDOR';
1410
        $aFont = $this->formatPadrao;
1411
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1412
        $aFont = $this->formatNegrito;
1413
        $texto = $this->getTagValue($this->exped, "xNome");
1414
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1415
        $y += 3;
1416
        $texto = 'ENDEREÇO';
1417
        $aFont = $this->formatPadrao;
1418
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1419
        $aFont = $this->formatNegrito;
1420
        if (isset($this->enderExped)) {
1421
            $texto = $this->getTagValue($this->enderExped, "xLgr") . ', ';
1422
            $texto .= $this->getTagValue($this->enderExped, "nro");
1423
            $texto .= $this->getTagValue($this->enderExped, "xCpl") != "" ?
1424
                ' - ' . $this->getTagValue($this->enderExped, "xCpl") :
1425
                '';
1426
        } else {
1427
            $texto = '';
1428
        }
1429
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1430
        $y += 3;
1431
        $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...
1432
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1433
        $y += 3;
1434
        $texto = 'MUNICÍPIO';
1435
        $aFont = $this->formatPadrao;
1436
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1437
        if (isset($this->enderExped)) {
1438
            $texto = $this->getTagValue($this->enderExped, "xMun") . ' - ';
1439
            $texto .= $this->getTagValue($this->enderExped, "UF");
1440
        } else {
1441
            $texto = '';
1442
        }
1443
        $aFont = $this->formatNegrito;
1444
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1445
        $x = $w - 18;
1446
        $texto = 'CEP';
1447
        $aFont = $this->formatPadrao;
1448
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1449
        $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...
1450
        $aFont = $this->formatNegrito;
1451
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1452
        $x = $oldX;
1453
        $y += 3;
1454
        $texto = 'CNPJ/CPF';
1455
        $aFont = $this->formatPadrao;
1456
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1457
        $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...
1458
        $aFont = $this->formatNegrito;
1459
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1460
        $x = $w - 45;
1461
        $texto = 'INSCRIÇÃO ESTADUAL';
1462
        $aFont = $this->formatPadrao;
1463
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1464
        $texto = $this->getTagValue($this->exped, "IE");
1465
        $aFont = $this->formatNegrito;
1466
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1467
        $x = $oldX;
1468
        $y += 3;
1469
        $texto = 'PAÍS';
1470
        $aFont = $this->formatPadrao;
1471
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1472
        $texto = $this->getTagValue($this->exped, "xPais");
1473
        $aFont = $this->formatNegrito;
1474
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1475
        $x = $w - 25;
1476
        $texto = 'FONE';
1477
        $aFont = $this->formatPadrao;
1478
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1479
        if (isset($this->exped)) {
1480
            $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...
1481
            $aFont = $this->formatNegrito;
1482
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1483
        }
1484
    }
1485
    
1486
    /**
1487
     * zRecebedor
1488
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1489
     *
1490
     * @param  number $x Posição horizontal canto esquerdo
1491
     * @param  number $y Posição vertical canto superior
1492
     * @return number Posição vertical final
1493
     */
1494
    protected function zRecebedor($x = 0, $y = 0)
1495
    {
1496
        $oldX = $x;
1497
        $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...
1498
        if ($this->orientacao == 'P') {
1499
            $maxW = $this->wPrint;
1500
        } else {
1501
            $maxW = $this->wPrint - $this->wCanhoto;
1502
        }
1503
        $w = ($maxW * 0.5) - 0.7;
1504
        $h = 19;
1505
        $x1 = $x + 19;
1506
        $texto = 'RECEBEDOR';
1507
        $aFont = $this->formatPadrao;
1508
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1509
        $aFont = $this->formatNegrito;
1510
        $texto = $this->getTagValue($this->receb, "xNome");
1511
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1512
        $y += 3;
1513
        $texto = 'ENDEREÇO';
1514
        $aFont = $this->formatPadrao;
1515
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1516
        $aFont = $this->formatNegrito;
1517
        if (isset($this->enderReceb)) {
1518
            $texto = $this->getTagValue($this->enderReceb, "xLgr") . ', ';
1519
            $texto .= $this->getTagValue($this->enderReceb, "nro");
1520
            $texto .= ($this->getTagValue($this->enderReceb, "xCpl") != "") ?
1521
                ' - ' . $this->getTagValue($this->enderReceb, "xCpl") :
1522
                '';
1523
        } else {
1524
            $texto = '';
1525
        }
1526
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1527
        $y += 3;
1528
        $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...
1529
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1530
        $y += 3;
1531
        $texto = 'MUNICÍPIO';
1532
        $aFont = $this->formatPadrao;
1533
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1534
        if (isset($this->enderReceb)) {
1535
            $texto = $this->getTagValue($this->enderReceb, "xMun") . ' - ';
1536
            $texto .= $this->getTagValue($this->enderReceb, "UF");
1537
        } else {
1538
            $texto = '';
1539
        }
1540
        $aFont = $this->formatNegrito;
1541
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1542
        $x = $w - 19 + $oldX;
1543
        $texto = 'CEP';
1544
        $aFont = $this->formatPadrao;
1545
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1546
        $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...
1547
        $aFont = $this->formatNegrito;
1548
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1549
        $x = $oldX;
1550
        $y += 3;
1551
        $texto = 'CNPJ/CPF';
1552
        $aFont = $this->formatPadrao;
1553
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1554
        $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...
1555
        $aFont = $this->formatNegrito;
1556
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1557
        $x = $w - 47 + $oldX;
1558
        $texto = 'INSCRIÇÃO ESTADUAL';
1559
        $aFont = $this->formatPadrao;
1560
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1561
        $texto = $this->getTagValue($this->receb, "IE");
1562
        $aFont = $this->formatNegrito;
1563
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1564
        $x = $oldX;
1565
        $y += 3;
1566
        $texto = 'PAÍS';
1567
        $aFont = $this->formatPadrao;
1568
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1569
        $texto = $this->getTagValue($this->receb, "xPais");
1570
        $aFont = $this->formatNegrito;
1571
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1572
        $x = $w - 27 + $oldX;
1573
        $texto = 'FONE';
1574
        $aFont = $this->formatPadrao;
1575
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1576
        if (isset($this->receb)) {
1577
            $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...
1578
            $aFont = $this->formatNegrito;
1579
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1580
        }
1581
    }
1582
    
1583
    /**
1584
     * zTomador
1585
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1586
     *
1587
     * @param  number $x Posição horizontal canto esquerdo
1588
     * @param  number $y Posição vertical canto superior
1589
     * @return number Posição vertical final
1590
     */
1591
    protected function zTomador($x = 0, $y = 0)
1592
    {
1593
        $oldX = $x;
1594
        $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...
1595
        if ($this->orientacao == 'P') {
1596
            $maxW = $this->wPrint;
1597
        } else {
1598
            $maxW = $this->wPrint - $this->wCanhoto;
1599
        }
1600
        $w = $maxW;
1601
        $h = 10;
1602
        $texto = 'TOMADOR DO SERVIÇO';
1603
        $aFont = $this->formatPadrao;
1604
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1605
        $aFont = $this->formatNegrito;
1606
        $texto = $this->getTagValue($this->toma, "xNome");
1607
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1608
        $x = $maxW * 0.60;
1609
        $texto = 'MUNICÍPIO';
1610
        $aFont = $this->formatPadrao;
1611
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1612
        $texto = $this->getTagValue($this->toma, "xMun");
1613
        $aFont = $this->formatNegrito;
1614
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1615
        $x = $maxW * 0.85;
1616
        $texto = 'UF';
1617
        $aFont = $this->formatPadrao;
1618
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1619
        $texto = $this->getTagValue($this->toma, "UF");
1620
        $aFont = $this->formatNegrito;
1621
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1622
        $x = $w - 18;
1623
        $texto = 'CEP';
1624
        $aFont = $this->formatPadrao;
1625
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1626
        $texto = $this->pFormat($this->getTagValue($this->toma, "CEP"), "#####-###");
1627
        $aFont = $this->formatNegrito;
1628
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1629
        $y += 3;
1630
        $x = $oldX;
1631
        $texto = 'ENDEREÇO';
1632
        $aFont = $this->formatPadrao;
1633
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1634
        $aFont = $this->formatNegrito;
1635
        $texto = $this->getTagValue($this->toma, "xLgr") . ',';
1636
        $texto .= $this->getTagValue($this->toma, "nro");
1637
        $texto .= ($this->getTagValue($this->toma, "xCpl") != "") ?
1638
            ' - ' . $this->getTagValue($this->toma, "xCpl") : '';
1639
        $texto .= ' - ' . $this->getTagValue($this->toma, "xBairro");
1640
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1641
        $y += 3;
1642
        $texto = 'CNPJ/CPF';
1643
        $aFont = $this->formatPadrao;
1644
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1645
        $texto = $this->zFormatCNPJCPF($this->toma);
1646
        $aFont = $this->formatNegrito;
1647
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1648
        $x = $x + 65;
1649
        $texto = 'INSCRIÇÃO ESTADUAL';
1650
        $aFont = $this->formatPadrao;
1651
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1652
        $texto = $this->getTagValue($this->toma, "IE");
1653
        $aFont = $this->formatNegrito;
1654
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1655
        $x = $w * 0.75;
1656
        $texto = 'PAÍS';
1657
        $aFont = $this->formatPadrao;
1658
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1659
        $texto = $this->getTagValue($this->toma, "xPais") != "" ?
1660
            $this->getTagValue($this->toma, "xPais") : 'BRASIL';
1661
        $aFont = $this->formatNegrito;
1662
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1663
        $x = $w - 27;
1664
        $texto = 'FONE';
1665
        $aFont = $this->formatPadrao;
1666
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1667
        $texto = $this->getTagValue($this->toma, "fone")!=""? $this->zFormatFone($this->toma):'';
1668
        $aFont = $this->formatNegrito;
1669
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1670
    }
1671
    
1672
    /**
1673
     * zDescricaoCarga
1674
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1675
     *
1676
     * @param  number $x Posição horizontal canto esquerdo
1677
     * @param  number $y Posição vertical canto superior
1678
     * @return number Posição vertical final
1679
     */
1680
    protected function zDescricaoCarga($x = 0, $y = 0)
1681
    {
1682
        $oldX = $x;
1683
        $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...
1684
        if ($this->orientacao == 'P') {
1685
            $maxW = $this->wPrint;
1686
        } else {
1687
            $maxW = $this->wPrint - $this->wCanhoto;
1688
        }
1689
        $w = $maxW;
1690
        $h = 17;
1691
        $texto = 'PRODUTO PREDOMINANTE';
1692
        $aFont = array(
1693
            'font' => $this->fontePadrao,
1694
            'size' => 6,
1695
            'style' => '');
1696
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1697
        $texto = $this->getTagValue($this->infCarga, "proPred");
1698
        $aFont = $this->formatNegrito;
1699
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1700
        $x = $w * 0.56;
1701
        $this->pdf->Line($x, $y, $x, $y + 8);
1702
        $aFont = $this->formatPadrao;
1703
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1704
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1705
        $texto = $this->getTagValue($this->infCarga, "xOutCat");
1706
        $aFont = $this->formatNegrito;
1707
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1708
        $x = $w * 0.8;
1709
        $this->pdf->Line($x, $y, $x, $y + 8);
1710
        $aFont = $this->formatPadrao;
1711
        $texto = 'VALOR TOTAL DA CARGA';
1712
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1713
        $texto = $this->getTagValue($this->infCarga, "vCarga") == "" ?
1714
            $this->getTagValue($this->infCarga, "vMerc") : $this->getTagValue($this->infCarga, "vCarga");
1715
        $texto = number_format($texto, 2, ",", ".");
1716
        $aFont = $this->formatNegrito;
1717
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1718
        $y += 8;
1719
        $x = $oldX;
1720
        $this->pdf->Line($x, $y, $w + 1, $y);
1721
        //Identifica código da unidade
1722
        //01 = KG (QUILOS)
1723
        if ($this->getTagValue($this->infQ->item(0), "cUnid") == '01') {
1724
            $qCarga = $this->getTagValue($this->infQ->item(0), "qCarga");
1725
        } elseif ($this->getTagValue($this->infQ->item(1), "cUnid") == '01') {
1726
            $qCarga = $this->getTagValue($this->infQ->item(1), "qCarga");
1727
        } elseif ($this->getTagValue($this->infQ->item(2), "cUnid") == '01') {
1728
            $qCarga = $this->getTagValue($this->infQ->item(2), "qCarga");
1729
        }
1730
        $texto = 'PESO BRUTO (KG)';
1731
        $aFont = array(
1732
            'font' => $this->fontePadrao,
1733
            'size' => 5,
1734
            'style' => '');
1735
        $this->pTextBox($x+8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1736
        $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...
1737
        $aFont = array(
1738
            'font' => $this->fontePadrao,
1739
            'size' => 7,
1740
            'style' => 'B');
1741
        $this->pTextBox($x+2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1742
        $x = $w * 0.12;
1743
        $this->pdf->Line($x+13.5, $y, $x+13.5, $y + 9);
1744
        $texto = 'PESO BASE CÁLCULO (KG)';
1745
        $aFont = array(
1746
            'font' => $this->fontePadrao,
1747
            'size' => 5,
1748
            'style' => '');
1749
        $this->pTextBox($x+20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1750
        $texto = number_format($qCarga, 3, ",", ".");
1751
        $aFont = array(
1752
            'font' => $this->fontePadrao,
1753
            'size' => 7,
1754
            'style' => 'B');
1755
        $this->pTextBox($x+17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1756
        $x = $w * 0.24;
1757
        $this->pdf->Line($x+25, $y, $x+25, $y + 9);
1758
        $texto = 'PESO AFERIDO (KG)';
1759
        $aFont = array(
1760
            'font' => $this->fontePadrao,
1761
            'size' => 5,
1762
            'style' => '');
1763
        $this->pTextBox($x+35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1764
        $texto = number_format($qCarga, 3, ",", ".");
1765
        $aFont = array(
1766
            'font' => $this->fontePadrao,
1767
            'size' => 7,
1768
            'style' => 'B');
1769
        $this->pTextBox($x+28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1770
        $x = $w * 0.36;
1771
        $this->pdf->Line($x+41.3, $y, $x+41.3, $y + 9);
1772
        $texto = 'CUBAGEM(M3)';
1773
        $aFont = $this->formatPadrao;
1774
        $this->pTextBox($x+60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1775
        $qCarga = '';
1776
        foreach ($this->infQ as $infQ) {
1777
            if ($this->getTagValue($infQ, "cUnid") == '00') {
1778
                $qCarga = $this->getTagValue($infQ, "qCarga");
1779
            }
1780
        }
1781
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1782
        $aFont = array(
1783
            'font' => $this->fontePadrao,
1784
            'size' => 7,
1785
            'style' => 'B');
1786
        $this->pTextBox($x+50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1787
        $x = $w * 0.45;
1788
        //$this->pdf->Line($x+37, $y, $x+37, $y + 9);
1789
        $texto = 'QTDE(VOL)';
1790
        $aFont = $this->formatPadrao;
1791
        $this->pTextBox($x+85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1792
        $qCarga = '';
1793
        foreach ($this->infQ as $infQ) {
1794
            if ($this->getTagValue($infQ, "cUnid") == '03') {
1795
                $qCarga = $this->getTagValue($infQ, "qCarga");
1796
            }
1797
        }
1798
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1799
        $aFont = array(
1800
            'font' => $this->fontePadrao,
1801
            'size' => 7,
1802
            'style' => 'B');
1803
        $this->pTextBox($x+85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1804
        $x = $w * 0.53;
1805
        $this->pdf->Line($x+56, $y, $x+56, $y + 9);
1806
        /*$texto = 'NOME DA SEGURADORA';
1807
        $aFont = $this->formatPadrao;
1808
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1809
        $texto = $this->getTagValue($this->seg, "xSeg");
1810
        $aFont = array(
1811
            'font' => $this->fontePadrao,
1812
            'size' => 7,
1813
            'style' => 'B');
1814
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1815
        $y += 3;
1816
        $this->pdf->Line($x, $y, $w + 1, $y);
1817
        $texto = 'RESPONSÁVEL';
1818
        $aFont = $this->formatPadrao;
1819
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1820
        $texto = $this->respSeg;
1821
        $aFont = array(
1822
            'font' => $this->fontePadrao,
1823
            'size' => 7,
1824
            'style' => 'B');
1825
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1826
        $x = $w * 0.68;
1827
        $this->pdf->Line($x, $y, $x, $y + 6);
1828
        $texto = 'NÚMERO DA APOLICE';
1829
        $aFont = $this->formatPadrao;
1830
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1831
        $texto = $this->getTagValue($this->seg, "nApol");
1832
        $aFont = array(
1833
            'font' => $this->fontePadrao,
1834
            'size' => 7,
1835
            'style' => 'B');
1836
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1837
        $x = $w * 0.85;
1838
        $this->pdf->Line($x, $y, $x, $y + 6);
1839
        $texto = 'NÚMERO DA AVERBAÇÃO';
1840
        $aFont = $this->formatPadrao;
1841
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1842
        $texto = $this->getTagValue($this->seg, "nAver");
1843
        $aFont = array(
1844
            'font' => $this->fontePadrao,
1845
            'size' => 7,
1846
            'style' => 'B');
1847
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1848
    }
1849
    
1850
    /**
1851
     * zCompValorServ
1852
     * Monta o campo com os componentes da prestação de serviços.
1853
     *
1854
     * @param  number $x Posição horizontal canto esquerdo
1855
     * @param  number $y Posição vertical canto superior
1856
     * @return number Posição vertical final
1857
     */
1858
    protected function zCompValorServ($x = 0, $y = 0)
1859
    {
1860
        $oldX = $x;
1861
        $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...
1862
        if ($this->orientacao == 'P') {
1863
            $maxW = $this->wPrint;
1864
        } else {
1865
            $maxW = $this->wPrint - $this->wCanhoto;
1866
        }
1867
        $w = $maxW;
1868
        $h = 25;
1869
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1870
        $aFont = $this->formatPadrao;
1871
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1872
        $y += 3.4;
1873
        $this->pdf->Line($x, $y, $w + 1, $y);
1874
        $texto = 'NOME';
1875
        $aFont = $this->formatPadrao;
1876
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1877
        $yIniDados = $y;
1878
        $x = $w * 0.14;
1879
        $texto = 'VALOR';
1880
        $aFont = $this->formatPadrao;
1881
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1882
        $x = $w * 0.28;
1883
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1884
        $texto = 'NOME';
1885
        $aFont = $this->formatPadrao;
1886
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1887
        $x = $w * 0.42;
1888
        $texto = 'VALOR';
1889
        $aFont = $this->formatPadrao;
1890
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1891
        $x = $w * 0.56;
1892
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1893
        $texto = 'NOME';
1894
        $aFont = $this->formatPadrao;
1895
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1896
        $x = $w * 0.70;
1897
        $texto = 'VALOR';
1898
        $aFont = $this->formatPadrao;
1899
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1900
        $x = $w * 0.86;
1901
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1902
        $y += 1;
1903
        $texto = 'VALOR TOTAL DO SERVIÇO';
1904
        $aFont = $this->formatPadrao;
1905
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1906
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1907
        $aFont = array(
1908
            'font' => $this->fontePadrao,
1909
            'size' => 9,
1910
            'style' => 'B');
1911
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1912
        $y += 10;
1913
        $this->pdf->Line($x, $y, $w + 1, $y);
1914
        $y += 1;
1915
        $texto = 'VALOR A RECEBER';
1916
        $aFont = $this->formatPadrao;
1917
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1918
        $texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
1919
        $aFont = array(
1920
            'font' => $this->fontePadrao,
1921
            'size' => 9,
1922
            'style' => 'B');
1923
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1924
        $auxX = $oldX;
1925
        $yIniDados += 4;
1926
        foreach ($this->Comp as $k => $d) {
1927
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1928
            $valor = number_format(
1929
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1930
                2,
1931
                ",",
1932
                "."
1933
            );
1934
            if ($auxX > $w * 0.60) {
1935
                $yIniDados = $yIniDados + 4;
1936
                $auxX = $oldX;
1937
            }
1938
            $texto = $nome;
1939
            $aFont = $this->formatPadrao;
1940
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1941
            $auxX += $w * 0.14;
1942
            $texto = $valor;
1943
            $aFont = $this->formatPadrao;
1944
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1945
            $auxX += $w * 0.14;
1946
        }
1947
    }
1948
    
1949
    /**
1950
     * zImpostos
1951
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1952
     *
1953
     * @param  number $x Posição horizontal canto esquerdo
1954
     * @param  number $y Posição vertical canto superior
1955
     * @return number Posição vertical final
1956
     */
1957
    protected function zImpostos($x = 0, $y = 0)
1958
    {
1959
        $oldX = $x;
1960
        $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...
1961
        if ($this->orientacao == 'P') {
1962
            $maxW = $this->wPrint;
1963
        } else {
1964
            $maxW = $this->wPrint - $this->wCanhoto;
1965
        }
1966
        $w = $maxW;
1967
        $h = 13;
1968
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1969
        $aFont = $this->formatPadrao;
1970
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1971
        $y += 3.4;
1972
        $this->pdf->Line($x, $y, $w + 1, $y);
1973
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1974
        $aFont = $this->formatPadrao;
1975
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1976
        $x += $w * 0.26;
1977
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1978
        $texto = 'BASE DE CALCULO';
1979
        $aFont = $this->formatPadrao;
1980
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1981
        $wCol02=0.15;
1982
        $x += $w * $wCol02;
1983
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1984
        $texto = 'ALÍQ ICMS';
1985
        $aFont = $this->formatPadrao;
1986
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1987
        $x += $w * $wCol02;
1988
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1989
        $texto = 'VALOR ICMS';
1990
        $aFont = $this->formatPadrao;
1991
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1992
        $x += $w * $wCol02;
1993
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1994
        $texto = '% RED. BC ICMS';
1995
        $aFont = $this->formatPadrao;
1996
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1997
        $x += $w * $wCol02;
1998
        $this->pdf->Line($x, $y, $x, $y + 9.5);
1999
        $texto = 'VALOR ICMS ST';
2000
        $aFont = $this->formatPadrao;
2001
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2002
        /*$x += $w * 0.14;
2003
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2004
        $texto = 'ICMS ST';
2005
        $aFont = $this->formatPadrao;
2006
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2007
         * */
2008
        $x = $oldX;
2009
        $y = $y + 4;
2010
        $texto = $this->getTagValue($this->ICMS, "CST");
2011
        switch ($texto) {
2012
            case '00':
2013
                $texto = "00 - Tributação normal ICMS";
2014
                break;
2015
            case '20':
2016
                $texto = "20 - Tributação com BC reduzida do ICMS";
2017
                break;
2018
            case '40':
2019
                $texto = "40 - ICMS isenção";
2020
                break;
2021
            case '41':
2022
                $texto = "41 - ICMS não tributada";
2023
                break;
2024
            case '51':
2025
                $texto = "51 - ICMS diferido";
2026
                break;
2027
            case '60':
2028
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2029
                break;
2030
            case '90':
2031
                if ($this->ICMSOutraUF) {
2032
                    $texto = "90 - ICMS Outra UF";
2033
                } else {
2034
                    $texto = "90 - ICMS Outros";
2035
                }
2036
                break;
2037
        }
2038
        if ($this->getTagValue($this->ICMS, "CST") == '60') {
2039
            $aFont = $this->formatNegrito;
2040
            $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2041
            $x += $w * 0.26;
2042
            $texto = !empty($this->ICMS->getElementsByTagName("vBCSTRet")->item(0)->nodeValue) ?
2043
                number_format($this->getTagValue($this->ICMS, "vBCSTRet"), 2, ",", ".") : (
2044
                    !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2045
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2046
                );
2047
            $aFont = $this->formatNegrito;
2048
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2049
            $x += $w * $wCol02;
2050
            $texto = !empty($this->ICMS->getElementsByTagName("pICMSSTRet")->item(0)->nodeValue) ?
2051
                number_format($this->getTagValue($this->ICMS, "pICMSSTRet"), 2, ",", ".") : (
2052
                    !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2053
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2054
                );
2055
            $aFont = $this->formatNegrito;
2056
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2057
            $x += $w * $wCol02;
2058
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2059
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2060
                    !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2061
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2062
                );
2063
            $aFont = $this->formatNegrito;
2064
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2065
            $x += $w * $wCol02;
2066
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2067
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2068
                    !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2069
                number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2070
                );
2071
            $aFont = $this->formatNegrito;
2072
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2073
            $x += $w * $wCol02;
2074
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2075
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2076
            $aFont = $this->formatNegrito;
2077
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2078
        } else {
2079
            $texto = $this->getTagValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
2080
            $aFont = $this->formatNegrito;
2081
            $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2082
            $x += $w * 0.26;
2083
            $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2084
                number_format($this->getTagValue($this->ICMS, "vBC"), 2, ",", ".") : (
2085
                    !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2086
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2087
                );
2088
            $aFont = $this->formatNegrito;
2089
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2090
            $x += $w * $wCol02;
2091
            $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2092
                number_format($this->getTagValue($this->ICMS, "pICMS"), 2, ",", ".") : (
2093
                    !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2094
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2095
                );
2096
            $aFont = $this->formatNegrito;
2097
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2098
            $x += $w * $wCol02;
2099
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2100
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2101
                    !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2102
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2103
                );
2104
            $aFont = $this->formatNegrito;
2105
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2106
            $x += $w * $wCol02;
2107
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2108
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2109
                    !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2110
                number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2111
                );
2112
            $aFont = $this->formatNegrito;
2113
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2114
            $x += $w * $wCol02;
2115
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2116
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2117
            $aFont = $this->formatNegrito;
2118
            $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2119
        }
2120
        /*$x += $w * 0.14;
2121
        $texto = '';
2122
        $aFont = $this->formatNegrito;
2123
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2124
    }
2125
    
2126
    /**
2127
     * zGeraChaveAdicCont
2128
     *
2129
     * @return string chave
2130
     */
2131
    protected function zGeraChaveAdicCont()
2132
    {
2133
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2134
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
2135
        $forma = "%02d%d%s%014d%01d%01d%02d";
2136
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2137
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2138
        $CNPJ = substr($CNPJ, -14);
2139
        $vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
2140
        $ICMS_CST = $this->getTagValue($this->ICMS, "CST");
2141
        switch ($ICMS_CST) {
2142
            case '00':
2143
            case '20':
2144
                $ICMSp = '1';
2145
                $ICMSs = '2';
2146
                break;
2147
            case '40':
2148
            case '41':
2149
            case '51':
2150
            case '90':
2151
                $ICMSp = '2';
2152
                $ICMSs = '2';
2153
                break;
2154
            case '60':
2155
                $ICMSp = '2';
2156
                $ICMSs = '1';
2157
                break;
2158
        }
2159
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
2160
        $rpos = strrpos($dd, '-');
2161
        $dd = substr($dd, $rpos + 1);
2162
        $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...
2163
        $chave = $chave . $this->pModulo11($chave);
2164
        return $chave;
2165
    }
2166
    
2167
    /**
2168
     * zDocOrig
2169
     * Monta o campo com os documentos originarios.
2170
     *
2171
     * @param  number $x Posição horizontal canto esquerdo
2172
     * @param  number $y Posição vertical canto superior
2173
     * @return number Posição vertical final
2174
     */
2175
    protected function zDocOrig($x = 0, $y = 0)
2176
    {
2177
        $oldX = $x;
2178
        $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...
2179
        if ($this->orientacao == 'P') {
2180
            $maxW = $this->wPrint;
2181
        } else {
2182
            $maxW = $this->wPrint - $this->wCanhoto;
2183
        }
2184
        $w = $maxW;
2185
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2186
        if ($this->modal == '1') {
2187
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2188
            // ou combinação veicular, e por viagem
2189
            $h = $this->lota == 1 ? 35 : 53;
2190
        } elseif ($this->modal == '2') {
2191
            $h = 53;
2192
        } elseif ($this->modal == '3') {
2193
            $h = 37.6;
2194
        } else {
2195
            $h = 35;
2196
        }
2197
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2198
        $aFont = $this->formatPadrao;
2199
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2200
        $descr1 = 'TIPO DOC';
2201
        $descr2 = 'CNPJ/CHAVE/OBS';
2202
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2203
        $y += 3.4;
2204
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2205
        $texto = $descr1;
2206
        $aFont = $this->formatPadrao;
2207
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2208
        $yIniDados = $y;
2209
        $x += $w * 0.07;
2210
        $texto = $descr2;
2211
        $aFont = $this->formatPadrao;
2212
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2213
        $x += $w * 0.28;
2214
        $texto = $descr3;
2215
        $aFont = $this->formatPadrao;
2216
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2217
        $x += $w * 0.14;
2218
        if ($this->modal == '1') {
2219
            if ($this->lota == 1) {
2220
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2221
            } else {
2222
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2223
            }
2224
        } elseif ($this->modal == '2') {
2225
            $this->pdf->Line($x, $y, $x, $y + 49.5);
2226
        } elseif ($this->modal == '3') {
2227
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2228
        } else {
2229
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2230
        }
2231
        $texto = $descr1;
2232
        $aFont = $this->formatPadrao;
2233
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2234
        $x += $w * 0.08;
2235
        $texto = $descr2;
2236
        $aFont = $this->formatPadrao;
2237
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2238
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2239
        $texto = $descr3;
2240
        $aFont = $this->formatPadrao;
2241
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2242
        $auxX = $oldX;
2243
        $yIniDados += 3;
2244
        foreach ($this->infNF as $k => $d) {
2245
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2246
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2247
            $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...
2248
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2249
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2250
            if ($auxX > $w * 0.90) {
2251
                $yIniDados = $yIniDados + 3;
2252
                $auxX = $oldX;
2253
            }
2254
            $texto = $tp;
2255
            $aFont = array(
2256
                'font' => $this->fontePadrao,
2257
                'size' => 8,
2258
                'style' => '');
2259
            //$this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2260
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2261
            //$auxX += $w * 0.09;
2262
            $auxX += $w * 0.07;
2263
            $texto = $cnpj;
2264
            $aFont = array(
2265
                'font' => $this->fontePadrao,
2266
                'size' => 8,
2267
                'style' => '');
2268
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2269
            $auxX += $w * 0.28;
2270
            $texto = $doc;
2271
            $aFont = array(
2272
                'font' => $this->fontePadrao,
2273
                'size' => 8,
2274
                'style' => '');
2275
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2276
            $auxX += $w * 0.15;
2277
        }
2278
        foreach ($this->infNFe as $k => $d) {
2279
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2280
            $this->arrayNFe[] = $chaveNFe;
2281
        }
2282
        $qtdeNFe = 1;
2283
        if (count($this->arrayNFe) >15) {
2284
            $this->flagDocOrigContinuacao = 1;
2285
            $qtdeNFe = count($this->arrayNFe);
2286
        }
2287
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
2288
        switch ($qtdeNFe) {
2289
            default:
2290
                $this->totPag = 1;
2291
            case ($qtdeNFe >= 1044):
2292
                $this->totPag = 11;
2293
                break;
2294
            case ($qtdeNFe > 928):
2295
                $this->totPag = 10;
2296
                break;
2297
            case ($qtdeNFe > 812):
2298
                $this->totPag = 9;
2299
                break;
2300
            case ($qtdeNFe > 696):
2301
                $this->totPag = 8;
2302
                break;
2303
            case ($qtdeNFe > 580):
2304
                $this->totPag = 7;
2305
                break;
2306
            case ($qtdeNFe > 464):
2307
                $this->totPag = 6;
2308
                break;
2309
            case ($qtdeNFe > 348):
2310
                $this->totPag = 5;
2311
                break;
2312
            case ($qtdeNFe > 232):
2313
                $this->totPag = 4;
2314
                break;
2315
            case ($qtdeNFe > 116):
2316
                $this->totPag = 3;
2317
                break;
2318
            case ($qtdeNFe > 16):
2319
                $this->totPag = 2;
2320
                break;
2321
            case ($qtdeNFe <= 16):
2322
                $this->totPag = 1;
2323
                break;
2324
        }
2325
        //$r = $this->zCabecalho(1, 1, '1', $this->totPag);
2326
        $contador = 0;
2327
        while ($contador < count($this->arrayNFe)) {
2328
            if ($contador == 15) {
2329
                break;
2330
            }
2331
            $tp = 'NF-e';
2332
            $chaveNFe = $this->arrayNFe[$contador];
2333
            $numNFe = substr($chaveNFe, 25, 9);
2334
            $serieNFe = substr($chaveNFe, 22, 3);
2335
            $doc = $serieNFe . '/' . $numNFe;
2336
            if ($auxX > $w * 0.90) {
2337
                $yIniDados = $yIniDados + 3.5;
2338
                $auxX = $oldX;
2339
            }
2340
            $texto = $tp;
2341
            $aFont = array(
2342
                'font' => $this->fontePadrao,
2343
                'size' => 7,
2344
                'style' => '');
2345
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2346
            $auxX += $w * 0.07;
2347
            $texto = $chaveNFe;
2348
            $aFont = array(
2349
                'font' => $this->fontePadrao,
2350
                'size' => 7,
2351
                'style' => '');
2352
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2353
            $auxX += $w * 0.28;
2354
            $texto = $doc;
2355
            $aFont = array(
2356
                'font' => $this->fontePadrao,
2357
                'size' => 7,
2358
                'style' => '');
2359
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2360
            $auxX += $w * 0.15;
2361
            $contador++;
2362
        }
2363
        foreach ($this->infOutros as $k => $d) {
2364
            $temp = $this->infOutros->item($k);
2365
            $tpDoc = $this->getTagValue($temp, "tpDoc");
2366
            $descOutros = $this->getTagValue($temp, "descOutros");
2367
            $nDoc = $this->getTagValue($temp, "nDoc");
2368
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2369
            $vDocFisc = $this->getTagValue($temp, "vDocFisc", "Valor: ");
2370
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2371
            switch ($tpDoc) {
2372
                case "00":
2373
                    $tpDoc = "00 - Declaração";
2374
                    break;
2375
                case "10":
2376
                    $tpDoc = "10 - Dutoviário";
2377
                    break;
2378
                case "99":
2379
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2380
                    break;
2381
                default:
2382
                    break;
2383
            }
2384
            $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...
2385
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2386
            if ($auxX > $w * 0.90) {
2387
                $yIniDados = $yIniDados + 4;
2388
                $auxX = $oldX;
2389
            }
2390
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2391
            $auxX += $w * 0.09;
2392
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2393
            $auxX += $w * 0.28;
2394
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2395
            $auxX += $w * 0.14;
2396
        }
2397
        foreach ($this->idDocAntEle as $k => $d) {
2398
            $tp = 'CT-e';
2399
            $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...
2400
            $numCTe = substr($chaveCTe, 25, 9);
2401
            $serieCTe = substr($chaveCTe, 22, 3);
2402
            $doc = $serieCTe . '/' . $numCTe;
2403
            if ($auxX > $w * 0.90) {
2404
                $yIniDados = $yIniDados + 4;
2405
                $auxX = $oldX;
2406
            }
2407
            $texto = $tp;
2408
            $aFont = array(
2409
                'font' => $this->fontePadrao,
2410
                'size' => 8,
2411
                'style' => '');
2412
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2413
            $auxX += $w * 0.09;
2414
            $texto = $chaveCTe;
2415
            $aFont = array(
2416
                'font' => $this->fontePadrao,
2417
                'size' => 8,
2418
                'style' => '');
2419
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2420
            $auxX += $w * 0.28;
2421
            $texto = $doc;
2422
            $aFont = array(
2423
                'font' => $this->fontePadrao,
2424
                'size' => 8,
2425
                'style' => '');
2426
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2427
            $auxX += $w * 0.14;
2428
        }
2429
    }
2430
    
2431
    /**
2432
     * zDocOrigContinuacao
2433
     * Monta o campo com os documentos originarios.
2434
     *
2435
     * @param  number $x Posição horizontal canto esquerdo
2436
     * @param  number $y Posição vertical canto superior
2437
     * @return number Posição vertical final
2438
     */
2439
    protected function zDocOrigContinuacao($x = 0, $y = 0)
2440
    {
2441
        $x2 = $x;
2442
        $y2 = $y;
2443
        $contador = 16;
2444
        for ($i = 2; $i <= $this->totPag; $i++) {
2445
            $x = $x2;
2446
            $y = $y2;
2447
            $this->pdf->AddPage($this->orientacao, $this->papel);
2448
            $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...
2449
            $oldX = $x;
2450
            $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...
2451
            if ($this->orientacao == 'P') {
2452
                $maxW = $this->wPrint;
2453
            } else {
2454
                $maxW = $this->wPrint - $this->wCanhoto;
2455
            }
2456
            $w = $maxW;
2457
            //$h = 6; // de sub-titulo
2458
            //$h = 6 + 3; // de altura do texto (primeira linha
2459
            //$h = 9 + 3.5 ;// segunda linha
2460
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
2461
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2462
            if (count($this->arrayNFe)%2 !=0) {
2463
                $h = $h+3.5;
2464
            } // Caso tenha apenas 1 registro na ultima linha
2465
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2466
            $aFont = $this->formatPadrao;
2467
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2468
            $descr1 = 'TIPO DOC';
2469
            $descr2 = 'CNPJ/CHAVE/OBS';
2470
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2471
            $y += 3.4;
2472
            $this->pdf->Line($x, $y, $w + 1, $y);
2473
            $texto = $descr1;
2474
            $aFont = $this->formatPadrao;
2475
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2476
            $yIniDados = $y;
2477
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2478
            $texto = $descr2;
2479
            $aFont = $this->formatPadrao;
2480
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2481
            $x += $w * 0.28;
2482
            $texto = $descr3;
2483
            $aFont = $this->formatPadrao;
2484
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2485
            $x += $w * 0.14;
2486
            if ($this->modal == '1') {
2487
                if ($this->lota == 1) {
2488
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2489
                } else {
2490
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2491
                }
2492
            } elseif ($this->modal == '2') {
2493
                $this->pdf->Line($x, $y, $x, $y + 49.5);
2494
            } elseif ($this->modal == '3') {
2495
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2496
            } else {
2497
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2498
            }
2499
            $texto = $descr1;
2500
            $aFont = $this->formatPadrao;
2501
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2502
            $x += $w * 0.08;
2503
            $texto = $descr2;
2504
            $aFont = $this->formatPadrao;
2505
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2506
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2507
            $texto = $descr3;
2508
            $aFont = $this->formatPadrao;
2509
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2510
            $auxX = $oldX;
2511
            $yIniDados += 3;
2512
            while ($contador < (count($this->arrayNFe))) {
2513
                if ($contador%(116*($i-1)) == 0) {
2514
//                    $contador++;
2515
                    break;
2516
                }
2517
                $tp = 'NF-e';
2518
                $chaveNFe = $this->arrayNFe[$contador];
2519
                $numNFe = substr($chaveNFe, 25, 9);
2520
                $serieNFe = substr($chaveNFe, 22, 3);
2521
                $doc = $serieNFe . '/' . $numNFe;
2522
                if ($auxX > $w * 0.90) {
2523
                    $yIniDados = $yIniDados + 3.5;
2524
                    $auxX = $oldX;
2525
                }
2526
                $texto = $tp;
2527
                $aFont = array(
2528
                    'font' => $this->fontePadrao,
2529
                    'size' => 7,
2530
                    'style' => '');
2531
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2532
                $auxX += $w * 0.07;
2533
                $texto = $chaveNFe;
2534
                $aFont = array(
2535
                    'font' => $this->fontePadrao,
2536
                    'size' => 7,
2537
                    'style' => '');
2538
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2539
                $auxX += $w * 0.28;
2540
                $texto = $doc;
2541
                $aFont = array(
2542
                    'font' => $this->fontePadrao,
2543
                    'size' => 7,
2544
                    'style' => '');
2545
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2546
                $auxX += $w * 0.15;
2547
                $contador++;
2548
            }
2549
        }
2550
    }
2551
    
2552
    /**
2553
     * zDocCompl
2554
     * Monta o campo com os dados do remetente na DACTE.
2555
     *
2556
     * @param number $x Posição horizontal canto esquerdo
2557
     * @param number $y Posição vertical canto superior
2558
     * @return number Posição vertical final
2559
     */
2560
    protected function zDocCompl($x = 0, $y = 0)
2561
    {
2562
        $oldX = $x;
2563
        $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...
2564
        if ($this->orientacao == 'P') {
2565
            $maxW = $this->wPrint;
2566
        } else {
2567
            $maxW = $this->wPrint - $this->wCanhoto;
2568
        }
2569
        $w = $maxW;
2570
        $h = 80;
2571
        if ($this->tpCTe == 1) {
2572
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2573
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2574
            $descr2 = 'VALOR COMPLEMENTADO';
2575
        } else {
2576
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2577
            $descr1 = 'CHAVE DO CT-E ANULADO';
2578
            $descr2 = 'VALOR ANULADO';
2579
        }
2580
        $aFont = $this->formatPadrao;
2581
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2582
        $y += 3.4;
2583
        $this->pdf->Line($x, $y, $w + 1, $y);
2584
        $texto = $descr1;
2585
        $aFont = $this->formatPadrao;
2586
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2587
        $yIniDados = $y;
2588
        $x += $w * 0.37;
2589
        $texto = $descr2;
2590
        $aFont = $this->formatPadrao;
2591
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2592
        $x += $w * 0.13;
2593
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2594
        $texto = $descr1;
2595
        $aFont = $this->formatPadrao;
2596
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2597
        $x += $w * 0.3;
2598
        $texto = $descr2;
2599
        $aFont = $this->formatPadrao;
2600
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2601
        $auxX = $oldX;
2602
        $yIniDados += 4;
2603
        if ($auxX > $w * 0.90) {
2604
            $yIniDados = $yIniDados + 4;
2605
            $auxX = $oldX;
2606
        }
2607
        $texto = $this->chaveCTeRef;
2608
        $aFont = array(
2609
            'font' => $this->fontePadrao,
2610
            'size' => 8,
2611
            'style' => '');
2612
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2613
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
2614
        $aFont = array(
2615
            'font' => $this->fontePadrao,
2616
            'size' => 8,
2617
            'style' => '');
2618
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2619
    }
2620
    
2621
    /**
2622
     * zObs
2623
     * Monta o campo com os dados do remetente na DACTE.
2624
     *
2625
     * @param  number $x Posição horizontal canto esquerdo
2626
     * @param  number $y Posição vertical canto superior
2627
     * @return number Posição vertical final
2628
     */
2629
    protected function zObs($x = 0, $y = 0)
2630
    {
2631
        $oldX = $x;
2632
        $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...
2633
        if ($this->orientacao == 'P') {
2634
            $maxW = $this->wPrint;
2635
        } else {
2636
            $maxW = $this->wPrint - $this->wCanhoto;
2637
        }
2638
        $w = $maxW;
2639
        //$h = 18;
2640
        $h = 18.8;
2641
        $texto = 'OBSERVAÇÕES';
2642
        $aFont = $this->formatPadrao;
2643
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2644
        $y += 3.4;
2645
        $this->pdf->Line($x, $y, $w + 1, $y);
2646
        $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...
2647
        $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...
2648
        $texto = '';
2649
        foreach ($this->compl as $k => $d) {
2650
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
2651
            $texto .= $xObs;
2652
        }
2653
        $textoObs = explode("Motorista:", $texto);
2654
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
2655
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
2656
        $aFont = array(
2657
            'font' => $this->fontePadrao,
2658
            'size' => 7.5,
2659
            'style' => '');
2660
        $this->pTextBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2661
        $this->pTextBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2662
    }
2663
    
2664
    /**
2665
     * zModalRod
2666
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2667
     *
2668
     * @param  number $x Posição horizontal canto esquerdo
2669
     * @param  number $y Posição vertical canto superior
2670
     * @return number Posição vertical final
2671
     */
2672
    protected function zModalRod($x = 0, $y = 0)
2673
    {
2674
        $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...
2675
        $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...
2676
        $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...
2677
        if ($this->orientacao == 'P') {
2678
            $maxW = $this->wPrint;
2679
        } else {
2680
            $maxW = $this->wPrint - $this->wCanhoto;
2681
        }
2682
        $w = $maxW;
2683
        $h = 3;
2684
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2685
        $aFont = $this->formatPadrao;
2686
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2687
        if ($this->lota == 1) {
2688
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2689
        }
2690
        $y += 3.4;
2691
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2692
        $texto = 'RNTRC DA EMPRESA';
2693
        $aFont = $this->formatPadrao;
2694
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2695
        $texto = $this->getTagValue($this->rodo, "RNTRC");
2696
        $aFont = $this->formatNegrito;
2697
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2698
        $x += $w * 0.23;
2699
        $this->pdf->Line($x-20, $y, $x-20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2700
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2701
        $aFont = $this->formatPadrao;
2702
        $this->pTextBox($x-20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2703
    }
2704
    
2705
    /**
2706
     * zModalAereo
2707
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2708
     *
2709
     * @param  number $x Posição horizontal canto esquerdo
2710
     * @param  number $y Posição vertical canto superior
2711
     * @return number Posição vertical final
2712
     */
2713
    protected function zModalAereo($x = 0, $y = 0)
2714
    {
2715
        $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...
2716
        $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...
2717
        $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...
2718
        if ($this->orientacao == 'P') {
2719
            $maxW = $this->wPrint;
2720
        } else {
2721
            $maxW = $this->wPrint - $this->wCanhoto;
2722
        }
2723
        $w = $maxW;
2724
        $h = 3;
2725
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2726
        $aFont = $this->formatPadrao;
2727
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2728
        $y += 3.4;
2729
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2730
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2731
        $aFont = $this->formatPadrao;
2732
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2733
        $texto = 'CLASSE DA TARIFA';
2734
        $aFont = $this->formatPadrao;
2735
        $this->pTextBox($x+50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2736
        $texto = 'CÓDIGO DA TARIFA';
2737
        $aFont = $this->formatPadrao;
2738
        $this->pTextBox($x+80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2739
        $texto = 'VALOR DA TARIFA';
2740
        $aFont = $this->formatPadrao;
2741
        $this->pTextBox($x+110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2742
        $texto = $this->getTagValue($this->aereo, "nOCA");
2743
        $aFont = $this->formatNegrito;
2744
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2745
        $x += $w * 0.23;
2746
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2747
        $texto = $this->getTagValue($this->aereo, "CL");
2748
        $aFont = $this->formatNegrito;
2749
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2750
        $x += 30;
2751
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2752
        $texto = $this->getTagValue($this->aereo, "cTar");
2753
        $aFont = $this->formatNegrito;
2754
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2755
        $x += 30;
2756
        $this->pdf->Line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2757
        $texto = $this->getTagValue($this->aereo, "vTar");
2758
        $aFont = $this->formatNegrito;
2759
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2760
    }
2761
    
2762
    /**
2763
     * zModalAquaviario
2764
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2765
     *
2766
     * @param  number $x Posição horizontal canto esquerdo
2767
     * @param  number $y Posição vertical canto superior
2768
     * @return number Posição vertical final
2769
     */
2770
    protected function zModalAquaviario($x = 0, $y = 0)
2771
    {
2772
        $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...
2773
        $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...
2774
        if ($this->orientacao == 'P') {
2775
            $maxW = $this->wPrint;
2776
        } else {
2777
            $maxW = $this->wPrint - $this->wCanhoto;
2778
        }
2779
        $w = $maxW;
2780
        $h = 8.5;
2781
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2782
        $aFont = $this->formatPadrao;
2783
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2784
        $y += 3.4;
2785
        $this->pdf->Line($x, $y, $w + 1, $y);
2786
        $texto = 'PORTO DE EMBARQUE';
2787
        $aFont = $this->formatPadrao;
2788
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2789
        $texto = $this->getTagValue($this->aquav, "prtEmb");
2790
        $aFont = $this->formatNegrito;
2791
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2792
        $x += $w * 0.50;
2793
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2794
        $texto = 'PORTO DE DESTINO';
2795
        $aFont = $this->formatPadrao;
2796
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2797
        $texto = $this->getTagValue($this->aquav, "prtDest");
2798
        $aFont = $this->formatNegrito;
2799
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2800
        $y += 8;
2801
        $this->pdf->Line(208, $y, 1, $y);
2802
        $x = 1;
2803
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2804
        $aFont = $this->formatPadrao;
2805
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2806
        $texto = $this->getTagValue($this->aquav, "xNavio");
2807
        $aFont = $this->formatNegrito;
2808
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2809
        $x += $w * 0.50;
2810
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2811
        $texto = 'VR DA B. DE CALC. AFRMM';
2812
        $aFont = $this->formatPadrao;
2813
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2814
        $texto = $this->getTagValue($this->aquav, "vPrest");
2815
        $aFont = $this->formatNegrito;
2816
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2817
        $x += $w * 0.17;
2818
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2819
        $texto = 'VALOR DO AFRMM';
2820
        $aFont = $this->formatPadrao;
2821
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2822
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
2823
        $aFont = $this->formatNegrito;
2824
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2825
        $x += $w * 0.12;
2826
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2827
        $texto = 'TIPO DE NAVEGAÇÃO';
2828
        $aFont = $this->formatPadrao;
2829
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2830
        $texto = $this->getTagValue($this->aquav, "tpNav");
2831
        switch ($texto) {
2832
            case '0':
2833
                $texto = 'INTERIOR';
2834
                break;
2835
            case '1':
2836
                $texto = 'CABOTAGEM';
2837
                break;
2838
        }
2839
        $aFont = $this->formatNegrito;
2840
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2841
        $x += $w * 0.14;
2842
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2843
        $texto = 'DIREÇÃO';
2844
        $aFont = $this->formatPadrao;
2845
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2846
        $texto = $this->getTagValue($this->aquav, "direc");
2847
        switch ($texto) {
2848
            case 'N':
2849
                $texto = 'NORTE';
2850
                break;
2851
            case 'L':
2852
                $texto = 'LESTE';
2853
                break;
2854
            case 'S':
2855
                $texto = 'SUL';
2856
                break;
2857
            case 'O':
2858
                $texto = 'OESTE';
2859
                break;
2860
        }
2861
        $aFont = $this->formatNegrito;
2862
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2863
        $y += 8;
2864
        $this->pdf->Line(208, $y, 1, $y);
2865
        $x = 1;
2866
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2867
        $aFont = $this->formatPadrao;
2868
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2869
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2870
            $texto = $this->infNF
2871
                ->item(0)
2872
                ->getElementsByTagName('infUnidCarga')
2873
                ->item(0)
2874
                ->getElementsByTagName('idUnidCarga')
2875
                ->item(0)->nodeValue;
2876
        } elseif ($this->infNFe->item(0) !== null
2877
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2878
        ) {
2879
            $texto = $this->infNFe
2880
                ->item(0)
2881
                ->getElementsByTagName('infUnidCarga')
2882
                ->item(0)
2883
                ->getElementsByTagName('idUnidCarga')
2884
                ->item(0)
2885
                ->nodeValue;
2886
        } elseif ($this->infOutros->item(0) !== null
2887
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2888
        ) {
2889
            $texto = $this->infOutros
2890
                ->item(0)
2891
                ->getElementsByTagName('infUnidCarga')
2892
                ->item(0)
2893
                ->getElementsByTagName('idUnidCarga')
2894
                ->item(0)
2895
                ->nodeValue;
2896
        } else {
2897
            $texto = '';
2898
        }
2899
        $aFont = $this->formatNegrito;
2900
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2901
        $x += $w * 0.50;
2902
        $this->pdf->Line($x, $y, $x, $y + 7.7);
2903
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2904
        $aFont = $this->formatPadrao;
2905
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2906
        $texto = '';
2907
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
2908
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2909
                if ($k == 0) {
2910
                    $texto = $this->aquav
2911
                        ->getElementsByTagName('balsa')
2912
                        ->item($k)
2913
                        ->getElementsByTagName('xBalsa')
2914
                        ->item(0)
2915
                        ->nodeValue;
2916
                } else {
2917
                    $texto = $texto
2918
                        . ' / '
2919
                        . $this->aquav
2920
                            ->getElementsByTagName('balsa')
2921
                            ->item($k)
2922
                            ->getElementsByTagName('xBalsa')
2923
                            ->item(0)
2924
                            ->nodeValue;
2925
                }
2926
            }
2927
        }
2928
        $aFont = $this->formatNegrito;
2929
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2930
    }
2931
    
2932
    /**
2933
     * zModalFerr
2934
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2935
     *
2936
     * @param  number $x Posição horizontal canto esquerdo
2937
     * @param  number $y Posição vertical canto superior
2938
     * @return number Posição vertical final
2939
     */
2940
    protected function zModalFerr($x = 0, $y = 0)
2941
    {
2942
        $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...
2943
        $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...
2944
        if ($this->orientacao == 'P') {
2945
            $maxW = $this->wPrint;
2946
        } else {
2947
            $maxW = $this->wPrint - $this->wCanhoto;
2948
        }
2949
        $w = $maxW;
2950
        $h = 19.6;
2951
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2952
        $aFont = $this->formatPadrao;
2953
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2954
        $y += 3.4;
2955
        $this->pdf->Line($x, $y, $w + 1, $y);
2956
        $texto = 'DCL';
2957
        $aFont = array(
2958
            'font' => $this->fontePadrao,
2959
            'size' => 7,
2960
            'style' => 'B');
2961
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2962
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2963
        $texto = 'VAGÕES';
2964
        $aFont = array(
2965
            'font' => $this->fontePadrao,
2966
            'size' => 7,
2967
            'style' => 'B');
2968
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2969
        $y += 3.4;
2970
        $this->pdf->Line($x, $y, $w + 1, $y);
2971
        // DCL
2972
        $texto = 'ID TREM';
2973
        $aFont = array(
2974
            'font' => $this->fontePadrao,
2975
            'size' => 6,
2976
            'style' => '');
2977
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2978
        $texto = $this->getTagValue($this->ferrov, "idTrem");
2979
        $aFont = array(
2980
            'font' => $this->fontePadrao,
2981
            'size' => 6,
2982
            'style' => 'B');
2983
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2984
        $x += $w * 0.06;
2985
        $y1 = $y + 12.5;
2986
        $this->pdf->Line($x, $y, $x, $y1);
2987
        $texto = 'NUM';
2988
        $aFont = array(
2989
            'font' => $this->fontePadrao,
2990
            'size' => 6,
2991
            'style' => '');
2992
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2993
        $texto = $this->getTagValue($this->rem, "nDoc");
2994
        $aFont = array(
2995
            'font' => $this->fontePadrao,
2996
            'size' => 6,
2997
            'style' => 'B');
2998
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2999
        $x += $w * 0.06;
3000
        $this->pdf->Line($x, $y, $x, $y1);
3001
        $texto = 'SÉRIE';
3002
        $aFont = array(
3003
            'font' => $this->fontePadrao,
3004
            'size' => 6,
3005
            'style' => '');
3006
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3007
        $texto = $this->getTagValue($this->rem, "serie");
3008
        $aFont = array(
3009
            'font' => $this->fontePadrao,
3010
            'size' => 6,
3011
            'style' => 'B');
3012
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3013
        $x += $w * 0.06;
3014
        $this->pdf->Line($x, $y, $x, $y1);
3015
        $texto = 'EMISSÃO';
3016
        $aFont = array(
3017
            'font' => $this->fontePadrao,
3018
            'size' => 6,
3019
            'style' => '');
3020
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3021
        $texto = $this->pYmd2dmy($this->getTagValue($this->rem, "dEmi"));
3022
        $aFont = array(
3023
            'font' => $this->fontePadrao,
3024
            'size' => 6,
3025
            'style' => 'B');
3026
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3027
        // VAGOES
3028
        $x += $w * 0.06;
3029
        $this->pdf->Line($x, $y, $x, $y1);
3030
        $texto = 'NUM';
3031
        $aFont = array(
3032
            'font' => $this->fontePadrao,
3033
            'size' => 6,
3034
            'style' => '');
3035
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3036
        $texto = $this->getTagValue($this->ferrov, "nVag");
3037
        $aFont = array(
3038
            'font' => $this->fontePadrao,
3039
            'size' => 6,
3040
            'style' => 'B');
3041
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3042
        $x += $w * 0.06;
3043
        $this->pdf->Line($x, $y, $x, $y1);
3044
        $texto = 'TIPO';
3045
        $aFont = array(
3046
            'font' => $this->fontePadrao,
3047
            'size' => 6,
3048
            'style' => '');
3049
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3050
        $texto = $this->getTagValue($this->ferrov, "tpVag");
3051
        $aFont = array(
3052
            'font' => $this->fontePadrao,
3053
            'size' => 6,
3054
            'style' => 'B');
3055
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3056
        $x += $w * 0.06;
3057
        $this->pdf->Line($x, $y, $x, $y1);
3058
        $texto = 'CAPACIDADE';
3059
        $aFont = array(
3060
            'font' => $this->fontePadrao,
3061
            'size' => 6,
3062
            'style' => '');
3063
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3064
        $texto = $this->getTagValue($this->ferrov, "cap");
3065
        $aFont = array(
3066
            'font' => $this->fontePadrao,
3067
            'size' => 6,
3068
            'style' => 'B');
3069
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3070
        $x += $w * 0.08;
3071
        $this->pdf->Line($x, $y, $x, $y1);
3072
        $texto = 'PESO REAL/TON';
3073
        $aFont = array(
3074
            'font' => $this->fontePadrao,
3075
            'size' => 6,
3076
            'style' => '');
3077
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3078
        $texto = $this->getTagValue($this->ferrov, "pesoR");
3079
        $aFont = array(
3080
            'font' => $this->fontePadrao,
3081
            'size' => 6,
3082
            'style' => 'B');
3083
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3084
        $x += $w * 0.09;
3085
        $this->pdf->Line($x, $y, $x, $y1);
3086
        $texto = 'PESO BRUTO/TON';
3087
        $aFont = array(
3088
            'font' => $this->fontePadrao,
3089
            'size' => 6,
3090
            'style' => '');
3091
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3092
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
3093
        $aFont = array(
3094
            'font' => $this->fontePadrao,
3095
            'size' => 6,
3096
            'style' => 'B');
3097
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3098
        $x += $w * 0.1;
3099
        $this->pdf->Line($x, $y, $x, $y1);
3100
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3101
        $aFont = array(
3102
            'font' => $this->fontePadrao,
3103
            'size' => 6,
3104
            'style' => '');
3105
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3106
        $texto = $this->getTagValue($this->ferrov, "nCont");
3107
        $aFont = array(
3108
            'font' => $this->fontePadrao,
3109
            'size' => 6,
3110
            'style' => 'B');
3111
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3112
        // FLUXO
3113
        $x = 1;
3114
        $y += 12.9;
3115
        $h1 = $h * 0.5 + 0.27;
3116
        $wa = round($w * 0.103) + 0.5;
3117
        $texto = 'FLUXO FERROVIARIO';
3118
        $aFont = $this->formatPadrao;
3119
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3120
        $texto = $this->getTagValue($this->ferrov, "fluxo");
3121
        $aFont = array(
3122
            'font' => $this->fontePadrao,
3123
            'size' => 7,
3124
            'style' => 'B');
3125
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3126
        $y += 10;
3127
        $texto = 'TIPO DE TRÁFEGO';
3128
        $aFont = $this->formatPadrao;
3129
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3130
        $texto = $this->zConvertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
3131
        $aFont = array(
3132
            'font' => $this->fontePadrao,
3133
            'size' => 7,
3134
            'style' => 'B');
3135
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3136
        // Novo Box Relativo a Modal Ferroviário
3137
        $x = 22.5;
3138
        $y += -10.2;
3139
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3140
        $aFont = $this->formatPadrao;
3141
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3142
        $y += 3.4;
3143
        $this->pdf->Line($x, $y, $w + 1, $y);
3144
        $w = $w * 0.2;
3145
        $h = $h * 1.04;
3146
        $texto = 'CÓDIGO INTERNO';
3147
        $aFont = array(
3148
            'font' => $this->fontePadrao,
3149
            'size' => 6,
3150
            'style' => '');
3151
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3152
        $texto = $this->getTagValue($this->ferrov, "cInt");
3153
        $aFont = array(
3154
            'font' => $this->fontePadrao,
3155
            'size' => 6,
3156
            'style' => 'B');
3157
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3158
        $texto = 'CNPJ';
3159
        $aFont = array(
3160
            'font' => $this->fontePadrao,
3161
            'size' => 6,
3162
            'style' => '');
3163
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3164
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
3165
        $aFont = array(
3166
            'font' => $this->fontePadrao,
3167
            'size' => 6,
3168
            'style' => 'B');
3169
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3170
        $x += 50;
3171
        $texto = 'NOME';
3172
        $aFont = array(
3173
            'font' => $this->fontePadrao,
3174
            'size' => 6,
3175
            'style' => '');
3176
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3177
        $texto = $this->getTagValue($this->ferrov, "xNome");
3178
        $aFont = array(
3179
            'font' => $this->fontePadrao,
3180
            'size' => 6,
3181
            'style' => 'B');
3182
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3183
        $texto = 'INSCRICAO ESTADUAL';
3184
        $aFont = array(
3185
            'font' => $this->fontePadrao,
3186
            'size' => 6,
3187
            'style' => '');
3188
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3189
        $texto = $this->getTagValue($this->ferrov, "IE");
3190
        $aFont = array(
3191
            'font' => $this->fontePadrao,
3192
            'size' => 6,
3193
            'style' => 'B');
3194
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3195
        $x += 50;
3196
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3197
        $aFont = array(
3198
            'font' => $this->fontePadrao,
3199
            'size' => 6,
3200
            'style' => '');
3201
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3202
        $texto = '';
3203
        $aFont = array(
3204
            'font' => $this->fontePadrao,
3205
            'size' => 6,
3206
            'style' => 'B');
3207
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3208
    }
3209
    
3210
    /**
3211
     * zCanhoto
3212
     * Monta o campo com os dados do remetente na DACTE.
3213
     *
3214
     * @param  number $x Posição horizontal canto esquerdo
3215
     * @param  number $y Posição vertical canto superior
3216
     * @return number Posição vertical final
3217
     */
3218
    protected function zCanhoto($x = 0, $y = 0)
3219
    {
3220
        //$this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3221
        //$y = $y + 2;
3222
        $oldX = $x;
3223
        $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...
3224
        if ($this->orientacao == 'P') {
3225
            $maxW = $this->wPrint;
3226
        } else {
3227
            $maxW = $this->wPrint - $this->wCanhoto;
3228
        }
3229
        $w = $maxW - 1;
3230
        $h = 20;
3231
        $y = $y + 1;
3232
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3233
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3234
        $aFont = $this->formatPadrao;
3235
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3236
        $y += 3.4;
3237
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3238
        $texto = 'NOME';
3239
        $aFont = array(
3240
            'font' => $this->fontePadrao,
3241
            'size' => 6,
3242
            'style' => '');
3243
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3244
        $x += $w * 0.25;
3245
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3246
        $texto = 'ASSINATURA / CARIMBO';
3247
        $aFont = array(
3248
            'font' => $this->fontePadrao,
3249
            'size' => 6,
3250
            'style' => '');
3251
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3252
        $x += $w * 0.25;
3253
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3254
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3255
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3256
        $aFont = array(
3257
            'font' => $this->fontePadrao,
3258
            'size' => 6,
3259
            'style' => '');
3260
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3261
        $x = $oldX;
3262
        $y = $y + 5;
3263
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3264
        $texto = 'RG';
3265
        $aFont = array(
3266
            'font' => $this->fontePadrao,
3267
            'size' => 6,
3268
            'style' => '');
3269
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3270
        $x += $w * 0.85;
3271
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3272
        $texto = "CT-E";
3273
        $aFont = $this->formatNegrito;
3274
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3275
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
3276
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
3277
        $aFont = array(
3278
            'font' => $this->fontePadrao,
3279
            'size' => 6,
3280
            'style' => '');
3281
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3282
        $x = $oldX;
3283
        $this->zhDashedLine($x, $y + 12.7, $this->wPrint, 0.1, 80);
3284
    }
3285
    
3286
    /**
3287
     * zDadosAdic
3288
     * Coloca o grupo de dados adicionais da DACTE.
3289
     *
3290
     * @param  number $x Posição horizontal canto esquerdo
3291
     * @param  number $y Posição vertical canto superior
3292
     * @param  number $h altura do campo
3293
     * @return number Posição vertical final
3294
     */
3295
    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...
3296
    {
3297
        $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...
3298
        //###########################################################################
3299
        //DADOS ADICIONAIS DACTE
3300
        if ($this->orientacao == 'P') {
3301
            $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...
3302
        } else {
3303
            $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...
3304
        }
3305
        //INFORMAÇÕES COMPLEMENTARES
3306
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3307
        $y += 3;
3308
        $w = $this->wAdic;
3309
        $h = 8; //mudar
3310
        $aFont = array(
3311
            'font' => $this->fontePadrao,
3312
            'size' => 6,
3313
            'style' => '');
3314
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3315
        //$this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3316
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3317
        //o texto com os dados adicionais foi obtido na função xxxxxx
3318
        //e carregado em uma propriedade privada da classe
3319
        //$this->wAdic com a largura do campo
3320
        //$this->textoAdic com o texto completo do campo
3321
        $y += 1;
3322
        $aFont = $this->formatPadrao;
3323
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3324
        //RESERVADO AO FISCO
3325
        $texto = "RESERVADO AO FISCO";
3326
        $x += $w;
3327
        $y -= 1;
3328
        if ($this->orientacao == 'P') {
3329
            $w = $this->wPrint - $w;
3330
        } else {
3331
            $w = $this->wPrint - $w - $this->wCanhoto;
3332
        }
3333
        $aFont = array(
3334
            'font' => $this->fontePadrao,
3335
            'size' => 6,
3336
            'style' => '');
3337
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3338
        //inserir texto informando caso de contingência
3339
        //1 – Normal – emissão normal;
3340
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3341
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3342
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3343
        //Emissão em Contingência – DPEC;
3344
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3345
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3346
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3347
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3348
        $texto = '';
3349
        switch ($this->tpEmis) {
3350
            case 2:
3351
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3352
                break;
3353
            case 3:
3354
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3355
                break;
3356
            case 4:
3357
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3358
                break;
3359
            case 5:
3360
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3361
                break;
3362
        }
3363
        $y += 2;
3364
        $aFont = $this->formatPadrao;
3365
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3366
        return $y + $h;
3367
    }
3368
    
3369
    /**
3370
     * zhDashedLine
3371
     * Desenha uma linha horizontal tracejada com o FPDF
3372
     *
3373
     * @param  number $x Posição horizontal inicial, em mm
3374
     * @param  number $y Posição vertical inicial, em mm
3375
     * @param  number $w Comprimento da linha, em mm
3376
     * @param  number $h Espessura da linha, em mm
3377
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3378
     * @return none
3379
     */
3380
    protected function zhDashedLine($x, $y, $w, $h, $n)
3381
    {
3382
        $this->pdf->SetLineWidth($h);
3383
        $wDash = ($w / $n) / 2; // comprimento dos traços
3384
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
3385
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3386
                if ($j <= ($x + $w - 1)) {
3387
                    $this->pdf->Line($j, $y, $j + 1, $y);
3388
                }
3389
            }
3390
        }
3391
    }
3392
    
3393
    /**
3394
     * zhDashedVerticalLine
3395
     * Desenha uma linha vertical tracejada com o FPDF
3396
     *
3397
     * @param  number $x Posição horizontal inicial, em mm
3398
     * @param  number $y Posição vertical inicial, em mm
3399
     * @param  number $w Comprimento da linha, em mm
3400
     * @param  number $yfinal Espessura da linha, em mm
3401
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3402
     * @return none
3403
     */
3404
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3405
    {
3406
        $this->pdf->SetLineWidth($w);
3407
        /* Organizando valores */
3408
        if ($y > $yfinal) {
3409
            $aux = $yfinal;
3410
            $yfinal = $y;
3411
            $y = $aux;
3412
        }
3413
        while ($y < $yfinal && $n > 0) {
3414
            $this->pdf->Line($x, $y, $x, $y + 1);
3415
            $y += 3;
3416
            $n--;
3417
        }
3418
    }
3419
    
3420
    /**
3421
     * zFormatCNPJCPF
3422
     * Formata campo CnpjCpf contida na CTe
3423
     *
3424
     * @param  string $field campo cnpjCpf da CT-e
3425
     * @return string
3426
     */
3427
    protected function zFormatCNPJCPF($field)
3428
    {
3429
        if (!isset($field)) {
3430
            return '';
3431
        }
3432
        $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...
3433
            $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...
3434
        if ($cnpj != "" && $cnpj != "00000000000000") {
3435
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3436
        } else {
3437
            $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...
3438
                $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...
3439
        }
3440
        return $cnpj;
3441
    }
3442
    
3443
    /**
3444
     * zFormatFone
3445
     * Formata campo fone contida na CTe
3446
     *
3447
     * @param  string $field campo fone da CT-e
3448
     * @return string
3449
     */
3450
    protected function zFormatFone($field)
3451
    {
3452
        try {
3453
            $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...
3454
            $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...
3455
            $foneLen = strlen($fone);
3456
            if ($foneLen > 0) {
3457
                $fone2 = substr($fone, 0, $foneLen - 4);
3458
                $fone1 = substr($fone, 0, $foneLen - 8);
3459
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3460
            } else {
3461
                $fone = '';
3462
            }
3463
            return $fone;
3464
        } catch (Exception $exc) {
3465
            return '';
3466
        }
3467
    }
3468
    
3469
    /**
3470
     * zUnidade
3471
     * Converte a imformação de peso contida na CTe
3472
     *
3473
     * @param  string $c unidade de trafego extraida da CTe
3474
     * @return string
3475
     */
3476
    protected function zUnidade($c = '')
3477
    {
3478
        switch ($c) {
3479
            case '00':
3480
                $r = 'M3';
3481
                break;
3482
            case '01':
3483
                $r = 'KG';
3484
                break;
3485
            case '02':
3486
                $r = 'TON';
3487
                break;
3488
            case '03':
3489
                $r = 'UN';
3490
                break;
3491
            case '04':
3492
                $r = 'LT';
3493
                break;
3494
            case '05':
3495
                $r = 'MMBTU';
3496
                break;
3497
            default:
3498
                $r = '';
3499
        }
3500
        return $r;
3501
    }
3502
    
3503
    /**
3504
     * zConvertUnidTrafego
3505
     * Converte a imformação de peso contida na CTe
3506
     *
3507
     * @param  string $U Informação de trafego extraida da CTe
3508
     * @return string
3509
     */
3510
    protected function zConvertUnidTrafego($U = '')
3511
    {
3512
        if ($U) {
3513
            switch ($U) {
3514
                case '0':
3515
                    $stringU = 'Próprio';
3516
                    break;
3517
                case '1':
3518
                    $stringU = 'Mútuo';
3519
                    break;
3520
                case '2':
3521
                    $stringU = 'Rodoferroviário';
3522
                    break;
3523
                case '3':
3524
                    $stringU = 'Rodoviário';
3525
                    break;
3526
            }
3527
            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...
3528
        }
3529
    }
3530
    
3531
    /**
3532
     * zMultiUniPeso
3533
     * Fornece a imformação multiplicação de peso contida na CTe
3534
     *
3535
     * @param  interger $U Informação de peso extraida da CTe
3536
     * @return interger
3537
     */
3538
    protected function zMultiUniPeso($U = '')
3539
    {
3540
        if ($U === "01") {
3541
            // tonelada
3542
            //return 1000;
3543
            return 1;
3544
        }
3545
        return 1; // M3, KG, Unidade, litros, mmbtu
3546
    }
3547
    
3548
    protected function pQRDAMDFE($y = 0)
3549
    {
3550
        $margemInterna = $this->margemInterna;
3551
        $barcode = new Barcode();
3552
        $bobj = $barcode->getBarcodeObj(
3553
            'QRCODE,M',
3554
            $this->qrCodMDFe,
3555
            -4,
3556
            -4,
3557
            'black',
3558
            array(-2, -2, -2, -2)
3559
        )->setBackgroundColor('white');
3560
        $qrcode = $bobj->getPngData();
3561
        $wQr = 30;
3562
        $hQr = 30;
3563
        $yQr = ($y + $margemInterna);
3564
        if ($this->orientacao == 'P') {
3565
            $xQr = 170;
3566
        } else {
3567
            $xQr = 245;
3568
        }
3569
        // prepare a base64 encoded "data url"
3570
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
3571
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
3572
    }
3573
}
3574