Completed
Pull Request — master (#40)
by
unknown
09:28
created

Dacte::zDocAnu()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 54
Code Lines 50

Duplication

Lines 5
Ratio 9.26 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 50
c 1
b 0
f 0
nc 4
nop 2
dl 5
loc 54
ccs 0
cts 54
cp 0
crap 12
rs 9.6716

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use NFePHP\Common\Dom\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Legacy\Common;
21
22
class Dacte extends Common
23
{
24
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
25
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
26
    const SIT_DPEC = 3;
27
28
    protected $logoAlign = 'C';
29
    protected $yDados = 0;
30
    protected $situacao_externa = 0;
31
    protected $numero_registro_dpec = '';
32
    protected $pdf;
33
    protected $xml;
34
    protected $logomarca = '';
35
    protected $errMsg = '';
36
    protected $errStatus = false;
37
    protected $orientacao = 'P';
38
    protected $papel = 'A4';
39
    protected $destino = 'I';
40
    protected $pdfDir = '';
41
    protected $fontePadrao = 'Times';
42
    protected $version = '1.3.0';
43
    protected $wPrint;
44
    protected $hPrint;
45
    protected $dom;
46
    protected $infCte;
47
    protected $infCteComp;
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 $infOutros;
73
    protected $idDocAntEle;
74
    protected $infCteAnu;
75
    protected $compl;
76
    protected $ICMS;
77
    protected $imp;
78
    protected $toma4;
79
    protected $toma03;
80
    protected $tpEmis;
81
    protected $tpImp;
82
    protected $tpAmb;
83
    protected $vPrest;
84
    protected $wAdic = 150;
85
    protected $textoAdic = '';
86
    protected $debugMode = 2;
87
    protected $formatPadrao;
88
    protected $formatNegrito;
89
    protected $aquav;
90
    protected $preVisualizar;
91
    protected $flagDocOrigContinuacao;
92
    protected $arrayNFe = array();
93
    protected $siteDesenvolvedor;
94
    protected $nomeDesenvolvedor;
95
    protected $totPag;
96
97
    /**
98
     * __construct
99
     *
100
     * @param string $docXML Arquivo XML da CTe
101
     * @param string $sOrientacao (Opcional) Orientação da impressão P ou L
102
     * @param string $sPapel Tamanho do papel (Ex. A4)
103
     * @param string $sPathLogo Caminho para o arquivo do logo
104
     * @param string $sDestino Estabelece a direção do envio do documento PDF
105
     * @param string $sDirPDF Caminho para o diretorio de armaz. dos PDF
106
     * @param string $fonteDACTE Nome da fonte a ser utilizada
107
     * @param number $mododebug 0-Não 1-Sim e 2-nada (2 default)
108
     * @param string $preVisualizar 0-Não 1-Sim
109
     * @param string $nomeDesenvolvedor Nome do desenvolvedor para rodapé da CT-e
110
     * @param string $siteDesenvolvedor Site do desenvolvedor para rodapé da CT-e
111
     */
112
    public function __construct(
113
        $docXML = '',
114
        $sOrientacao = '',
115
        $sPapel = '',
116
        $sPathLogo = '',
117
        $sDestino = 'I',
118
        $sDirPDF = '',
119
        $fonteDACTE = '',
120
        $mododebug = 2,
121
        $preVisualizar = false,
122
        $nomeDesenvolvedor = 'Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org',
123
        $siteDesenvolvedor = 'http://www.nfephp.org'
124
    ) {
125
    
126
        if (is_numeric($mododebug)) {
127
            $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...
128
        }
129
        if ($mododebug == 1) {
130
            //ativar modo debug
131
            error_reporting(E_ALL);
132
            ini_set('display_errors', 'On');
133
        } elseif ($mododebug == 0) {
134
            //desativar modo debug
135
            error_reporting(0);
136
            ini_set('display_errors', 'Off');
137
        }
138
        $this->orientacao = $sOrientacao;
139
        $this->papel = $sPapel;
140
        $this->pdf = '';
141
        $this->xml = $docXML;
142
        $this->logomarca = $sPathLogo;
143
        $this->destino = $sDestino;
144
        $this->pdfDir = $sDirPDF;
145
        $this->preVisualizar = $preVisualizar;
146
        $this->siteDesenvolvedor = $siteDesenvolvedor;
147
        $this->nomeDesenvolvedor = $nomeDesenvolvedor;
148
        // verifica se foi passa a fonte a ser usada
149
        if (!empty($fonteDACTE)) {
150
            $this->fontePadrao = $fonteDACTE;
151
        }
152
        $this->formatPadrao = array(
153
            'font' => $this->fontePadrao,
154
            'size' => 6,
155
            'style' => '');
156
        $this->formatNegrito = array(
157
            'font' => $this->fontePadrao,
158
            'size' => 7,
159
            'style' => 'B');
160
        //se for passado o xml
161
        if (!empty($this->xml)) {
162
            $this->dom = new Dom();
163
            $this->dom->loadXML($this->xml);
164
            $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...
165
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
166
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
167
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
168
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
169
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
170
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
171
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
172
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
173
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
174
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
175
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
176
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
177
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
178
            $this->infQ = $this->dom->getElementsByTagName("infQ");
179
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
180
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
181
            $this->lota = $this->pSimpleGetValue($this->rodo, "lota");
0 ignored issues
show
Bug introduced by
The property lota does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
182
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
183
            $this->veic = $this->dom->getElementsByTagName("veic");
184
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
185
            // adicionar outros modais
186
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
187
            $this->chaveCTeRef = $this->pSimpleGetValue($this->infCteComp, "chave");
188
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
189
            $this->Comp = $this->dom->getElementsByTagName("Comp");
190
            $this->infNF = $this->dom->getElementsByTagName("infNF");
191
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
192
            $this->infOutros = $this->dom->getElementsByTagName("infOutros");
193
            $this->idDocAntEle = $this->dom->getElementsByTagName("idDocAntEle");
194
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
195
            $this->compl = $this->dom->getElementsByTagName("compl");
196
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
197
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
0 ignored issues
show
Bug introduced by
The property ICMSSN does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
198
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
199
            $textoAdic = number_format((double)$this->pSimpleGetValue($this->imp, "vTotTrib"), 2, ",", ".");
200
            $this->textoAdic = "O valor aproximado de tributos incidentes sobre o preço deste serviço é de R$ "
201
                    .$textoAdic;
202
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
203
            $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
204
            //modal aquaviário
205
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
206
            $tomador = $this->pSimpleGetValue($this->toma03, "toma");
207
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
208
            switch ($tomador) {
209
                case '0':
210
                    $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...
211
                    $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...
212
                    break;
213
                case '1':
214
                    $this->toma = $this->exped;
215
                    $this->enderToma = $this->enderExped;
216
                    break;
217
                case '2':
218
                    $this->toma = $this->receb;
219
                    $this->enderToma = $this->enderReceb;
220
                    break;
221
                case '3':
222
                    $this->toma = $this->dest;
223
                    $this->enderToma = $this->enderDest;
224
                    break;
225
                default:
226
                    $this->toma = $this->toma4;
227
                    $this->enderToma = $this->pSimpleGetValue($this->toma4, "enderToma");
228
                    break;
229
            }
230
            $seguro = $this->pSimpleGetValue($this->seg, "respSeg");
231
            switch ($seguro) {
232
                case '0':
233
                    $this->respSeg = 'Remetente';
0 ignored issues
show
Bug introduced by
The property respSeg does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
234
                    break;
235
                case '1':
236
                    $this->respSeg = 'Expedidor';
237
                    break;
238
                case '2':
239
                    $this->respSeg = 'Recebedor';
240
                    break;
241
                case '3':
242
                    $this->respSeg = 'Destinatário';
243
                    break;
244
                case '4':
245
                    $this->respSeg = 'Emitente';
246
                    break;
247
                case '5':
248
                    $this->respSeg = 'Tomador';
249
                    break;
250
                default:
251
                    $this->respSeg = '';
252
                    break;
253
            }
254
            $this->tpEmis = $this->pSimpleGetValue($this->ide, "tpEmis");
255
            $this->tpImp = $this->pSimpleGetValue($this->ide, "tpImp");
256
            $this->tpAmb = $this->pSimpleGetValue($this->ide, "tpAmb");
257
            $this->tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
258
            $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...
259
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
260
            $this->modal = $this->pSimpleGetValue($this->ide, "modal");
261
        }
262
    }
263
264
    /**
265
     * monta
266
     * @param string $orientacao L ou P
267
     * @param string $papel A4
268
     * @param string $logoAlign C, L ou R
269
     * @param Pdf $classPDF
270
     * @return string montagem
271
     */
272
    public function monta(
273
        $orientacao = '',
274
        $papel = 'A4',
275
        $logoAlign = 'C',
276
        $classPDF = false
277
    ) {
278
    
279
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 276 can also be of type object<NFePHP\DA\Legacy\Pdf>; however, NFePHP\DA\CTe\Dacte::montaDACTE() does only seem to accept boolean, maybe add an additional type check?

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

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

An additional type check may prevent trouble.

Loading history...
280
    }
281
282
    /**
283
     * printDocument
284
     * @param string $nome
285
     * @param string $destino
286
     * @param string $printer
287
     * @return
288
     */
289
    public function printDocument($nome = '', $destino = 'I', $printer = '')
290
    {
291
        return $this->printDACTE($nome, $destino, $printer);
292
    }
293
294
    /**
295
     * Dados brutos do PDF
296
     * @return string
297
     */
298
    public function render()
299
    {
300
        return $this->pdf->getPdf();
301
    }
302
303
304
    protected function zCteDPEC()
305
    {
306
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
307
    }
308
309
310
    /**
311
     * montaDACTE
312
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
313
     * durante sua construção.
314
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
315
     * pelo conteúdo da funçao e podem ser modificados.
316
     *
317
     * @param  string $orientacao (Opcional) Estabelece a orientação da
318
     *                impressão (ex. P-retrato), se nada for fornecido será
319
     *                usado o padrão da NFe
320
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
321
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
322
     */
323
    public function montaDACTE(
324
        $orientacao = '',
325
        $papel = 'A4',
326
        $logoAlign = 'C',
327
        $classPDF = false
328
    ) {
329
    
330
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
331 View Code Duplication
        if ($orientacao == '') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
332
            if ($this->tpImp == '1') {
333
                $orientacao = 'P';
334
            } else {
335
                $orientacao = 'P';
336
            }
337
        }
338
        $this->orientacao = $orientacao;
339
        $this->papel = $papel;
340
        $this->logoAlign = $logoAlign;
341
342
        //$this->situacao_externa = $situacao_externa;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
343
        //instancia a classe pdf
344
        if ($classPDF !== false) {
345
            $this->pdf = $classPDF;
346
        } else {
347
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
348
        }
349
        if ($this->orientacao == 'P') {
350
            // margens do PDF
351
            $margSup = 2;
352
            $margEsq = 2;
353
            $margDir = 2;
354
            // posição inicial do relatorio
355
            $xInic = 1;
356
            $yInic = 1;
357
            if ($papel == 'A4') {
358
                //A4 210x297mm
359
                $maxW = 210;
360
                $maxH = 297;
361
            }
362
        } else {
363
            // margens do PDF
364
            $margSup = 3;
365
            $margEsq = 3;
366
            $margDir = 3;
367
            // posição inicial do relatorio
368
            $xInic = 5;
369
            $yInic = 5;
370
            if ($papel == 'A4') {
371
                //A4 210x297mm
372
                $maxH = 210;
373
                $maxW = 297;
374
                $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...
375
            }
376
        }
377
        //total inicial de paginas
378
        $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...
379
        //largura imprimivel em mm
380
        $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...
381
        //comprimento imprimivel em mm
382
        $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...
383
        // estabelece contagem de paginas
384
        $this->pdf->AliasNbPages();
385
        // fixa as margens
386
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
387
        $this->pdf->SetDrawColor(0, 0, 0);
388
        $this->pdf->SetFillColor(255, 255, 255);
389
        // inicia o documento
390
        $this->pdf->Open();
391
        // adiciona a primeira página
392
        $this->pdf->AddPage($this->orientacao, $this->papel);
393
        $this->pdf->SetLineWidth(0.1);
394
        $this->pdf->SetTextColor(0, 0, 0);
395
        //calculo do numero de páginas ???
396
        $totPag = 1;
397
        //montagem da primeira página
398
        $pag = 1;
399
        $x = $xInic;
400
        $y = $yInic;
401
        //coloca o cabeçalho
402
        //$r = $this->zCabecalho($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
403
        $y += 70;
404
        $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...
405
        $x = $this->wPrint * 0.5 + 2;
406
        $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...
407
        $y += 19;
408
        $x = $xInic;
409
        $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...
410
        $x = $this->wPrint * 0.5 + 2;
411
        $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...
412
        $y += 19;
413
        $x = $xInic;
414
        $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...
415
        if ($this->tpCTe == '0') {
416
            //Normal
417
            $y += 10;
418
            $x = $xInic;
419
            $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...
420
            $y += 17;
421
            $x = $xInic;
422
            $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...
423
            $y += 25;
424
            $x = $xInic;
425
            $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...
426
            $y += 13;
427
            $x = $xInic;
428
            $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...
429 View Code Duplication
            if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
430
                if ($this->lota == 1) {
431
                    //$y += 24.95;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
432
                    $y += 35;
433
                } else {
434
                    $y += 53;
435
                }
436
            } elseif ($this->modal == '3') {
437
                $y += 37.75;
438
            } else {
439
                $y += 24.95;
440
            }
441
            $x = $xInic;
442
            $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...
443
            $y = $y-6;
444
            switch ($this->modal) {
445
                case '1':
446
                    $y += 17.9;
447
                    $x = $xInic;
448
                    $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...
449
                    break;
450
                case '2':
451
                    $y += 17.9;
452
                    $x = $xInic;
453
                    // TODO fmertins 31/10/14: este método não existe...
454
                    $r = $this->zModalAereo($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalAereo() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

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

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

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

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

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

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

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

Loading history...
455
                    break;
456
                case '3':
457
                    $y += 17.9;
458
                    $x = $xInic;
459
                    $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...
460
                    break;
461
                case '4':
462
                    $y += 17.9;
463
                    $x = $xInic;
464
                    $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...
465
                    break;
466
                case '5':
467
                    $y += 17.9;
468
                    $x = $xInic;
469
                    // TODO fmertins 31/10/14: este método não existe...
470
                    $r = $this->zModalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method zModalDutoviario() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

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

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

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

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

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

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

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

Loading history...
471
                    break;
472
            }
473 View Code Duplication
            if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
474
                if ($this->lota == 1) {
475
                    $y += 37;
476
                } else {
477
                    $y += 8.9;
478
                }
479
            } elseif ($this->modal == '3') {
480
                $y += 24.15;
481
            } else {
482
                $y += 37;
483
            }
484
        } elseif ($this->tpCTe == '2') {
485
            //Anulação de valores
486
            $r = $this->zCabecalho(1, 1, $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...
487
            $y += 10;
488
            $x = $xInic;
489
            $r = $this->zDocAnu($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
490
            $y += 80;
491
            $x = $xInic;
492
            $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...
493
            $y += 25;
494
            $x = $xInic;
495
            $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...
496
            $y += 13;
497
            $x = $xInic;
498
            $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...
499
            $y += 15;
500
        } else {
501
            $r = $this->zCabecalho(1, 1, $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...
502
            //Complementado
503
            $y += 10;
504
            $x = $xInic;
505
            $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...
506
            $y += 80;
507
            $x = $xInic;
508
            $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...
509
            $y += 25;
510
            $x = $xInic;
511
            $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...
512
            $y += 13;
513
            $x = $xInic;
514
            $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...
515
            $y += 15;
516
        }
517
        $x = $xInic;
518
        $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...
519
        
520
        //$y += 19;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
521
        $y += 10;
522
        $y = $this->zCanhoto($x, $y);
0 ignored issues
show
Unused Code introduced by
$y is not used, you could remove the assignment.

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

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

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

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

Loading history...
523
        
524
        //coloca o rodapé da página
525
        if ($this->orientacao == 'P') {
526
            $this->zRodape(2, $this->hPrint - 2);
527
        } else {
528
            $this->zRodape($xInic, $this->hPrint + 2.3);
529
        }
530
        if ($this->flagDocOrigContinuacao == 1) {
531
            $this->zdocOrigContinuacao(1, 71);
532
        }
533
        //retorna o ID na CTe
534 View Code Duplication
        if ($classPDF !== false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
535
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
536
            return $aR;
537
        } else {
538
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
539
        }
540
    } //fim da função montaDACTE
541
542
    /**
543
     * printDACTE
544
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
545
     * O destino da impressão pode ser :
546
     * I-browser
547
     * D-browser com download
548
     * F-salva em um arquivo local com o nome informado
549
     * S-retorna o documento como uma string e o nome é ignorado.
550
     * Para enviar o pdf diretamente para uma impressora indique o
551
     * nome da impressora e o destino deve ser 'S'.
552
     *
553
     * @param  string $nome Path completo com o nome do arquivo pdf
554
     * @param  string $destino Direção do envio do PDF
555
     * @param  string $printer Identificação da impressora no sistema
556
     * @return string Caso o destino seja S o pdf é retornado como uma string
557
     * @todo Rotina de impressão direta do arquivo pdf criado
558
     */
559 View Code Duplication
    public function printDACTE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer is not used and could be removed.

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

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
560
    {
561
        $arq = $this->pdf->Output($nome, $destino);
562
        if ($destino == 'S') {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
563
            //aqui pode entrar a rotina de impressão direta
564
        }
565
        return $arq;
566
    } //fim função printDACTE
567
568
    /**
569
     * zCabecalho
570
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
571
     *
572
     * @param  number $x Posição horizontal inicial, canto esquerdo
573
     * @param  number $y Posição vertical inicial, canto superior
574
     * @param  number $pag Número da Página
575
     * @param  number $totPag Total de páginas
576
     * @return number Posição vertical final
577
     */
578
    protected function zCabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
579
    {
580
        $oldX = $x;
581
        $oldY = $y;
582
        if ($this->orientacao == 'P') {
583
            $maxW = $this->wPrint;
584
        } else {
585
            if ($pag == 1) {
586
                // primeira página
587
                $maxW = $this->wPrint - $this->wCanhoto;
588
            } else {
589
                // páginas seguintes
590
                $maxW = $this->wPrint;
591
            }
592
        }
593
        //##################################################################
594
        //coluna esquerda identificação do emitente
595
        $w = round($maxW * 0.42);
596
        if ($this->orientacao == 'P') {
597
            $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...
598
                'font' => $this->fontePadrao,
599
                'size' => 6,
600
                'style' => '');
601
        } else {
602
            $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...
603
        }
604
        $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...
605
        $h = 35;
606
        $oldY += $h;
607
        //desenha a caixa
608
        $this->pTextBox($x, $y, $w + 2, $h + 1);
609
        // coloca o logo
610 View Code Duplication
        if (is_file($this->logomarca)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
611
            $logoInfo = getimagesize($this->logomarca);
612
            //largura da imagem em mm
613
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
614
            //altura da imagem em mm
615
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
616
            if ($this->logoAlign == 'L') {
617
                $nImgW = round($w / 3, 0);
618
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
619
                $xImg = $x + 1;
620
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
621
                //estabelecer posições do texto
622
                $x1 = round($xImg + $nImgW + 1, 0);
623
                $y1 = round($h / 3 + $y, 0);
624
                $tw = round(2 * $w / 3, 0);
625
            } elseif ($this->logoAlign == 'C') {
626
                $nImgH = round($h / 3, 0);
627
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
628
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
629
                $yImg = $y + 3;
630
                $x1 = $x;
631
                $y1 = round($yImg + $nImgH + 1, 0);
632
                $tw = $w;
633
            } elseif ($this->logoAlign == 'R') {
634
                $nImgW = round($w / 3, 0);
635
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
636
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
637
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
638
                $x1 = $x;
639
                $y1 = round($h / 3 + $y, 0);
640
                $tw = round(2 * $w / 3, 0);
641
            }
642
            $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...
643
        } else {
644
            $x1 = $x;
645
            $y1 = round($h / 3 + $y, 0);
646
            $tw = $w;
647
        }
648
        //Nome emitente
649
        $aFont = array(
650
            'font' => $this->fontePadrao,
651
            'size' => 9,
652
            'style' => 'B');
653
        $texto = $this->pSimpleGetValue($this->emit, "xNome");
654
        $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...
655
        //endereço
656
        $y1 = $y1 + 3;
657
        $aFont = array(
658
            'font' => $this->fontePadrao,
659
            'size' => 7,
660
            'style' => '');
661
        $fone = $this->zFormatFone($this->enderEmit);
0 ignored issues
show
Compatibility introduced by
$this->enderEmit of type object<DOMNode> is not a sub-type of object<DOMElement>. It seems like you assume a child class of the class DOMNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
662
        $lgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
663
        $nro = $this->pSimpleGetValue($this->enderEmit, "nro");
664
        $cpl = $this->pSimpleGetValue($this->enderEmit, "xCpl");
0 ignored issues
show
Unused Code introduced by
$cpl is not used, you could remove the assignment.

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

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

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

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

Loading history...
665
        $bairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
666
        $CEP = $this->pSimpleGetValue($this->enderEmit, "CEP");
667
        $CEP = $this->pFormat($CEP, "#####-###");
668
        $mun = $this->pSimpleGetValue($this->enderEmit, "xMun");
669
        $UF = $this->pSimpleGetValue($this->enderEmit, "UF");
670
        $xPais = $this->pSimpleGetValue($this->enderEmit, "xPais");
671
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
672
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
673
            . "\n  Fone/Fax: " . $fone;
674
        $this->pTextBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
675
        //CNPJ/CPF IE
676
        $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...
677
        $ie = $this->pSimpleGetValue($this->emit, "IE");
678
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
679
        $this->pTextBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
680
        //outra caixa
681
        $h1 = 17.5;
682
        $y1 = $y + $h + 1;
683
        $this->pTextBox($x, $y1, $w + 2, $h1);
684
        //TIPO DO CT-E
685
        $texto = 'TIPO DO CTE';
686
        $wa = 37;
687
        $aFont = array(
688
            'font' => $this->fontePadrao,
689
            'size' => 8,
690
            'style' => '');
691
        $this->pTextBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
692
        $tpCTe = $this->pSimpleGetValue($this->ide, "tpCTe");
693
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
694
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
695
        switch ($tpCTe) {
696
            case '0':
697
                $texto = 'Normal';
698
                break;
699
            case '1':
700
                $texto = 'Complemento de Valores';
701
                break;
702
            case '2':
703
                $texto = 'Anulação de Valores';
704
                break;
705
            case '3':
706
                $texto = 'Substituto';
707
                break;
708
            default:
709
                $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...
710
        }
711
        $aFont = $this->formatNegrito;
712
        $this->pTextBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
713
        //TIPO DO SERVIÇO
714
        $texto = 'TIPO DO SERVIÇO';
715
        $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...
716
        $aFont = array(
717
            'font' => $this->fontePadrao,
718
            'size' => 8,
719
            'style' => '');
720
        $this->pTextBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
721
        $tpServ = $this->pSimpleGetValue($this->ide, "tpServ");
722
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
723 View Code Duplication
        switch ($tpServ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
724
            case '0':
725
                $texto = 'Normal';
726
                break;
727
            case '1':
728
                $texto = 'Subcontratação';
729
                break;
730
            case '2':
731
                $texto = 'Redespacho';
732
                break;
733
            case '3':
734
                $texto = 'Redespacho Intermediário';
735
                break;
736
            default:
737
                $texto = 'ERRO' . $tpServ;
738
        }
739
        $aFont = $this->formatNegrito;
740
        $this->pTextBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
741
        $this->pdf->Line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
742
        //TOMADOR DO SERVIÇO
743
        $texto = 'TOMADOR DO SERVIÇO';
744
        $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...
745
        $y2 = $y1 + 8;
746
        $aFont = array(
747
            'font' => $this->fontePadrao,
748
            'size' => 8,
749
            'style' => '');
750
        $this->pTextBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
751
        $this->pdf->Line($x, $y1 + 8, $w + 3, $y1 + 8);
752
        $toma = $this->pSimpleGetValue($this->ide, "toma");
753
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
754 View Code Duplication
        switch ($toma) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
755
            case '0':
756
                $texto = 'Remetente';
757
                break;
758
            case '1':
759
                $texto = 'Expedidor';
760
                break;
761
            case '2':
762
                $texto = 'Recebedor';
763
                break;
764
            case '3':
765
                $texto = 'Destinatário';
766
                break;
767
            case '4':
768
                $texto = 'Outros';
769
                break;
770
            default:
771
                $texto = 'ERRO' . $toma;
772
        }
773
        $aFont = $this->formatNegrito;
774
        $this->pTextBox($x, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
775
        //FORMA DE PAGAMENTO
776
        $texto = 'FORMA DE PAGAMENTO';
777
        $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...
778
        $aFont = array(
779
            'font' => $this->fontePadrao,
780
            'size' => 8,
781
            'style' => '');
782
        $this->pTextBox($x + $wa + 4.5, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
783
        $forma = $this->pSimpleGetValue($this->ide, "forPag");
784
        //0 - Pago;1 - A pagar;2 - outros
785
        switch ($forma) {
786
            case '0':
787
                $texto = 'Pago';
788
                break;
789
            case '1':
790
                $texto = 'A pagar';
791
                break;
792
            case '2':
793
                $texto = 'Outros';
794
                break;
795
            default:
796
                $texto = 'ERRO' . $forma;
797
        }
798
        $aFont = $this->formatNegrito;
799
        $this->pTextBox($x + $wa + 4.5, $y2 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
800
        //##################################################################
801
        //coluna direita
802
        $x += $w + 2;
803
        $w = round($maxW * 0.335);
804
        $w1 = $w;
805
        $h = 11;
806
        $this->pTextBox($x, $y, $w + 2, $h + 1);
807
        $texto = "DACTE";
808
        $aFont = array(
809
            'font' => $this->fontePadrao,
810
            'size' => 10,
811
            'style' => 'B');
812
        $this->pTextBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
813
        $aFont = array(
814
            'font' => $this->fontePadrao,
815
            'size' => 8,
816
            'style' => '');
817
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico";
818
        $h = 10;
819
        $this->pTextBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
820
        $x1 = $x + $w + 2;
821
        $w = round($maxW * 0.22, 0);
822
        $w2 = $w;
823
        $h = 11;
824
        $this->pTextBox($x1, $y, $w + 0.5, $h + 1);
825
        $texto = "MODAL";
826
        $aFont = array(
827
            'font' => $this->fontePadrao,
828
            'size' => 8,
829
            'style' => '');
830
        $this->pTextBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
831
        //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
832
        $modal = $this->pSimpleGetValue($this->ide, "modal");
833
        $this->modal = $modal;
834
        switch ($this->modal) {
835
            case '1':
836
                $texto = 'Rodoviário';
837
                break;
838
            case '2':
839
                $texto = 'Aéreo';
840
                break;
841
            case '3':
842
                $texto = 'Aquaviário';
843
                break;
844
            case '4':
845
                $texto = 'Ferroviário';
846
                break;
847
            case '5':
848
                $texto = 'Dutoviário';
849
                break;
850
        }
851
        $aFont = array(
852
            'font' => $this->fontePadrao,
853
            'size' => 10,
854
            'style' => 'B');
855
        $this->pTextBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
856
        //outra caixa
857
        $y += 12;
858
        $h = 9;
859
        $w = $w1 + $w2 + 2;
860
        $this->pTextBox($x, $y, $w + 0.5, $h + 1);
861
        //modelo
862
        $wa = 12;
863
        $xa = $x;
864
        $texto = 'MODELO';
865
        $aFont = array(
866
            'font' => $this->fontePadrao,
867
            'size' => 8,
868
            'style' => '');
869
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
870
        $texto = $this->pSimpleGetValue($this->ide, "mod");
871
        $aFont = $this->formatNegrito;
872
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
873
        $this->pdf->Line($x + $wa, $y, $x + $wa, $y + $h + 1);
874
        //serie
875
        $xa += $wa;
876
        $texto = 'SÉRIE';
877
        $aFont = array(
878
            'font' => $this->fontePadrao,
879
            'size' => 8,
880
            'style' => '');
881
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
882
        $texto = $this->pSimpleGetValue($this->ide, "serie");
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
        //numero
887
        $xa += $wa;
888
        $wa = 20;
889
        $texto = 'NÚMERO';
890
        $aFont = array(
891
            'font' => $this->fontePadrao,
892
            'size' => 8,
893
            'style' => '');
894
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
895
        $texto = $this->pSimpleGetValue($this->ide, "nCT");
896
        $aFont = $this->formatNegrito;
897
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
898
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
899
        //folha
900
        $xa += $wa;
901
        $wa = 12;
902
        $texto = 'FL';
903
        $aFont = array(
904
            'font' => $this->fontePadrao,
905
            'size' => 8,
906
            'style' => '');
907
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
908
        //$texto = '1/1';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
909
        $texto = $pag."/".$totPag;
910
        $aFont = $this->formatNegrito;
911
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
912
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
913
        //data  hora de emissão
914
        $xa += $wa;
915
        $wa = 30;
916
        $texto = 'DATA E HORA DE EMISSÃO';
917
        $aFont = array(
918
            'font' => $this->fontePadrao,
919
            'size' => 8,
920
            'style' => '');
921
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
922
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
923
            date('d/m/Y H:i:s', $this->pConvertTime($this->pSimpleGetValue($this->ide, "dhEmi"))) : '';
924
        $aFont = $this->formatNegrito;
925
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
926
        $this->pdf->Line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
927
        //ISUF
928
        $xa += $wa;
929
        $wa = 32;
930
        $texto = 'INSC. SUFRAMA DO DESTINATÁRIO';
931
        $aFont = $this->formatPadrao;
932
        $this->pTextBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
933
        $texto = $this->pSimpleGetValue($this->dest, "ISUF");
934
        $aFont = array(
935
            'font' => $this->fontePadrao,
936
            'size' => 7,
937
            'style' => 'B');
938
        $this->pTextBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
939
        //outra caixa
940
        $y += $h + 1;
941
        $h = 23;
942
        $h1 = 14;
943
        $this->pTextBox($x, $y, $w + 0.5, $h1);
944
        //CODIGO DE BARRAS
945
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
946
        $bW = 85;
947
        $bH = 10;
948
        //codigo de barras
949
        $this->pdf->SetFillColor(0, 0, 0);
950
        $this->pdf->Code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
951
        $this->pTextBox($x, $y + $h1, $w + 0.5, $h1 - 6);
952
        $texto = 'CHAVE DE ACESSO';
953
        $aFont = $this->formatPadrao;
954
        $this->pTextBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
955
        $aFont = $this->formatNegrito;
956
        $texto = $this->pFormat($chave_acesso, '##.####.##.###.###/####-##-##-###-###.###.###-###.###.###-#');
957
        $this->pTextBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
958
        $this->pTextBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
959
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
960
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
961
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
962
            $texto = "";
963
            $this->pdf->SetFillColor(0, 0, 0);
964
            if ($this->tpEmis == 5) {
965
                $chaveContingencia = $this->zGeraChaveAdicCont();
966
                $this->pdf->Code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
967
            } else {
968
                $chaveContingencia = $this->pSimpleGetValue($this->protCTe, "nProt");
969
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
970
            }
971
            //codigo de barras
972
        }
973
        $aFont = array(
974
            'font' => $this->fontePadrao,
975
            'size' => 8,
976
            'style' => '');
977
        $this->pTextBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
978
        //outra caixa
979
        $y += $h + 1;
980
        $h = 8.5;
981
        $wa = $w;
982
        $this->pTextBox($x, $y + 7.5, $w + 0.5, $h);
983
        if ($this->zCteDPEC()) {
984
            $texto = 'NÚMERO DE REGISTRO DPEC';
985
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
986
            $texto = "DADOS DO CT-E";
987
        } else {
988
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
989
        }
990
        $aFont = $this->formatPadrao;
991
        $this->pTextBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
992
        if ($this->zCteDPEC()) {
993
            $texto = $this->numero_registro_dpec;
994
        } elseif ($this->tpEmis == 5) {
995
            $chaveContingencia = $this->zGeraChaveAdicCont();
996
            $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...
997
                'font' => $this->fontePadrao,
998
                'size' => 8,
999
                'style' => 'B');
1000
            $texto = $this->pFormat($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
1001
            $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...
1002
        } else {
1003
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") . " - ";
1004
            // empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue)
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1005
            if (!empty($this->protCTe)
1006
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
1007
            ) {
1008
                $texto .= date(
1009
                    'd/m/Y   H:i:s',
1010
                    $this->pConvertTime($this->pSimpleGetValue($this->protCTe, "dhRecbto"))
1011
                );
1012
            }
1013
            $texto = $this->pSimpleGetValue($this->protCTe, "nProt") == '' ? '' : $texto;
1014
        }
1015
        $aFont = $this->formatNegrito;
1016
        $this->pTextBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
1017
        //CFOP
1018
        $x = $oldX;
1019
        $h = 8.5;
1020
        $w = round($maxW * 0.42);
1021
        $y1 = $y + 7.5;
1022
        $this->pTextBox($x, $y1, $w + 2, $h);
1023
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
1024
        $aFont = array(
1025
            'font' => $this->fontePadrao,
1026
            'size' => 8,
1027
            'style' => '');
1028
        $this->pTextBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1029
        $texto = $this->pSimpleGetValue($this->ide, "CFOP") . ' - ' . $this->pSimpleGetValue($this->ide, "natOp");
1030
        $aFont = $this->formatNegrito;
1031
        $this->pTextBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1032
        //ORIGEM DA PRESTAÇÃO
1033
        $y += $h + 7.5;
1034
        $x = $oldX;
1035
        $h = 8;
1036
        $w = ($maxW * 0.5);
1037
        $this->pTextBox($x, $y, $w + 0.5, $h);
1038
        $texto = 'INÍCIO DA PRESTAÇÃO';
1039
        $aFont = array(
1040
            'font' => $this->fontePadrao,
1041
            'size' => 8,
1042
            'style' => '');
1043
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1044
        $texto = $this->pSimpleGetValue($this->ide, "xMunIni") . ' - ' . $this->pSimpleGetValue($this->ide, "UFIni");
1045
        $aFont = $this->formatNegrito;
1046
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1047
        //DESTINO DA PRESTAÇÃO
1048
        $x = $oldX + $w + 1;
1049
        $h = 8;
1050
        $w = $w - 1.3;
1051
        $this->pTextBox($x - 0.5, $y, $w + 0.5, $h);
1052
        $texto = 'TÉRMINO DA PRESTAÇÃO';
1053
        $aFont = array(
1054
            'font' => $this->fontePadrao,
1055
            'size' => 8,
1056
            'style' => '');
1057
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1058
        $texto = $this->pSimpleGetValue($this->ide, "xMunFim") . ' - ' . $this->pSimpleGetValue($this->ide, "UFFim");
1059
        $aFont = $this->formatNegrito;
1060
        $this->pTextBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1061
        //#########################################################################
1062
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
1063
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
1064
        //indicar cancelamento
1065
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1066
        if ($cStat == '101' || $cStat == '135' || $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_CANCELADA) {
1067
            //101 Cancelamento
1068
            $x = 10;
1069
            $y = $this->hPrint - 130;
1070
            $h = 25;
1071
            $w = $maxW - (2 * $x);
1072
            $this->pdf->SetTextColor(90, 90, 90);
1073
            $texto = "CTe CANCELADO";
1074
            $aFont = array(
1075
                'font' => $this->fontePadrao,
1076
                'size' => 48,
1077
                'style' => 'B');
1078
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1079
            $this->pdf->SetTextColor(0, 0, 0);
1080
        }
1081
        $cStat = $this->pSimpleGetValue($this->cteProc, "cStat");
1082
        if ($cStat == '110' ||
1083
            $cStat == '301' ||
1084
            $cStat == '302' ||
1085
            $this->situacao_externa == self::NFEPHP_SITUACAO_EXTERNA_DENEGADA
1086
        ) {
1087
            //110 Denegada
1088
            $x = 10;
1089
            $y = $this->hPrint - 130;
1090
            $h = 25;
1091
            $w = $maxW - (2 * $x);
1092
            $this->pdf->SetTextColor(90, 90, 90);
1093
            $texto = "CTe USO DENEGADO";
1094
            $aFont = array(
1095
                'font' => $this->fontePadrao,
1096
                'size' => 48,
1097
                'style' => 'B');
1098
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1099
            $y += $h;
1100
            $h = 5;
1101
            $w = $maxW - (2 * $x);
1102
            $texto = "SEM VALOR FISCAL";
1103
            $aFont = array(
1104
                'font' => $this->fontePadrao,
1105
                'size' => 48,
1106
                'style' => 'B');
1107
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1108
            $this->pdf->SetTextColor(0, 0, 0);
1109
        }
1110
        //indicar sem valor
1111
        if ($tpAmb != 1 && $this->preVisualizar=='0') { // caso não seja uma DA de produção
1112
            $x = 10;
1113
            if ($this->orientacao == 'P') {
1114
                $y = round($this->hPrint * 2 / 3, 0);
1115
            } else {
1116
                $y = round($this->hPrint / 2, 0);
1117
            }
1118
            $h = 5;
1119
            $w = $maxW - (2 * $x);
1120
            $this->pdf->SetTextColor(90, 90, 90);
1121
            $texto = "SEM VALOR FISCAL";
1122
            $aFont = array(
1123
                'font' => $this->fontePadrao,
1124
                'size' => 48,
1125
                'style' => 'B');
1126
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1127
            $aFont = array(
1128
                'font' => $this->fontePadrao,
1129
                'size' => 30,
1130
                'style' => 'B');
1131
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1132
            $this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1133
            $this->pdf->SetTextColor(0, 0, 0);
1134
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
1135
            $h = 5;
1136
            $w = $maxW - (2 * 10);
1137
            $x = 55;
1138
            $y = 240;
1139
            $this->pdf->SetTextColor(255, 100, 100);
1140
            $aFont = array(
1141
                'font' => $this->fontePadrao,
1142
                'size' => 40,
1143
                'style' => 'B');
1144
            $texto = "Pré-visualização";
1145
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1146
            $this->pdf->SetTextColor(255, 100, 100);
1147
            $aFont = array(
1148
                'font' => $this->fontePadrao,
1149
                'size' => 41,
1150
                'style' => 'B');
1151
            $texto = "Sem Validade Jurídica";
1152
            $this->pTextBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1153
            $this->pdf->SetTextColor(90, 90, 90);
1154
            $texto = "SEM VALOR FISCAL";
1155
            $aFont = array(
1156
                'font' => $this->fontePadrao,
1157
                'size' => 48,
1158
                'style' => 'B');
1159
            $this->pTextBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1160
            $this->pdf->SetTextColor(0, 0, 0); // voltar a cor default
1161
        } else {
1162
            $x = 10;
1163
            if ($this->orientacao == 'P') {
1164
                $y = round($this->hPrint * 2 / 3, 0);
1165
            } else {
1166
                $y = round($this->hPrint / 2, 0);
1167
            } //fim orientacao
1168
            $h = 5;
1169
            $w = $maxW - (2 * $x);
1170
            $this->pdf->SetTextColor(90, 90, 90);
1171
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1172
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->zCteDPEC()) {
1173
                //Contingência
1174
                $texto = "DACTE Emitido em Contingência";
1175
                $aFont = array(
1176
                    'font' => $this->fontePadrao,
1177
                    'size' => 48,
1178
                    'style' => 'B');
1179
                $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1180
                $aFont = array(
1181
                    'font' => $this->fontePadrao,
1182
                    'size' => 30,
1183
                    'style' => 'B');
1184
                $texto = "devido à problemas técnicos";
1185
                $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1186
            } else {
1187 View Code Duplication
                if (!isset($this->cteProc)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1188
                    if (!$this->zCteDPEC()) {
1189
                        $texto = "SEM VALOR FISCAL";
1190
                        $aFont = array(
1191
                            'font' => $this->fontePadrao,
1192
                            'size' => 48,
1193
                            'style' => 'B');
1194
                        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1195
                    }
1196
                    $aFont = array(
1197
                        'font' => $this->fontePadrao,
1198
                        'size' => 30,
1199
                        'style' => 'B');
1200
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1201
                    if (!$this->zCteDPEC()) {
1202
                        $this->pTextBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1203
                    } else {
1204
                        $this->pTextBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1205
                    }
1206
                } //fim cteProc
1207 View Code Duplication
                if ($this->tpEmis == 4) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1208
                    //DPEC
1209
                    $x = 10;
1210
                    $y = $this->hPrint - 130;
1211
                    $h = 25;
1212
                    $w = $maxW - (2 * $x);
1213
                    $this->pdf->SetTextColor(200, 200, 200); // 90,90,90 é muito escuro
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1214
                    $texto = "DACTE impresso em contingência -\n"
1215
                        . "DPEC regularmente recebido pela Receita\n"
1216
                        . "Federal do Brasil";
1217
                    $aFont = array(
1218
                        'font' => $this->fontePadrao,
1219
                        'size' => 48,
1220
                        'style' => 'B');
1221
                    $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1222
                    $this->pdf->SetTextColor(0, 0, 0);
1223
                }
1224
            } //fim tpEmis
1225
            $this->pdf->SetTextColor(0, 0, 0);
1226
        }
1227
        return $oldY;
1228
    } //fim zCabecalho
1229
1230
    /**
1231
     * rodapeDACTE
1232
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1233
     *
1234
     * @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...
1235
     * @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...
1236
     */
1237
    protected function zRodape($x, $y)
1238
    {
1239
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1240
        $w = $this->wPrint - 4;
1241
        $aFont = array(
1242
            'font' => $this->fontePadrao,
1243
            'size' => 6,
1244
            'style' => '');
1245
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1246
        $texto = 'Desenvolvido por '.$this->nomeDesenvolvedor . ' - '. $this->siteDesenvolvedor;
1247
        $aFont = array(
1248
            'font' => $this->fontePadrao,
1249
            'size' => 6,
1250
            'style' => '');
1251
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, $this->siteDesenvolvedor);
1252
    } //fim zRodape
1253
1254
    /**
1255
     * zRemetente
1256
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1257
     *
1258
     * @param  number $x Posição horizontal canto esquerdo
1259
     * @param  number $y Posição vertical canto superior
1260
     * @return number Posição vertical final
1261
     */
1262
    protected function zRemetente($x = 0, $y = 0)
1263
    {
1264
        $oldX = $x;
1265
        $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...
1266 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1267
            $maxW = $this->wPrint;
1268
        } else {
1269
            $maxW = $this->wPrint - $this->wCanhoto;
1270
        }
1271
        $w = $maxW * 0.5 + 0.5;
1272
        $h = 19;
1273
        $x1 = $x + 16;
1274
        $texto = 'REMETENTE';
1275
        $aFont = $this->formatPadrao;
1276
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1277
        $aFont = $this->formatNegrito;
1278
        $texto = $this->pSimpleGetValue($this->rem, "xNome");
1279
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1280
        $y += 3;
1281
        $texto = 'ENDEREÇO';
1282
        $aFont = $this->formatPadrao;
1283
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1284
        $aFont = $this->formatNegrito;
1285
        $texto = $this->pSimpleGetValue($this->enderReme, "xLgr") . ',';
1286
        $texto .= $this->pSimpleGetValue($this->enderReme, "nro");
1287
        $texto .= ($this->pSimpleGetValue($this->enderReme, "xCpl") != "") ?
1288
            ' - ' . $this->pSimpleGetValue($this->enderReme, "xCpl") : '';
1289
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1290
        $y += 3;
1291
        $texto = $this->pSimpleGetValue($this->enderReme, "xBairro");
1292
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1293
        $y += 3;
1294
        $texto = 'MUNICÍPIO';
1295
        $aFont = $this->formatPadrao;
1296
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1297
        $texto = $this->pSimpleGetValue($this->enderReme, "xMun") . ' - ';
1298
        $texto .= $this->pSimpleGetValue($this->enderReme, "UF");
1299
        $aFont = $this->formatNegrito;
1300
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1301
        $x = $w - 18;
1302
        $texto = 'CEP';
1303
        $aFont = $this->formatPadrao;
1304
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1305
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReme, "CEP"), "#####-###");
1306
        $aFont = $this->formatNegrito;
1307
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1308
        $x = $oldX;
1309
        $y += 3;
1310
        $texto = 'CNPJ/CPF';
1311
        $aFont = $this->formatPadrao;
1312
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1313
        $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...
1314
        $aFont = $this->formatNegrito;
1315
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1316
        $x = $w - 45;
1317
        $texto = 'INSCRIÇÃO ESTADUAL';
1318
        $aFont = $this->formatPadrao;
1319
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1320
        $texto = $this->pSimpleGetValue($this->rem, "IE");
1321
        $aFont = $this->formatNegrito;
1322
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1323
        $x = $oldX;
1324
        $y += 3;
1325
        $texto = 'PAÍS';
1326
        $aFont = $this->formatPadrao;
1327
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1328
        $texto = $this->pSimpleGetValue($this->rem, "xPais") != "" ?
1329
            $this->pSimpleGetValue($this->rem, "xPais") : 'BRASIL';
1330
        $aFont = $this->formatNegrito;
1331
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1332
        $x = $w - 25;
1333
        $texto = 'FONE';
1334
        $aFont = $this->formatPadrao;
1335
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1336
        $texto = $this->zFormatFone($this->rem);
0 ignored issues
show
Compatibility introduced by
$this->rem of type object<DOMNode> is not a sub-type of object<DOMElement>. It seems like you assume a child class of the class DOMNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
1337
        $aFont = $this->formatNegrito;
1338
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1339
    } //fim da função remetenteDACTE
1340
1341
    /**
1342
     * zDestinatario
1343
     * Monta o campo com os dados do destinatário na DACTE.
1344
     *
1345
     * @param  number $x Posição horizontal canto esquerdo
1346
     * @param  number $y Posição vertical canto superior
1347
     * @return number Posição vertical final
1348
     */
1349
    protected function zDestinatario($x = 0, $y = 0)
1350
    {
1351
        $oldX = $x;
1352
        $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...
1353 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1354
            $maxW = $this->wPrint;
1355
        } else {
1356
            $maxW = $this->wPrint - $this->wCanhoto;
1357
        }
1358
        $w = ($maxW * 0.5) - 0.7;
1359
        $h = 19;
1360
        $x1 = $x + 19;
1361
        $texto = 'DESTINATÁRIO';
1362
        $aFont = $this->formatPadrao;
1363
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1364
        $aFont = $this->formatNegrito;
1365
        $texto = $this->pSimpleGetValue($this->dest, "xNome");
1366
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1367
        $y += 3;
1368
        $texto = 'ENDEREÇO';
1369
        $aFont = $this->formatPadrao;
1370
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1371
        $aFont = $this->formatNegrito;
1372
        $texto = $this->pSimpleGetValue($this->enderDest, "xLgr") . ',';
1373
        $texto .= $this->pSimpleGetValue($this->enderDest, "nro");
1374
        $texto .= $this->pSimpleGetValue($this->enderDest, "xCpl") != "" ?
1375
            ' - ' . $this->pSimpleGetValue($this->enderDest, "xCpl") : '';
1376
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1377
        $y += 3;
1378
        $texto = $this->pSimpleGetValue($this->enderDest, "xBairro");
1379
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1380
        $y += 3;
1381
        $texto = 'MUNICÍPIO';
1382
        $aFont = $this->formatPadrao;
1383
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1384
        $texto = $this->pSimpleGetValue($this->enderDest, "xMun") . ' - ';
1385
        $texto .= $this->pSimpleGetValue($this->enderDest, "UF");
1386
        $aFont = $this->formatNegrito;
1387
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1388
        $x = $w - 19 + $oldX;
1389
        $texto = 'CEP';
1390
        $aFont = $this->formatPadrao;
1391
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1392
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderDest, "CEP"), "#####-###");
1393
        $aFont = $this->formatNegrito;
1394
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1395
        $x = $oldX;
1396
        $y += 3;
1397
        $texto = 'CNPJ/CPF';
1398
        $aFont = $this->formatPadrao;
1399
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1400
        $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...
1401
        $aFont = $this->formatNegrito;
1402
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1403
        $x = $w - 47.5 + $oldX;
1404
        $texto = 'INSCRIÇÃO ESTADUAL';
1405
        $aFont = $this->formatPadrao;
1406
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1407
        $texto = $this->pSimpleGetValue($this->dest, "IE");
1408
        $aFont = $this->formatNegrito;
1409
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1410
        $x = $oldX;
1411
        $y += 3;
1412
        $texto = 'PAÍS';
1413
        $aFont = $this->formatPadrao;
1414
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1415
        $texto = $this->pSimpleGetValue($this->dest, "xPais");
1416
        $aFont = $this->formatNegrito;
1417
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1418
        $x = $w - 27 + $oldX;
1419
        $texto = 'FONE';
1420
        $aFont = $this->formatPadrao;
1421
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1422
        $texto = $this->zFormatFone($this->dest);
0 ignored issues
show
Compatibility introduced by
$this->dest of type object<DOMNode> is not a sub-type of object<DOMElement>. It seems like you assume a child class of the class DOMNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
1423
        $aFont = $this->formatNegrito;
1424
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1425
    } //fim da função destinatarioDACTE
1426
1427
    /**
1428
     * zExpedidor
1429
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1430
     *
1431
     * @param  number $x Posição horizontal canto esquerdo
1432
     * @param  number $y Posição vertical canto superior
1433
     * @return number Posição vertical final
1434
     */
1435
    protected function zExpedidor($x = 0, $y = 0)
1436
    {
1437
        $oldX = $x;
1438
        $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...
1439 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1440
            $maxW = $this->wPrint;
1441
        } else {
1442
            $maxW = $this->wPrint - $this->wCanhoto;
1443
        }
1444
        $w = $maxW * 0.5 + 0.5;
1445
        $h = 19;
1446
        $x1 = $x + 16;
1447
        $texto = 'EXPEDIDOR';
1448
        $aFont = $this->formatPadrao;
1449
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1450
        $aFont = $this->formatNegrito;
1451
        $texto = $this->pSimpleGetValue($this->exped, "xNome");
1452
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1453
        $y += 3;
1454
        $texto = 'ENDEREÇO';
1455
        $aFont = $this->formatPadrao;
1456
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1457
        $aFont = $this->formatNegrito;
1458 View Code Duplication
        if (isset($this->enderExped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1459
            $texto = $this->pSimpleGetValue($this->enderExped, "xLgr") . ', ';
1460
            $texto .= $this->pSimpleGetValue($this->enderExped, "nro");
1461
            $texto .= $this->pSimpleGetValue($this->enderExped, "xCpl") != "" ?
1462
                ' - ' . $this->pSimpleGetValue($this->enderExped, "xCpl") :
1463
                '';
1464
        } else {
1465
            $texto = '';
1466
        }
1467
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1468
        $y += 3;
1469
        $texto = $this->pSimpleGetValue($this->enderExped, "xBairro");
1470
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1471
        $y += 3;
1472
        $texto = 'MUNICÍPIO';
1473
        $aFont = $this->formatPadrao;
1474
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1475 View Code Duplication
        if (isset($this->enderExped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1476
            $texto = $this->pSimpleGetValue($this->enderExped, "xMun") . ' - ';
1477
            $texto .= $this->pSimpleGetValue($this->enderExped, "UF");
1478
        } else {
1479
            $texto = '';
1480
        }
1481
        $aFont = $this->formatNegrito;
1482
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1483
        $x = $w - 18;
1484
        $texto = 'CEP';
1485
        $aFont = $this->formatPadrao;
1486
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1487
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderExped, "CEP"), "#####-###");
1488
        $aFont = $this->formatNegrito;
1489
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1490
        $x = $oldX;
1491
        $y += 3;
1492
        $texto = 'CNPJ/CPF';
1493
        $aFont = $this->formatPadrao;
1494
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1495
        $cpfCnpj = $this->zFormatCNPJCPF($this->exped);
1496
        $aFont = $this->formatNegrito;
1497
        $this->pTextBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1498
        $x = $w - 45;
1499
        $texto = 'INSCRIÇÃO ESTADUAL';
1500
        $aFont = $this->formatPadrao;
1501
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1502
        $texto = $this->pSimpleGetValue($this->exped, "IE");
1503
        $aFont = $this->formatNegrito;
1504
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1505
        $x = $oldX;
1506
        $y += 3;
1507
        $texto = 'PAÍS';
1508
        $aFont = $this->formatPadrao;
1509
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1510
        $texto = $this->pSimpleGetValue($this->exped, "xPais");
1511
        $aFont = $this->formatNegrito;
1512
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1513
        $x = $w - 25;
1514
        $texto = 'FONE';
1515
        $aFont = $this->formatPadrao;
1516
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1517 View Code Duplication
        if (isset($this->exped)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1518
            $texto = $this->zFormatFone($this->exped);
1519
            $aFont = $this->formatNegrito;
1520
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1521
        }
1522
    } //fim da função remetenteDACTE
1523
1524
    /**
1525
     * zRecebedor
1526
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1527
     *
1528
     * @param  number $x Posição horizontal canto esquerdo
1529
     * @param  number $y Posição vertical canto superior
1530
     * @return number Posição vertical final
1531
     */
1532
    protected function zRecebedor($x = 0, $y = 0)
1533
    {
1534
        $oldX = $x;
1535
        $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...
1536 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1537
            $maxW = $this->wPrint;
1538
        } else {
1539
            $maxW = $this->wPrint - $this->wCanhoto;
1540
        }
1541
        $w = ($maxW * 0.5) - 0.7;
1542
        $h = 19;
1543
        $x1 = $x + 19;
1544
        $texto = 'RECEBEDOR';
1545
        $aFont = $this->formatPadrao;
1546
        $this->pTextBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1547
        $aFont = $this->formatNegrito;
1548
        $texto = $this->pSimpleGetValue($this->receb, "xNome");
1549
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1550
        $y += 3;
1551
        $texto = 'ENDEREÇO';
1552
        $aFont = $this->formatPadrao;
1553
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1554
        $aFont = $this->formatNegrito;
1555 View Code Duplication
        if (isset($this->enderReceb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1556
            $texto = $this->pSimpleGetValue($this->enderReceb, "xLgr") . ', ';
1557
            $texto .= $this->pSimpleGetValue($this->enderReceb, "nro");
1558
            $texto .= ($this->pSimpleGetValue($this->enderReceb, "xCpl") != "") ?
1559
                ' - ' . $this->pSimpleGetValue($this->enderReceb, "xCpl") :
1560
                '';
1561
        } else {
1562
            $texto = '';
1563
        }
1564
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1565
        $y += 3;
1566
        $texto = $this->pSimpleGetValue($this->enderReceb, "xBairro");
1567
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1568
        $y += 3;
1569
        $texto = 'MUNICÍPIO';
1570
        $aFont = $this->formatPadrao;
1571
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1572 View Code Duplication
        if (isset($this->enderReceb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1573
            $texto = $this->pSimpleGetValue($this->enderReceb, "xMun") . ' - ';
1574
            $texto .= $this->pSimpleGetValue($this->enderReceb, "UF");
1575
        } else {
1576
            $texto = '';
1577
        }
1578
        $aFont = $this->formatNegrito;
1579
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1580
        $x = $w - 19 + $oldX;
1581
        $texto = 'CEP';
1582
        $aFont = $this->formatPadrao;
1583
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1584
        $texto = $this->pFormat($this->pSimpleGetValue($this->enderReceb, "CEP"), "#####-###");
1585
        $aFont = $this->formatNegrito;
1586
        $this->pTextBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1587
        $x = $oldX;
1588
        $y += 3;
1589
        $texto = 'CNPJ/CPF';
1590
        $aFont = $this->formatPadrao;
1591
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1592
        $texto = $this->zFormatCNPJCPF($this->receb);
1593
        $aFont = $this->formatNegrito;
1594
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1595
        $x = $w - 47 + $oldX;
1596
        $texto = 'INSCRIÇÃO ESTADUAL';
1597
        $aFont = $this->formatPadrao;
1598
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1599
        $texto = $this->pSimpleGetValue($this->receb, "IE");
1600
        $aFont = $this->formatNegrito;
1601
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1602
        $x = $oldX;
1603
        $y += 3;
1604
        $texto = 'PAÍS';
1605
        $aFont = $this->formatPadrao;
1606
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1607
        $texto = $this->pSimpleGetValue($this->receb, "xPais");
1608
        $aFont = $this->formatNegrito;
1609
        $this->pTextBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1610
        $x = $w - 27 + $oldX;
1611
        $texto = 'FONE';
1612
        $aFont = $this->formatPadrao;
1613
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1614 View Code Duplication
        if (isset($this->receb)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1615
            $texto = $this->zFormatFone($this->receb);
1616
            $aFont = $this->formatNegrito;
1617
            $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1618
        }
1619
    } //fim da função recebedorDACTE
1620
1621
    /**
1622
     * zTomador
1623
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1624
     *
1625
     * @param  number $x Posição horizontal canto esquerdo
1626
     * @param  number $y Posição vertical canto superior
1627
     * @return number Posição vertical final
1628
     */
1629
    protected function zTomador($x = 0, $y = 0)
1630
    {
1631
        $oldX = $x;
1632
        $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...
1633 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1634
            $maxW = $this->wPrint;
1635
        } else {
1636
            $maxW = $this->wPrint - $this->wCanhoto;
1637
        }
1638
        $w = $maxW;
1639
        $h = 10;
1640
        $texto = 'TOMADOR DO SERVIÇO';
1641
        $aFont = $this->formatPadrao;
1642
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1643
        $aFont = $this->formatNegrito;
1644
        $texto = $this->pSimpleGetValue($this->toma, "xNome");
1645
        $this->pTextBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1646
        $x = $maxW * 0.60;
1647
        $texto = 'MUNICÍPIO';
1648
        $aFont = $this->formatPadrao;
1649
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1650
        $texto = $this->pSimpleGetValue($this->toma, "xMun");
1651
        $aFont = $this->formatNegrito;
1652
        $this->pTextBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1653
        $x = $maxW * 0.85;
1654
        $texto = 'UF';
1655
        $aFont = $this->formatPadrao;
1656
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1657
        $texto = $this->pSimpleGetValue($this->toma, "UF");
1658
        $aFont = $this->formatNegrito;
1659
        $this->pTextBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1660
        $x = $w - 18;
1661
        $texto = 'CEP';
1662
        $aFont = $this->formatPadrao;
1663
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1664
        $texto = $this->pFormat($this->pSimpleGetValue($this->toma, "CEP"), "#####-###");
1665
        $aFont = $this->formatNegrito;
1666
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1667
        $y += 3;
1668
        $x = $oldX;
1669
        $texto = 'ENDEREÇO';
1670
        $aFont = $this->formatPadrao;
1671
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1672
        $aFont = $this->formatNegrito;
1673
        $texto = $this->pSimpleGetValue($this->toma, "xLgr") . ',';
1674
        $texto .= $this->pSimpleGetValue($this->toma, "nro");
1675
        $texto .= ($this->pSimpleGetValue($this->toma, "xCpl") != "") ?
1676
            ' - ' . $this->pSimpleGetValue($this->toma, "xCpl") : '';
1677
        $texto .= ' - ' . $this->pSimpleGetValue($this->toma, "xBairro");
1678
        $this->pTextBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1679
        $y += 3;
1680
        $texto = 'CNPJ/CPF';
1681
        $aFont = $this->formatPadrao;
1682
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1683
        $texto = $this->zFormatCNPJCPF($this->toma);
1684
        $aFont = $this->formatNegrito;
1685
        $this->pTextBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1686
        $x = $x + 65;
1687
        $texto = 'INSCRIÇÃO ESTADUAL';
1688
        $aFont = $this->formatPadrao;
1689
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1690
        $texto = $this->pSimpleGetValue($this->toma, "IE");
1691
        $aFont = $this->formatNegrito;
1692
        $this->pTextBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1693
        $x = $w * 0.75;
1694
        $texto = 'PAÍS';
1695
        $aFont = $this->formatPadrao;
1696
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1697
        $texto = $this->pSimpleGetValue($this->toma, "xPais") != "" ?
1698
            $this->pSimpleGetValue($this->toma, "xPais") : 'BRASIL';
1699
        $aFont = $this->formatNegrito;
1700
        $this->pTextBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1701
        $x = $w - 27;
1702
        $texto = 'FONE';
1703
        $aFont = $this->formatPadrao;
1704
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1705
        $texto = $this->zFormatFone($this->toma);
1706
        $aFont = $this->formatNegrito;
1707
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1708
    } //fim da função tomadorDACTE
1709
1710
    /**
1711
     * zDescricaoCarga
1712
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1713
     *
1714
     * @param  number $x Posição horizontal canto esquerdo
1715
     * @param  number $y Posição vertical canto superior
1716
     * @return number Posição vertical final
1717
     */
1718
    protected function zDescricaoCarga($x = 0, $y = 0)
1719
    {
1720
        $oldX = $x;
1721
        $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...
1722 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1723
            $maxW = $this->wPrint;
1724
        } else {
1725
            $maxW = $this->wPrint - $this->wCanhoto;
1726
        }
1727
        $w = $maxW;
1728
        $h = 17;
1729
        $texto = 'PRODUTO PREDOMINANTE';
1730
        $aFont = array(
1731
            'font' => $this->fontePadrao,
1732
            'size' => 6,
1733
            'style' => '');
1734
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1735
        $texto = $this->pSimpleGetValue($this->infCarga, "proPred");
1736
        $aFont = $this->formatNegrito;
1737
        $this->pTextBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1738
        $x = $w * 0.56;
1739
        $this->pdf->Line($x, $y, $x, $y + 8);
1740
        $aFont = $this->formatPadrao;
1741
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1742
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1743
        $texto = $this->pSimpleGetValue($this->infCarga, "xOutCat");
1744
        $aFont = $this->formatNegrito;
1745
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1746
        $x = $w * 0.8;
1747
        $this->pdf->Line($x, $y, $x, $y + 8);
1748
        $aFont = $this->formatPadrao;
1749
        $texto = 'VALOR TOTAL DA MERCADORIA';
1750
        $this->pTextBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1751
        $texto = $this->pSimpleGetValue($this->infCarga, "vCarga") == "" ?
1752
            $this->pSimpleGetValue($this->infCarga, "vMerc") : $this->pSimpleGetValue($this->infCarga, "vCarga");
1753
        $texto = number_format($texto, 2, ",", ".");
1754
        $aFont = $this->formatNegrito;
1755
        $this->pTextBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1756
        $y += 8;
1757
        $x = $oldX;
1758
        $this->pdf->Line($x, $y, $w + 1, $y);
1759
        $texto = 'TP MED /UN. MED';
1760
        $aFont = array(
1761
            'font' => $this->fontePadrao,
1762
            'size' => 5,
1763
            'style' => '');
1764
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1765
        $texto = $this->pSimpleGetValue($this->infQ->item(0), "tpMed") . "\r\n";
1766
        $texto .= number_format(
1767
            $this->pSimpleGetValue(
1768
                $this->infQ->item(0),
1769
                "qCarga"
1770
            )
1771
            / $this->zMultiUniPeso(
1772
                $this->pSimpleGetValue(
1773
                    $this->infQ->item(0),
1774
                    "cUnid"
1775
                )
1776
            ),
1777
            3,
1778
            ".",
1779
            ""
1780
        );
1781
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(0), "cUnid"));
1782
        $aFont = array(
1783
            'font' => $this->fontePadrao,
1784
            'size' => 7,
1785
            'style' => 'B');
1786
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1787
        $x = $w * 0.12;
1788
        $this->pdf->Line($x, $y, $x, $y + 9);
1789
        $texto = 'TP MED /UN. MED';
1790
        $aFont = array(
1791
            'font' => $this->fontePadrao,
1792
            'size' => 5,
1793
            'style' => '');
1794
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1795
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "tpMed") . "\r\n";
1796
        $texto .= number_format(
1797
            $this->pSimpleGetValue(
1798
                $this->infQ->item(1),
1799
                "qCarga"
1800
            )
1801
            / $this->zMultiUniPeso(
1802
                $this->pSimpleGetValue($this->infQ->item(1), "cUnid")
1803
            ),
1804
            3,
1805
            ".",
1806
            ""
1807
        );
1808
        $texto = $this->pSimpleGetValue($this->infQ->item(1), "qCarga") == '' ? '' : $texto;
1809
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(1), "cUnid"));
1810
        $aFont = array(
1811
            'font' => $this->fontePadrao,
1812
            'size' => 7,
1813
            'style' => 'B');
1814
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1815
        $x = $w * 0.24;
1816
        $this->pdf->Line($x, $y, $x, $y + 9);
1817
        $texto = 'TP MED /UN. MED';
1818
        $aFont = array(
1819
            'font' => $this->fontePadrao,
1820
            'size' => 5,
1821
            'style' => '');
1822
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1823
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "tpMed") . "\r\n";
1824
        $qCarga = $this->pSimpleGetValue($this->infQ->item(2), "qCarga");
1825
        $texto .= !empty($qCarga) ?
1826
            number_format(
1827
                $qCarga
1828
                / $this->zMultiUniPeso(
1829
                    $this->pSimpleGetValue($this->infQ->item(2), "cUnid")
1830
                ),
1831
                3,
1832
                ".",
1833
                ""
1834
            ) :
1835
            '';
1836
        $texto = $this->pSimpleGetValue($this->infQ->item(2), "qCarga") == '' ? '' : $texto;
1837
        $texto .= ' ' . $this->zUnidade($this->pSimpleGetValue($this->infQ->item(2), "cUnid"));
1838
        $aFont = array(
1839
            'font' => $this->fontePadrao,
1840
            'size' => 7,
1841
            'style' => 'B');
1842
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1843
        $x = $w * 0.36;
1844
        $this->pdf->Line($x, $y, $x, $y + 9);
1845
        $texto = 'CUBAGEM(M3)';
1846
        $aFont = $this->formatPadrao;
1847
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1848
        if ($this->pSimpleGetValue($this->infQ->item(0), "cUnid") == '00') {
1849
            $qCarga = $this->pSimpleGetValue($this->infQ->item(0), "qCarga");
1850
            $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1851
        } else {
1852
            $texto = '';
1853
        }
1854
        $aFont = array(
1855
            'font' => $this->fontePadrao,
1856
            'size' => 7,
1857
            'style' => 'B');
1858
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1859
        $x = $w * 0.45;
1860
        $this->pdf->Line($x, $y, $x, $y + 9);
1861
        $texto = 'QTDE(VOL)';
1862
        $aFont = $this->formatPadrao;
1863
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1864
        $qCarga = $this->pSimpleGetValue($this->infQ->item(3), "qCarga");
1865
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1866
        $aFont = array(
1867
            'font' => $this->fontePadrao,
1868
            'size' => 7,
1869
            'style' => 'B');
1870
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1871
        $x = $w * 0.53;
1872
        $this->pdf->Line($x, $y, $x, $y + 9);
1873
        $texto = 'NOME DA SEGURADORA';
1874
        $aFont = $this->formatPadrao;
1875
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1876
        $texto = $this->pSimpleGetValue($this->seg, "xSeg");
1877
        $aFont = array(
1878
            'font' => $this->fontePadrao,
1879
            'size' => 7,
1880
            'style' => 'B');
1881
        $this->pTextBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1882
        $y += 3;
1883
        $this->pdf->Line($x, $y, $w + 1, $y);
1884
        $texto = 'RESPONSÁVEL';
1885
        $aFont = $this->formatPadrao;
1886
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1887
        $texto = $this->respSeg;
1888
        $aFont = array(
1889
            'font' => $this->fontePadrao,
1890
            'size' => 7,
1891
            'style' => 'B');
1892
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1893
        $x = $w * 0.68;
1894
        $this->pdf->Line($x, $y, $x, $y + 6);
1895
        $texto = 'NÚMERO DA APOLICE';
1896
        $aFont = $this->formatPadrao;
1897
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1898
        $texto = $this->pSimpleGetValue($this->seg, "nApol");
1899
        $aFont = array(
1900
            'font' => $this->fontePadrao,
1901
            'size' => 7,
1902
            'style' => 'B');
1903
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1904
        $x = $w * 0.85;
1905
        $this->pdf->Line($x, $y, $x, $y + 6);
1906
        $texto = 'NÚMERO DA AVERBAÇÃO';
1907
        $aFont = $this->formatPadrao;
1908
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1909
        $texto = $this->pSimpleGetValue($this->seg, "nAver");
1910
        $aFont = array(
1911
            'font' => $this->fontePadrao,
1912
            'size' => 7,
1913
            'style' => 'B');
1914
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1915
    } //fim da função zDescricaoCarga
1916
1917
    /**
1918
     * zCompValorServ
1919
     * Monta o campo com os componentes da prestação de serviços.
1920
     *
1921
     * @param  number $x Posição horizontal canto esquerdo
1922
     * @param  number $y Posição vertical canto superior
1923
     * @return number Posição vertical final
1924
     */
1925
    protected function zCompValorServ($x = 0, $y = 0)
1926
    {
1927
        $oldX = $x;
1928
        $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...
1929 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1930
            $maxW = $this->wPrint;
1931
        } else {
1932
            $maxW = $this->wPrint - $this->wCanhoto;
1933
        }
1934
        $w = $maxW;
1935
        $h = 25;
1936
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1937
        $aFont = $this->formatPadrao;
1938
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1939
        $y += 3.4;
1940
        $this->pdf->Line($x, $y, $w + 1, $y);
1941
        $texto = 'NOME';
1942
        $aFont = $this->formatPadrao;
1943
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1944
        $yIniDados = $y;
1945
        $x = $w * 0.14;
1946
        $texto = 'VALOR';
1947
        $aFont = $this->formatPadrao;
1948
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1949
        $x = $w * 0.28;
1950
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1951
        $texto = 'NOME';
1952
        $aFont = $this->formatPadrao;
1953
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1954
        $x = $w * 0.42;
1955
        $texto = 'VALOR';
1956
        $aFont = $this->formatPadrao;
1957
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1958
        $x = $w * 0.56;
1959
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1960
        $texto = 'NOME';
1961
        $aFont = $this->formatPadrao;
1962
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1963
        $x = $w * 0.70;
1964
        $texto = 'VALOR';
1965
        $aFont = $this->formatPadrao;
1966
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1967
        $x = $w * 0.86;
1968
        $this->pdf->Line($x, $y, $x, $y + 21.5);
1969
        $y += 1;
1970
        $texto = 'VALOR TOTAL DO SERVIÇO';
1971
        $aFont = $this->formatPadrao;
1972
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1973
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
1974
        $aFont = array(
1975
            'font' => $this->fontePadrao,
1976
            'size' => 9,
1977
            'style' => 'B');
1978
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1979
        $y += 10;
1980
        $this->pdf->Line($x, $y, $w + 1, $y);
1981
        $y += 1;
1982
        $texto = 'VALOR A RECEBER';
1983
        $aFont = $this->formatPadrao;
1984
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1985
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vRec"), 2, ",", ".");
1986
        $aFont = array(
1987
            'font' => $this->fontePadrao,
1988
            'size' => 9,
1989
            'style' => 'B');
1990
        $this->pTextBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1991
        $auxX = $oldX;
1992
        $yIniDados += 4;
1993
        foreach ($this->Comp as $k => $d) {
1994
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1995
            $valor = number_format(
1996
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1997
                2,
1998
                ",",
1999
                "."
2000
            );
2001
            if ($auxX > $w * 0.60) {
2002
                $yIniDados = $yIniDados + 4;
2003
                $auxX = $oldX;
2004
            }
2005
            $texto = $nome;
2006
            $aFont = $this->formatPadrao;
2007
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2008
            $auxX += $w * 0.14;
2009
            $texto = $valor;
2010
            $aFont = $this->formatPadrao;
2011
            $this->pTextBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2012
            $auxX += $w * 0.14;
2013
        }
2014
    } //fim da função compValorDACTE
2015
2016
    /**
2017
     * zImpostos
2018
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2019
     *
2020
     * @param  number $x Posição horizontal canto esquerdo
2021
     * @param  number $y Posição vertical canto superior
2022
     * @return number Posição vertical final
2023
     */
2024
    protected function zImpostos($x = 0, $y = 0)
2025
    {
2026
        $oldX = $x;
2027
        $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...
2028 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2029
            $maxW = $this->wPrint;
2030
        } else {
2031
            $maxW = $this->wPrint - $this->wCanhoto;
2032
        }
2033
        $w = $maxW;
2034
        $h = 13;
2035
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
2036
        $aFont = $this->formatPadrao;
2037
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2038
        
2039
        $y += 3.4;
2040
        $this->pdf->Line($x, $y, $w + 1, $y);
2041
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
2042
        $aFont = $this->formatPadrao;
2043
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2044
        
2045
        $x += $w * 0.26;
2046
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2047
        $texto = 'BASE DE CALCULO';
2048
        $aFont = $this->formatPadrao;
2049
        $this->pTextBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
2050
        
2051
        $wCol02=0.18;
2052
        $x += $w * $wCol02;
2053
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2054
        $texto = 'ALÍQ ICMS';
2055
        $aFont = $this->formatPadrao;
2056
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2057
        
2058
        $x += $w * $wCol02;
2059
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2060
        $texto = 'VALOR ICMS';
2061
        $aFont = $this->formatPadrao;
2062
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2063
        
2064
        $x += $w * $wCol02;
2065
        $this->pdf->Line($x, $y, $x, $y + 9.5);
2066
        $texto = '% RED. BC ICMS';
2067
        $aFont = $this->formatPadrao;
2068
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2069
        
2070
        $x = $oldX;
2071
        $y = $y + 4;
2072
        $texto = $this->pSimpleGetValue($this->ICMS, "CST");
2073
        switch ($texto) {
2074
            case '00':
2075
                $texto = "00 - Tributação normal ICMS";
2076
                break;
2077
            case '20':
2078
                $texto = "20 - Tributação com BC reduzida do ICMS";
2079
                break;
2080
            case '40':
2081
                $texto = "40 - ICMS isenção";
2082
                break;
2083
            case '41':
2084
                $texto = "41 - ICMS não tributada";
2085
                break;
2086
            case '51':
2087
                $texto = "51 - ICMS diferido";
2088
                break;
2089
            case '60':
2090
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
2091
                break;
2092
            case '90':
2093
                $texto = "90 - ICMS outros";
2094
                break;
2095
        }
2096
        $texto .= $this->pSimpleGetValue($this->ICMSSN, "indSN");
2097
        $texto = $texto == 1 ? 'Simples Nacional' : $texto;
2098
        $aFont = $this->formatNegrito;
2099
        $this->pTextBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2100
        $x += $w * 0.26;
2101
        
2102
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2103
            number_format($this->pSimpleGetValue($this->ICMS, "vBC"), 2, ",", ".") : '';
2104
        $aFont = $this->formatNegrito;
2105
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2106
        $x += $w * $wCol02;
2107
        
2108
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2109
            number_format($this->pSimpleGetValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
2110
        $aFont = $this->formatNegrito;
2111
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2112
        $x += $w * $wCol02;
2113
        
2114
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2115
            number_format($this->pSimpleGetValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
2116
        $aFont = $this->formatNegrito;
2117
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2118
        $x += $w * $wCol02;
2119
        
2120
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2121
            number_format($this->pSimpleGetValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
2122
        $aFont = $this->formatNegrito;
2123
        $this->pTextBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2124
    } //fim da função compValorDACTE
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
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
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->pSimpleGetValue($this->vPrest, "vRec"), 2, "", "") * 100;
2140
        $ICMS_CST = $this->pSimpleGetValue($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
    } //fim zGeraChaveAdicCont
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 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2180
            $maxW = $this->wPrint;
2181
        } else {
2182
            $maxW = $this->wPrint - $this->wCanhoto;
2183
        }
2184
        $w = $maxW;
2185
        
2186
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2187 View Code Duplication
        if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2188
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2189
            // ou combinação veicular, e por viagem
2190
            $h = $this->lota == 1 ? 35 : 53;
2191
        } elseif ($this->modal == '3') {
2192
            $h = 37.6;
2193
        } else {
2194
            $h = 35;
2195
        }
2196
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2197
        $aFont = $this->formatPadrao;
2198
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2199
        $descr1 = 'TIPO DOC';
2200
        $descr2 = 'CNPJ/CHAVE/OBS';
2201
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2202
        
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
        
2210
        $x += $w * 0.07;
2211
        $texto = $descr2;
2212
        $aFont = $this->formatPadrao;
2213
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2214
        
2215
        $x += $w * 0.28;
2216
        $texto = $descr3;
2217
        $aFont = $this->formatPadrao;
2218
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2219
        
2220
        $x += $w * 0.14;
2221 View Code Duplication
        if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2222
            if ($this->lota == 1) {
2223
                $this->pdf->Line($x, $y, $x, $y + 31.5); // TESTE
2224
            } else {
2225
                $this->pdf->Line($x, $y, $x, $y + 49.5); // TESTE
2226
            }
2227
        } elseif ($this->modal == '3') {
2228
            $this->pdf->Line($x, $y, $x, $y + 34.1);
2229
        } else {
2230
            $this->pdf->Line($x, $y, $x, $y + 21.5);
2231
        }
2232
        $texto = $descr1;
2233
        $aFont = $this->formatPadrao;
2234
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2235
        
2236
        $x += $w * 0.08;
2237
        $texto = $descr2;
2238
        $aFont = $this->formatPadrao;
2239
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2240
        
2241
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2242
        $texto = $descr3;
2243
        $aFont = $this->formatPadrao;
2244
        $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2245
        $auxX = $oldX;
2246
        $yIniDados += 3;
2247
        foreach ($this->infNF as $k => $d) {
2248
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2249
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2250
            $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...
2251
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2252
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2253
            if ($auxX > $w * 0.90) {
2254
                $yIniDados = $yIniDados + 3;
2255
                $auxX = $oldX;
2256
            }
2257
            $texto = $tp;
2258
            $aFont = array(
2259
                'font' => $this->fontePadrao,
2260
                'size' => 8,
2261
                'style' => '');
2262
            //$this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2263
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2264
            //$auxX += $w * 0.09;
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2265
            $auxX += $w * 0.07;
2266
            $texto = $cnpj;
2267
            $aFont = array(
2268
                'font' => $this->fontePadrao,
2269
                'size' => 8,
2270
                'style' => '');
2271
            $this->pTextBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2272
            $auxX += $w * 0.28;
2273
            $texto = $doc;
2274
            $aFont = array(
2275
                'font' => $this->fontePadrao,
2276
                'size' => 8,
2277
                'style' => '');
2278
            $this->pTextBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2279
            $auxX += $w * 0.15;
2280
        }
2281
        
2282
        foreach ($this->infNFe as $k => $d) {
2283
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2284
            $this->arrayNFe[] = $chaveNFe;
2285
        }
2286
        if (count($this->arrayNFe) >15) {
2287
            $this->flagDocOrigContinuacao = 1;
2288
        }
2289
        $qtdeNFe = count($this->arrayNFe);
2290
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2291
        switch ($qtdeNFe){
2292
            case ($qtdeNFe >= 1044):
2293
                $this->totPag = 11;
2294
                break;
2295
            case ($qtdeNFe > 928):
2296
                $this->totPag = 10;
2297
                break;
2298
            case ($qtdeNFe > 812):
2299
                $this->totPag = 9;
2300
                break;
2301
            case ($qtdeNFe > 696):
2302
                $this->totPag = 8;
2303
                break;
2304
            case ($qtdeNFe > 580):
2305
                $this->totPag = 7;
2306
                break;
2307
            case ($qtdeNFe > 464):
2308
                $this->totPag = 6;
2309
                break;
2310
            case ($qtdeNFe > 348):
2311
                $this->totPag = 5;
2312
                break;
2313
            case ($qtdeNFe > 232):
2314
                $this->totPag = 4;
2315
                break;
2316
            case ($qtdeNFe > 116):
2317
                $this->totPag = 3;
2318
                break;
2319
            case ($qtdeNFe > 16):
2320
                $this->totPag = 2;
2321
                break;
2322
            default: $this->totPag = 1;
0 ignored issues
show
Coding Style introduced by
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
2323
        }
2324
        $r = $this->zCabecalho(1, 1, '1', $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...
2325
        $contador = 0;
2326 View Code Duplication
        while ($contador < count($this->arrayNFe)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2327
            if ($contador == 16) {
2328
                break;
2329
            }
2330
            $tp = 'NF-e';
2331
            $chaveNFe = $this->arrayNFe[$contador];
2332
            $numNFe = substr($chaveNFe, 25, 9);
2333
            $serieNFe = substr($chaveNFe, 22, 3);
2334
            $doc = $serieNFe . '/' . $numNFe;
2335
            if ($auxX > $w * 0.90) {
2336
                $yIniDados = $yIniDados + 3.5;
2337
                $auxX = $oldX;
2338
            }
2339
            $texto = $tp;
2340
            $aFont = array(
2341
                'font' => $this->fontePadrao,
2342
                'size' => 7,
2343
                'style' => '');
2344
            $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2345
            $auxX += $w * 0.07;
2346
            $texto = $chaveNFe;
2347
            $aFont = array(
2348
                'font' => $this->fontePadrao,
2349
                'size' => 7,
2350
                'style' => '');
2351
            $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2352
            $auxX += $w * 0.28;
2353
            $texto = $doc;
2354
            $aFont = array(
2355
                'font' => $this->fontePadrao,
2356
                'size' => 7,
2357
                'style' => '');
2358
            $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2359
            $auxX += $w * 0.15;
2360
            $contador++;
2361
        }
2362
        
2363
        foreach ($this->infOutros as $k => $d) {
2364
            $temp = $this->infOutros->item($k);
2365
            $tpDoc = $this->pSimpleGetValue($temp, "tpDoc");
2366
            $descOutros = $this->pSimpleGetValue($temp, "descOutros");
2367
            $nDoc = $this->pSimpleGetValue($temp, "nDoc");
2368
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
0 ignored issues
show
Documentation introduced by
$temp is of type object<DOMNode>, but the function expects a object<NFePHP\DA\Legacy\DOM>.

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...
2369
            $vDocFisc = $this->pSimpleGetValue($temp, "vDocFisc", "Valor: ");
2370
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
0 ignored issues
show
Documentation introduced by
$temp is of type object<DOMNode>, but the function expects a object<NFePHP\DA\Legacy\DOM>.

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...
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;
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
    } //fim da função zDocOrig
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 View Code Duplication
            if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2452
                $maxW = $this->wPrint;
2453
            } else {
2454
                $maxW = $this->wPrint - $this->wCanhoto;
2455
            }
2456
            $w = $maxW;
2457
2458
            //$h = 6; // de sub-titulo
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2459
            //$h = 6 + 3; // de altura do texto (primeira linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2460
            //$h = 9 + 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2461
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2462
            $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9;
2463
            if (count($this->arrayNFe)%2 !=0) {
2464
                $h = $h+3.5;
2465
            } // Caso tenha apenas 1 registro na ultima linha
2466
2467
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2468
            $aFont = $this->formatPadrao;
2469
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2470
            $descr1 = 'TIPO DOC';
2471
            $descr2 = 'CNPJ/CHAVE/OBS';
2472
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2473
2474
            $y += 3.4;
2475
            $this->pdf->Line($x, $y, $w + 1, $y);
2476
            $texto = $descr1;
2477
            $aFont = $this->formatPadrao;
2478
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2479
            $yIniDados = $y;
2480
2481
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2482
            $texto = $descr2;
2483
            $aFont = $this->formatPadrao;
2484
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2485
2486
            $x += $w * 0.28;
2487
            $texto = $descr3;
2488
            $aFont = $this->formatPadrao;
2489
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2490
2491
            $x += $w * 0.14;
2492 View Code Duplication
            if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2493
                if ($this->lota == 1) {
2494
                    $this->pdf->Line($x, $y, $x, $y + 31.5);
2495
                } else {
2496
                    $this->pdf->Line($x, $y, $x, $y + 49.5);
2497
                }
2498
            } elseif ($this->modal == '3') {
2499
                $this->pdf->Line($x, $y, $x, $y + 34.1);
2500
            } else {
2501
                $this->pdf->Line($x, $y, $x, $y + 21.5);
2502
            }
2503
            $texto = $descr1;
2504
            $aFont = $this->formatPadrao;
2505
            $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2506
2507
            $x += $w * 0.08;
2508
            $texto = $descr2;
2509
            $aFont = $this->formatPadrao;
2510
            $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2511
2512
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2513
            $texto = $descr3;
2514
            $aFont = $this->formatPadrao;
2515
            $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2516
            $auxX = $oldX;
2517
            $yIniDados += 3;
2518
2519 View Code Duplication
            while ($contador < (count($this->arrayNFe))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2520
                if($contador%(116*($i-1)) == 0){
2521
//                    $contador++;
2522
                    break;
2523
                }
2524
                $tp = 'NF-e';
2525
                $chaveNFe = $this->arrayNFe[$contador];
2526
                $numNFe = substr($chaveNFe, 25, 9);
2527
                $serieNFe = substr($chaveNFe, 22, 3);
2528
                $doc = $serieNFe . '/' . $numNFe;
2529
                if ($auxX > $w * 0.90) {
2530
                    $yIniDados = $yIniDados + 3.5;
2531
                    $auxX = $oldX;
2532
                }
2533
                $texto = $tp;
2534
                $aFont = array(
2535
                    'font' => $this->fontePadrao,
2536
                    'size' => 7,
2537
                    'style' => '');
2538
                $this->pTextBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2539
                $auxX += $w * 0.07;
2540
                $texto = $chaveNFe;
2541
                $aFont = array(
2542
                    'font' => $this->fontePadrao,
2543
                    'size' => 7,
2544
                    'style' => '');
2545
                $this->pTextBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2546
                $auxX += $w * 0.28;
2547
                $texto = $doc;
2548
                $aFont = array(
2549
                    'font' => $this->fontePadrao,
2550
                    'size' => 7,
2551
                    'style' => '');
2552
                $this->pTextBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2553
                $auxX += $w * 0.15;
2554
                $contador++;
2555
            }
2556
        }
2557
    } //fim da função zDocOrigContinuacao
2558
2559
    /**
2560
     * zDocCompl
2561
     * Monta o campo com os dados do remetente na DACTE.
2562
     *
2563
     * @param number $x Posição horizontal canto esquerdo
2564
     * @param number $y Posição vertical canto superior
2565
     * @return number Posição vertical final
2566
     */
2567
    protected function zDocCompl($x = 0, $y = 0)
2568
    {
2569
        $oldX = $x;
2570
        $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...
2571 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2572
            $maxW = $this->wPrint;
2573
        } else {
2574
            $maxW = $this->wPrint - $this->wCanhoto;
2575
        }
2576
        $w = $maxW;
2577
        $h = 80;
2578
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2579
        $aFont = $this->formatPadrao;
2580
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2581
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2582
        $descr2 = 'VALOR COMPLEMENTADO';
2583
        $y += 3.4;
2584
        $this->pdf->Line($x, $y, $w + 1, $y);
2585
        $texto = $descr1;
2586
        $aFont = $this->formatPadrao;
2587
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2588
        $yIniDados = $y;
2589
        $x += $w * 0.37;
2590
        $texto = $descr2;
2591
        $aFont = $this->formatPadrao;
2592
        $this->pTextBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2593
        $x += $w * 0.13;
2594
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2595
        $texto = $descr1;
2596
        $aFont = $this->formatPadrao;
2597
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2598
        $x += $w * 0.3;
2599
        $texto = $descr2;
2600
        $aFont = $this->formatPadrao;
2601
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2602
        $auxX = $oldX;
2603
        $yIniDados += 4;
2604
        if ($auxX > $w * 0.90) {
2605
            $yIniDados = $yIniDados + 4;
2606
            $auxX = $oldX;
2607
        }
2608
        $texto = $this->chaveCTeRef;
2609
        $aFont = array(
2610
            'font' => $this->fontePadrao,
2611
            'size' => 8,
2612
            'style' => '');
2613
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2614
        $texto = number_format($this->pSimpleGetValue($this->vPrest, "vTPrest"), 2, ",", ".");
2615
        $aFont = array(
2616
            'font' => $this->fontePadrao,
2617
            'size' => 8,
2618
            'style' => '');
2619
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2620
    } //fim da função zDocCompl
2621
2622
    /**
2623
     * zDocAnu
2624
     * Monta o campo com os dados do remetente na DACTE.
2625
     *
2626
     * @param number $x Posição horizontal canto esquerdo
2627
     * @param number $y Posição vertical canto superior
2628
     * @return number Posição vertical final
2629
     */
2630
    protected function zDocAnu($x = 0, $y = 0)
2631
    {
2632
        $oldX = $x;
2633
        $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...
2634 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2635
            $maxW = $this->wPrint;
2636
        } else {
2637
            $maxW = $this->wPrint - $this->wCanhoto;
2638
        }
2639
        $w = $maxW;
2640
        $h = 80;
2641
        $texto = 'DETALHAMENTO DO CT-E ANULADO';
2642
        $aFont = $this->formatPadrao;
2643
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2644
        $descr1 = 'CHAVE DO CT-E ANULADO';
2645
        $descr2 = 'DATA DE EMISSÃO';
2646
        $y += 3.4;
2647
        $this->pdf->Line($x, $y, $w + 1, $y);
2648
        $texto = $descr1;
2649
        $aFont = $this->formatPadrao;
2650
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2651
        $yIniDados = $y;
2652
        $x += $w * 0.37;
2653
        $texto = $descr2;
2654
        $aFont = $this->formatPadrao;
2655
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2656
        $x += $w * 0.13;
2657
        $this->pdf->Line($x, $y, $x, $y + 76.5);
2658
        $texto = $descr1;
2659
        $aFont = $this->formatPadrao;
2660
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2661
        $x += $w * 0.3;
2662
        $texto = $descr2;
2663
        $aFont = $this->formatPadrao;
2664
        $this->pTextBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2665
        $auxX = $oldX;
2666
        $yIniDados += 4;
2667
        if ($auxX > $w * 0.90) {
2668
            $yIniDados = $yIniDados + 4;
2669
            $auxX = $oldX;
2670
        }
2671
        $texto = $this->pSimpleGetValue($this->infCteAnu, "chCte");
2672
        $aFont = array(
2673
            'font' => $this->fontePadrao,
2674
            'size' => 8,
2675
            'style' => '');
2676
        $this->pTextBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2677
        $texto = date('d/m/Y', $this->pConvertTime($this->pSimpleGetValue($this->infCteAnu, "dEmi")));
2678
        $aFont = array(
2679
            'font' => $this->fontePadrao,
2680
            'size' => 8,
2681
            'style' => '');
2682
        $this->pTextBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2683
    } //fim da função zDocCompl
2684
2685
    /**
2686
     * zObs
2687
     * Monta o campo com os dados do remetente na DACTE.
2688
     *
2689
     * @param  number $x Posição horizontal canto esquerdo
2690
     * @param  number $y Posição vertical canto superior
2691
     * @return number Posição vertical final
2692
     */
2693
    protected function zObs($x = 0, $y = 0)
2694
    {
2695
        $oldX = $x;
2696
        $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...
2697 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2698
            $maxW = $this->wPrint;
2699
        } else {
2700
            $maxW = $this->wPrint - $this->wCanhoto;
2701
        }
2702
        $w = $maxW;
2703
        $h = 12;
2704
        $texto = 'OBSERVAÇÕES';
2705
        $aFont = $this->formatPadrao;
2706
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2707
        $y += 3.4;
2708
        $this->pdf->Line($x, $y, $w + 1, $y);
2709
        $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...
2710
        $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...
2711
        $texto = '';
2712
        foreach ($this->compl as $k => $d) {
2713
            $xObs = $this->pSimpleGetValue($this->compl->item($k), "xObs");
2714
            $texto .= "\r\n" . $xObs;
2715
        }
2716
        $texto .= $this->pSimpleGetValue($this->imp, "infAdFisco", "\r\n");
2717
        $texto .= $this->zLocalEntrega();
2718
        $aFont = array(
2719
            'font' => $this->fontePadrao,
2720
            'size' => 7.5,
2721
            'style' => '');
2722
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '', false);
2723
    } //fim da função obsDACTE
2724
2725
    /**
2726
     * zLocalEntrega
2727
     *
2728
     * @return string
2729
     */
2730
    protected function zLocalEntrega()
2731
    {
2732
        $locEntX = $this->dest->getElementsByTagName('locEnt');
2733
        if ($locEntX->length > 0) {
2734
            $locEnt = $locEntX->item(0);
2735
            $output = "Entrega: " . $output = $this->zFormatCNPJCPF($locEnt);
2736
            $output .= $this->pSimpleGetValue($locEnt, "CPF") . " ";
2737
            $output .= $this->pSimpleGetValue($locEnt, "xNome") . " ";
2738
            $output .= $this->pSimpleGetValue($locEnt, "xLgr") . " ";
2739
            $output .= $this->pSimpleGetValue($locEnt, "nro ") . " ";
2740
            $output .= $this->pSimpleGetValue($locEnt, "xCpl") . " ";
2741
            $output .= $this->pSimpleGetValue($locEnt, "xBairro") . " ";
2742
            $output .= $this->pSimpleGetValue($locEnt, "xMun") . " ";
2743
            $output .= $this->pSimpleGetValue($locEnt, "UF") . " ";
2744
            return $output;
2745
        }
2746
        return "";
2747
    } //fim zLocalEntrega
2748
2749
    /**
2750
     * zModalRod
2751
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2752
     *
2753
     * @param  number $x Posição horizontal canto esquerdo
2754
     * @param  number $y Posição vertical canto superior
2755
     * @return number Posição vertical final
2756
     */
2757
    protected function zModalRod($x = 0, $y = 0)
2758
    {
2759
        $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...
2760
        $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...
2761
        $lotacao = '';
2762 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2763
            $maxW = $this->wPrint;
2764
        } else {
2765
            $maxW = $this->wPrint - $this->wCanhoto;
2766
        }
2767
        $w = $maxW;
2768 View Code Duplication
        if ($this->modal == '1') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2769
            $h = $this->lota == 1 ? 12.5 : 3.7;
2770
            $lotacao = $this->lota == 1 ? 'Sim' : 'Não';
2771
        } else {
2772
            $h = 12.5;
2773
        }
2774
        $textolota = $this->lota == 1 ? 'LOTAÇÃO' : 'CARGA FRACIONADA';
2775
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO - ' . $textolota;
2776
        $aFont = $this->formatPadrao;
2777
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2778
        if ($this->lota == 1) {
2779
            $this->pdf->Line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2780
        }
2781
        $y += 3.4;
2782
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA DE CIMA
2783
        $texto = 'RNTRC DA EMPRESA';
2784
        $aFont = $this->formatPadrao;
2785
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2786
        $texto = $this->pSimpleGetValue($this->rodo, "RNTRC");
2787
        $aFont = $this->formatNegrito;
2788
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2789
        $x += $w * 0.23;
2790
        
2791
        //$this->pdf->Line($x, $y, $x, $y + 8.5);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2792
        $this->pdf->Line($x-20, $y, $x-20, $y + 8.5); // LINHA A FRENTE DA RNTRC DA EMPRESA
2793
        $texto = 'CIOT';
2794
        $aFont = $this->formatPadrao;
2795
        $this->pTextBox($x-20, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2796
        $texto = $this->pSimpleGetValue($this->rodo, "CIOT");
2797
        $aFont = $this->formatNegrito;
2798
        $this->pTextBox($x-20, $y + 3, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2799
        
2800
        //$this->pdf->Line($x, $y, $x, $y + 8.5);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2801
        $this->pdf->Line($x+10, $y, $x+10, $y + 8.5); // LINHA A FRENTE DO CIOT
2802
        $texto = 'LOTAÇÃO';
2803
        $aFont = $this->formatPadrao;
2804
        $this->pTextBox($x+10, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2805
        $texto = $lotacao;
2806
        $aFont = $this->formatNegrito;
2807
        $this->pTextBox($x+10, $y + 3, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2808
        
2809
        $x += $w * 0.13;
2810
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2811
        $texto = 'DATA PREVISTA DE ENTREGA';
2812
        $aFont = $this->formatPadrao;
2813
        $this->pTextBox($x, $y, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2814
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rodo, "dPrev"));
2815
        $aFont = $this->formatNegrito;
2816
        $this->pTextBox($x, $y + 3, $w * 0.15, $h, $texto, $aFont, 'T', 'L', 0, '');
2817
        $x += $w * 0.15;
2818
        $this->pdf->Line($x, $y, $x, $y + 8.5);
2819
        $h = 25;
2820
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE ' . "\r\n";
2821
        $texto .= ' À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2822
        $aFont = $this->formatPadrao;
2823
        $this->pTextBox($x, $y + 1, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2824
        if ($this->lota == 1) {
2825
            $y += 10;
2826
            $x = 1;
2827
            $texto = 'IDENTIFICAÇÃO DO CONJUNTO TRANSPORTADOR';
2828
            $aFont = $this->formatPadrao;
2829
            $this->pTextBox($x, $y, $w * 0.465, $h, $texto, $aFont, 'T', 'C', 0, '');
2830
            $this->pdf->Line($x, $y + 3.5, $w * 0.465, $y + 3.5);
2831
            $y += 3.5;
2832
            $texto = 'TIPO';
2833
            $aFont = $this->formatPadrao;
2834
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2835
            $yIniDados = $y;
2836
            if (count($this->veic) >= 0) {
2837
                foreach ($this->veic as $k => $d) {
2838
                    $yIniDados = $yIniDados + 3;
2839
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "tpVeic");
2840
                    switch ($texto) {
2841
                        case '0':
2842
                            $texto = 'Tração';
2843
                            break;
2844
                        case '1':
2845
                            $texto = 'Reboque';
2846
                            break;
2847
                        default:
2848
                            $texto = ' ';
2849
                    }
2850
                    $aFont = array(
2851
                        'font' => $this->fontePadrao,
2852
                        'size' => 6,
2853
                        'style' => 'B');
2854
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2855
                } //fim foreach
2856
            }
2857
            $x += $w * 0.10;
2858
            $texto = 'PLACA';
2859
            $aFont = $this->formatPadrao;
2860
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2861
            $this->pdf->Line($x, $y, $x, $y + 14);
2862
            $yIniDados = $y;
2863 View Code Duplication
            if (count($this->veic) >= 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2864
                foreach ($this->veic as $k => $d) {
2865
                    $yIniDados = $yIniDados + 3;
2866
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "placa");
2867
                    $aFont = array(
2868
                        'font' => $this->fontePadrao,
2869
                        'size' => 6,
2870
                        'style' => 'B');
2871
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2872
                }
2873
            }
2874
            $x += $w * 0.13;
2875
            $texto = 'UF';
2876
            $aFont = $this->formatPadrao;
2877
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2878
            $this->pdf->Line($x, $y, $x, $y + 23);
2879
            $yIniDados = $y;
2880 View Code Duplication
            if (count($this->veic) >= 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2881
                foreach ($this->veic as $k => $d) {
2882
                    $yIniDados = $yIniDados + 3;
2883
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "UF");
2884
                    $aFont = array(
2885
                        'font' => $this->fontePadrao,
2886
                        'size' => 6,
2887
                        'style' => 'B');
2888
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2889
                }
2890
            }
2891
            $x += $w * 0.03;
2892
            $texto = 'RNTRC';
2893
            $aFont = $this->formatPadrao;
2894
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2895
            $this->pdf->Line($x, $y, $x, $y + 14);
2896
            $yIniDados = $y;
2897 View Code Duplication
            if (count($this->veic) >= 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2898
                foreach ($this->veic as $k => $d) {
2899
                    $yIniDados = $yIniDados + 3;
2900
                    $texto = $this->pSimpleGetValue($this->veic->item($k), "RNTRC");
2901
                    $aFont = array(
2902
                        'font' => $this->fontePadrao,
2903
                        'size' => 6,
2904
                        'style' => 'B');
2905
                    $this->pTextBox($x, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2906
                }
2907
            }
2908
            $y += 14;
2909
            $x = 1;
2910
            $texto = 'NOME DO MOTORISTA';
2911
            $aFont = array(
2912
                'font' => $this->fontePadrao,
2913
                'size' => 5,
2914
                'style' => '');
2915
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2916
            $this->pdf->Line($x, $y, $w + 1, $y);
2917
            $texto = !empty($this->moto) ? $this->pSimpleGetValue($this->moto, "xNome") : '';
2918
            $aFont = array(
2919
                'font' => $this->fontePadrao,
2920
                'size' => 7,
2921
                'style' => 'B');
2922
            $this->pTextBox($x, $y + 3, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
2923
            $x += $w * 0.23;
2924
            $texto = 'CPF MOTORISTA';
2925
            $aFont = array(
2926
                'font' => $this->fontePadrao,
2927
                'size' => 5,
2928
                'style' => '');
2929
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2930
            $texto = !empty($this->moto) ? $this->zFormatCNPJCPF($this->moto) : '';            // CPF COM MASCARA
2931
            $aFont = array(
2932
                'font' => $this->fontePadrao,
2933
                'size' => 7,
2934
                'style' => 'B');
2935
            $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2936
            $x += $w * 0.23;
2937
            $texto = 'IDENTIFICAÇÃO DOS LACRES EM TRANSITO';
2938
            $aFont = array(
2939
                'font' => $this->fontePadrao,
2940
                'size' => 5,
2941
                'style' => '');
2942
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2943
            $this->pdf->Line($x, $y, $x, $y - 18.7);
2944
            $this->pdf->Line($x, $y, $x, $y + 9);
2945
            $x = $w * 0.465;
2946
            $y -= 16;
2947
            $texto = 'INFORMAÇÕES REFERENTES AO VALE PEDÁGIO';
2948
            $aFont = $this->formatPadrao;
2949
            $this->pTextBox($x, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2950
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2951
            $y += 4;
2952
            $texto = 'CNPJ FORNECEDOR';
2953
            $aFont = array(
2954
                'font' => $this->fontePadrao,
2955
                'size' => 5,
2956
                'style' => '');
2957
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2958
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2959
            $y += 4;
2960
            $texto = 'NUMERO COMPROVANTE';
2961
            $aFont = array(
2962
                'font' => $this->fontePadrao,
2963
                'size' => 5,
2964
                'style' => '');
2965
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2966
            $this->pdf->Line($x, $y + 4, $w + 1, $y + 4);
2967
            $y += 4;
2968
            $texto = 'CNPJ RESPONSÁVEL';
2969
            $aFont = array(
2970
                'font' => $this->fontePadrao,
2971
                'size' => 5,
2972
                'style' => '');
2973
            $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2974
        }
2975
    } //fim da função zModalRod
2976
2977
    /**
2978
     * zModalAquaviario
2979
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2980
     *
2981
     * @param  number $x Posição horizontal canto esquerdo
2982
     * @param  number $y Posição vertical canto superior
2983
     * @return number Posição vertical final
2984
     */
2985
    protected function zModalAquaviario($x = 0, $y = 0)
2986
    {
2987
        $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...
2988
        $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...
2989 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2990
            $maxW = $this->wPrint;
2991
        } else {
2992
            $maxW = $this->wPrint - $this->wCanhoto;
2993
        }
2994
        $w = $maxW;
2995
        $h = 8.5;
2996
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2997
        $aFont = $this->formatPadrao;
2998
        $this->pTextBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2999
        $y += 3.4;
3000
        $this->pdf->Line($x, $y, $w + 1, $y);
3001
        $texto = 'PORTO DE EMBARQUE';
3002
        $aFont = $this->formatPadrao;
3003
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3004
        $texto = $this->pSimpleGetValue($this->aquav, "prtEmb");
3005
        $aFont = $this->formatNegrito;
3006
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3007
        $x += $w * 0.50;
3008
        $this->pdf->Line($x, $y, $x, $y + 7.7);
3009
        $texto = 'PORTO DE DESTINO';
3010
        $aFont = $this->formatPadrao;
3011
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3012
        $texto = $this->pSimpleGetValue($this->aquav, "prtDest");
3013
        $aFont = $this->formatNegrito;
3014
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
3015
        $y += 8;
3016
        $this->pdf->Line(208, $y, 1, $y);
3017
        $x = 1;
3018
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
3019
        $aFont = $this->formatPadrao;
3020
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3021
        $texto = $this->pSimpleGetValue($this->aquav, "xNavio");
3022
        $aFont = $this->formatNegrito;
3023
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3024
        $x += $w * 0.50;
3025
        $this->pdf->Line($x, $y, $x, $y + 7.7);
3026
        $texto = 'VR DA B. DE CALC. AFRMM';
3027
        $aFont = $this->formatPadrao;
3028
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3029
        $texto = $this->pSimpleGetValue($this->aquav, "vPrest");
3030
        $aFont = $this->formatNegrito;
3031
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
3032
        $x += $w * 0.17;
3033
        $this->pdf->Line($x, $y, $x, $y + 7.7);
3034
        $texto = 'VALOR DO AFRMM';
3035
        $aFont = $this->formatPadrao;
3036
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3037
        $texto = $this->pSimpleGetValue($this->aquav, "vAFRMM");
3038
        $aFont = $this->formatNegrito;
3039
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
3040
        $x += $w * 0.12;
3041
        $this->pdf->Line($x, $y, $x, $y + 7.7);
3042
        $texto = 'TIPO DE NAVEGAÇÃO';
3043
        $aFont = $this->formatPadrao;
3044
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3045
        $texto = $this->pSimpleGetValue($this->aquav, "tpNav");
3046
        switch ($texto) {
3047
            case '0':
3048
                $texto = 'INTERIOR';
3049
                break;
3050
            case '1':
3051
                $texto = 'CABOTAGEM';
3052
                break;
3053
        }
3054
        $aFont = $this->formatNegrito;
3055
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
3056
        $x += $w * 0.14;
3057
        $this->pdf->Line($x, $y, $x, $y + 7.7);
3058
        $texto = 'DIREÇÃO';
3059
        $aFont = $this->formatPadrao;
3060
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3061
        $texto = $this->pSimpleGetValue($this->aquav, "direc");
3062
        switch ($texto) {
3063
            case 'N':
3064
                $texto = 'NORTE';
3065
                break;
3066
            case 'L':
3067
                $texto = 'LESTE';
3068
                break;
3069
            case 'S':
3070
                $texto = 'SUL';
3071
                break;
3072
            case 'O':
3073
                $texto = 'OESTE';
3074
                break;
3075
        }
3076
        $aFont = $this->formatNegrito;
3077
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
3078
        $y += 8;
3079
        $this->pdf->Line(208, $y, 1, $y);
3080
        $x = 1;
3081
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
3082
        $aFont = $this->formatPadrao;
3083
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3084
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
3085
            $texto = $this->infNF
3086
                ->item(0)
3087
                ->getElementsByTagName('infUnidCarga')
3088
                ->item(0)
3089
                ->getElementsByTagName('idUnidCarga')
3090
                ->item(0)->nodeValue;
3091
        } elseif ($this->infNFe->item(0) !== null
3092
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
3093
        ) {
3094
            $texto = $this->infNFe
3095
                ->item(0)
3096
                ->getElementsByTagName('infUnidCarga')
3097
                ->item(0)
3098
                ->getElementsByTagName('idUnidCarga')
3099
                ->item(0)
3100
                ->nodeValue;
3101
        } elseif ($this->infOutros->item(0) !== null
3102
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
3103
        ) {
3104
            $texto = $this->infOutros
3105
                ->item(0)
3106
                ->getElementsByTagName('infUnidCarga')
3107
                ->item(0)
3108
                ->getElementsByTagName('idUnidCarga')
3109
                ->item(0)
3110
                ->nodeValue;
3111
        } else {
3112
            $texto = '';
3113
        }
3114
        $aFont = $this->formatNegrito;
3115
        $this->pTextBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3116
        $x += $w * 0.50;
3117
        $this->pdf->Line($x, $y, $x, $y + 7.7);
3118
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
3119
        $aFont = $this->formatPadrao;
3120
        $this->pTextBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
3121
        $texto = '';
3122
        if ($this->pSimpleGetValue($this->aquav, "balsa") !== '') {
3123
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
3124
                if ($k == 0) {
3125
                    $texto = $this->aquav
3126
                        ->getElementsByTagName('balsa')
3127
                        ->item($k)
3128
                        ->getElementsByTagName('xBalsa')
3129
                        ->item(0)
3130
                        ->nodeValue;
3131
                } else {
3132
                    $texto = $texto
3133
                        . ' / '
3134
                        . $this->aquav
3135
                            ->getElementsByTagName('balsa')
3136
                            ->item($k)
3137
                            ->getElementsByTagName('xBalsa')
3138
                            ->item(0)
3139
                            ->nodeValue;
3140
                }
3141
            }
3142
        }
3143
        $aFont = $this->formatNegrito;
3144
        $this->pTextBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
3145
    } //fim da função zModalRod
3146
3147
    /**
3148
     * zModalFerr
3149
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
3150
     *
3151
     * @param  number $x Posição horizontal canto esquerdo
3152
     * @param  number $y Posição vertical canto superior
3153
     * @return number Posição vertical final
3154
     */
3155
    protected function zModalFerr($x = 0, $y = 0)
3156
    {
3157
        $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...
3158
        $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...
3159 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3160
            $maxW = $this->wPrint;
3161
        } else {
3162
            $maxW = $this->wPrint - $this->wCanhoto;
3163
        }
3164
        $w = $maxW;
3165
        $h = 19.6;
3166
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
3167
        $aFont = $this->formatPadrao;
3168
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3169
        $y += 3.4;
3170
        $this->pdf->Line($x, $y, $w + 1, $y);
3171
        $texto = 'DCL';
3172
        $aFont = array(
3173
            'font' => $this->fontePadrao,
3174
            'size' => 7,
3175
            'style' => 'B');
3176
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
3177
        $this->pdf->Line($x + 49.6, $y, $x + 49.6, $y + 3.5);
3178
        $texto = 'VAGÕES';
3179
        $aFont = array(
3180
            'font' => $this->fontePadrao,
3181
            'size' => 7,
3182
            'style' => 'B');
3183
        $this->pTextBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
3184
        $y += 3.4;
3185
        $this->pdf->Line($x, $y, $w + 1, $y);
3186
        // DCL
3187
        $texto = 'ID TREM';
3188
        $aFont = array(
3189
            'font' => $this->fontePadrao,
3190
            'size' => 6,
3191
            'style' => '');
3192
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3193
        $texto = $this->pSimpleGetValue($this->ferrov, "idTrem");
3194
        $aFont = array(
3195
            'font' => $this->fontePadrao,
3196
            'size' => 6,
3197
            'style' => 'B');
3198
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3199
        $x += $w * 0.06;
3200
        $y1 = $y + 12.5;
3201
        $this->pdf->Line($x, $y, $x, $y1);
3202
        $texto = 'NUM';
3203
        $aFont = array(
3204
            'font' => $this->fontePadrao,
3205
            'size' => 6,
3206
            'style' => '');
3207
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3208
        $texto = $this->pSimpleGetValue($this->rem, "nDoc");
3209
        $aFont = array(
3210
            'font' => $this->fontePadrao,
3211
            'size' => 6,
3212
            'style' => 'B');
3213
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3214
        $x += $w * 0.06;
3215
        $this->pdf->Line($x, $y, $x, $y1);
3216
        $texto = 'SÉRIE';
3217
        $aFont = array(
3218
            'font' => $this->fontePadrao,
3219
            'size' => 6,
3220
            'style' => '');
3221
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3222
        $texto = $this->pSimpleGetValue($this->rem, "serie");
3223
        $aFont = array(
3224
            'font' => $this->fontePadrao,
3225
            'size' => 6,
3226
            'style' => 'B');
3227
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3228
        $x += $w * 0.06;
3229
        $this->pdf->Line($x, $y, $x, $y1);
3230
        $texto = 'EMISSÃO';
3231
        $aFont = array(
3232
            'font' => $this->fontePadrao,
3233
            'size' => 6,
3234
            'style' => '');
3235
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3236
        $texto = $this->pYmd2dmy($this->pSimpleGetValue($this->rem, "dEmi"));
3237
        $aFont = array(
3238
            'font' => $this->fontePadrao,
3239
            'size' => 6,
3240
            'style' => 'B');
3241
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3242
        // VAGOES
3243
        $x += $w * 0.06;
3244
        $this->pdf->Line($x, $y, $x, $y1);
3245
        $texto = 'NUM';
3246
        $aFont = array(
3247
            'font' => $this->fontePadrao,
3248
            'size' => 6,
3249
            'style' => '');
3250
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3251
        $texto = $this->pSimpleGetValue($this->ferrov, "nVag");
3252
        $aFont = array(
3253
            'font' => $this->fontePadrao,
3254
            'size' => 6,
3255
            'style' => 'B');
3256
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3257
        $x += $w * 0.06;
3258
        $this->pdf->Line($x, $y, $x, $y1);
3259
        $texto = 'TIPO';
3260
        $aFont = array(
3261
            'font' => $this->fontePadrao,
3262
            'size' => 6,
3263
            'style' => '');
3264
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3265
        $texto = $this->pSimpleGetValue($this->ferrov, "tpVag");
3266
        $aFont = array(
3267
            'font' => $this->fontePadrao,
3268
            'size' => 6,
3269
            'style' => 'B');
3270
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3271
        $x += $w * 0.06;
3272
        $this->pdf->Line($x, $y, $x, $y1);
3273
        $texto = 'CAPACIDADE';
3274
        $aFont = array(
3275
            'font' => $this->fontePadrao,
3276
            'size' => 6,
3277
            'style' => '');
3278
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3279
        $texto = $this->pSimpleGetValue($this->ferrov, "cap");
3280
        $aFont = array(
3281
            'font' => $this->fontePadrao,
3282
            'size' => 6,
3283
            'style' => 'B');
3284
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3285
        $x += $w * 0.08;
3286
        $this->pdf->Line($x, $y, $x, $y1);
3287
        $texto = 'PESO REAL/TON';
3288
        $aFont = array(
3289
            'font' => $this->fontePadrao,
3290
            'size' => 6,
3291
            'style' => '');
3292
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3293
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoR");
3294
        $aFont = array(
3295
            'font' => $this->fontePadrao,
3296
            'size' => 6,
3297
            'style' => 'B');
3298
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3299
        $x += $w * 0.09;
3300
        $this->pdf->Line($x, $y, $x, $y1);
3301
        $texto = 'PESO BRUTO/TON';
3302
        $aFont = array(
3303
            'font' => $this->fontePadrao,
3304
            'size' => 6,
3305
            'style' => '');
3306
        $this->pTextBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3307
        $texto = $this->pSimpleGetValue($this->ferrov, "pesoBC");
3308
        $aFont = array(
3309
            'font' => $this->fontePadrao,
3310
            'size' => 6,
3311
            'style' => 'B');
3312
        $this->pTextBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3313
        $x += $w * 0.1;
3314
        $this->pdf->Line($x, $y, $x, $y1);
3315
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3316
        $aFont = array(
3317
            'font' => $this->fontePadrao,
3318
            'size' => 6,
3319
            'style' => '');
3320
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3321
        $texto = $this->pSimpleGetValue($this->ferrov, "nCont");
3322
        $aFont = array(
3323
            'font' => $this->fontePadrao,
3324
            'size' => 6,
3325
            'style' => 'B');
3326
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3327
        // FLUXO
3328
        $x = 1;
3329
        $y += 12.9;
3330
        $h1 = $h * 0.5 + 0.27;
3331
        $wa = round($w * 0.103) + 0.5;
3332
        $texto = 'FLUXO FERROVIARIO';
3333
        $aFont = $this->formatPadrao;
3334
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3335
        $texto = $this->pSimpleGetValue($this->ferrov, "fluxo");
3336
        $aFont = array(
3337
            'font' => $this->fontePadrao,
3338
            'size' => 7,
3339
            'style' => 'B');
3340
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3341
        $y += 10;
3342
        $texto = 'TIPO DE TRÁFEGO';
3343
        $aFont = $this->formatPadrao;
3344
        $this->pTextBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3345
        $texto = $this->zConvertUnidTrafego($this->pSimpleGetValue($this->ferrov, "tpTraf"));
3346
        $aFont = array(
3347
            'font' => $this->fontePadrao,
3348
            'size' => 7,
3349
            'style' => 'B');
3350
        $this->pTextBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3351
        // Novo Box Relativo a Modal Ferroviário
3352
        $x = 22.5;
3353
        $y += -10.2;
3354
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3355
        $aFont = $this->formatPadrao;
3356
        $this->pTextBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3357
        $y += 3.4;
3358
        $this->pdf->Line($x, $y, $w + 1, $y);
3359
        $w = $w * 0.2;
3360
        $h = $h * 1.04;
3361
        $texto = 'CÓDIGO INTERNO';
3362
        $aFont = array(
3363
            'font' => $this->fontePadrao,
3364
            'size' => 6,
3365
            'style' => '');
3366
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3367
        $texto = $this->pSimpleGetValue($this->ferrov, "cInt");
3368
        $aFont = array(
3369
            'font' => $this->fontePadrao,
3370
            'size' => 6,
3371
            'style' => 'B');
3372
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3373
        $texto = 'CNPJ';
3374
        $aFont = array(
3375
            'font' => $this->fontePadrao,
3376
            'size' => 6,
3377
            'style' => '');
3378
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3379
        $texto = $this->pSimpleGetValue($this->ferrov, "CNPJ");
3380
        $aFont = array(
3381
            'font' => $this->fontePadrao,
3382
            'size' => 6,
3383
            'style' => 'B');
3384
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3385
        $x += 50;
3386
        $texto = 'NOME';
3387
        $aFont = array(
3388
            'font' => $this->fontePadrao,
3389
            'size' => 6,
3390
            'style' => '');
3391
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3392
        $texto = $this->pSimpleGetValue($this->ferrov, "xNome");
3393
        $aFont = array(
3394
            'font' => $this->fontePadrao,
3395
            'size' => 6,
3396
            'style' => 'B');
3397
        $this->pTextBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3398
        $texto = 'INSCRICAO ESTADUAL';
3399
        $aFont = array(
3400
            'font' => $this->fontePadrao,
3401
            'size' => 6,
3402
            'style' => '');
3403
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3404
        $texto = $this->pSimpleGetValue($this->ferrov, "IE");
3405
        $aFont = array(
3406
            'font' => $this->fontePadrao,
3407
            'size' => 6,
3408
            'style' => 'B');
3409
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3410
        $x += 50;
3411
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3412
        $aFont = array(
3413
            'font' => $this->fontePadrao,
3414
            'size' => 6,
3415
            'style' => '');
3416
        $this->pTextBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3417
        $texto = '';
3418
        $aFont = array(
3419
            'font' => $this->fontePadrao,
3420
            'size' => 6,
3421
            'style' => 'B');
3422
        $this->pTextBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3423
    } //fim da função zModalFerr
3424
3425
    /**
3426
     * zCanhoto
3427
     * Monta o campo com os dados do remetente na DACTE.
3428
     *
3429
     * @param  number $x Posição horizontal canto esquerdo
3430
     * @param  number $y Posição vertical canto superior
3431
     * @return number Posição vertical final
3432
     */
3433
    protected function zCanhoto($x = 0, $y = 0)
3434
    {
3435
        $this->zhDashedLine($x, $y+2, $this->wPrint, 0.1, 80);
3436
        $y = $y + 2;
3437
        $oldX = $x;
3438
        $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...
3439
        if ($this->orientacao == 'P') {
3440
            $maxW = $this->wPrint;
3441
        } else {
3442
            $maxW = $this->wPrint - $this->wCanhoto;
3443
        }
3444
        $w = $maxW - 1;
3445
        $h = 20;
3446
        $y = $y + 1;
3447
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3448
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3449
        $aFont = $this->formatPadrao;
3450
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3451
        $y += 3.4;
3452
        $this->pdf->Line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3453
        
3454
        $texto = 'NOME';
3455
        $aFont = array(
3456
            'font' => $this->fontePadrao,
3457
            'size' => 6,
3458
            'style' => '');
3459
        $this->pTextBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3460
        $x += $w * 0.25;
3461
        
3462
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3463
        
3464
        $texto = 'ASSINATURA / CARIMBO';
3465
        $aFont = array(
3466
            'font' => $this->fontePadrao,
3467
            'size' => 6,
3468
            'style' => '');
3469
        $this->pTextBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3470
        $x += $w * 0.25;
3471
        
3472
        $this->pdf->Line($x, $y, $x, $y + 16.5);
3473
        
3474
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
3475
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3476
        $aFont = array(
3477
            'font' => $this->fontePadrao,
3478
            'size' => 6,
3479
            'style' => '');
3480
        $this->pTextBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3481
        $x = $oldX;
3482
        $y = $y + 5;
3483
        
3484
        $this->pdf->Line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3485
        
3486
        $texto = 'RG';
3487
        $aFont = array(
3488
            'font' => $this->fontePadrao,
3489
            'size' => 6,
3490
            'style' => '');
3491
        $this->pTextBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3492
        $x += $w * 0.85;
3493
        
3494
        $this->pdf->Line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3495
        
3496
        $texto = "CT-E";
3497
        $aFont = $this->formatNegrito;
3498
        $this->pTextBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3499
        $texto = "\r\n Nº. DOCUMENTO  " . $this->pSimpleGetValue($this->ide, "nCT") . " \n";
3500
        $texto .= "\r\n SÉRIE  " . $this->pSimpleGetValue($this->ide, "serie");
3501
        $aFont = array(
3502
            'font' => $this->fontePadrao,
3503
            'size' => 6,
3504
            'style' => '');
3505
        $this->pTextBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3506
        $x = $oldX;
0 ignored issues
show
Unused Code introduced by
$x is not used, you could remove the assignment.

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

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

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

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

Loading history...
3507
        //$this->zhDashedLine($x, $y + 7.5, $this->wPrint, 0.1, 80);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3508
    } //fim da função canhotoDACTE
3509
3510
    /**
3511
     * zDadosAdic
3512
     * Coloca o grupo de dados adicionais da DACTE.
3513
     *
3514
     * @param  number $x Posição horizontal canto esquerdo
3515
     * @param  number $y Posição vertical canto superior
3516
     * @param  number $h altura do campo
3517
     * @return number Posição vertical final
3518
     */
3519
    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...
3520
    {
3521
        $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...
3522
        //###########################################################################
3523
        //DADOS ADICIONAIS DACTE
3524
        if ($this->orientacao == 'P') {
3525
            $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...
3526
        } else {
3527
            $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...
3528
        }
3529
        //INFORMAÇÕES COMPLEMENTARES
3530
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3531
        $y += 3;
3532
        $w = $this->wAdic;
3533
        $h = 8; //mudar
3534
        $aFont = array(
3535
            'font' => $this->fontePadrao,
3536
            'size' => 6,
3537
            'style' => '');
3538
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3539
        $this->pdf->Line($x, $y + 3, $w * 1.385, $y + 3);
3540
        //o texto com os dados adicionais foi obtido na função xxxxxx
3541
        //e carregado em uma propriedade privada da classe
3542
        //$this->wAdic com a largura do campo
3543
        //$this->textoAdic com o texto completo do campo
3544
        $y += 1;
3545
        $aFont = $this->formatPadrao;
3546
        $this->pTextBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3547
        //RESERVADO AO FISCO
3548
        $texto = "RESERVADO AO FISCO";
3549
        $x += $w;
3550
        $y -= 1;
3551 View Code Duplication
        if ($this->orientacao == 'P') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3552
            $w = $this->wPrint - $w;
3553
        } else {
3554
            $w = $this->wPrint - $w - $this->wCanhoto;
3555
        }
3556
        $aFont = array(
3557
            'font' => $this->fontePadrao,
3558
            'size' => 6,
3559
            'style' => '');
3560
        $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3561
        //inserir texto informando caso de contingência
3562
        //1 – Normal – emissão normal;
3563
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3564
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3565
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3566
        //Emissão em Contingência – DPEC;
3567
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3568
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3569
        $xJust = $this->pSimpleGetValue($this->ide, 'xJust', 'Justificativa: ');
3570
        $dhCont = $this->pSimpleGetValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3571
        $texto = '';
3572
        switch ($this->tpEmis) {
3573
            case 2:
3574
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3575
                break;
3576
            case 3:
3577
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3578
                break;
3579
            case 4:
3580
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3581
                break;
3582
            case 5:
3583
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3584
                break;
3585
        }
3586
        $y += 2;
3587
        $aFont = $this->formatPadrao;
3588
        $this->pTextBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3589
        return $y + $h;
3590
    } //fim zDadosAdic
3591
3592
    /**
3593
     * zhDashedLine
3594
     * Desenha uma linha horizontal tracejada com o FPDF
3595
     *
3596
     * @param  number $x Posição horizontal inicial, em mm
3597
     * @param  number $y Posição vertical inicial, em mm
3598
     * @param  number $w Comprimento da linha, em mm
3599
     * @param  number $h Espessura da linha, em mm
3600
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3601
     * @return none
3602
     */
3603
    protected function zhDashedLine($x, $y, $w, $h, $n)
3604
    {
3605
        $this->pdf->SetLineWidth($h);
3606
        $wDash = ($w / $n) / 2; // comprimento dos traços
3607 View Code Duplication
        for ($i = $x; $i <= $x + $w; $i += $wDash + $wDash) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3608
            for ($j = $i; $j <= ($i + $wDash); $j++) {
3609
                if ($j <= ($x + $w - 1)) {
3610
                    $this->pdf->Line($j, $y, $j + 1, $y);
3611
                }
3612
            }
3613
        }
3614
    } //fim função hDashedLine
3615
3616
    /**
3617
     * zhDashedVerticalLine
3618
     * Desenha uma linha vertical tracejada com o FPDF
3619
     *
3620
     * @param  number $x Posição horizontal inicial, em mm
3621
     * @param  number $y Posição vertical inicial, em mm
3622
     * @param  number $w Comprimento da linha, em mm
3623
     * @param  number $yfinal Espessura da linha, em mm
3624
     * @param  number $n Numero de traços na seção da linha com o comprimento $w
3625
     * @return none
3626
     */
3627
    protected function zhDashedVerticalLine($x, $y, $w, $yfinal, $n)
3628
    {
3629
        $this->pdf->SetLineWidth($w);
3630
        /* Organizando valores */
3631
        if ($y > $yfinal) {
3632
            $aux = $yfinal;
3633
            $yfinal = $y;
3634
            $y = $aux;
3635
        }
3636
        while ($y < $yfinal && $n > 0) {
3637
            $this->pdf->Line($x, $y, $x, $y + 1);
3638
            $y += 3;
3639
            $n--;
3640
        }
3641
    } //fim função hDashedVerticalLine
3642
3643
    /**
3644
     * zFormatCNPJCPF
3645
     * Formata campo CnpjCpf contida na CTe
3646
     *
3647
     * @param  string $field campo cnpjCpf da CT-e
3648
     * @return string
3649
     */
3650
    protected function zFormatCNPJCPF($field)
3651
    {
3652
        if (!isset($field)) {
3653
            return '';
3654
        }
3655
        $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...
3656
            $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...
3657
        if ($cnpj != "" && $cnpj != "00000000000000") {
3658
            $cnpj = $this->pFormat($cnpj, '###.###.###/####-##');
3659
        } else {
3660
            $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...
3661
                $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...
3662
        }
3663
        return $cnpj;
3664
    } //fim formatCNPJCPF
3665
3666
    /**
3667
     * zFormatFone
3668
     * Formata campo fone contida na CTe
3669
     *
3670
     * @param  \DOMElement $field campo fone da CT-e
3671
     * @return string
3672
     */
3673
    protected function zFormatFone($field)
3674
    {
3675
        $fone = '';
3676
        if (is_null($field)) {
3677
            return $fone;
3678
        }
3679
        if ($field->getElementsByTagName("fone")->length > 0) {
3680
            $fone = $field->getElementsByTagName("fone")->item(0)->nodeValue;
3681
        }
3682
3683
        $foneLen = strlen($fone);
3684 View Code Duplication
        if ($foneLen > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
3685
            $fone2 = substr($fone, 0, $foneLen - 4);
3686
            $fone1 = substr($fone, 0, $foneLen - 8);
3687
            $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3688
        }
3689
3690
        return $fone;
3691
    } //fim formatFone
3692
3693
    /**
3694
     * zUnidade
3695
     * Converte a imformação de peso contida na CTe
3696
     *
3697
     * @param  string $c unidade de trafego extraida da CTe
3698
     * @return string
3699
     */
3700
    protected function zUnidade($c = '')
3701
    {
3702
        switch ($c) {
3703
            case '00':
3704
                $r = 'M3';
3705
                break;
3706
            case '01':
3707
                $r = 'KG';
3708
                break;
3709
            case '02':
3710
                $r = 'TON';
3711
                break;
3712
            case '03':
3713
                $r = 'UN';
3714
                break;
3715
            case '04':
3716
                $r = 'LT';
3717
                break;
3718
            case '05':
3719
                $r = 'MMBTU';
3720
                break;
3721
            default:
3722
                $r = '';
3723
        }
3724
        return $r;
3725
    } //fim unidade
3726
3727
    /**
3728
     * zConvertUnidTrafego
3729
     * Converte a imformação de peso contida na CTe
3730
     *
3731
     * @param  string $U Informação de trafego extraida da CTe
3732
     * @return string
3733
     */
3734
    protected function zConvertUnidTrafego($U = '')
3735
    {
3736
        if ($U) {
3737
            switch ($U) {
3738
                case '0':
3739
                    $stringU = 'Próprio';
3740
                    break;
3741
                case '1':
3742
                    $stringU = 'Mútuo';
3743
                    break;
3744
                case '2':
3745
                    $stringU = 'Rodoferroviário';
3746
                    break;
3747
                case '3':
3748
                    $stringU = 'Rodoviário';
3749
                    break;
3750
            }
3751
            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...
3752
        }
3753
    } //fim da função zConvertUnidTrafego
3754
3755
    /**
3756
     * zMultiUniPeso
3757
     * Fornece a imformação multiplicação de peso contida na CTe
3758
     *
3759
     * @param  interger $U Informação de peso extraida da CTe
3760
     * @return interger
3761
     */
3762
    protected function zMultiUniPeso($U = '')
3763
    {
3764
        if ($U === "01") {
3765
            // tonelada
3766
            //return 1000;
3767
            return 1;
3768
        }
3769
        return 1; // M3, KG, Unidade, litros, mmbtu
3770
    } //fim da função zMultiUniPeso
3771
}
3772