Passed
Push — master ( 74a043...e78e20 )
by Roberto
02:57 queued 11s
created

DacteOS::creditsIntegratorFooter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2019 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Com\Tecnick\Barcode\Barcode;
19
use Exception;
20
use NFePHP\DA\Legacy\Dom;
21
use NFePHP\DA\Legacy\Pdf;
22
use NFePHP\DA\Legacy\Common;
23
24
class DacteOS extends Common
25
{
26
    const NFEPHP_SITUACAO_EXTERNA_CANCELADA = 1;
27
    const NFEPHP_SITUACAO_EXTERNA_DENEGADA = 2;
28
    const SIT_DPEC = 3;
29
30
    protected $logoAlign = 'C';
31
    protected $yDados = 0;
32
    protected $situacao_externa = 0;
33
    protected $numero_registro_dpec = '';
34
    protected $pdf;
35
    protected $xml;
36
    protected $logomarca = '';
37
    protected $errMsg = '';
38
    protected $errStatus = false;
39
    protected $orientacao = 'P';
40
    protected $papel = 'A4';
41
    protected $destino = 'I';
42
    protected $pdfDir = '';
43
    protected $fontePadrao = 'Times';
44
    protected $version = '1.3.0';
45
    protected $wPrint;
46
    protected $hPrint;
47
    protected $dom;
48
    protected $infCte;
49
    protected $infPercurso;
50
    protected $infCteComp;
51
    protected $chaveCTeRef;
52
    protected $tpCTe;
53
    protected $ide;
54
    protected $emit;
55
    protected $enderEmit;
56
    protected $infCarga;
57
    protected $infQ;
58
    protected $seg;
59
    protected $modal;
60
    protected $rodo;
61
    protected $moto;
62
    protected $veic;
63
    protected $ferrov;
64
    protected $Comp;
65
    protected $infNF;
66
    protected $infNFe;
67
    protected $compl;
68
    protected $ICMS;
69
    protected $imp;
70
    protected $toma4;
71
    protected $toma03;
72
    protected $tpEmis;
73
    protected $tpImp;
74
    protected $tpAmb;
75
    protected $vPrest;
76
    protected $infServico;
77
    protected $wAdic = 150;
78
    protected $textoAdic = '';
79
    protected $debugMode = 2;
80
    protected $formatPadrao;
81
    protected $formatNegrito;
82
    protected $aquav;
83
    protected $preVisualizar;
84
    protected $flagDocOrigContinuacao;
85
    protected $arrayNFe = array();
86
    protected $siteDesenvolvedor;
87
    protected $nomeDesenvolvedor;
88
    protected $totPag;
89
    protected $idDocAntEle = [];
90
    protected $lota;
91
92
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
93
    protected $margemInterna = 0;
94
    
95
    private $creditos;
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
     */
110
    public function __construct(
111
        $docXML = '',
112
        $sOrientacao = '',
113
        $sPapel = '',
114
        $sPathLogo = '',
115
        $sDestino = 'I',
116
        $sDirPDF = '',
117
        $fonteDACTE = '',
118
        $mododebug = 2,
119
        $preVisualizar = false
120
    ) {
121
122
        if (is_numeric($mododebug)) {
123
            $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...
124
        }
125
        if ($mododebug == 1) {
126
            //ativar modo debug
127
            error_reporting(E_ALL);
128
            ini_set('display_errors', 'On');
129
        } elseif ($mododebug == 0) {
130
            //desativar modo debug
131
            error_reporting(0);
132
            ini_set('display_errors', 'Off');
133
        }
134
        $this->orientacao = $sOrientacao;
135
        $this->papel = $sPapel;
136
        $this->pdf = '';
137
        $this->xml = $docXML;
138
        $this->logomarca = $sPathLogo;
139
        $this->destino = $sDestino;
140
        $this->pdfDir = $sDirPDF;
141
        $this->preVisualizar = $preVisualizar;
142
        //$this->siteDesenvolvedor = $siteDesenvolvedor;
143
        //$this->nomeDesenvolvedor = $nomeDesenvolvedor;
144
        // verifica se foi passa a fonte a ser usada
145
        if (!empty($fonteDACTE)) {
146
            $this->fontePadrao = $fonteDACTE;
147
        }
148
        $this->formatPadrao = array(
149
            'font' => $this->fontePadrao,
150
            'size' => 6,
151
            'style' => '');
152
        $this->formatNegrito = array(
153
            'font' => $this->fontePadrao,
154
            'size' => 7,
155
            'style' => 'B');
156
        //se for passado o xml
157
        if (!empty($this->xml)) {
158
            $this->dom = new Dom();
159
            $this->dom->loadXML($this->xml);
160
            $this->cteProc = $this->dom->getElementsByTagName("cteOSProc")->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...
161
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
162
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
163
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
164
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
165
            $this->infPercurso = $this->dom->getElementsByTagName("infPercurso");
166
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
167
            $this->infQ = $this->dom->getElementsByTagName("infQ");
168
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
169
            $this->rodo = $this->dom->getElementsByTagName("rodoOS")->item(0);
170
            $this->veic = $this->dom->getElementsByTagName("veic");
171
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
172
            // adicionar outros modais
173
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
174
            $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chave");
175
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
176
            $this->Comp = $this->dom->getElementsByTagName("Comp");
177
            $this->infNF = $this->dom->getElementsByTagName("infNF");
178
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
179
            $this->infOutros = $this->dom->getElementsByTagName("infOutros");
0 ignored issues
show
Bug introduced by
The property infOutros does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
180
            $this->infServico = $this->dom->getElementsByTagName("infServico");
181
            $this->compl = $this->dom->getElementsByTagName("compl");
182
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
183
            $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...
184
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
185
186
            $vTrib = $this->getTagValue($this->imp, "vTotTrib");
187
            if (!is_numeric($vTrib)) {
188
                $vTrib = 0;
189
            }
190
            $textoAdic = number_format($vTrib, 2, ",", ".");
191
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
192
                    .$textoAdic;
193
            $this->toma = $this->dom->getElementsByTagName("toma")->item(0);
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...
194
            $this->enderToma = $this->getTagValue($this->toma, "enderToma");
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...
195
            //modal aquaviário
196
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
197
            $seguro = $this->getTagValue($this->seg, "respSeg");
198
            switch ($seguro) {
199
                case '4':
200
                    $this->respSeg = 'Emitente';
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...
201
                    break;
202
                case '5':
203
                    $this->respSeg = 'Tomador do Serviço';
204
                    break;
205
                default:
206
                    $this->respSeg = '';
207
                    break;
208
            }
209
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
210
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
211
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
212
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
213
            $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...
214
            $this->qrCodMDFe = $this->dom->getElementsByTagName('qrCodCTe')->item(0) ?
0 ignored issues
show
Bug introduced by
The property qrCodMDFe 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...
215
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE';
216
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
217
            $this->modal = $this->getTagValue($this->ide, "modal");
218
        }
219
    }
220
221
    /**
222
     * monta
223
     * @param string $orientacao L ou P
224
     * @param string $papel A4
225
     * @param string $logoAlign C, L ou R
226
     * @param Pdf $classPDF
227
     * @return string montagem
228
     */
229
    public function monta(
230
        $orientacao = '',
231
        $papel = 'A4',
232
        $logoAlign = 'C',
233
        $classPDF = false
234
    ) {
235
236
        return $this->montaDACTE($orientacao, $papel, $logoAlign, $classPDF);
0 ignored issues
show
Bug introduced by
It seems like $classPDF defined by parameter $classPDF on line 233 can also be of type object<NFePHP\DA\Legacy\Pdf>; however, NFePHP\DA\CTe\DacteOS::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...
237
    }
238
239
    /**
240
     * printDocument
241
     * @param string $nome
242
     * @param string $destino
243
     * @param string $printer
244
     * @return
245
     */
246
    public function printDocument($nome = '', $destino = 'I', $printer = '')
247
    {
248
        return $this->printDACTE($nome, $destino, $printer);
249
    }
250
251
    /**
252
     * Dados brutos do PDF
253
     * @return string
254
     */
255
    public function render()
256
    {
257
        return $this->pdf->getPdf();
258
    }
259
260
261
    protected function cteDPEC()
262
    {
263
        return $this->situacao_externa == self::SIT_DPEC && $this->numero_registro_dpec != '';
264
    }
265
266
267
    /**
268
     * montaDACTE
269
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
270
     * durante sua construção.
271
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
272
     * pelo conteúdo da funçao e podem ser modificados.
273
     *
274
     * @param  string $orientacao (Opcional) Estabelece a orientação da
275
     *                impressão (ex. P-retrato), se nada for fornecido será
276
     *                usado o padrão da NFe
277
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
278
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
279
     */
280
    public function montaDACTE(
281
        $orientacao = '',
282
        $papel = 'A4',
283
        $logoAlign = 'C',
284
        $classPDF = false
285
    ) {
286
287
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
288
        if ($orientacao == '') {
289
            if ($this->tpImp == '1') {
290
                $orientacao = 'P';
291
            } else {
292
                $orientacao = 'P';
293
            }
294
        }
295
        $this->orientacao = $orientacao;
296
        $this->papel = $papel;
297
        $this->logoAlign = $logoAlign;
298
299
        //$this->situacao_externa = $situacao_externa;
300
        //instancia a classe pdf
301
        if ($classPDF !== false) {
302
            $this->pdf = $classPDF;
303
        } else {
304
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
305
        }
306
        if ($this->orientacao == 'P') {
307
            // margens do PDF
308
            $margSup = 2;
309
            $margEsq = 2;
310
            $margDir = 2;
311
            // posição inicial do relatorio
312
            $xInic = 1;
313
            $yInic = 1;
314
            if ($papel == 'A4') {
315
                //A4 210x297mm
316
                $maxW = 210;
317
                $maxH = 297;
318
            }
319
        } else {
320
            // margens do PDF
321
            $margSup = 3;
322
            $margEsq = 3;
323
            $margDir = 3;
324
            // posição inicial do relatorio
325
            $xInic = 5;
326
            $yInic = 5;
327
            if ($papel == 'A4') {
328
                //A4 210x297mm
329
                $maxH = 210;
330
                $maxW = 297;
331
                $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...
332
            }
333
        }
334
        //total inicial de paginas
335
        $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...
336
        //largura imprimivel em mm
337
        $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...
338
        //comprimento imprimivel em mm
339
        $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...
340
        // estabelece contagem de paginas
341
        $this->pdf->aliasNbPages();
342
        // fixa as margens
343
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
344
        $this->pdf->setDrawColor(0, 0, 0);
345
        $this->pdf->setFillColor(255, 255, 255);
346
        // inicia o documento
347
        $this->pdf->open();
348
        // adiciona a primeira página
349
        $this->pdf->addPage($this->orientacao, $this->papel);
350
        $this->pdf->setLineWidth(0.1);
351
        $this->pdf->setTextColor(0, 0, 0);
352
        //calculo do numero de páginas ???
353
        $totPag = 1;
354
        //montagem da primeira página
355
        $pag = 1;
356
        $x = $xInic;
357
        $y = $yInic;
358
        //coloca o cabeçalho
359
        //$r = $this->cabecalho($x, $y, $pag, $totPag);
360
        $y += 70;
361
        $r = $this->tomador($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
362
        if ($this->tpCTe == '0') {
363
            //Normal
364
            $y += 10;
365
            $x = $xInic;
366
            //$r = $this->zDocOrig($x, $y);
367
            $r = $this->infPrestacaoServico($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...
368
            $y += 53;
369
            $x = $xInic;
370
            $r = $this->compValorServ($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading history...
377
            $y += 19;
378
            $x = $xInic;
379
            $r = $this->seguro($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...
380
            $y = $y-12;
381
382
383
            switch ($this->modal) {
384
                case '1':
385
                    $y += 24.9;
386
                    $x = $xInic;
387
                    $r = $this->modalRod($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
388
                    break;
389
                case '2':
390
                    $y += 17.9;
391
                    $x = $xInic;
392
                    // TODO fmertins 31/10/14: este método não existe...
393
                    $r = $this->modalAereo($x, $y);
0 ignored issues
show
Bug introduced by
The method modalAereo() does not seem to exist on object<NFePHP\DA\CTe\DacteOS>.

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...
394
                    break;
395
                case '3':
396
                    $y += 17.9;
397
                    $x = $xInic;
398
                    $r = $this->modalAquaviario($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
399
                    break;
400
                case '4':
401
                    $y += 17.9;
402
                    $x = $xInic;
403
                    $r = $this->modalFerr($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
404
                    break;
405
                case '5':
406
                    $y += 17.9;
407
                    $x = $xInic;
408
                    // TODO fmertins 31/10/14: este método não existe...
409
                    $r = $this->modalDutoviario($x, $y);
0 ignored issues
show
Bug introduced by
The method modalDutoviario() does not seem to exist on object<NFePHP\DA\CTe\DacteOS>.

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...
410
                    break;
411
            }
412
            if ($this->modal == '1') {
413
                if ($this->lota == 1) {
414
                    $y += 37;
415
                } else {
416
                    $y += 8.9;
417
                }
418
            } elseif ($this->modal == '3') {
419
                $y += 24.15;
420
            } else {
421
                $y += 37;
422
            }
423
        } else {
424
            $r = $this->cabecalho(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...
425
            //Complementado
426
            $y += 10;
427
            $x = $xInic;
428
            $r = $this->docCompl($x, $y);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading history...
438
            $y += 15;
439
        }
440
        $x = $xInic;
441
        $y += 1;
442
        $r = $this->dadosAdic($x, $y, $pag, $totPag);
0 ignored issues
show
Unused Code introduced by
$r is not used, you could remove the assignment.

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

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

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

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

Loading history...
443
444
        $y += 21;
445
        //$y += 11;
446
        $y = $this->canhoto($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...
447
448
        //coloca o rodapé da página
449
        if ($this->orientacao == 'P') {
450
            $this->rodape(2, $this->hPrint - 2);
451
        } else {
452
            $this->rodape($xInic, $this->hPrint + 2.3);
453
        }
454
        if ($this->flagDocOrigContinuacao == 1) {
455
            $this->docOrigContinuacao(1, 71);
0 ignored issues
show
Bug introduced by
The method docOrigContinuacao() does not seem to exist on object<NFePHP\DA\CTe\DacteOS>.

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...
456
        }
457
        //retorna o ID na CTe
458
        if ($classPDF !== false) {
459
            $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf);
460
            return $aR;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $aR; (array) is incompatible with the return type documented by NFePHP\DA\CTe\DacteOS::montaDACTE of type string.

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

Let’s take a look at an example:

class Author {
    private $name;

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

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

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

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

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

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

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

Loading history...
461
        } else {
462
            return str_replace('CTe', '', $this->infCte->getAttribute("Id"));
463
        }
464
    } //fim da função montaDACTE
465
466
    /**
467
     * printDACTE
468
     * Esta função envia a DACTE em PDF criada para o dispositivo informado.
469
     * O destino da impressão pode ser :
470
     * I-browser
471
     * D-browser com download
472
     * F-salva em um arquivo local com o nome informado
473
     * S-retorna o documento como uma string e o nome é ignorado.
474
     * Para enviar o pdf diretamente para uma impressora indique o
475
     * nome da impressora e o destino deve ser 'S'.
476
     *
477
     * @param  string $nome Path completo com o nome do arquivo pdf
478
     * @param  string $destino Direção do envio do PDF
479
     * @param  string $printer Identificação da impressora no sistema
480
     * @return string Caso o destino seja S o pdf é retornado como uma string
481
     * @todo Rotina de impressão direta do arquivo pdf criado
482
     */
483
    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...
484
    {
485
        $arq = $this->pdf->Output($nome, $destino);
486
        if ($destino == 'S') {
487
            //aqui pode entrar a rotina de impressão direta
488
        }
489
        return $arq;
490
    } //fim função printDACTE
491
492
    /**
493
     * cabecalho
494
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
495
     *
496
     * @param  number $x Posição horizontal inicial, canto esquerdo
497
     * @param  number $y Posição vertical inicial, canto superior
498
     * @param  number $pag Número da Página
499
     * @param  number $totPag Total de páginas
500
     * @return number Posição vertical final
501
     */
502
    protected function cabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
0 ignored issues
show
Unused Code introduced by
The parameter $totPag 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...
503
    {
504
        $oldX = $x;
505
        $oldY = $y;
506
        if ($this->orientacao == 'P') {
507
            $maxW = $this->wPrint;
508
        } else {
509
            if ($pag == 1) {
510
                // primeira página
511
                $maxW = $this->wPrint - $this->wCanhoto;
512
            } else {
513
                // páginas seguintes
514
                $maxW = $this->wPrint;
515
            }
516
        }
517
        //##################################################################
518
        //coluna esquerda identificação do emitente
519
        $w = round($maxW * 0.42);
520
        if ($this->orientacao == 'P') {
521
            $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...
522
                'font' => $this->fontePadrao,
523
                'size' => 6,
524
                'style' => '');
525
        } else {
526
            $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...
527
        }
528
        $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...
529
        $h = 35;
530
        $oldY += $h;
531
        //desenha a caixa
532
        $this->pdf->textBox($x, $y, $w + 2, $h + 1);
533
        // coloca o logo
534
        if (is_file($this->logomarca)) {
535
            $logoInfo = getimagesize($this->logomarca);
536
            //largura da imagem em mm
537
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
538
            //altura da imagem em mm
539
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
540
            if ($this->logoAlign == 'L') {
541
                $nImgW = round($w / 3, 0);
542
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
543
                $xImg = $x + 1;
544
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
545
                //estabelecer posições do texto
546
                $x1 = round($xImg + $nImgW + 1, 0);
547
                $y1 = round($h / 3 + $y, 0);
548
                $tw = round(2 * $w / 3, 0);
549
            } elseif ($this->logoAlign == 'C') {
550
                $nImgH = round($h / 3, 0);
551
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
552
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
553
                $yImg = $y + 3;
554
                $x1 = $x;
555
                $y1 = round($yImg + $nImgH + 1, 0);
556
                $tw = $w;
557
            } elseif ($this->logoAlign == 'R') {
558
                $nImgW = round($w / 3, 0);
559
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
560
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
561
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
562
                $x1 = $x;
563
                $y1 = round($h / 3 + $y, 0);
564
                $tw = round(2 * $w / 3, 0);
565
            }
566
            $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...
567
        } else {
568
            $x1 = $x;
569
            $y1 = round($h / 3 + $y, 0);
570
            $tw = $w;
571
        }
572
        //Nome emitente
573
        $aFont = array(
574
            'font' => $this->fontePadrao,
575
            'size' => 9,
576
            'style' => 'B');
577
        $texto = $this->getTagValue($this->emit, "xNome");
578
        $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
586
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
587
        $nro = $this->getTagValue($this->enderEmit, "nro");
588
        $cpl = $this->getTagValue($this->enderEmit, "xCpl");
0 ignored issues
show
Unused Code introduced by
$cpl is not used, you could remove the assignment.

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

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

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

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

Loading history...
589
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
590
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
591
        $CEP = $this->formatField($CEP, "#####-###");
592
        $mun = $this->getTagValue($this->enderEmit, "xMun");
593
        $UF = $this->getTagValue($this->enderEmit, "UF");
594
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
595
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
596
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
597
            . "\n  Fone/Fax: " . $fone;
598
        $this->pdf->textBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
599
        //CNPJ/CPF IE
600
        $cpfCnpj = $this->formatCNPJCPF($this->emit);
0 ignored issues
show
Documentation introduced by
$this->emit is of type object<DOMNode>, but the function expects a string.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
601
        $ie = $this->getTagValue($this->emit, "IE");
602
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
603
        $this->pdf->textBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
604
        //outra caixa
605
        $h1 = 17.5;
606
        $y1 = $y + $h + 1;
607
        $this->pdf->textBox($x, $y1, $w + 2, $h1);
608
        //TIPO DO CT-E
609
        $texto = 'TIPO DO CTE';
610
        $wa = 37;
611
        $aFont = array(
612
            'font' => $this->fontePadrao,
613
            'size' => 8,
614
            'style' => '');
615
        $this->pdf->textBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
616
        $tpCTe = $this->getTagValue($this->ide, "tpCTe");
617
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
618
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
619
        switch ($tpCTe) {
620
            case '0':
621
                $texto = 'Normal';
622
                break;
623
            case '1':
624
                $texto = 'Complemento de Valores';
625
                break;
626
            case '2':
627
                $texto = 'Anulação de Valores';
628
                break;
629
            case '3':
630
                $texto = 'Substituto';
631
                break;
632
            default:
633
                $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...
634
        }
635
        $aFont = $this->formatNegrito;
636
        $this->pdf->textBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
637
        //TIPO DO SERVIÇO
638
        $texto = 'TIPO DO SERVIÇO';
639
        $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...
640
        $aFont = array(
641
            'font' => $this->fontePadrao,
642
            'size' => 8,
643
            'style' => '');
644
        $this->pdf->textBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
645
        $tpServ = $this->getTagValue($this->ide, "tpServ");
646
        //'6' => 'Transporte de Pessoas', '7' => 'Transporte de Valores', '8' => 'Transporte de Bagagem'
647
        switch ($tpServ) {
648
            case '6':
649
                $texto = 'Transporte de Pessoas';
650
                break;
651
            case '7':
652
                $texto = 'Transporte de Valores';
653
                break;
654
            case '8':
655
                $texto = 'Transporte de Bagagem';
656
                break;
657
            default:
658
                $texto = 'ERRO' . $tpServ;
659
        }
660
        $aFont = $this->formatNegrito;
661
        $this->pdf->textBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
662
        $this->pdf->line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
663
        //TOMADOR DO SERVIÇO
664
        $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...
665
666
        //##################################################################
667
        //coluna direita
668
        $x += $w + 2;
669
        $w = round($maxW * 0.335);
670
        $w1 = $w;
671
        $h = 11;
672
        $this->pdf->textBox($x, $y, $w + 10, $h + 1);
673
        $texto = "DACTE OS";
674
        $aFont = array(
675
            'font' => $this->fontePadrao,
676
            'size' => 10,
677
            'style' => 'B');
678
        $this->pdf->textBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
679
        $aFont = array(
680
            'font' => $this->fontePadrao,
681
            'size' => 9,
682
            'style' => '');
683
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico para Outros Serviços";
684
        $h = 10;
685
        $this->pdf->textBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
686
        $x1 = $x + $w + 2;
687
        $w = round($maxW * 0.22, 0);
688
        $w2 = $w;
0 ignored issues
show
Unused Code introduced by
$w2 is not used, you could remove the assignment.

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

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

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

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

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

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1121
    }
1122
1123
    /**
1124
     * tomador
1125
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1126
     *
1127
     * @param  number $x Posição horizontal canto esquerdo
1128
     * @param  number $y Posição vertical canto superior
1129
     * @return number Posição vertical final
1130
     */
1131
    protected function tomador($x = 0, $y = 0)
1132
    {
1133
        $oldX = $x;
1134
        $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...
1135
        if ($this->orientacao == 'P') {
1136
            $maxW = $this->wPrint;
1137
        } else {
1138
            $maxW = $this->wPrint - $this->wCanhoto;
1139
        }
1140
        $w = $maxW;
1141
        $h = 10;
1142
        $texto = 'TOMADOR DO SERVIÇO';
1143
        $aFont = $this->formatPadrao;
1144
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1145
        $aFont = $this->formatNegrito;
1146
        $texto = $this->getTagValue($this->toma, "xNome");
1147
        $this->pdf->textBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1148
        $x = $maxW * 0.60;
1149
        $texto = 'MUNICÍPIO';
1150
        $aFont = $this->formatPadrao;
1151
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1152
        $texto = $this->getTagValue($this->toma, "xMun");
1153
        $aFont = $this->formatNegrito;
1154
        $this->pdf->textBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1155
        $x = $maxW * 0.85;
1156
        $texto = 'UF';
1157
        $aFont = $this->formatPadrao;
1158
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1159
        $texto = $this->getTagValue($this->toma, "UF");
1160
        $aFont = $this->formatNegrito;
1161
        $this->pdf->textBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1162
        $x = $w - 18;
1163
        $texto = 'CEP';
1164
        $aFont = $this->formatPadrao;
1165
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1166
        $texto = $this->formatField($this->getTagValue($this->toma, "CEP"), "#####-###");
1167
        $aFont = $this->formatNegrito;
1168
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1169
        $y += 3;
1170
        $x = $oldX;
1171
        $texto = 'ENDEREÇO';
1172
        $aFont = $this->formatPadrao;
1173
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1174
        $aFont = $this->formatNegrito;
1175
        $texto = $this->getTagValue($this->toma, "xLgr") . ',';
1176
        $texto .= $this->getTagValue($this->toma, "nro");
1177
        $texto .= ($this->getTagValue($this->toma, "xCpl") != "") ?
1178
            ' - ' . $this->getTagValue($this->toma, "xCpl") : '';
1179
        $texto .= ' - ' . $this->getTagValue($this->toma, "xBairro");
1180
        $this->pdf->textBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1181
        $y += 3;
1182
        $texto = 'CNPJ/CPF';
1183
        $aFont = $this->formatPadrao;
1184
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1185
        $texto = $this->formatCNPJCPF($this->toma);
1186
        $aFont = $this->formatNegrito;
1187
        $this->pdf->textBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1188
        $x = $x + 65;
1189
        $texto = 'INSCRIÇÃO ESTADUAL';
1190
        $aFont = $this->formatPadrao;
1191
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1192
        $texto = $this->getTagValue($this->toma, "IE");
1193
        $aFont = $this->formatNegrito;
1194
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1195
        $x = $w * 0.75;
1196
        $texto = 'PAÍS';
1197
        $aFont = $this->formatPadrao;
1198
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1199
        $texto = $this->getTagValue($this->toma, "xPais") != "" ?
1200
            $this->getTagValue($this->toma, "xPais") : 'BRASIL';
1201
        $aFont = $this->formatNegrito;
1202
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1203
        $x = $w - 27;
1204
        $texto = 'FONE';
1205
        $aFont = $this->formatPadrao;
1206
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1207
        $texto = $this->getTagValue($this->toma, "fone")!=""? $this->formatFone($this->toma):'';
1208
        $aFont = $this->formatNegrito;
1209
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1210
    }
1211
1212
    /**
1213
     * compValorServ
1214
     * Monta o campo com os componentes da prestação de serviços.
1215
     *
1216
     * @param  number $x Posição horizontal canto esquerdo
1217
     * @param  number $y Posição vertical canto superior
1218
     * @return number Posição vertical final
1219
     */
1220
    protected function compValorServ($x = 0, $y = 0)
1221
    {
1222
        $oldX = $x;
1223
        $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...
1224
        if ($this->orientacao == 'P') {
1225
            $maxW = $this->wPrint;
1226
        } else {
1227
            $maxW = $this->wPrint - $this->wCanhoto;
1228
        }
1229
        $w = $maxW;
1230
        $h = 25;
1231
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1232
        $aFont = $this->formatPadrao;
1233
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1234
        $y += 3.4;
1235
        $this->pdf->line($x, $y, $w + 1, $y);
1236
        $texto = 'NOME';
1237
        $aFont = $this->formatPadrao;
1238
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1239
        $yIniDados = $y;
1240
        $x = $w * 0.14;
1241
        $texto = 'VALOR';
1242
        $aFont = $this->formatPadrao;
1243
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1244
        $x = $w * 0.28;
1245
        $this->pdf->line($x, $y, $x, $y + 21.5);
1246
        $texto = 'NOME';
1247
        $aFont = $this->formatPadrao;
1248
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1249
        $x = $w * 0.42;
1250
        $texto = 'VALOR';
1251
        $aFont = $this->formatPadrao;
1252
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1253
        $x = $w * 0.56;
1254
        $this->pdf->line($x, $y, $x, $y + 21.5);
1255
        $texto = 'NOME';
1256
        $aFont = $this->formatPadrao;
1257
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1258
        $x = $w * 0.70;
1259
        $texto = 'VALOR';
1260
        $aFont = $this->formatPadrao;
1261
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1262
        $x = $w * 0.86;
1263
        $this->pdf->line($x, $y, $x, $y + 21.5);
1264
        $y += 1;
1265
        $texto = 'VALOR TOTAL DO SERVIÇO';
1266
        $aFont = $this->formatPadrao;
1267
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1268
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1269
        $aFont = array(
1270
            'font' => $this->fontePadrao,
1271
            'size' => 9,
1272
            'style' => 'B');
1273
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1274
        $y += 10;
1275
        $this->pdf->line($x, $y, $w + 1, $y);
1276
        $y += 1;
1277
        $texto = 'VALOR A RECEBER';
1278
        $aFont = $this->formatPadrao;
1279
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1280
        $texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
1281
        $aFont = array(
1282
            'font' => $this->fontePadrao,
1283
            'size' => 9,
1284
            'style' => 'B');
1285
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1286
        $auxX = $oldX;
1287
        $yIniDados += 4;
1288
1289
        foreach ($this->Comp as $k => $d) {
1290
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1291
            $valor = number_format(
1292
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1293
                2,
1294
                ",",
1295
                "."
1296
            );
1297
            if ($auxX > $w * 0.60) {
1298
                $yIniDados = $yIniDados + 4;
1299
                $auxX = $oldX;
1300
            }
1301
            $texto = $nome;
1302
            $aFont = $this->formatPadrao;
1303
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1304
            $auxX += $w * 0.14;
1305
            $texto = $valor;
1306
            $aFont = $this->formatPadrao;
1307
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1308
            $auxX += $w * 0.14;
1309
        }
1310
    } //fim da função compValorDACTE
1311
1312
    /**
1313
     * impostos
1314
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1315
     *
1316
     * @param  number $x Posição horizontal canto esquerdo
1317
     * @param  number $y Posição vertical canto superior
1318
     * @return number Posição vertical final
1319
     */
1320
    protected function impostos($x = 0, $y = 0)
1321
    {
1322
        $oldX = $x;
1323
        $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...
1324
        if ($this->orientacao == 'P') {
1325
            $maxW = $this->wPrint;
1326
        } else {
1327
            $maxW = $this->wPrint - $this->wCanhoto;
1328
        }
1329
        $w = $maxW;
1330
        $h = 13;
1331
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1332
        $aFont = $this->formatPadrao;
1333
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1334
1335
        $y += 3.4;
1336
        $this->pdf->line($x, $y, $w + 1, $y);
1337
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1338
        $aFont = $this->formatPadrao;
1339
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1340
1341
        $x += $w * 0.26;
1342
        $this->pdf->line($x, $y, $x, $y + 9.5);
1343
        $texto = 'BASE DE CALCULO';
1344
        $aFont = $this->formatPadrao;
1345
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1346
1347
        $wCol02=0.18;
1348
        $x += $w * $wCol02;
1349
        $this->pdf->line($x, $y, $x, $y + 9.5);
1350
        $texto = 'ALÍQ ICMS';
1351
        $aFont = $this->formatPadrao;
1352
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1353
1354
        $x += $w * $wCol02;
1355
        $this->pdf->line($x, $y, $x, $y + 9.5);
1356
        $texto = 'VALOR ICMS';
1357
        $aFont = $this->formatPadrao;
1358
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1359
1360
        $x += $w * $wCol02;
1361
        $this->pdf->line($x, $y, $x, $y + 9.5);
1362
        $texto = '% RED. BC ICMS';
1363
        $aFont = $this->formatPadrao;
1364
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1365
1366
        /*$x += $w * 0.14;
1367
        $this->pdf->line($x, $y, $x, $y + 9.5);
1368
        $texto = 'ICMS ST';
1369
        $aFont = $this->formatPadrao;
1370
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1371
         * */
1372
1373
        $x = $oldX;
1374
        $y = $y + 4;
1375
        $texto = $this->getTagValue($this->ICMS, "CST");
1376
        switch ($texto) {
1377
            case '00':
1378
                $texto = "00 - Tributação normal ICMS";
1379
                break;
1380
            case '20':
1381
                $texto = "20 - Tributação com BC reduzida do ICMS";
1382
                break;
1383
            case '40':
1384
                $texto = "40 - ICMS isenção";
1385
                break;
1386
            case '41':
1387
                $texto = "41 - ICMS não tributada";
1388
                break;
1389
            case '51':
1390
                $texto = "51 - ICMS diferido";
1391
                break;
1392
            case '60':
1393
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
1394
                break;
1395
            case '90':
1396
                $texto = "90 - ICMS outros";
1397
                break;
1398
        }
1399
        $texto = $this->getTagValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
1400
        $aFont = $this->formatNegrito;
1401
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1402
        $x += $w * 0.26;
1403
1404
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
1405
            number_format($this->getTagValue($this->ICMS, "vBC"), 2, ",", ".") : '';
1406
        $aFont = $this->formatNegrito;
1407
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1408
        $x += $w * $wCol02;
1409
1410
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
1411
            number_format($this->getTagValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
1412
        $aFont = $this->formatNegrito;
1413
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1414
        $x += $w * $wCol02;
1415
1416
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
1417
            number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
1418
        $aFont = $this->formatNegrito;
1419
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1420
        $x += $w * $wCol02;
1421
1422
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
1423
            number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
1424
        $aFont = $this->formatNegrito;
1425
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1426
1427
        /*$x += $w * 0.14;
1428
        $texto = '';
1429
        $aFont = $this->formatNegrito;
1430
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1431
    } //fim da função compValorDACTE
1432
1433
    /**
1434
     * geraChaveAdicCont
1435
     *
1436
     * @return string chave
1437
     */
1438
    protected function geraChaveAdicCont()
1439
    {
1440
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
1441
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
1442
        $forma = "%02d%d%s%014d%01d%01d%02d";
1443
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
1444
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
1445
        $CNPJ = substr($CNPJ, -14);
1446
        $vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
1447
        $ICMS_CST = $this->getTagValue($this->ICMS, "CST");
1448
        switch ($ICMS_CST) {
1449
            case '00':
1450
            case '20':
1451
                $ICMSp = '1';
1452
                $ICMSs = '2';
1453
                break;
1454
            case '40':
1455
            case '41':
1456
            case '51':
1457
            case '90':
1458
                $ICMSp = '2';
1459
                $ICMSs = '2';
1460
                break;
1461
            case '60':
1462
                $ICMSp = '2';
1463
                $ICMSs = '1';
1464
                break;
1465
        }
1466
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
1467
        $rpos = strrpos($dd, '-');
1468
        $dd = substr($dd, $rpos + 1);
1469
        $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...
1470
        $chave = $chave . $this->pModulo11($chave);
0 ignored issues
show
Bug introduced by
The method pModulo11() does not exist on NFePHP\DA\CTe\DacteOS. Did you maybe mean modulo11()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1471
        return $chave;
1472
    } //fim geraChaveAdicCont
1473
1474
    /**
1475
     * infPrestacaoServico
1476
     * Monta o campo com das informações da prestação do serviço
1477
     *
1478
     * @param  number $x Posição horizontal canto esquerdo
1479
     * @param  number $y Posição vertical canto superior
1480
     * @return number Posição vertical final
1481
     */
1482
    protected function infPrestacaoServico($x = 0, $y = 0)
1483
    {
1484
        $oldX = $x;
1485
        $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...
1486
        if ($this->orientacao == 'P') {
1487
            $maxW = $this->wPrint;
1488
        } else {
1489
            $maxW = $this->wPrint - $this->wCanhoto;
1490
        }
1491
        $w = $maxW;
1492
1493
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
1494
        if ($this->modal == '1') {
1495
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
1496
            // ou combinação veicular, e por viagem
1497
            $h = $this->lota == 1 ? 35 : 53;
1498
        } elseif ($this->modal == '3') {
1499
            $h = 37.6;
1500
        } else {
1501
            $h = 35;
1502
        }
1503
        $texto = 'INFORMAÇÕES DA PRESTAÇÃO DO SERVIÇO';
1504
        $aFont = $this->formatPadrao;
1505
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1506
        $descr1 = 'QUANTIDADE';
1507
        $descr2 = 'DESCRIÇÃO DO SERVIÇO PRESTADO';
1508
1509
        $y += 3.4;
1510
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
1511
        $texto = $descr1;
1512
        $aFont = $this->formatPadrao;
1513
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1514
        $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...
1515
1516
        $x += $w * 0.14;
1517
        if ($this->modal == '1') {
1518
            if ($this->lota == 1) {
1519
                $this->pdf->line($x, $y, $x, $y + 31.5); // TESTE
1520
            } else {
1521
                $this->pdf->line($x, $y, $x, $y + 49.5); // TESTE
1522
            }
1523
        } elseif ($this->modal == '3') {
1524
            $this->pdf->line($x, $y, $x, $y + 34.1);
1525
        } else {
1526
            $this->pdf->line($x, $y, $x, $y + 21.5);
1527
        }
1528
1529
        $x += $w * 0.08;
1530
        $texto = $descr2;
1531
        $aFont = $this->formatPadrao;
1532
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1533
1534
        //$auxX = $oldX;
1535
        //$yIniDados += 3;
1536
1537
        $x = $oldX;
1538
        $y = $y + 4;
1539
        $texto = number_format($this->getTagValue($this->infQ->item(0), "qCarga"), 3, ",", ".");
1540
        $aFont = $this->formatNegrito;
1541
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1542
        $x += $w * 0.26;
1543
1544
        $x = $oldX + 35;
1545
        $texto = $this->getTagValue($this->infServico->item(0), "xDescServ");
1546
        $aFont = $this->formatNegrito;
1547
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1548
        $x += $w * 0.26;
1549
1550
1551
        $r = $this->cabecalho(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...
1552
        $contador = 0;
0 ignored issues
show
Unused Code introduced by
$contador is not used, you could remove the assignment.

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

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

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

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

Loading history...
1553
    }
1554
1555
    /**
1556
     * docCompl
1557
     * Monta o campo com os dados do remetente na DACTE.
1558
     *
1559
     * @param number $x Posição horizontal canto esquerdo
1560
     * @param number $y Posição vertical canto superior
1561
     * @return number Posição vertical final
1562
     */
1563
    protected function docCompl($x = 0, $y = 0)
1564
    {
1565
        $oldX = $x;
1566
        $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...
1567
        if ($this->orientacao == 'P') {
1568
            $maxW = $this->wPrint;
1569
        } else {
1570
            $maxW = $this->wPrint - $this->wCanhoto;
1571
        }
1572
        $w = $maxW;
1573
        $h = 80;
1574
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
1575
        $aFont = $this->formatPadrao;
1576
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1577
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
1578
        $descr2 = 'VALOR COMPLEMENTADO';
1579
        $y += 3.4;
1580
        $this->pdf->line($x, $y, $w + 1, $y);
1581
        $texto = $descr1;
1582
        $aFont = $this->formatPadrao;
1583
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1584
        $yIniDados = $y;
1585
        $x += $w * 0.37;
1586
        $texto = $descr2;
1587
        $aFont = $this->formatPadrao;
1588
        $this->pdf->textBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1589
        $x += $w * 0.13;
1590
        $this->pdf->line($x, $y, $x, $y + 76.5);
1591
        $texto = $descr1;
1592
        $aFont = $this->formatPadrao;
1593
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1594
        $x += $w * 0.3;
1595
        $texto = $descr2;
1596
        $aFont = $this->formatPadrao;
1597
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1598
        $auxX = $oldX;
1599
        $yIniDados += 4;
1600
        if ($auxX > $w * 0.90) {
1601
            $yIniDados = $yIniDados + 4;
1602
            $auxX = $oldX;
1603
        }
1604
        $texto = $this->chaveCTeRef;
1605
        $aFont = array(
1606
            'font' => $this->fontePadrao,
1607
            'size' => 8,
1608
            'style' => '');
1609
        $this->pdf->textBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1610
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1611
        $aFont = array(
1612
            'font' => $this->fontePadrao,
1613
            'size' => 8,
1614
            'style' => '');
1615
        $this->pdf->textBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1616
    }
1617
    
1618
    /**
1619
     * observacoes
1620
     * Monta o campo com os dados do remetente na DACTE.
1621
     *
1622
     * @param  number $x Posição horizontal canto esquerdo
1623
     * @param  number $y Posição vertical canto superior
1624
     * @return number Posição vertical final
1625
     */
1626
    protected function observacoes($x = 0, $y = 0)
1627
    {
1628
        $oldX = $x;
1629
        $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...
1630
        if ($this->orientacao == 'P') {
1631
            $maxW = $this->wPrint;
1632
        } else {
1633
            $maxW = $this->wPrint - $this->wCanhoto;
1634
        }
1635
        $w = $maxW;
1636
        //$h = 18;
1637
        $h = 18.8;
1638
        $texto = 'OBSERVAÇÕES GERAIS';
1639
        $aFont = $this->formatPadrao;
1640
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1641
        $y += 3.4;
1642
        $this->pdf->line($x, $y, $w + 1, $y);
1643
        $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...
1644
        $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...
1645
        $texto = '';
1646
        foreach ($this->compl as $k => $d) {
1647
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
1648
            $texto .= $xObs;
1649
        }
1650
        $textoObs = explode("Motorista:", $texto);
1651
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
1652
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
1653
        $aFont = array(
1654
            'font' => $this->fontePadrao,
1655
            'size' => 7.5,
1656
            'style' => '');
1657
        $this->pdf->textBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
1658
        $this->pdf->textBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
1659
    }
1660
1661
    /**
1662
     * seguro
1663
     * Monta o campo com os dados de seguro do CT-e OS.
1664
     *
1665
     * @param  number $x Posição horizontal canto esquerdo
1666
     * @param  number $y Posição vertical canto superior
1667
     * @return number Posição vertical final
1668
     */
1669
    protected function seguro($x = 0, $y = 0)
1670
    {
1671
        $oldX = $x;
1672
        $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...
1673
        if ($this->orientacao == 'P') {
1674
            $maxW = $this->wPrint;
1675
        } else {
1676
            $maxW = $this->wPrint - $this->wCanhoto;
1677
        }
1678
        $w = $maxW;
1679
        $h = 13;
1680
        $texto = 'SEGURO DA VIAGEM';
1681
        $aFont = $this->formatPadrao;
1682
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1683
1684
        $y += 3.4;
1685
        $this->pdf->line($x, $y, $w + 1, $y);
1686
        $texto = 'RESPONSÁVEL';
1687
        $aFont = $this->formatPadrao;
1688
        $this->pdf->textBox($x, $y, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
1689
1690
        $x += $w * 0.33;
1691
        $this->pdf->line($x, $y, $x, $y + 9.5);
1692
        $texto = 'NOME DA SEGURADORA';
1693
        $aFont = $this->formatPadrao;
1694
        $this->pdf->textBox($x, $y, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
1695
1696
        $wCol02=0.33;
1697
        $x += $w * $wCol02;
1698
        $this->pdf->line($x, $y, $x, $y + 9.5);
1699
        $texto = 'NÚMERO DA APÓLICE';
1700
        $aFont = $this->formatPadrao;
1701
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1702
1703
        $x = $oldX;
1704
        $y = $y + 4;
1705
        $texto = $this->respSeg;
1706
        $aFont = $this->formatNegrito;
1707
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1708
        $x += $w * 0.26;
1709
1710
        $texto = '';
1711
        $aFont = $this->formatNegrito;
1712
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1713
        $x += $w * $wCol02;
1714
1715
        $texto = '';
1716
        $aFont = $this->formatNegrito;
1717
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1718
        $x += $w * $wCol02;
1719
    }
1720
1721
    /**
1722
     * modalRod
1723
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1724
     *
1725
     * @param  number $x Posição horizontal canto esquerdo
1726
     * @param  number $y Posição vertical canto superior
1727
     * @return number Posição vertical final
1728
     */
1729
    protected function modalRod($x = 0, $y = 0)
1730
    {
1731
        $oldX = $x;
1732
        $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...
1733
        if ($this->orientacao == 'P') {
1734
            $maxW = $this->wPrint;
1735
        } else {
1736
            $maxW = $this->wPrint - $this->wCanhoto;
1737
        }
1738
        $w = $maxW;
1739
        $h = 13;
1740
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
1741
        $aFont = $this->formatPadrao;
1742
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1743
1744
        $y += 3.4;
1745
        $this->pdf->line($x, $y, $w + 1, $y);
1746
        $texto = 'TERMO DE AUTORIZAÇÃO DE FRETAMENTO';
1747
        $aFont = $this->formatPadrao;
1748
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1749
1750
        $x += $w * 0.26;
1751
        $this->pdf->line($x, $y, $x, $y + 9.5);
1752
        $texto = 'Nº DE REGISTRO ESTADUAL';
1753
        $aFont = $this->formatPadrao;
1754
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1755
1756
        $wCol02=0.18;
1757
        $x += $w * $wCol02;
1758
        $this->pdf->line($x, $y, $x, $y + 9.5);
1759
        $texto = 'PLACA DO VEÍCULO';
1760
        $aFont = $this->formatPadrao;
1761
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1762
1763
        $x += $w * $wCol02;
1764
        $this->pdf->line($x, $y, $x, $y + 9.5);
1765
        $texto = 'RENAVAM DO VEÍCULO';
1766
        $aFont = $this->formatPadrao;
1767
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1768
1769
        $x += $w * $wCol02;
1770
        $this->pdf->line($x, $y, $x, $y + 9.5);
1771
        $texto = 'CNPJ/CPF';
1772
        $aFont = $this->formatPadrao;
1773
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1774
1775
        $x = $oldX;
1776
        $y = $y + 4;
1777
        $texto = $this->getTagValue($this->rodo, "TAF");
1778
        $aFont = $this->formatNegrito;
1779
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1780
        $x += $w * 0.26;
1781
1782
        $texto = $this->getTagValue($this->rodo, "NroRegEstadual");
1783
        $aFont = $this->formatNegrito;
1784
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1785
        $x += $w * $wCol02;
1786
1787
        $texto = $this->getTagValue($this->veic->item(0), "placa");
1788
        $aFont = $this->formatNegrito;
1789
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1790
        $x += $w * $wCol02;
1791
1792
        $texto = $this->getTagValue($this->veic->item(0), "RENAVAM");
1793
        $aFont = $this->formatNegrito;
1794
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1795
        $x += $w * $wCol02;
1796
1797
        $texto = !empty($this->getTagValue($this->veic->item(0), "CPF")) ?
1798
            $this->getTagValue($this->veic->item(0), "CPF") :
1799
            (!empty($this->getTagValue($this->veic->item(0), "CNPJ")) ?
1800
            $this->getTagValue($this->veic->item(0), "CNPJ") : '');
1801
        $aFont = $this->formatNegrito;
1802
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1803
1804
        /*$x += $w * 0.14;
1805
        $texto = '';
1806
        $aFont = $this->formatNegrito;
1807
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1808
    }
1809
1810
    /**
1811
     * modalAquaviario
1812
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1813
     *
1814
     * @param  number $x Posição horizontal canto esquerdo
1815
     * @param  number $y Posição vertical canto superior
1816
     * @return number Posição vertical final
1817
     */
1818
    protected function modalAquaviario($x = 0, $y = 0)
1819
    {
1820
        $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...
1821
        $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...
1822
        if ($this->orientacao == 'P') {
1823
            $maxW = $this->wPrint;
1824
        } else {
1825
            $maxW = $this->wPrint - $this->wCanhoto;
1826
        }
1827
        $w = $maxW;
1828
        $h = 8.5;
1829
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
1830
        $aFont = $this->formatPadrao;
1831
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
1832
        $y += 3.4;
1833
        $this->pdf->line($x, $y, $w + 1, $y);
1834
        $texto = 'PORTO DE EMBARQUE';
1835
        $aFont = $this->formatPadrao;
1836
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1837
        $texto = $this->getTagValue($this->aquav, "prtEmb");
1838
        $aFont = $this->formatNegrito;
1839
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1840
        $x += $w * 0.50;
1841
        $this->pdf->line($x, $y, $x, $y + 7.7);
1842
        $texto = 'PORTO DE DESTINO';
1843
        $aFont = $this->formatPadrao;
1844
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1845
        $texto = $this->getTagValue($this->aquav, "prtDest");
1846
        $aFont = $this->formatNegrito;
1847
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1848
        $y += 8;
1849
        $this->pdf->line(208, $y, 1, $y);
1850
        $x = 1;
1851
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
1852
        $aFont = $this->formatPadrao;
1853
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1854
        $texto = $this->getTagValue($this->aquav, "xNavio");
1855
        $aFont = $this->formatNegrito;
1856
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1857
        $x += $w * 0.50;
1858
        $this->pdf->line($x, $y, $x, $y + 7.7);
1859
        $texto = 'VR DA B. DE CALC. AFRMM';
1860
        $aFont = $this->formatPadrao;
1861
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1862
        $texto = $this->getTagValue($this->aquav, "vPrest");
1863
        $aFont = $this->formatNegrito;
1864
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1865
        $x += $w * 0.17;
1866
        $this->pdf->line($x, $y, $x, $y + 7.7);
1867
        $texto = 'VALOR DO AFRMM';
1868
        $aFont = $this->formatPadrao;
1869
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1870
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
1871
        $aFont = $this->formatNegrito;
1872
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1873
        $x += $w * 0.12;
1874
        $this->pdf->line($x, $y, $x, $y + 7.7);
1875
        $texto = 'TIPO DE NAVEGAÇÃO';
1876
        $aFont = $this->formatPadrao;
1877
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1878
        $texto = $this->getTagValue($this->aquav, "tpNav");
1879
        switch ($texto) {
1880
            case '0':
1881
                $texto = 'INTERIOR';
1882
                break;
1883
            case '1':
1884
                $texto = 'CABOTAGEM';
1885
                break;
1886
        }
1887
        $aFont = $this->formatNegrito;
1888
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1889
        $x += $w * 0.14;
1890
        $this->pdf->line($x, $y, $x, $y + 7.7);
1891
        $texto = 'DIREÇÃO';
1892
        $aFont = $this->formatPadrao;
1893
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1894
        $texto = $this->getTagValue($this->aquav, "direc");
1895
        switch ($texto) {
1896
            case 'N':
1897
                $texto = 'NORTE';
1898
                break;
1899
            case 'L':
1900
                $texto = 'LESTE';
1901
                break;
1902
            case 'S':
1903
                $texto = 'SUL';
1904
                break;
1905
            case 'O':
1906
                $texto = 'OESTE';
1907
                break;
1908
        }
1909
        $aFont = $this->formatNegrito;
1910
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1911
        $y += 8;
1912
        $this->pdf->line(208, $y, 1, $y);
1913
        $x = 1;
1914
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
1915
        $aFont = $this->formatPadrao;
1916
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1917
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
1918
            $texto = $this->infNF
1919
                ->item(0)
1920
                ->getElementsByTagName('infUnidCarga')
1921
                ->item(0)
1922
                ->getElementsByTagName('idUnidCarga')
1923
                ->item(0)->nodeValue;
1924
        } elseif ($this->infNFe->item(0) !== null
1925
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
1926
        ) {
1927
            $texto = $this->infNFe
1928
                ->item(0)
1929
                ->getElementsByTagName('infUnidCarga')
1930
                ->item(0)
1931
                ->getElementsByTagName('idUnidCarga')
1932
                ->item(0)
1933
                ->nodeValue;
1934
        } elseif ($this->infOutros->item(0) !== null
1935
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
1936
        ) {
1937
            $texto = $this->infOutros
1938
                ->item(0)
1939
                ->getElementsByTagName('infUnidCarga')
1940
                ->item(0)
1941
                ->getElementsByTagName('idUnidCarga')
1942
                ->item(0)
1943
                ->nodeValue;
1944
        } else {
1945
            $texto = '';
1946
        }
1947
        $aFont = $this->formatNegrito;
1948
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1949
        $x += $w * 0.50;
1950
        $this->pdf->line($x, $y, $x, $y + 7.7);
1951
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
1952
        $aFont = $this->formatPadrao;
1953
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1954
        $texto = '';
1955
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
1956
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
1957
                if ($k == 0) {
1958
                    $texto = $this->aquav
1959
                        ->getElementsByTagName('balsa')
1960
                        ->item($k)
1961
                        ->getElementsByTagName('xBalsa')
1962
                        ->item(0)
1963
                        ->nodeValue;
1964
                } else {
1965
                    $texto = $texto
1966
                        . ' / '
1967
                        . $this->aquav
1968
                            ->getElementsByTagName('balsa')
1969
                            ->item($k)
1970
                            ->getElementsByTagName('xBalsa')
1971
                            ->item(0)
1972
                            ->nodeValue;
1973
                }
1974
            }
1975
        }
1976
        $aFont = $this->formatNegrito;
1977
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1978
    }
1979
1980
    /**
1981
     * modalFerr
1982
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1983
     *
1984
     * @param  number $x Posição horizontal canto esquerdo
1985
     * @param  number $y Posição vertical canto superior
1986
     * @return number Posição vertical final
1987
     */
1988
    protected function modalFerr($x = 0, $y = 0)
1989
    {
1990
        $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...
1991
        $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...
1992
        if ($this->orientacao == 'P') {
1993
            $maxW = $this->wPrint;
1994
        } else {
1995
            $maxW = $this->wPrint - $this->wCanhoto;
1996
        }
1997
        $w = $maxW;
1998
        $h = 19.6;
1999
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2000
        $aFont = $this->formatPadrao;
2001
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2002
        $y += 3.4;
2003
        $this->pdf->line($x, $y, $w + 1, $y);
2004
        $texto = 'DCL';
2005
        $aFont = array(
2006
            'font' => $this->fontePadrao,
2007
            'size' => 7,
2008
            'style' => 'B');
2009
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2010
        $this->pdf->line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2011
        $texto = 'VAGÕES';
2012
        $aFont = array(
2013
            'font' => $this->fontePadrao,
2014
            'size' => 7,
2015
            'style' => 'B');
2016
        $this->pdf->textBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2017
        $y += 3.4;
2018
        $this->pdf->line($x, $y, $w + 1, $y);
2019
        // DCL
2020
        $texto = 'ID TREM';
2021
        $aFont = array(
2022
            'font' => $this->fontePadrao,
2023
            'size' => 6,
2024
            'style' => '');
2025
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2026
        $texto = $this->getTagValue($this->ferrov, "idTrem");
2027
        $aFont = array(
2028
            'font' => $this->fontePadrao,
2029
            'size' => 6,
2030
            'style' => 'B');
2031
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2032
        $x += $w * 0.06;
2033
        $y1 = $y + 12.5;
2034
        $this->pdf->line($x, $y, $x, $y1);
2035
        $texto = 'NUM';
2036
        $aFont = array(
2037
            'font' => $this->fontePadrao,
2038
            'size' => 6,
2039
            'style' => '');
2040
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2041
        $texto = $this->getTagValue($this->rem, "nDoc");
0 ignored issues
show
Bug introduced by
The property rem 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...
2042
        $aFont = array(
2043
            'font' => $this->fontePadrao,
2044
            'size' => 6,
2045
            'style' => 'B');
2046
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2047
        $x += $w * 0.06;
2048
        $this->pdf->line($x, $y, $x, $y1);
2049
        $texto = 'SÉRIE';
2050
        $aFont = array(
2051
            'font' => $this->fontePadrao,
2052
            'size' => 6,
2053
            'style' => '');
2054
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2055
        $texto = $this->getTagValue($this->rem, "serie");
2056
        $aFont = array(
2057
            'font' => $this->fontePadrao,
2058
            'size' => 6,
2059
            'style' => 'B');
2060
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2061
        $x += $w * 0.06;
2062
        $this->pdf->line($x, $y, $x, $y1);
2063
        $texto = 'EMISSÃO';
2064
        $aFont = array(
2065
            'font' => $this->fontePadrao,
2066
            'size' => 6,
2067
            'style' => '');
2068
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2069
        $texto = $this->pYmd2dmy($this->getTagValue($this->rem, "dEmi"));
0 ignored issues
show
Bug introduced by
The method pYmd2dmy() does not seem to exist on object<NFePHP\DA\CTe\DacteOS>.

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...
2070
        $aFont = array(
2071
            'font' => $this->fontePadrao,
2072
            'size' => 6,
2073
            'style' => 'B');
2074
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2075
        // VAGOES
2076
        $x += $w * 0.06;
2077
        $this->pdf->line($x, $y, $x, $y1);
2078
        $texto = 'NUM';
2079
        $aFont = array(
2080
            'font' => $this->fontePadrao,
2081
            'size' => 6,
2082
            'style' => '');
2083
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2084
        $texto = $this->getTagValue($this->ferrov, "nVag");
2085
        $aFont = array(
2086
            'font' => $this->fontePadrao,
2087
            'size' => 6,
2088
            'style' => 'B');
2089
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2090
        $x += $w * 0.06;
2091
        $this->pdf->line($x, $y, $x, $y1);
2092
        $texto = 'TIPO';
2093
        $aFont = array(
2094
            'font' => $this->fontePadrao,
2095
            'size' => 6,
2096
            'style' => '');
2097
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2098
        $texto = $this->getTagValue($this->ferrov, "tpVag");
2099
        $aFont = array(
2100
            'font' => $this->fontePadrao,
2101
            'size' => 6,
2102
            'style' => 'B');
2103
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2104
        $x += $w * 0.06;
2105
        $this->pdf->line($x, $y, $x, $y1);
2106
        $texto = 'CAPACIDADE';
2107
        $aFont = array(
2108
            'font' => $this->fontePadrao,
2109
            'size' => 6,
2110
            'style' => '');
2111
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2112
        $texto = $this->getTagValue($this->ferrov, "cap");
2113
        $aFont = array(
2114
            'font' => $this->fontePadrao,
2115
            'size' => 6,
2116
            'style' => 'B');
2117
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2118
        $x += $w * 0.08;
2119
        $this->pdf->line($x, $y, $x, $y1);
2120
        $texto = 'PESO REAL/TON';
2121
        $aFont = array(
2122
            'font' => $this->fontePadrao,
2123
            'size' => 6,
2124
            'style' => '');
2125
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2126
        $texto = $this->getTagValue($this->ferrov, "pesoR");
2127
        $aFont = array(
2128
            'font' => $this->fontePadrao,
2129
            'size' => 6,
2130
            'style' => 'B');
2131
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2132
        $x += $w * 0.09;
2133
        $this->pdf->line($x, $y, $x, $y1);
2134
        $texto = 'PESO BRUTO/TON';
2135
        $aFont = array(
2136
            'font' => $this->fontePadrao,
2137
            'size' => 6,
2138
            'style' => '');
2139
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2140
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
2141
        $aFont = array(
2142
            'font' => $this->fontePadrao,
2143
            'size' => 6,
2144
            'style' => 'B');
2145
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2146
        $x += $w * 0.1;
2147
        $this->pdf->line($x, $y, $x, $y1);
2148
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
2149
        $aFont = array(
2150
            'font' => $this->fontePadrao,
2151
            'size' => 6,
2152
            'style' => '');
2153
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2154
        $texto = $this->getTagValue($this->ferrov, "nCont");
2155
        $aFont = array(
2156
            'font' => $this->fontePadrao,
2157
            'size' => 6,
2158
            'style' => 'B');
2159
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2160
        // FLUXO
2161
        $x = 1;
2162
        $y += 12.9;
2163
        $h1 = $h * 0.5 + 0.27;
2164
        $wa = round($w * 0.103) + 0.5;
2165
        $texto = 'FLUXO FERROVIARIO';
2166
        $aFont = $this->formatPadrao;
2167
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2168
        $texto = $this->getTagValue($this->ferrov, "fluxo");
2169
        $aFont = array(
2170
            'font' => $this->fontePadrao,
2171
            'size' => 7,
2172
            'style' => 'B');
2173
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2174
        $y += 10;
2175
        $texto = 'TIPO DE TRÁFEGO';
2176
        $aFont = $this->formatPadrao;
2177
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2178
        $texto = $this->convertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
2179
        $aFont = array(
2180
            'font' => $this->fontePadrao,
2181
            'size' => 7,
2182
            'style' => 'B');
2183
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2184
        // Novo Box Relativo a Modal Ferroviário
2185
        $x = 22.5;
2186
        $y += -10.2;
2187
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
2188
        $aFont = $this->formatPadrao;
2189
        $this->pdf->textBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
2190
        $y += 3.4;
2191
        $this->pdf->line($x, $y, $w + 1, $y);
2192
        $w = $w * 0.2;
2193
        $h = $h * 1.04;
2194
        $texto = 'CÓDIGO INTERNO';
2195
        $aFont = array(
2196
            'font' => $this->fontePadrao,
2197
            'size' => 6,
2198
            'style' => '');
2199
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2200
        $texto = $this->getTagValue($this->ferrov, "cInt");
2201
        $aFont = array(
2202
            'font' => $this->fontePadrao,
2203
            'size' => 6,
2204
            'style' => 'B');
2205
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2206
        $texto = 'CNPJ';
2207
        $aFont = array(
2208
            'font' => $this->fontePadrao,
2209
            'size' => 6,
2210
            'style' => '');
2211
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2212
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
2213
        $aFont = array(
2214
            'font' => $this->fontePadrao,
2215
            'size' => 6,
2216
            'style' => 'B');
2217
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2218
        $x += 50;
2219
        $texto = 'NOME';
2220
        $aFont = array(
2221
            'font' => $this->fontePadrao,
2222
            'size' => 6,
2223
            'style' => '');
2224
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2225
        $texto = $this->getTagValue($this->ferrov, "xNome");
2226
        $aFont = array(
2227
            'font' => $this->fontePadrao,
2228
            'size' => 6,
2229
            'style' => 'B');
2230
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2231
        $texto = 'INSCRICAO ESTADUAL';
2232
        $aFont = array(
2233
            'font' => $this->fontePadrao,
2234
            'size' => 6,
2235
            'style' => '');
2236
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2237
        $texto = $this->getTagValue($this->ferrov, "IE");
2238
        $aFont = array(
2239
            'font' => $this->fontePadrao,
2240
            'size' => 6,
2241
            'style' => 'B');
2242
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2243
        $x += 50;
2244
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
2245
        $aFont = array(
2246
            'font' => $this->fontePadrao,
2247
            'size' => 6,
2248
            'style' => '');
2249
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2250
        $texto = '';
2251
        $aFont = array(
2252
            'font' => $this->fontePadrao,
2253
            'size' => 6,
2254
            'style' => 'B');
2255
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2256
    }
2257
2258
    /**
2259
     * canhoto
2260
     * Monta o campo com os dados do remetente na DACTE.
2261
     *
2262
     * @param  number $x Posição horizontal canto esquerdo
2263
     * @param  number $y Posição vertical canto superior
2264
     * @return number Posição vertical final
2265
     */
2266
    protected function canhoto($x = 0, $y = 0)
2267
    {
2268
        $this->pdf->dashedHLine($x, $y+2, $this->wPrint, 0.1, 80);
2269
        $y = $y + 2;
2270
        $oldX = $x;
2271
        $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...
2272
        if ($this->orientacao == 'P') {
2273
            $maxW = $this->wPrint;
2274
        } else {
2275
            $maxW = $this->wPrint - $this->wCanhoto;
2276
        }
2277
        $w = $maxW - 1;
2278
        $h = 20;
2279
        $y = $y + 1;
2280
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
2281
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
2282
        $aFont = $this->formatPadrao;
2283
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2284
        $y += 3.4;
2285
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
2286
2287
        $texto = 'NOME';
2288
        $aFont = array(
2289
            'font' => $this->fontePadrao,
2290
            'size' => 6,
2291
            'style' => '');
2292
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
2293
        $x += $w * 0.25;
2294
2295
        $this->pdf->line($x, $y, $x, $y + 16.5);
2296
2297
        $texto = 'ASSINATURA / CARIMBO';
2298
        $aFont = array(
2299
            'font' => $this->fontePadrao,
2300
            'size' => 6,
2301
            'style' => '');
2302
        $this->pdf->textBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
2303
        $x += $w * 0.25;
2304
2305
        $this->pdf->line($x, $y, $x, $y + 16.5);
2306
2307
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
2308
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
2309
        $aFont = array(
2310
            'font' => $this->fontePadrao,
2311
            'size' => 6,
2312
            'style' => '');
2313
        $this->pdf->textBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
2314
        $x = $oldX;
2315
        $y = $y + 5;
2316
2317
        $this->pdf->line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
2318
2319
        $texto = 'RG';
2320
        $aFont = array(
2321
            'font' => $this->fontePadrao,
2322
            'size' => 6,
2323
            'style' => '');
2324
        $this->pdf->textBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
2325
        $x += $w * 0.85;
2326
2327
        $this->pdf->line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
2328
2329
        $texto = "CT-E OS";
2330
        $aFont = $this->formatNegrito;
2331
        $this->pdf->textBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
2332
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
2333
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
2334
        $aFont = array(
2335
            'font' => $this->fontePadrao,
2336
            'size' => 6,
2337
            'style' => '');
2338
        $this->pdf->textBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
2339
        $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...
2340
    }
2341
2342
    /**
2343
     * dadosAdic
2344
     * Coloca o grupo de dados adicionais da DACTE.
2345
     *
2346
     * @param  number $x Posição horizontal canto esquerdo
2347
     * @param  number $y Posição vertical canto superior
2348
     * @param  number $h altura do campo
2349
     * @return number Posição vertical final
2350
     */
2351
    protected function dadosAdic($x, $y, $pag, $h)
0 ignored issues
show
Unused Code introduced by
The parameter $pag is not used and could be removed.

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

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

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

Loading history...
2352
    {
2353
        $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...
2354
        //###########################################################################
2355
        //DADOS ADICIONAIS DACTE
2356
        if ($this->orientacao == 'P') {
2357
            $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...
2358
        } else {
2359
            $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...
2360
        }
2361
        //INFORMAÇÕES COMPLEMENTARES
2362
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
2363
        $y += 3;
2364
        $w = $this->wAdic;
2365
        $h = 20; //mudar
2366
        $aFont = array(
2367
            'font' => $this->fontePadrao,
2368
            'size' => 6,
2369
            'style' => '');
2370
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2371
        //$this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
2372
        $this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
2373
        //o texto com os dados adicionais foi obtido na função xxxxxx
2374
        //e carregado em uma propriedade privada da classe
2375
        //$this->wAdic com a largura do campo
2376
        //$this->textoAdic com o texto completo do campo
2377
        $y += 1;
2378
        $aFont = $this->formatPadrao;
2379
        $this->pdf->textBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
2380
        //RESERVADO AO FISCO
2381
        $texto = "RESERVADO AO FISCO";
2382
        $x += $w;
2383
        $y -= 1;
2384
        if ($this->orientacao == 'P') {
2385
            $w = $this->wPrint - $w;
2386
        } else {
2387
            $w = $this->wPrint - $w - $this->wCanhoto;
2388
        }
2389
        $aFont = array(
2390
            'font' => $this->fontePadrao,
2391
            'size' => 6,
2392
            'style' => '');
2393
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2394
        //inserir texto informando caso de contingência
2395
        //1 – Normal – emissão normal;
2396
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
2397
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
2398
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
2399
        //Emissão em Contingência – DPEC;
2400
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
2401
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
2402
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
2403
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
2404
        $texto = '';
2405
        switch ($this->tpEmis) {
2406
            case 2:
2407
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
2408
                break;
2409
            case 3:
2410
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
2411
                break;
2412
            case 4:
2413
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
2414
                break;
2415
            case 5:
2416
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
2417
                break;
2418
        }
2419
        $y += 2;
2420
        $aFont = $this->formatPadrao;
2421
        $this->pdf->textBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
2422
        return $y + $h;
2423
    }
2424
2425
    /**
2426
     * formatCNPJCPF
2427
     * Formata campo CnpjCpf contida na CTe
2428
     *
2429
     * @param  string $field campo cnpjCpf da CT-e
2430
     * @return string
2431
     */
2432
    protected function formatCNPJCPF($field)
2433
    {
2434
        if (!isset($field)) {
2435
            return '';
2436
        }
2437
        $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...
2438
            $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...
2439
        if ($cnpj != "" && $cnpj != "00000000000000") {
2440
            $cnpj = $this->formatField($cnpj, '###.###.###/####-##');
2441
        } else {
2442
            $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...
2443
                $this->formatField($field->getElementsByTagName("CPF")->item(0)->nodeValue, '###.###.###.###-##') : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

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

Loading history...
2444
        }
2445
        return $cnpj;
2446
    }
2447
2448
    /**
2449
     * formatFone
2450
     * Formata campo fone contida na CTe
2451
     *
2452
     * @param  string $field campo fone da CT-e
2453
     * @return string
2454
     */
2455
    protected function formatFone($field)
2456
    {
2457
        try {
2458
            $fone = !empty($field->getElementsByTagName("fone")->item(0)->nodeValue) ?
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

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

Loading history...
2459
            $field->getElementsByTagName("fone")->item(0)->nodeValue : '';
0 ignored issues
show
Bug introduced by
The method getElementsByTagName cannot be called on $field (of type string).

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

Loading history...
2460
            $foneLen = strlen($fone);
2461
            if ($foneLen > 0) {
2462
                $fone2 = substr($fone, 0, $foneLen - 4);
2463
                $fone1 = substr($fone, 0, $foneLen - 8);
2464
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
2465
            } else {
2466
                $fone = '';
2467
            }
2468
            return $fone;
2469
        } catch (Exception $exc) {
2470
            return '';
2471
        }
2472
    }
2473
2474
    /**
2475
     * unidade
2476
     * Converte a imformação de peso contida na CTe
2477
     *
2478
     * @param  string $c unidade de trafego extraida da CTe
2479
     * @return string
2480
     */
2481
    protected function unidade($c = '')
2482
    {
2483
        switch ($c) {
2484
            case '00':
2485
                $r = 'M3';
2486
                break;
2487
            case '01':
2488
                $r = 'KG';
2489
                break;
2490
            case '02':
2491
                $r = 'TON';
2492
                break;
2493
            case '03':
2494
                $r = 'UN';
2495
                break;
2496
            case '04':
2497
                $r = 'LT';
2498
                break;
2499
            case '05':
2500
                $r = 'MMBTU';
2501
                break;
2502
            default:
2503
                $r = '';
2504
        }
2505
        return $r;
2506
    }
2507
2508
    /**
2509
     * convertUnidTrafego
2510
     * Converte a imformação de peso contida na CTe
2511
     *
2512
     * @param  string $U Informação de trafego extraida da CTe
2513
     * @return string
2514
     */
2515
    protected function convertUnidTrafego($U = '')
2516
    {
2517
        if ($U) {
2518
            switch ($U) {
2519
                case '0':
2520
                    $stringU = 'Próprio';
2521
                    break;
2522
                case '1':
2523
                    $stringU = 'Mútuo';
2524
                    break;
2525
                case '2':
2526
                    $stringU = 'Rodoferroviário';
2527
                    break;
2528
                case '3':
2529
                    $stringU = 'Rodoviário';
2530
                    break;
2531
            }
2532
            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...
2533
        }
2534
    }
2535
2536
    /**
2537
     * multiUniPeso
2538
     * Fornece a imformação multiplicação de peso contida na CTe
2539
     *
2540
     * @param  interger $U Informação de peso extraida da CTe
2541
     * @return interger
2542
     */
2543
    protected function multiUniPeso($U = '')
2544
    {
2545
        if ($U === "01") {
2546
            // tonelada
2547
            //return 1000;
2548
            return 1;
2549
        }
2550
        return 1; // M3, KG, Unidade, litros, mmbtu
2551
    }
2552
2553
    protected function qrCodeDacteOs($y = 0)
2554
    {
2555
        $margemInterna = $this->margemInterna;
2556
        $barcode = new Barcode();
2557
        $bobj = $barcode->getBarcodeObj(
2558
            'QRCODE,M',
2559
            $this->qrCodMDFe,
2560
            -4,
2561
            -4,
2562
            'black',
2563
            array(-1, -1, -1, -1)
2564
        )->setBackgroundColor('white');
2565
        $qrcode = $bobj->getPngData();
2566
        $wQr = 36;
2567
        $hQr = 36;
2568
        $yQr = ($y + $margemInterna);
2569
        if ($this->orientacao == 'P') {
2570
            $xQr = 170;
2571
        } else {
2572
            $xQr = 250;
2573
        }
2574
        // prepare a base64 encoded "data url"
2575
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
2576
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
2577
    }
2578
    
2579
    /**
2580
     * Add the credits to the integrator in the footer message
2581
     * @param string $message
2582
     */
2583
    public function creditsIntegratorFooter($message = '')
2584
    {
2585
        $this->creditos = trim($message);
2586
    }
2587
}
2588