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

DacteOS::loadDoc()   B

Complexity

Conditions 8
Paths 15

Size

Total Lines 72

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 0
Metric Value
cc 8
nc 15
nop 1
dl 0
loc 72
ccs 0
cts 68
cp 0
crap 72
rs 7.3664
c 0
b 0
f 0

How to fix   Long Method   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2019 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Com\Tecnick\Barcode\Barcode;
19
use Exception;
20
use NFePHP\DA\Legacy\Dom;
21
use NFePHP\DA\Legacy\Pdf;
22
use NFePHP\DA\Common\DaCommon;
23
24
class DacteOS extends DaCommon
25
{
26
    protected $logoAlign = 'C';
27
    protected $yDados = 0;
28
    protected $numero_registro_dpec = '';
29
    protected $pdf;
30
    protected $xml;
31
    protected $errMsg = '';
32
    protected $errStatus = false;
33
    protected $orientacao = 'P';
34
    protected $papel = 'A4';
35
    protected $fontePadrao = 'Times';
36
    protected $wPrint;
37
    protected $hPrint;
38
    protected $dom;
39
    protected $infCte;
40
    protected $infPercurso;
41
    protected $infCteComp;
42
    protected $chaveCTeRef;
43
    protected $tpCTe;
44
    protected $ide;
45
    protected $emit;
46
    protected $enderEmit;
47
    protected $infCarga;
48
    protected $infQ;
49
    protected $seg;
50
    protected $modal;
51
    protected $rodo;
52
    protected $moto;
53
    protected $veic;
54
    protected $ferrov;
55
    protected $Comp;
56
    protected $infNF;
57
    protected $infNFe;
58
    protected $compl;
59
    protected $ICMS;
60
    protected $imp;
61
    protected $toma4;
62
    protected $toma03;
63
    protected $tpEmis;
64
    protected $tpImp;
65
    protected $tpAmb;
66
    protected $vPrest;
67
    protected $infServico;
68
    protected $wAdic = 150;
69
    protected $textoAdic = '';
70
    protected $formatPadrao;
71
    protected $formatNegrito;
72
    protected $aquav;
73
    protected $preVisualizar;
74
    protected $flagDocOrigContinuacao;
75
    protected $arrayNFe = array();
76
    protected $siteDesenvolvedor;
77
    protected $nomeDesenvolvedor;
78
    protected $totPag;
79
    protected $idDocAntEle = [];
80
    protected $lota;
81
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
82
    protected $margemInterna = 0;
83
    protected $creditos;
84
85
    /**
86
     * __construct
87
     *
88
     * @param string $xml Arquivo XML da CTe
89
     */
90
    public function __construct(
91
        $xml = ''
92
    ) {
93
        $this->loadDoc($xml);
94
    }
95
96
    private function loadDoc($xml)
97
    {
98
        $this->xml = $xml;
99
        if (!empty($xml)) {
100
            $this->dom = new Dom();
101
            $this->dom->loadXML($this->xml);
102
            $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...
103
            if (empty($this->dom->getElementsByTagName("infCte")->item(0))) {
104
                throw new \Exception('Isso não é um CT-e.');
105
            }
106
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
107
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
108
            if ($this->getTagValue($this->ide, "mod") != '67') {
109
                throw new \Exception("O xml deve ser CT-e modelo 67.");
110
            }
111
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
112
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
113
            $this->infPercurso = $this->dom->getElementsByTagName("infPercurso");
114
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
115
            $this->infQ = $this->dom->getElementsByTagName("infQ");
116
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
117
            $this->rodo = $this->dom->getElementsByTagName("rodoOS")->item(0);
118
            $this->veic = $this->dom->getElementsByTagName("veic");
119
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
120
            // adicionar outros modais
121
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
122
            $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chave");
123
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
124
            $this->Comp = $this->dom->getElementsByTagName("Comp");
125
            $this->infNF = $this->dom->getElementsByTagName("infNF");
126
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
127
            $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...
128
            $this->infServico = $this->dom->getElementsByTagName("infServico");
129
            $this->compl = $this->dom->getElementsByTagName("compl");
130
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
131
            $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...
132
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
133
134
            $vTrib = $this->getTagValue($this->imp, "vTotTrib");
135
            if (!is_numeric($vTrib)) {
136
                $vTrib = 0;
137
            }
138
            $textoAdic = number_format($vTrib, 2, ",", ".");
139
            $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
140
                .$textoAdic;
141
            $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...
142
            $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...
143
            //modal aquaviário
144
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
145
            $seguro = $this->getTagValue($this->seg, "respSeg");
146
            switch ($seguro) {
147
                case '4':
148
                    $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...
149
                    break;
150
                case '5':
151
                    $this->respSeg = 'Tomador do Serviço';
152
                    break;
153
                default:
154
                    $this->respSeg = '';
155
                    break;
156
            }
157
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
158
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
159
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
160
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
161
            $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...
162
            $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...
163
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE';
164
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
165
            $this->modal = $this->getTagValue($this->ide, "modal");
166
        }
167
    }
168
169
170
    protected function cteDPEC()
171
    {
172
        return $this->numero_registro_dpec != '';
173
    }
174
175
176
    /**
177
     * montaDACTE
178
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
179
     * durante sua construção.
180
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
181
     * pelo conteúdo da funçao e podem ser modificados.
182
     *
183
     * @param  string $orientacao (Opcional) Estabelece a orientação da
184
     *                impressão (ex. P-retrato), se nada for fornecido será
185
     *                usado o padrão da NFe
186
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
187
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
188
     */
189
    public function monta(
190
        $logo = '',
191
        $orientacao = '',
192
        $papel = 'A4',
193
        $logoAlign = 'C'
194
    ) {
195
        $this->pdf = '';
196
        $this->logomarca = $this->adjustImage($logo);
197
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
198
        if ($orientacao == '') {
199
            if ($this->tpImp == '1') {
200
                $orientacao = 'P';
201
            } else {
202
                $orientacao = 'P';
203
            }
204
        }
205
        $this->orientacao = $orientacao;
206
        $this->papel = $papel;
207
        $this->logoAlign = $logoAlign;
208
        //instancia a classe pdf
209
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
210
        $this->formatPadrao = array(
211
            'font' => $this->fontePadrao,
212
            'size' => 6,
213
            'style' => '');
214
        $this->formatNegrito = array(
215
            'font' => $this->fontePadrao,
216
            'size' => 7,
217
            'style' => 'B');
218
        if ($this->orientacao == 'P') {
219
            // margens do PDF
220
            $margSup = 2;
221
            $margEsq = 2;
222
            $margDir = 2;
223
            // posição inicial do relatorio
224
            $xInic = 1;
225
            $yInic = 1;
226
            if ($papel == 'A4') {
227
                //A4 210x297mm
228
                $maxW = 210;
229
                $maxH = 297;
230
            }
231
        } else {
232
            // margens do PDF
233
            $margSup = 3;
234
            $margEsq = 3;
235
            $margDir = 3;
236
            // posição inicial do relatorio
237
            $xInic = 5;
238
            $yInic = 5;
239
            if ($papel == 'A4') {
240
                //A4 210x297mm
241
                $maxH = 210;
242
                $maxW = 297;
243
                $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...
244
            }
245
        }
246
        //total inicial de paginas
247
        $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...
248
        //largura imprimivel em mm
249
        $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...
250
        //comprimento imprimivel em mm
251
        $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...
252
        // estabelece contagem de paginas
253
        $this->pdf->aliasNbPages();
254
        // fixa as margens
255
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
256
        $this->pdf->setDrawColor(0, 0, 0);
257
        $this->pdf->setFillColor(255, 255, 255);
258
        // inicia o documento
259
        $this->pdf->open();
260
        // adiciona a primeira página
261
        $this->pdf->addPage($this->orientacao, $this->papel);
262
        $this->pdf->setLineWidth(0.1);
263
        $this->pdf->setTextColor(0, 0, 0);
264
        //calculo do numero de páginas ???
265
        $totPag = 1;
266
        //montagem da primeira página
267
        $pag = 1;
268
        $x = $xInic;
269
        $y = $yInic;
270
        //coloca o cabeçalho
271
        //$r = $this->cabecalho($x, $y, $pag, $totPag);
272
        $y += 70;
273
        $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...
274
        if ($this->tpCTe == '0') {
275
            //Normal
276
            $y += 10;
277
            $x = $xInic;
278
            //$r = $this->zDocOrig($x, $y);
279
            $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...
280
            $y += 53;
281
            $x = $xInic;
282
            $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...
283
            $y += 25;
284
            $x = $xInic;
285
            $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...
286
            $y += 13;
287
            $x = $xInic;
288
            $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...
289
            $y += 19;
290
            $x = $xInic;
291
            $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...
292
            $y = $y-12;
293
            switch ($this->modal) {
294
                case '1':
295
                    $y += 24.9;
296
                    $x = $xInic;
297
                    $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...
298
                    break;
299
                case '2':
300
                    $y += 17.9;
301
                    $x = $xInic;
302
                    // TODO fmertins 31/10/14: este método não existe...
303
                    $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...
304
                    break;
305
                case '3':
306
                    $y += 17.9;
307
                    $x = $xInic;
308
                    $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...
309
                    break;
310
                case '4':
311
                    $y += 17.9;
312
                    $x = $xInic;
313
                    $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...
314
                    break;
315
                case '5':
316
                    $y += 17.9;
317
                    $x = $xInic;
318
                    // TODO fmertins 31/10/14: este método não existe...
319
                    $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...
320
                    break;
321
            }
322
            if ($this->modal == '1') {
323
                if ($this->lota == 1) {
324
                    $y += 37;
325
                } else {
326
                    $y += 8.9;
327
                }
328
            } elseif ($this->modal == '3') {
329
                $y += 24.15;
330
            } else {
331
                $y += 37;
332
            }
333
        } else {
334
            $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...
335
            //Complementado
336
            $y += 10;
337
            $x = $xInic;
338
            $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...
339
            $y += 80;
340
            $x = $xInic;
341
            $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...
342
            $y += 25;
343
            $x = $xInic;
344
            $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...
345
            $y += 13;
346
            $x = $xInic;
347
            $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...
348
            $y += 15;
349
        }
350
        $x = $xInic;
351
        $y += 1;
352
        $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...
353
354
        $y += 21;
355
        //$y += 11;
356
        $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...
357
358
        //coloca o rodapé da página
359
        if ($this->orientacao == 'P') {
360
            $this->rodape(2, $this->hPrint - 2);
361
        } else {
362
            $this->rodape($xInic, $this->hPrint + 2.3);
363
        }
364
        if ($this->flagDocOrigContinuacao == 1) {
365
            $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...
366
        }
367
    }
368
369
    /**
370
     * cabecalho
371
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
372
     *
373
     * @param  number $x Posição horizontal inicial, canto esquerdo
374
     * @param  number $y Posição vertical inicial, canto superior
375
     * @param  number $pag Número da Página
376
     * @param  number $totPag Total de páginas
377
     * @return number Posição vertical final
378
     */
379
    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...
380
    {
381
        $oldX = $x;
382
        $oldY = $y;
383
        if ($this->orientacao == 'P') {
384
            $maxW = $this->wPrint;
385
        } else {
386
            if ($pag == 1) {
387
                // primeira página
388
                $maxW = $this->wPrint - $this->wCanhoto;
389
            } else {
390
                // páginas seguintes
391
                $maxW = $this->wPrint;
392
            }
393
        }
394
        //##################################################################
395
        //coluna esquerda identificação do emitente
396
        $w = round($maxW * 0.42);
397
        if ($this->orientacao == 'P') {
398
            $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...
399
                'font' => $this->fontePadrao,
400
                'size' => 6,
401
                'style' => '');
402
        } else {
403
            $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...
404
        }
405
        $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...
406
        $h = 35;
407
        $oldY += $h;
408
        //desenha a caixa
409
        $this->pdf->textBox($x, $y, $w + 2, $h + 1);
410
        // coloca o logo
411
        if (!empty($this->logomarca)) {
412
            $logoInfo = getimagesize($this->logomarca);
413
            //largura da imagem em mm
414
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
415
            //altura da imagem em mm
416
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
417
            if ($this->logoAlign == 'L') {
418
                $nImgW = round($w / 3, 0);
419
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
420
                $xImg = $x + 1;
421
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
422
                //estabelecer posições do texto
423
                $x1 = round($xImg + $nImgW + 1, 0);
424
                $y1 = round($h / 3 + $y, 0);
425
                $tw = round(2 * $w / 3, 0);
426
            } elseif ($this->logoAlign == 'C') {
427
                $nImgH = round($h / 3, 0);
428
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
429
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
430
                $yImg = $y + 3;
431
                $x1 = $x;
432
                $y1 = round($yImg + $nImgH + 1, 0);
433
                $tw = $w;
434
            } elseif ($this->logoAlign == 'R') {
435
                $nImgW = round($w / 3, 0);
436
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
437
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
438
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
439
                $x1 = $x;
440
                $y1 = round($h / 3 + $y, 0);
441
                $tw = round(2 * $w / 3, 0);
442
            }
443
            $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...
444
        } else {
445
            $x1 = $x;
446
            $y1 = round($h / 3 + $y, 0);
447
            $tw = $w;
448
        }
449
        //Nome emitente
450
        $aFont = array(
451
            'font' => $this->fontePadrao,
452
            'size' => 9,
453
            'style' => 'B');
454
        $texto = $this->getTagValue($this->emit, "xNome");
455
        $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...
456
        //endereço
457
        $y1 = $y1 + 3;
458
        $aFont = array(
459
            'font' => $this->fontePadrao,
460
            'size' => 7,
461
            'style' => '');
462
        $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...
463
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
464
        $nro = $this->getTagValue($this->enderEmit, "nro");
465
        $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...
466
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
467
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
468
        $CEP = $this->formatField($CEP, "#####-###");
469
        $mun = $this->getTagValue($this->enderEmit, "xMun");
470
        $UF = $this->getTagValue($this->enderEmit, "UF");
471
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
472
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
473
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
474
            . "\n  Fone/Fax: " . $fone;
475
        $this->pdf->textBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
476
        //CNPJ/CPF IE
477
        $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...
478
        $ie = $this->getTagValue($this->emit, "IE");
479
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
480
        $this->pdf->textBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
481
        //outra caixa
482
        $h1 = 17.5;
483
        $y1 = $y + $h + 1;
484
        $this->pdf->textBox($x, $y1, $w + 2, $h1);
485
        //TIPO DO CT-E
486
        $texto = 'TIPO DO CTE';
487
        $wa = 37;
488
        $aFont = array(
489
            'font' => $this->fontePadrao,
490
            'size' => 8,
491
            'style' => '');
492
        $this->pdf->textBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
493
        $tpCTe = $this->getTagValue($this->ide, "tpCTe");
494
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
495
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
496
        switch ($tpCTe) {
497
            case '0':
498
                $texto = 'Normal';
499
                break;
500
            case '1':
501
                $texto = 'Complemento de Valores';
502
                break;
503
            case '2':
504
                $texto = 'Anulação de Valores';
505
                break;
506
            case '3':
507
                $texto = 'Substituto';
508
                break;
509
            default:
510
                $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...
511
        }
512
        $aFont = $this->formatNegrito;
513
        $this->pdf->textBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
514
        //TIPO DO SERVIÇO
515
        $texto = 'TIPO DO SERVIÇO';
516
        $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...
517
        $aFont = array(
518
            'font' => $this->fontePadrao,
519
            'size' => 8,
520
            'style' => '');
521
        $this->pdf->textBox($x + $wa + 4.5, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
522
        $tpServ = $this->getTagValue($this->ide, "tpServ");
523
        //'6' => 'Transporte de Pessoas', '7' => 'Transporte de Valores', '8' => 'Transporte de Bagagem'
524
        switch ($tpServ) {
525
            case '6':
526
                $texto = 'Transporte de Pessoas';
527
                break;
528
            case '7':
529
                $texto = 'Transporte de Valores';
530
                break;
531
            case '8':
532
                $texto = 'Transporte de Bagagem';
533
                break;
534
            default:
535
                $texto = 'ERRO' . $tpServ;
536
        }
537
        $aFont = $this->formatNegrito;
538
        $this->pdf->textBox($x + $wa + 4.5, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
539
        $this->pdf->line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
540
        //TOMADOR DO SERVIÇO
541
        $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...
542
543
        //##################################################################
544
        //coluna direita
545
        $x += $w + 2;
546
        $w = round($maxW * 0.335);
547
        $w1 = $w;
548
        $h = 11;
549
        $this->pdf->textBox($x, $y, $w + 10, $h + 1);
550
        $texto = "DACTE OS";
551
        $aFont = array(
552
            'font' => $this->fontePadrao,
553
            'size' => 10,
554
            'style' => 'B');
555
        $this->pdf->textBox($x, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
556
        $aFont = array(
557
            'font' => $this->fontePadrao,
558
            'size' => 9,
559
            'style' => '');
560
        $texto = "Documento Auxiliar do Conhecimento\nde Transporte Eletrônico para Outros Serviços";
561
        $h = 10;
562
        $this->pdf->textBox($x, $y + 4, $w, $h, $texto, $aFont, 'T', 'C', 0, '', false);
563
        $x1 = $x + $w + 2;
564
        $w = round($maxW * 0.22, 0);
565
        $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...
566
        $h = 11;
567
        $this->pdf->textBox($x1 + 8, $y, $w - 7.5, $h + 1);
568
        $texto = "MODAL";
569
        $aFont = array(
570
            'font' => $this->fontePadrao,
571
            'size' => 10,
572
            'style' => '');
573
        $this->pdf->textBox($x1, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
574
        switch ($this->modal) {
575
            case '1':
576
                $texto = 'Rodoviário';
577
                break;
578
            case '2':
579
                $texto = 'Aéreo';
580
                break;
581
            case '3':
582
                $texto = 'Aquaviário';
583
                break;
584
            case '4':
585
                $texto = 'Ferroviário';
586
                break;
587
            case '5':
588
                $texto = 'Dutoviário';
589
                break;
590
        }
591
        $aFont = array(
592
            'font' => $this->fontePadrao,
593
            'size' => 10,
594
            'style' => 'B');
595
        $this->pdf->textBox($x1, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
596
        //outra caixa
597
        $y += 12;
598
        $h = 9;
599
        $w = $w1 + 10;
600
        $this->pdf->textBox($x, $y, $w, $h + 1);
601
        //modelo
602
        $wa = 12;
603
        $xa = $x;
604
        $texto = 'MODELO';
605
        $aFont = array(
606
            'font' => $this->fontePadrao,
607
            'size' => 8,
608
            'style' => '');
609
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
610
        $texto = $this->getTagValue($this->ide, "mod");
611
        $aFont = $this->formatNegrito;
612
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
613
        $this->pdf->line($x + $wa, $y, $x + $wa, $y + $h + 1);
614
        //serie
615
        $xa += $wa;
616
        $texto = 'SÉRIE';
617
        $aFont = array(
618
            'font' => $this->fontePadrao,
619
            'size' => 8,
620
            'style' => '');
621
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
622
        $texto = $this->getTagValue($this->ide, "serie");
623
        $aFont = $this->formatNegrito;
624
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
625
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
626
        //numero
627
        $xa += $wa;
628
        $wa = 20;
629
        $texto = 'NÚMERO';
630
        $aFont = array(
631
            'font' => $this->fontePadrao,
632
            'size' => 8,
633
            'style' => '');
634
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
635
        $texto = $this->getTagValue($this->ide, "nCT");
636
        $aFont = $this->formatNegrito;
637
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
638
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
639
        //data  hora de emissão
640
        $xa += $wa;
641
        $wa = 35;
642
        $texto = 'DATA E HORA DE EMISSÃO';
643
        $aFont = array(
644
            'font' => $this->fontePadrao,
645
            'size' => 8,
646
            'style' => '');
647
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
648
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
649
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
650
            date('d/m/Y H:i:s', $this->toTimestamp($this->getTagValue($this->ide, "dhEmi"))) : '';
651
        $aFont = $this->formatNegrito;
652
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
653
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
654
        //outra caixa
655
        $y += $h + 1;
656
        $h = 23;
657
        $h1 = 14;
658
        //$this->pdf->textBox($x, $y, $w + 0.5, $h1);
659
        //CODIGO DE BARRAS
660
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
661
        $bW = 75;
662
        $bH = 10;
663
        //codigo de barras
664
        $this->pdf->setFillColor(0, 0, 0);
665
        $this->pdf->code128($x + 2, $y + 2, $chave_acesso, $bW, $bH);
666
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h - 1);
667
        $this->pdf->textBox($x, $y + $h1, $w + 0.5, $h1 - 6);
668
        $texto = 'CHAVE DE ACESSO';
669
        $aFont = $this->formatPadrao;
670
        $this->pdf->textBox($x + 1, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
671
        $aFont = $this->formatNegrito;
672
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
673
        $this->pdf->textBox($x + 1, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
674
        $this->pdf->textBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
675
        $texto = "Consulta de autenticidade no portal nacional do CT-e, ";
676
        $texto .= "no site da Sefaz Autorizadora, \r\n ou em http://www.cte.fazenda.gov.br";
677
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
678
            $texto = "";
679
            $this->pdf->setFillColor(0, 0, 0);
680
            if ($this->tpEmis == 5) {
681
                $chaveContingencia = $this->geraChaveAdicCont();
682
                $this->pdf->code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
683
            } else {
684
                $chaveContingencia = $this->getTagValue($this->protCTe, "nProt");
685
                $this->pdf->code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
686
            }
687
            //codigo de barras
688
        }
689
        $aFont = array(
690
            'font' => $this->fontePadrao,
691
            'size' => 8,
692
            'style' => '');
693
        $this->pdf->textBox($x, $y + $h1 + 9, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
694
        //outra caixa
695
        $y += $h + 1;
696
        $h = 8.5;
697
        $wa = $w;
698
        $this->pdf->textBox($x, $y + 7.5, $w + 0.5, $h);
699
        if ($this->cteDPEC()) {
700
            $texto = 'NÚMERO DE REGISTRO DPEC';
701
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
702
            $texto = "DADOS DO CT-E";
703
        } else {
704
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
705
        }
706
        $aFont = $this->formatPadrao;
707
        $this->pdf->textBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
708
        if ($this->cteDPEC()) {
709
            $texto = $this->numero_registro_dpec;
710
        } elseif ($this->tpEmis == 5) {
711
            $chaveContingencia = $this->geraChaveAdicCont();
712
            $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...
713
                'font' => $this->fontePadrao,
714
                'size' => 8,
715
                'style' => 'B');
716
            $texto = $this->formatField($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
717
            $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...
718
        } else {
719
            $texto = $this->getTagValue($this->protCTe, "nProt") . " - ";
720
            // empty($volume->getElementsByTagName("qVol")->item(0)->nodeValue)
721
            if (!empty($this->protCTe)
722
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
723
            ) {
724
                $texto .= date(
725
                    'd/m/Y   H:i:s',
726
                    $this->toTimestamp($this->getTagValue($this->protCTe, "dhRecbto"))
727
                );
728
            }
729
            $texto = $this->getTagValue($this->protCTe, "nProt") == '' ? '' : $texto;
730
        }
731
        $aFont = $this->formatNegrito;
732
        $this->pdf->textBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
733
734
        if ($this->qrCodMDFe !== null) {
735
            $this->qrCodeDacteOs($y-25);
736
            $w = 38;
737
            $x += 79;
738
            $this->pdf->textBox($x, $y - 34, $w + 0.5, $h + 41.5);
739
        }
740
        //CFOP
741
        $x = $oldX;
742
        $h = 8.5;
743
        $w = round($maxW * 0.42);
744
        $y1 = $y + 7.5;
745
        $this->pdf->textBox($x, $y1, $w + 2, $h);
746
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
747
        $aFont = array(
748
            'font' => $this->fontePadrao,
749
            'size' => 8,
750
            'style' => '');
751
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
752
        $texto = $this->getTagValue($this->ide, "CFOP") . ' - ' . $this->getTagValue($this->ide, "natOp");
753
        $aFont = $this->formatNegrito;
754
        $this->pdf->textBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
755
        //ORIGEM DA PRESTAÇÃO
756
        $y += $h + 7.5;
757
        $x = $oldX;
758
        $h = 8;
759
        $w = ($maxW * 0.33);
760
        $this->pdf->textBox($x, $y, $w + 0.5, $h);
761
        $texto = 'INÍCIO DA PRESTAÇÃO';
762
        $aFont = array(
763
            'font' => $this->fontePadrao,
764
            'size' => 8,
765
            'style' => '');
766
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
767
        $texto = $this->getTagValue($this->ide, "xMunIni") . ' - ' . $this->getTagValue($this->ide, "UFIni");
768
        $aFont = $this->formatNegrito;
769
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
770
        //PERCURSO DO VEÍCULO
771
        $x = $oldX + 69;
772
        $oldX = $x;
773
        $h = 8;
774
        $w = ($maxW * 0.334);
775
        $this->pdf->textBox($x, $y, $w + 0.5, $h);
776
        $texto = 'PERCURSO DO VEÍCULO';
777
        $aFont = array(
778
            'font' => $this->fontePadrao,
779
            'size' => 8,
780
            'style' => '');
781
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
782
        $texto = '';
783
        $first = true;
784
        if (!empty($this->infPercurso)) {
785
            foreach ($this->infPercurso as $k => $d) {
786
                if (!$first) {
787
                    $texto .= ' - ';
788
                } else {
789
                    $first = false;
790
                }
791
                $texto .= $this->infPercurso->item($k)->getElementsByTagName('UFPer')->item(0)->nodeValue;
792
            }
793
        }
794
        $aFont = $this->formatNegrito;
795
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
796
        //DESTINO DA PRESTAÇÃO
797
        $x = $oldX + $w + 1;
798
        $h = 8;
799
        $w = $w - 1.3;
800
        $this->pdf->textBox($x - 0.5, $y, $w + 0.5, $h);
801
        $texto = 'TÉRMINO DA PRESTAÇÃO';
802
        $aFont = array(
803
            'font' => $this->fontePadrao,
804
            'size' => 8,
805
            'style' => '');
806
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
807
        $texto = $this->getTagValue($this->ide, "xMunFim") . ' - ' . $this->getTagValue($this->ide, "UFFim");
808
        $aFont = $this->formatNegrito;
809
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
810
        //#########################################################################
811
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
812
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
813
        //indicar cancelamento
814
        $cStat = $this->getTagValue($this->cteProc, "cStat");
815
        if ($cStat == '101' || $cStat == '135') {
816
            //101 Cancelamento
817
            $x = 10;
818
            $y = $this->hPrint - 130;
819
            $h = 25;
820
            $w = $maxW - (2 * $x);
821
            $this->pdf->setTextColor(90, 90, 90);
822
            $texto = "CTe CANCELADO";
823
            $aFont = array(
824
                'font' => $this->fontePadrao,
825
                'size' => 48,
826
                'style' => 'B');
827
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
828
            $this->pdf->setTextColor(0, 0, 0);
829
        }
830
        $cStat = $this->getTagValue($this->cteProc, "cStat");
831
        if ($cStat == '110' ||
832
            $cStat == '301' ||
833
            $cStat == '302'
834
        ) {
835
            //110 Denegada
836
            $x = 10;
837
            $y = $this->hPrint - 130;
838
            $h = 25;
839
            $w = $maxW - (2 * $x);
840
            $this->pdf->setTextColor(90, 90, 90);
841
            $texto = "CTe USO DENEGADO";
842
            $aFont = array(
843
                'font' => $this->fontePadrao,
844
                'size' => 48,
845
                'style' => 'B');
846
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
847
            $y += $h;
848
            $h = 5;
849
            $w = $maxW - (2 * $x);
850
            $texto = "SEM VALOR FISCAL";
851
            $aFont = array(
852
                'font' => $this->fontePadrao,
853
                'size' => 48,
854
                'style' => 'B');
855
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
856
            $this->pdf->setTextColor(0, 0, 0);
857
        }
858
        //indicar sem valor
859
        if ($tpAmb != 1) { // caso não seja uma DA de produção
860
            $x = 10;
861
            if ($this->orientacao == 'P') {
862
                $y = round($this->hPrint / 2, 0);
863
            } else {
864
                $y = round($this->hPrint / 2, 0);
865
            }
866
            $h = 5;
867
            $w = $maxW - (2 * $x);
868
            $this->pdf->setTextColor(90, 90, 90);
869
            $texto = "SEM VALOR FISCAL";
870
            $aFont = array(
871
                'font' => $this->fontePadrao,
872
                'size' => 48,
873
                'style' => 'B');
874
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
875
            $aFont = array(
876
                'font' => $this->fontePadrao,
877
                'size' => 30,
878
                'style' => 'B');
879
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
880
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
881
            $this->pdf->setTextColor(0, 0, 0);
882
        } elseif ($this->preVisualizar=='1') { // caso seja uma DA de Pré-Visualização
883
            $h = 5;
884
            $w = $maxW - (2 * 10);
885
            $x = 55;
886
            $y = 240;
887
            $this->pdf->setTextColor(255, 100, 100);
888
            $aFont = array(
889
                'font' => $this->fontePadrao,
890
                'size' => 40,
891
                'style' => 'B');
892
            $texto = "Pré-visualização";
893
            $this->pdf->textBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
894
            $this->pdf->setTextColor(255, 100, 100);
895
            $aFont = array(
896
                'font' => $this->fontePadrao,
897
                'size' => 41,
898
                'style' => 'B');
899
            $texto = "Sem Validade Jurídica";
900
            $this->pdf->textBox90($x+20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
901
            $this->pdf->setTextColor(90, 90, 90);
902
            $texto = "SEM VALOR FISCAL";
903
            $aFont = array(
904
                'font' => $this->fontePadrao,
905
                'size' => 48,
906
                'style' => 'B');
907
            $this->pdf->textBox90($x+40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
908
            $this->pdf->setTextColor(0, 0, 0); // voltar a cor default
909
        } else {
910
            $x = 10;
911
            if ($this->orientacao == 'P') {
912
                $y = round($this->hPrint * 2 / 3, 0);
913
            } else {
914
                $y = round($this->hPrint / 2, 0);
915
            } //fim orientacao
916
            $h = 5;
917
            $w = $maxW - (2 * $x);
918
            $this->pdf->setTextColor(90, 90, 90);
919
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
920
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->cteDPEC()) {
921
                //Contingência
922
                $texto = "DACTE Emitido em Contingência";
923
                $aFont = array(
924
                    'font' => $this->fontePadrao,
925
                    'size' => 48,
926
                    'style' => 'B');
927
                $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
928
                $aFont = array(
929
                    'font' => $this->fontePadrao,
930
                    'size' => 30,
931
                    'style' => 'B');
932
                $texto = "devido à problemas técnicos";
933
                $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
934
            } else {
935
                if (!isset($this->protCTe)) {
936
                    if (!$this->cteDPEC()) {
937
                        $texto = "SEM VALOR FISCAL";
938
                        $aFont = array(
939
                            'font' => $this->fontePadrao,
940
                            'size' => 48,
941
                            'style' => 'B');
942
                        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
943
                    }
944
                    $aFont = array(
945
                        'font' => $this->fontePadrao,
946
                        'size' => 30,
947
                        'style' => 'B');
948
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
949
                    if (!$this->cteDPEC()) {
950
                        $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
951
                    } else {
952
                        $this->pdf->textBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
953
                    }
954
                } //fim cteProc
955
                if ($this->tpEmis == 4) {
956
                    //DPEC
957
                    $x = 10;
958
                    $y = $this->hPrint - 130;
959
                    $h = 25;
960
                    $w = $maxW - (2 * $x);
961
                    $this->pdf->setTextColor(200, 200, 200); // 90,90,90 é muito escuro
962
                    $texto = "DACTE impresso em contingência -\n"
963
                        . "DPEC regularmente recebido pela Receita\n"
964
                        . "Federal do Brasil";
965
                    $aFont = array(
966
                        'font' => $this->fontePadrao,
967
                        'size' => 48,
968
                        'style' => 'B');
969
                    $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
970
                    $this->pdf->setTextColor(0, 0, 0);
971
                }
972
            } //fim tpEmis
973
            $this->pdf->setTextColor(0, 0, 0);
974
        }
975
        return $oldY;
976
    }
977
978
    /**
979
     * rodapeDACTE
980
     * Monta o rodape no final da DACTE ( retrato e paisagem )
981
     *
982
     * @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...
983
     * @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...
984
     */
985
    protected function rodape($x, $y)
986
    {
987
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
988
        $w = $this->wPrint - 4;
989
        $aFont = array(
990
            'font' => $this->fontePadrao,
991
            'size' => 6,
992
            'style' => '');
993
        $this->pdf->textBox($x-1, $y+2, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
994
995
        $texto = $this->creditos .  "  Powered by NFePHP®";
996
        $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...
997
    }
998
999
    /**
1000
     * tomador
1001
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1002
     *
1003
     * @param  number $x Posição horizontal canto esquerdo
1004
     * @param  number $y Posição vertical canto superior
1005
     * @return number Posição vertical final
1006
     */
1007
    protected function tomador($x = 0, $y = 0)
1008
    {
1009
        $oldX = $x;
1010
        $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...
1011
        if ($this->orientacao == 'P') {
1012
            $maxW = $this->wPrint;
1013
        } else {
1014
            $maxW = $this->wPrint - $this->wCanhoto;
1015
        }
1016
        $w = $maxW;
1017
        $h = 10;
1018
        $texto = 'TOMADOR DO SERVIÇO';
1019
        $aFont = $this->formatPadrao;
1020
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1021
        $aFont = $this->formatNegrito;
1022
        $texto = $this->getTagValue($this->toma, "xNome");
1023
        $this->pdf->textBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1024
        $x = $maxW * 0.60;
1025
        $texto = 'MUNICÍPIO';
1026
        $aFont = $this->formatPadrao;
1027
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1028
        $texto = $this->getTagValue($this->toma, "xMun");
1029
        $aFont = $this->formatNegrito;
1030
        $this->pdf->textBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1031
        $x = $maxW * 0.85;
1032
        $texto = 'UF';
1033
        $aFont = $this->formatPadrao;
1034
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1035
        $texto = $this->getTagValue($this->toma, "UF");
1036
        $aFont = $this->formatNegrito;
1037
        $this->pdf->textBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1038
        $x = $w - 18;
1039
        $texto = 'CEP';
1040
        $aFont = $this->formatPadrao;
1041
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1042
        $texto = $this->formatField($this->getTagValue($this->toma, "CEP"), "#####-###");
1043
        $aFont = $this->formatNegrito;
1044
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1045
        $y += 3;
1046
        $x = $oldX;
1047
        $texto = 'ENDEREÇO';
1048
        $aFont = $this->formatPadrao;
1049
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1050
        $aFont = $this->formatNegrito;
1051
        $texto = $this->getTagValue($this->toma, "xLgr") . ',';
1052
        $texto .= $this->getTagValue($this->toma, "nro");
1053
        $texto .= ($this->getTagValue($this->toma, "xCpl") != "") ?
1054
            ' - ' . $this->getTagValue($this->toma, "xCpl") : '';
1055
        $texto .= ' - ' . $this->getTagValue($this->toma, "xBairro");
1056
        $this->pdf->textBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1057
        $y += 3;
1058
        $texto = 'CNPJ/CPF';
1059
        $aFont = $this->formatPadrao;
1060
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1061
        $texto = $this->formatCNPJCPF($this->toma);
1062
        $aFont = $this->formatNegrito;
1063
        $this->pdf->textBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1064
        $x = $x + 65;
1065
        $texto = 'INSCRIÇÃO ESTADUAL';
1066
        $aFont = $this->formatPadrao;
1067
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1068
        $texto = $this->getTagValue($this->toma, "IE");
1069
        $aFont = $this->formatNegrito;
1070
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1071
        $x = $w * 0.75;
1072
        $texto = 'PAÍS';
1073
        $aFont = $this->formatPadrao;
1074
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1075
        $texto = $this->getTagValue($this->toma, "xPais") != "" ?
1076
            $this->getTagValue($this->toma, "xPais") : 'BRASIL';
1077
        $aFont = $this->formatNegrito;
1078
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1079
        $x = $w - 27;
1080
        $texto = 'FONE';
1081
        $aFont = $this->formatPadrao;
1082
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1083
        $texto = $this->getTagValue($this->toma, "fone")!=""? $this->formatFone($this->toma):'';
1084
        $aFont = $this->formatNegrito;
1085
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1086
    }
1087
1088
    /**
1089
     * compValorServ
1090
     * Monta o campo com os componentes da prestação de serviços.
1091
     *
1092
     * @param  number $x Posição horizontal canto esquerdo
1093
     * @param  number $y Posição vertical canto superior
1094
     * @return number Posição vertical final
1095
     */
1096
    protected function compValorServ($x = 0, $y = 0)
1097
    {
1098
        $oldX = $x;
1099
        $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...
1100
        if ($this->orientacao == 'P') {
1101
            $maxW = $this->wPrint;
1102
        } else {
1103
            $maxW = $this->wPrint - $this->wCanhoto;
1104
        }
1105
        $w = $maxW;
1106
        $h = 25;
1107
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1108
        $aFont = $this->formatPadrao;
1109
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1110
        $y += 3.4;
1111
        $this->pdf->line($x, $y, $w + 1, $y);
1112
        $texto = 'NOME';
1113
        $aFont = $this->formatPadrao;
1114
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1115
        $yIniDados = $y;
1116
        $x = $w * 0.14;
1117
        $texto = 'VALOR';
1118
        $aFont = $this->formatPadrao;
1119
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1120
        $x = $w * 0.28;
1121
        $this->pdf->line($x, $y, $x, $y + 21.5);
1122
        $texto = 'NOME';
1123
        $aFont = $this->formatPadrao;
1124
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1125
        $x = $w * 0.42;
1126
        $texto = 'VALOR';
1127
        $aFont = $this->formatPadrao;
1128
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1129
        $x = $w * 0.56;
1130
        $this->pdf->line($x, $y, $x, $y + 21.5);
1131
        $texto = 'NOME';
1132
        $aFont = $this->formatPadrao;
1133
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1134
        $x = $w * 0.70;
1135
        $texto = 'VALOR';
1136
        $aFont = $this->formatPadrao;
1137
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1138
        $x = $w * 0.86;
1139
        $this->pdf->line($x, $y, $x, $y + 21.5);
1140
        $y += 1;
1141
        $texto = 'VALOR TOTAL DO SERVIÇO';
1142
        $aFont = $this->formatPadrao;
1143
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1144
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1145
        $aFont = array(
1146
            'font' => $this->fontePadrao,
1147
            'size' => 9,
1148
            'style' => 'B');
1149
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1150
        $y += 10;
1151
        $this->pdf->line($x, $y, $w + 1, $y);
1152
        $y += 1;
1153
        $texto = 'VALOR A RECEBER';
1154
        $aFont = $this->formatPadrao;
1155
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1156
        $texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
1157
        $aFont = array(
1158
            'font' => $this->fontePadrao,
1159
            'size' => 9,
1160
            'style' => 'B');
1161
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1162
        $auxX = $oldX;
1163
        $yIniDados += 4;
1164
1165
        foreach ($this->Comp as $k => $d) {
1166
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1167
            $valor = number_format(
1168
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1169
                2,
1170
                ",",
1171
                "."
1172
            );
1173
            if ($auxX > $w * 0.60) {
1174
                $yIniDados = $yIniDados + 4;
1175
                $auxX = $oldX;
1176
            }
1177
            $texto = $nome;
1178
            $aFont = $this->formatPadrao;
1179
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1180
            $auxX += $w * 0.14;
1181
            $texto = $valor;
1182
            $aFont = $this->formatPadrao;
1183
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1184
            $auxX += $w * 0.14;
1185
        }
1186
    } //fim da função compValorDACTE
1187
1188
    /**
1189
     * impostos
1190
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1191
     *
1192
     * @param  number $x Posição horizontal canto esquerdo
1193
     * @param  number $y Posição vertical canto superior
1194
     * @return number Posição vertical final
1195
     */
1196
    protected function impostos($x = 0, $y = 0)
1197
    {
1198
        $oldX = $x;
1199
        $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...
1200
        if ($this->orientacao == 'P') {
1201
            $maxW = $this->wPrint;
1202
        } else {
1203
            $maxW = $this->wPrint - $this->wCanhoto;
1204
        }
1205
        $w = $maxW;
1206
        $h = 13;
1207
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1208
        $aFont = $this->formatPadrao;
1209
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1210
1211
        $y += 3.4;
1212
        $this->pdf->line($x, $y, $w + 1, $y);
1213
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1214
        $aFont = $this->formatPadrao;
1215
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1216
1217
        $x += $w * 0.26;
1218
        $this->pdf->line($x, $y, $x, $y + 9.5);
1219
        $texto = 'BASE DE CALCULO';
1220
        $aFont = $this->formatPadrao;
1221
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1222
1223
        $wCol02=0.18;
1224
        $x += $w * $wCol02;
1225
        $this->pdf->line($x, $y, $x, $y + 9.5);
1226
        $texto = 'ALÍQ ICMS';
1227
        $aFont = $this->formatPadrao;
1228
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1229
1230
        $x += $w * $wCol02;
1231
        $this->pdf->line($x, $y, $x, $y + 9.5);
1232
        $texto = 'VALOR ICMS';
1233
        $aFont = $this->formatPadrao;
1234
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1235
1236
        $x += $w * $wCol02;
1237
        $this->pdf->line($x, $y, $x, $y + 9.5);
1238
        $texto = '% RED. BC ICMS';
1239
        $aFont = $this->formatPadrao;
1240
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1241
1242
        /*$x += $w * 0.14;
1243
        $this->pdf->line($x, $y, $x, $y + 9.5);
1244
        $texto = 'ICMS ST';
1245
        $aFont = $this->formatPadrao;
1246
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1247
         * */
1248
1249
        $x = $oldX;
1250
        $y = $y + 4;
1251
        $texto = $this->getTagValue($this->ICMS, "CST");
1252
        switch ($texto) {
1253
            case '00':
1254
                $texto = "00 - Tributação normal ICMS";
1255
                break;
1256
            case '20':
1257
                $texto = "20 - Tributação com BC reduzida do ICMS";
1258
                break;
1259
            case '40':
1260
                $texto = "40 - ICMS isenção";
1261
                break;
1262
            case '41':
1263
                $texto = "41 - ICMS não tributada";
1264
                break;
1265
            case '51':
1266
                $texto = "51 - ICMS diferido";
1267
                break;
1268
            case '60':
1269
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
1270
                break;
1271
            case '90':
1272
                $texto = "90 - ICMS outros";
1273
                break;
1274
        }
1275
        $texto = $this->getTagValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
1276
        $aFont = $this->formatNegrito;
1277
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1278
        $x += $w * 0.26;
1279
1280
        $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
1281
            number_format($this->getTagValue($this->ICMS, "vBC"), 2, ",", ".") : '';
1282
        $aFont = $this->formatNegrito;
1283
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1284
        $x += $w * $wCol02;
1285
1286
        $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
1287
            number_format($this->getTagValue($this->ICMS, "pICMS"), 2, ",", ".") : '';
1288
        $aFont = $this->formatNegrito;
1289
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1290
        $x += $w * $wCol02;
1291
1292
        $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
1293
            number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : '';
1294
        $aFont = $this->formatNegrito;
1295
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1296
        $x += $w * $wCol02;
1297
1298
        $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
1299
            number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".").'%' :'';
1300
        $aFont = $this->formatNegrito;
1301
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1302
1303
        /*$x += $w * 0.14;
1304
        $texto = '';
1305
        $aFont = $this->formatNegrito;
1306
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1307
    } //fim da função compValorDACTE
1308
1309
    /**
1310
     * geraChaveAdicCont
1311
     *
1312
     * @return string chave
1313
     */
1314
    protected function geraChaveAdicCont()
1315
    {
1316
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
1317
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
1318
        $forma = "%02d%d%s%014d%01d%01d%02d";
1319
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
1320
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
1321
        $CNPJ = substr($CNPJ, -14);
1322
        $vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
1323
        $ICMS_CST = $this->getTagValue($this->ICMS, "CST");
1324
        switch ($ICMS_CST) {
1325
            case '00':
1326
            case '20':
1327
                $ICMSp = '1';
1328
                $ICMSs = '2';
1329
                break;
1330
            case '40':
1331
            case '41':
1332
            case '51':
1333
            case '90':
1334
                $ICMSp = '2';
1335
                $ICMSs = '2';
1336
                break;
1337
            case '60':
1338
                $ICMSp = '2';
1339
                $ICMSs = '1';
1340
                break;
1341
        }
1342
        $dd = $this->ide->getElementsByTagName('dEmi')->item(0)->nodeValue;
1343
        $rpos = strrpos($dd, '-');
1344
        $dd = substr($dd, $rpos + 1);
1345
        $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...
1346
        $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...
1347
        return $chave;
1348
    } //fim geraChaveAdicCont
1349
1350
    /**
1351
     * infPrestacaoServico
1352
     * Monta o campo com das informações da prestação do serviço
1353
     *
1354
     * @param  number $x Posição horizontal canto esquerdo
1355
     * @param  number $y Posição vertical canto superior
1356
     * @return number Posição vertical final
1357
     */
1358
    protected function infPrestacaoServico($x = 0, $y = 0)
1359
    {
1360
        $oldX = $x;
1361
        $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...
1362
        if ($this->orientacao == 'P') {
1363
            $maxW = $this->wPrint;
1364
        } else {
1365
            $maxW = $this->wPrint - $this->wCanhoto;
1366
        }
1367
        $w = $maxW;
1368
1369
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
1370
        if ($this->modal == '1') {
1371
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
1372
            // ou combinação veicular, e por viagem
1373
            $h = $this->lota == 1 ? 35 : 53;
1374
        } elseif ($this->modal == '3') {
1375
            $h = 37.6;
1376
        } else {
1377
            $h = 35;
1378
        }
1379
        $texto = 'INFORMAÇÕES DA PRESTAÇÃO DO SERVIÇO';
1380
        $aFont = $this->formatPadrao;
1381
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1382
        $descr1 = 'QUANTIDADE';
1383
        $descr2 = 'DESCRIÇÃO DO SERVIÇO PRESTADO';
1384
1385
        $y += 3.4;
1386
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
1387
        $texto = $descr1;
1388
        $aFont = $this->formatPadrao;
1389
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1390
        $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...
1391
1392
        $x += $w * 0.14;
1393
        if ($this->modal == '1') {
1394
            if ($this->lota == 1) {
1395
                $this->pdf->line($x, $y, $x, $y + 31.5); // TESTE
1396
            } else {
1397
                $this->pdf->line($x, $y, $x, $y + 49.5); // TESTE
1398
            }
1399
        } elseif ($this->modal == '3') {
1400
            $this->pdf->line($x, $y, $x, $y + 34.1);
1401
        } else {
1402
            $this->pdf->line($x, $y, $x, $y + 21.5);
1403
        }
1404
1405
        $x += $w * 0.08;
1406
        $texto = $descr2;
1407
        $aFont = $this->formatPadrao;
1408
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1409
1410
        //$auxX = $oldX;
1411
        //$yIniDados += 3;
1412
1413
        $x = $oldX;
1414
        $y = $y + 4;
1415
        $texto = number_format($this->getTagValue($this->infQ->item(0), "qCarga"), 3, ",", ".");
1416
        $aFont = $this->formatNegrito;
1417
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1418
        $x += $w * 0.26;
1419
1420
        $x = $oldX + 35;
1421
        $texto = $this->getTagValue($this->infServico->item(0), "xDescServ");
1422
        $aFont = $this->formatNegrito;
1423
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1424
        $x += $w * 0.26;
1425
1426
1427
        $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...
1428
        $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...
1429
    }
1430
1431
    /**
1432
     * docCompl
1433
     * Monta o campo com os dados do remetente na DACTE.
1434
     *
1435
     * @param number $x Posição horizontal canto esquerdo
1436
     * @param number $y Posição vertical canto superior
1437
     * @return number Posição vertical final
1438
     */
1439
    protected function docCompl($x = 0, $y = 0)
1440
    {
1441
        $oldX = $x;
1442
        $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...
1443
        if ($this->orientacao == 'P') {
1444
            $maxW = $this->wPrint;
1445
        } else {
1446
            $maxW = $this->wPrint - $this->wCanhoto;
1447
        }
1448
        $w = $maxW;
1449
        $h = 80;
1450
        $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
1451
        $aFont = $this->formatPadrao;
1452
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1453
        $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
1454
        $descr2 = 'VALOR COMPLEMENTADO';
1455
        $y += 3.4;
1456
        $this->pdf->line($x, $y, $w + 1, $y);
1457
        $texto = $descr1;
1458
        $aFont = $this->formatPadrao;
1459
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1460
        $yIniDados = $y;
1461
        $x += $w * 0.37;
1462
        $texto = $descr2;
1463
        $aFont = $this->formatPadrao;
1464
        $this->pdf->textBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1465
        $x += $w * 0.13;
1466
        $this->pdf->line($x, $y, $x, $y + 76.5);
1467
        $texto = $descr1;
1468
        $aFont = $this->formatPadrao;
1469
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1470
        $x += $w * 0.3;
1471
        $texto = $descr2;
1472
        $aFont = $this->formatPadrao;
1473
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1474
        $auxX = $oldX;
1475
        $yIniDados += 4;
1476
        if ($auxX > $w * 0.90) {
1477
            $yIniDados = $yIniDados + 4;
1478
            $auxX = $oldX;
1479
        }
1480
        $texto = $this->chaveCTeRef;
1481
        $aFont = array(
1482
            'font' => $this->fontePadrao,
1483
            'size' => 8,
1484
            'style' => '');
1485
        $this->pdf->textBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1486
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1487
        $aFont = array(
1488
            'font' => $this->fontePadrao,
1489
            'size' => 8,
1490
            'style' => '');
1491
        $this->pdf->textBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1492
    }
1493
1494
    /**
1495
     * observacoes
1496
     * Monta o campo com os dados do remetente na DACTE.
1497
     *
1498
     * @param  number $x Posição horizontal canto esquerdo
1499
     * @param  number $y Posição vertical canto superior
1500
     * @return number Posição vertical final
1501
     */
1502
    protected function observacoes($x = 0, $y = 0)
1503
    {
1504
        $oldX = $x;
1505
        $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...
1506
        if ($this->orientacao == 'P') {
1507
            $maxW = $this->wPrint;
1508
        } else {
1509
            $maxW = $this->wPrint - $this->wCanhoto;
1510
        }
1511
        $w = $maxW;
1512
        //$h = 18;
1513
        $h = 18.8;
1514
        $texto = 'OBSERVAÇÕES GERAIS';
1515
        $aFont = $this->formatPadrao;
1516
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1517
        $y += 3.4;
1518
        $this->pdf->line($x, $y, $w + 1, $y);
1519
        $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...
1520
        $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...
1521
        $texto = '';
1522
        foreach ($this->compl as $k => $d) {
1523
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
1524
            $texto .= $xObs;
1525
        }
1526
        $textoObs = explode("Motorista:", $texto);
1527
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: ".$textoObs[1]: '';
1528
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
1529
        $aFont = array(
1530
            'font' => $this->fontePadrao,
1531
            'size' => 7.5,
1532
            'style' => '');
1533
        $this->pdf->textBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
1534
        $this->pdf->textBox($x, $y+11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
1535
    }
1536
1537
    /**
1538
     * seguro
1539
     * Monta o campo com os dados de seguro do CT-e OS.
1540
     *
1541
     * @param  number $x Posição horizontal canto esquerdo
1542
     * @param  number $y Posição vertical canto superior
1543
     * @return number Posição vertical final
1544
     */
1545
    protected function seguro($x = 0, $y = 0)
1546
    {
1547
        $oldX = $x;
1548
        $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...
1549
        if ($this->orientacao == 'P') {
1550
            $maxW = $this->wPrint;
1551
        } else {
1552
            $maxW = $this->wPrint - $this->wCanhoto;
1553
        }
1554
        $w = $maxW;
1555
        $h = 13;
1556
        $texto = 'SEGURO DA VIAGEM';
1557
        $aFont = $this->formatPadrao;
1558
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1559
1560
        $y += 3.4;
1561
        $this->pdf->line($x, $y, $w + 1, $y);
1562
        $texto = 'RESPONSÁVEL';
1563
        $aFont = $this->formatPadrao;
1564
        $this->pdf->textBox($x, $y, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
1565
1566
        $x += $w * 0.33;
1567
        $this->pdf->line($x, $y, $x, $y + 9.5);
1568
        $texto = 'NOME DA SEGURADORA';
1569
        $aFont = $this->formatPadrao;
1570
        $this->pdf->textBox($x, $y, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
1571
1572
        $wCol02=0.33;
1573
        $x += $w * $wCol02;
1574
        $this->pdf->line($x, $y, $x, $y + 9.5);
1575
        $texto = 'NÚMERO DA APÓLICE';
1576
        $aFont = $this->formatPadrao;
1577
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1578
1579
        $x = $oldX;
1580
        $y = $y + 4;
1581
        $texto = $this->respSeg;
1582
        $aFont = $this->formatNegrito;
1583
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1584
        $x += $w * 0.26;
1585
1586
        $texto = '';
1587
        $aFont = $this->formatNegrito;
1588
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1589
        $x += $w * $wCol02;
1590
1591
        $texto = '';
1592
        $aFont = $this->formatNegrito;
1593
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1594
        $x += $w * $wCol02;
1595
    }
1596
1597
    /**
1598
     * modalRod
1599
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1600
     *
1601
     * @param  number $x Posição horizontal canto esquerdo
1602
     * @param  number $y Posição vertical canto superior
1603
     * @return number Posição vertical final
1604
     */
1605
    protected function modalRod($x = 0, $y = 0)
1606
    {
1607
        $oldX = $x;
1608
        $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...
1609
        if ($this->orientacao == 'P') {
1610
            $maxW = $this->wPrint;
1611
        } else {
1612
            $maxW = $this->wPrint - $this->wCanhoto;
1613
        }
1614
        $w = $maxW;
1615
        $h = 13;
1616
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
1617
        $aFont = $this->formatPadrao;
1618
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1619
1620
        $y += 3.4;
1621
        $this->pdf->line($x, $y, $w + 1, $y);
1622
        $texto = 'TERMO DE AUTORIZAÇÃO DE FRETAMENTO';
1623
        $aFont = $this->formatPadrao;
1624
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1625
1626
        $x += $w * 0.26;
1627
        $this->pdf->line($x, $y, $x, $y + 9.5);
1628
        $texto = 'Nº DE REGISTRO ESTADUAL';
1629
        $aFont = $this->formatPadrao;
1630
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1631
1632
        $wCol02=0.18;
1633
        $x += $w * $wCol02;
1634
        $this->pdf->line($x, $y, $x, $y + 9.5);
1635
        $texto = 'PLACA DO VEÍCULO';
1636
        $aFont = $this->formatPadrao;
1637
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1638
1639
        $x += $w * $wCol02;
1640
        $this->pdf->line($x, $y, $x, $y + 9.5);
1641
        $texto = 'RENAVAM DO VEÍCULO';
1642
        $aFont = $this->formatPadrao;
1643
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1644
1645
        $x += $w * $wCol02;
1646
        $this->pdf->line($x, $y, $x, $y + 9.5);
1647
        $texto = 'CNPJ/CPF';
1648
        $aFont = $this->formatPadrao;
1649
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1650
1651
        $x = $oldX;
1652
        $y = $y + 4;
1653
        $texto = $this->getTagValue($this->rodo, "TAF");
1654
        $aFont = $this->formatNegrito;
1655
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1656
        $x += $w * 0.26;
1657
1658
        $texto = $this->getTagValue($this->rodo, "NroRegEstadual");
1659
        $aFont = $this->formatNegrito;
1660
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1661
        $x += $w * $wCol02;
1662
1663
        $texto = $this->getTagValue($this->veic->item(0), "placa");
1664
        $aFont = $this->formatNegrito;
1665
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1666
        $x += $w * $wCol02;
1667
1668
        $texto = $this->getTagValue($this->veic->item(0), "RENAVAM");
1669
        $aFont = $this->formatNegrito;
1670
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1671
        $x += $w * $wCol02;
1672
1673
        $texto = !empty($this->getTagValue($this->veic->item(0), "CPF")) ?
1674
            $this->getTagValue($this->veic->item(0), "CPF") :
1675
            (!empty($this->getTagValue($this->veic->item(0), "CNPJ")) ?
1676
            $this->getTagValue($this->veic->item(0), "CNPJ") : '');
1677
        $aFont = $this->formatNegrito;
1678
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1679
1680
        /*$x += $w * 0.14;
1681
        $texto = '';
1682
        $aFont = $this->formatNegrito;
1683
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1684
    }
1685
1686
    /**
1687
     * modalAquaviario
1688
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1689
     *
1690
     * @param  number $x Posição horizontal canto esquerdo
1691
     * @param  number $y Posição vertical canto superior
1692
     * @return number Posição vertical final
1693
     */
1694
    protected function modalAquaviario($x = 0, $y = 0)
1695
    {
1696
        $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...
1697
        $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...
1698
        if ($this->orientacao == 'P') {
1699
            $maxW = $this->wPrint;
1700
        } else {
1701
            $maxW = $this->wPrint - $this->wCanhoto;
1702
        }
1703
        $w = $maxW;
1704
        $h = 8.5;
1705
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
1706
        $aFont = $this->formatPadrao;
1707
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
1708
        $y += 3.4;
1709
        $this->pdf->line($x, $y, $w + 1, $y);
1710
        $texto = 'PORTO DE EMBARQUE';
1711
        $aFont = $this->formatPadrao;
1712
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1713
        $texto = $this->getTagValue($this->aquav, "prtEmb");
1714
        $aFont = $this->formatNegrito;
1715
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1716
        $x += $w * 0.50;
1717
        $this->pdf->line($x, $y, $x, $y + 7.7);
1718
        $texto = 'PORTO DE DESTINO';
1719
        $aFont = $this->formatPadrao;
1720
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1721
        $texto = $this->getTagValue($this->aquav, "prtDest");
1722
        $aFont = $this->formatNegrito;
1723
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1724
        $y += 8;
1725
        $this->pdf->line(208, $y, 1, $y);
1726
        $x = 1;
1727
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
1728
        $aFont = $this->formatPadrao;
1729
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1730
        $texto = $this->getTagValue($this->aquav, "xNavio");
1731
        $aFont = $this->formatNegrito;
1732
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1733
        $x += $w * 0.50;
1734
        $this->pdf->line($x, $y, $x, $y + 7.7);
1735
        $texto = 'VR DA B. DE CALC. AFRMM';
1736
        $aFont = $this->formatPadrao;
1737
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1738
        $texto = $this->getTagValue($this->aquav, "vPrest");
1739
        $aFont = $this->formatNegrito;
1740
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1741
        $x += $w * 0.17;
1742
        $this->pdf->line($x, $y, $x, $y + 7.7);
1743
        $texto = 'VALOR DO AFRMM';
1744
        $aFont = $this->formatPadrao;
1745
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1746
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
1747
        $aFont = $this->formatNegrito;
1748
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1749
        $x += $w * 0.12;
1750
        $this->pdf->line($x, $y, $x, $y + 7.7);
1751
        $texto = 'TIPO DE NAVEGAÇÃO';
1752
        $aFont = $this->formatPadrao;
1753
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1754
        $texto = $this->getTagValue($this->aquav, "tpNav");
1755
        switch ($texto) {
1756
            case '0':
1757
                $texto = 'INTERIOR';
1758
                break;
1759
            case '1':
1760
                $texto = 'CABOTAGEM';
1761
                break;
1762
        }
1763
        $aFont = $this->formatNegrito;
1764
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1765
        $x += $w * 0.14;
1766
        $this->pdf->line($x, $y, $x, $y + 7.7);
1767
        $texto = 'DIREÇÃO';
1768
        $aFont = $this->formatPadrao;
1769
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1770
        $texto = $this->getTagValue($this->aquav, "direc");
1771
        switch ($texto) {
1772
            case 'N':
1773
                $texto = 'NORTE';
1774
                break;
1775
            case 'L':
1776
                $texto = 'LESTE';
1777
                break;
1778
            case 'S':
1779
                $texto = 'SUL';
1780
                break;
1781
            case 'O':
1782
                $texto = 'OESTE';
1783
                break;
1784
        }
1785
        $aFont = $this->formatNegrito;
1786
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1787
        $y += 8;
1788
        $this->pdf->line(208, $y, 1, $y);
1789
        $x = 1;
1790
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
1791
        $aFont = $this->formatPadrao;
1792
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1793
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
1794
            $texto = $this->infNF
1795
                ->item(0)
1796
                ->getElementsByTagName('infUnidCarga')
1797
                ->item(0)
1798
                ->getElementsByTagName('idUnidCarga')
1799
                ->item(0)->nodeValue;
1800
        } elseif ($this->infNFe->item(0) !== null
1801
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
1802
        ) {
1803
            $texto = $this->infNFe
1804
                ->item(0)
1805
                ->getElementsByTagName('infUnidCarga')
1806
                ->item(0)
1807
                ->getElementsByTagName('idUnidCarga')
1808
                ->item(0)
1809
                ->nodeValue;
1810
        } elseif ($this->infOutros->item(0) !== null
1811
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
1812
        ) {
1813
            $texto = $this->infOutros
1814
                ->item(0)
1815
                ->getElementsByTagName('infUnidCarga')
1816
                ->item(0)
1817
                ->getElementsByTagName('idUnidCarga')
1818
                ->item(0)
1819
                ->nodeValue;
1820
        } else {
1821
            $texto = '';
1822
        }
1823
        $aFont = $this->formatNegrito;
1824
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1825
        $x += $w * 0.50;
1826
        $this->pdf->line($x, $y, $x, $y + 7.7);
1827
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
1828
        $aFont = $this->formatPadrao;
1829
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
1830
        $texto = '';
1831
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
1832
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
1833
                if ($k == 0) {
1834
                    $texto = $this->aquav
1835
                        ->getElementsByTagName('balsa')
1836
                        ->item($k)
1837
                        ->getElementsByTagName('xBalsa')
1838
                        ->item(0)
1839
                        ->nodeValue;
1840
                } else {
1841
                    $texto = $texto
1842
                        . ' / '
1843
                        . $this->aquav
1844
                            ->getElementsByTagName('balsa')
1845
                            ->item($k)
1846
                            ->getElementsByTagName('xBalsa')
1847
                            ->item(0)
1848
                            ->nodeValue;
1849
                }
1850
            }
1851
        }
1852
        $aFont = $this->formatNegrito;
1853
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
1854
    }
1855
1856
    /**
1857
     * modalFerr
1858
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1859
     *
1860
     * @param  number $x Posição horizontal canto esquerdo
1861
     * @param  number $y Posição vertical canto superior
1862
     * @return number Posição vertical final
1863
     */
1864
    protected function modalFerr($x = 0, $y = 0)
1865
    {
1866
        $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...
1867
        $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...
1868
        if ($this->orientacao == 'P') {
1869
            $maxW = $this->wPrint;
1870
        } else {
1871
            $maxW = $this->wPrint - $this->wCanhoto;
1872
        }
1873
        $w = $maxW;
1874
        $h = 19.6;
1875
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
1876
        $aFont = $this->formatPadrao;
1877
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1878
        $y += 3.4;
1879
        $this->pdf->line($x, $y, $w + 1, $y);
1880
        $texto = 'DCL';
1881
        $aFont = array(
1882
            'font' => $this->fontePadrao,
1883
            'size' => 7,
1884
            'style' => 'B');
1885
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
1886
        $this->pdf->line($x + 49.6, $y, $x + 49.6, $y + 3.5);
1887
        $texto = 'VAGÕES';
1888
        $aFont = array(
1889
            'font' => $this->fontePadrao,
1890
            'size' => 7,
1891
            'style' => 'B');
1892
        $this->pdf->textBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
1893
        $y += 3.4;
1894
        $this->pdf->line($x, $y, $w + 1, $y);
1895
        // DCL
1896
        $texto = 'ID TREM';
1897
        $aFont = array(
1898
            'font' => $this->fontePadrao,
1899
            'size' => 6,
1900
            'style' => '');
1901
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1902
        $texto = $this->getTagValue($this->ferrov, "idTrem");
1903
        $aFont = array(
1904
            'font' => $this->fontePadrao,
1905
            'size' => 6,
1906
            'style' => 'B');
1907
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1908
        $x += $w * 0.06;
1909
        $y1 = $y + 12.5;
1910
        $this->pdf->line($x, $y, $x, $y1);
1911
        $texto = 'NUM';
1912
        $aFont = array(
1913
            'font' => $this->fontePadrao,
1914
            'size' => 6,
1915
            'style' => '');
1916
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1917
        $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...
1918
        $aFont = array(
1919
            'font' => $this->fontePadrao,
1920
            'size' => 6,
1921
            'style' => 'B');
1922
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1923
        $x += $w * 0.06;
1924
        $this->pdf->line($x, $y, $x, $y1);
1925
        $texto = 'SÉRIE';
1926
        $aFont = array(
1927
            'font' => $this->fontePadrao,
1928
            'size' => 6,
1929
            'style' => '');
1930
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1931
        $texto = $this->getTagValue($this->rem, "serie");
1932
        $aFont = array(
1933
            'font' => $this->fontePadrao,
1934
            'size' => 6,
1935
            'style' => 'B');
1936
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1937
        $x += $w * 0.06;
1938
        $this->pdf->line($x, $y, $x, $y1);
1939
        $texto = 'EMISSÃO';
1940
        $aFont = array(
1941
            'font' => $this->fontePadrao,
1942
            'size' => 6,
1943
            'style' => '');
1944
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1945
        $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...
1946
        $aFont = array(
1947
            'font' => $this->fontePadrao,
1948
            'size' => 6,
1949
            'style' => 'B');
1950
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1951
        // VAGOES
1952
        $x += $w * 0.06;
1953
        $this->pdf->line($x, $y, $x, $y1);
1954
        $texto = 'NUM';
1955
        $aFont = array(
1956
            'font' => $this->fontePadrao,
1957
            'size' => 6,
1958
            'style' => '');
1959
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1960
        $texto = $this->getTagValue($this->ferrov, "nVag");
1961
        $aFont = array(
1962
            'font' => $this->fontePadrao,
1963
            'size' => 6,
1964
            'style' => 'B');
1965
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1966
        $x += $w * 0.06;
1967
        $this->pdf->line($x, $y, $x, $y1);
1968
        $texto = 'TIPO';
1969
        $aFont = array(
1970
            'font' => $this->fontePadrao,
1971
            'size' => 6,
1972
            'style' => '');
1973
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1974
        $texto = $this->getTagValue($this->ferrov, "tpVag");
1975
        $aFont = array(
1976
            'font' => $this->fontePadrao,
1977
            'size' => 6,
1978
            'style' => 'B');
1979
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1980
        $x += $w * 0.06;
1981
        $this->pdf->line($x, $y, $x, $y1);
1982
        $texto = 'CAPACIDADE';
1983
        $aFont = array(
1984
            'font' => $this->fontePadrao,
1985
            'size' => 6,
1986
            'style' => '');
1987
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1988
        $texto = $this->getTagValue($this->ferrov, "cap");
1989
        $aFont = array(
1990
            'font' => $this->fontePadrao,
1991
            'size' => 6,
1992
            'style' => 'B');
1993
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
1994
        $x += $w * 0.08;
1995
        $this->pdf->line($x, $y, $x, $y1);
1996
        $texto = 'PESO REAL/TON';
1997
        $aFont = array(
1998
            'font' => $this->fontePadrao,
1999
            'size' => 6,
2000
            'style' => '');
2001
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2002
        $texto = $this->getTagValue($this->ferrov, "pesoR");
2003
        $aFont = array(
2004
            'font' => $this->fontePadrao,
2005
            'size' => 6,
2006
            'style' => 'B');
2007
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2008
        $x += $w * 0.09;
2009
        $this->pdf->line($x, $y, $x, $y1);
2010
        $texto = 'PESO BRUTO/TON';
2011
        $aFont = array(
2012
            'font' => $this->fontePadrao,
2013
            'size' => 6,
2014
            'style' => '');
2015
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2016
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
2017
        $aFont = array(
2018
            'font' => $this->fontePadrao,
2019
            'size' => 6,
2020
            'style' => 'B');
2021
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2022
        $x += $w * 0.1;
2023
        $this->pdf->line($x, $y, $x, $y1);
2024
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
2025
        $aFont = array(
2026
            'font' => $this->fontePadrao,
2027
            'size' => 6,
2028
            'style' => '');
2029
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2030
        $texto = $this->getTagValue($this->ferrov, "nCont");
2031
        $aFont = array(
2032
            'font' => $this->fontePadrao,
2033
            'size' => 6,
2034
            'style' => 'B');
2035
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2036
        // FLUXO
2037
        $x = 1;
2038
        $y += 12.9;
2039
        $h1 = $h * 0.5 + 0.27;
2040
        $wa = round($w * 0.103) + 0.5;
2041
        $texto = 'FLUXO FERROVIARIO';
2042
        $aFont = $this->formatPadrao;
2043
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2044
        $texto = $this->getTagValue($this->ferrov, "fluxo");
2045
        $aFont = array(
2046
            'font' => $this->fontePadrao,
2047
            'size' => 7,
2048
            'style' => 'B');
2049
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2050
        $y += 10;
2051
        $texto = 'TIPO DE TRÁFEGO';
2052
        $aFont = $this->formatPadrao;
2053
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
2054
        $texto = $this->convertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
2055
        $aFont = array(
2056
            'font' => $this->fontePadrao,
2057
            'size' => 7,
2058
            'style' => 'B');
2059
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
2060
        // Novo Box Relativo a Modal Ferroviário
2061
        $x = 22.5;
2062
        $y += -10.2;
2063
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
2064
        $aFont = $this->formatPadrao;
2065
        $this->pdf->textBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
2066
        $y += 3.4;
2067
        $this->pdf->line($x, $y, $w + 1, $y);
2068
        $w = $w * 0.2;
2069
        $h = $h * 1.04;
2070
        $texto = 'CÓDIGO INTERNO';
2071
        $aFont = array(
2072
            'font' => $this->fontePadrao,
2073
            'size' => 6,
2074
            'style' => '');
2075
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2076
        $texto = $this->getTagValue($this->ferrov, "cInt");
2077
        $aFont = array(
2078
            'font' => $this->fontePadrao,
2079
            'size' => 6,
2080
            'style' => 'B');
2081
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2082
        $texto = 'CNPJ';
2083
        $aFont = array(
2084
            'font' => $this->fontePadrao,
2085
            'size' => 6,
2086
            'style' => '');
2087
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2088
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
2089
        $aFont = array(
2090
            'font' => $this->fontePadrao,
2091
            'size' => 6,
2092
            'style' => 'B');
2093
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2094
        $x += 50;
2095
        $texto = 'NOME';
2096
        $aFont = array(
2097
            'font' => $this->fontePadrao,
2098
            'size' => 6,
2099
            'style' => '');
2100
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2101
        $texto = $this->getTagValue($this->ferrov, "xNome");
2102
        $aFont = array(
2103
            'font' => $this->fontePadrao,
2104
            'size' => 6,
2105
            'style' => 'B');
2106
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2107
        $texto = 'INSCRICAO ESTADUAL';
2108
        $aFont = array(
2109
            'font' => $this->fontePadrao,
2110
            'size' => 6,
2111
            'style' => '');
2112
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2113
        $texto = $this->getTagValue($this->ferrov, "IE");
2114
        $aFont = array(
2115
            'font' => $this->fontePadrao,
2116
            'size' => 6,
2117
            'style' => 'B');
2118
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2119
        $x += 50;
2120
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
2121
        $aFont = array(
2122
            'font' => $this->fontePadrao,
2123
            'size' => 6,
2124
            'style' => '');
2125
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2126
        $texto = '';
2127
        $aFont = array(
2128
            'font' => $this->fontePadrao,
2129
            'size' => 6,
2130
            'style' => 'B');
2131
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2132
    }
2133
2134
    /**
2135
     * canhoto
2136
     * Monta o campo com os dados do remetente na DACTE.
2137
     *
2138
     * @param  number $x Posição horizontal canto esquerdo
2139
     * @param  number $y Posição vertical canto superior
2140
     * @return number Posição vertical final
2141
     */
2142
    protected function canhoto($x = 0, $y = 0)
2143
    {
2144
        $this->pdf->dashedHLine($x, $y+2, $this->wPrint, 0.1, 80);
2145
        $y = $y + 2;
2146
        $oldX = $x;
2147
        $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...
2148
        if ($this->orientacao == 'P') {
2149
            $maxW = $this->wPrint;
2150
        } else {
2151
            $maxW = $this->wPrint - $this->wCanhoto;
2152
        }
2153
        $w = $maxW - 1;
2154
        $h = 20;
2155
        $y = $y + 1;
2156
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
2157
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
2158
        $aFont = $this->formatPadrao;
2159
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2160
        $y += 3.4;
2161
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
2162
2163
        $texto = 'NOME';
2164
        $aFont = array(
2165
            'font' => $this->fontePadrao,
2166
            'size' => 6,
2167
            'style' => '');
2168
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
2169
        $x += $w * 0.25;
2170
2171
        $this->pdf->line($x, $y, $x, $y + 16.5);
2172
2173
        $texto = 'ASSINATURA / CARIMBO';
2174
        $aFont = array(
2175
            'font' => $this->fontePadrao,
2176
            'size' => 6,
2177
            'style' => '');
2178
        $this->pdf->textBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
2179
        $x += $w * 0.25;
2180
2181
        $this->pdf->line($x, $y, $x, $y + 16.5);
2182
2183
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n". "\r\n";
2184
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
2185
        $aFont = array(
2186
            'font' => $this->fontePadrao,
2187
            'size' => 6,
2188
            'style' => '');
2189
        $this->pdf->textBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
2190
        $x = $oldX;
2191
        $y = $y + 5;
2192
2193
        $this->pdf->line($x, $y+3, $w * 0.255, $y+3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
2194
2195
        $texto = 'RG';
2196
        $aFont = array(
2197
            'font' => $this->fontePadrao,
2198
            'size' => 6,
2199
            'style' => '');
2200
        $this->pdf->textBox($x, $y+3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
2201
        $x += $w * 0.85;
2202
2203
        $this->pdf->line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
2204
2205
        $texto = "CT-E OS";
2206
        $aFont = $this->formatNegrito;
2207
        $this->pdf->textBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
2208
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
2209
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
2210
        $aFont = array(
2211
            'font' => $this->fontePadrao,
2212
            'size' => 6,
2213
            'style' => '');
2214
        $this->pdf->textBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
2215
        $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...
2216
    }
2217
2218
    /**
2219
     * dadosAdic
2220
     * Coloca o grupo de dados adicionais da DACTE.
2221
     *
2222
     * @param  number $x Posição horizontal canto esquerdo
2223
     * @param  number $y Posição vertical canto superior
2224
     * @param  number $h altura do campo
2225
     * @return number Posição vertical final
2226
     */
2227
    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...
2228
    {
2229
        $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...
2230
        //###########################################################################
2231
        //DADOS ADICIONAIS DACTE
2232
        if ($this->orientacao == 'P') {
2233
            $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...
2234
        } else {
2235
            $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...
2236
        }
2237
        //INFORMAÇÕES COMPLEMENTARES
2238
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
2239
        $y += 3;
2240
        $w = $this->wAdic;
2241
        $h = 20; //mudar
2242
        $aFont = array(
2243
            'font' => $this->fontePadrao,
2244
            'size' => 6,
2245
            'style' => '');
2246
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2247
        //$this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
2248
        $this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
2249
        //o texto com os dados adicionais foi obtido na função xxxxxx
2250
        //e carregado em uma propriedade privada da classe
2251
        //$this->wAdic com a largura do campo
2252
        //$this->textoAdic com o texto completo do campo
2253
        $y += 1;
2254
        $aFont = $this->formatPadrao;
2255
        $this->pdf->textBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
2256
        //RESERVADO AO FISCO
2257
        $texto = "RESERVADO AO FISCO";
2258
        $x += $w;
2259
        $y -= 1;
2260
        if ($this->orientacao == 'P') {
2261
            $w = $this->wPrint - $w;
2262
        } else {
2263
            $w = $this->wPrint - $w - $this->wCanhoto;
2264
        }
2265
        $aFont = array(
2266
            'font' => $this->fontePadrao,
2267
            'size' => 6,
2268
            'style' => '');
2269
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2270
        //inserir texto informando caso de contingência
2271
        //1 – Normal – emissão normal;
2272
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
2273
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
2274
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
2275
        //Emissão em Contingência – DPEC;
2276
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
2277
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
2278
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
2279
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
2280
        $texto = '';
2281
        switch ($this->tpEmis) {
2282
            case 2:
2283
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
2284
                break;
2285
            case 3:
2286
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
2287
                break;
2288
            case 4:
2289
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
2290
                break;
2291
            case 5:
2292
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
2293
                break;
2294
        }
2295
        $y += 2;
2296
        $aFont = $this->formatPadrao;
2297
        $this->pdf->textBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
2298
        return $y + $h;
2299
    }
2300
2301
    /**
2302
     * formatCNPJCPF
2303
     * Formata campo CnpjCpf contida na CTe
2304
     *
2305
     * @param  string $field campo cnpjCpf da CT-e
2306
     * @return string
2307
     */
2308
    protected function formatCNPJCPF($field)
2309
    {
2310
        if (!isset($field)) {
2311
            return '';
2312
        }
2313
        $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...
2314
            $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...
2315
        if ($cnpj != "" && $cnpj != "00000000000000") {
2316
            $cnpj = $this->formatField($cnpj, '###.###.###/####-##');
2317
        } else {
2318
            $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...
2319
                $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...
2320
        }
2321
        return $cnpj;
2322
    }
2323
2324
    /**
2325
     * formatFone
2326
     * Formata campo fone contida na CTe
2327
     *
2328
     * @param  string $field campo fone da CT-e
2329
     * @return string
2330
     */
2331
    protected function formatFone($field)
2332
    {
2333
        try {
2334
            $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...
2335
            $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...
2336
            $foneLen = strlen($fone);
2337
            if ($foneLen > 0) {
2338
                $fone2 = substr($fone, 0, $foneLen - 4);
2339
                $fone1 = substr($fone, 0, $foneLen - 8);
2340
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
2341
            } else {
2342
                $fone = '';
2343
            }
2344
            return $fone;
2345
        } catch (Exception $exc) {
2346
            return '';
2347
        }
2348
    }
2349
2350
    /**
2351
     * unidade
2352
     * Converte a imformação de peso contida na CTe
2353
     *
2354
     * @param  string $c unidade de trafego extraida da CTe
2355
     * @return string
2356
     */
2357
    protected function unidade($c = '')
2358
    {
2359
        switch ($c) {
2360
            case '00':
2361
                $r = 'M3';
2362
                break;
2363
            case '01':
2364
                $r = 'KG';
2365
                break;
2366
            case '02':
2367
                $r = 'TON';
2368
                break;
2369
            case '03':
2370
                $r = 'UN';
2371
                break;
2372
            case '04':
2373
                $r = 'LT';
2374
                break;
2375
            case '05':
2376
                $r = 'MMBTU';
2377
                break;
2378
            default:
2379
                $r = '';
2380
        }
2381
        return $r;
2382
    }
2383
2384
    /**
2385
     * convertUnidTrafego
2386
     * Converte a imformação de peso contida na CTe
2387
     *
2388
     * @param  string $U Informação de trafego extraida da CTe
2389
     * @return string
2390
     */
2391
    protected function convertUnidTrafego($U = '')
2392
    {
2393
        if ($U) {
2394
            switch ($U) {
2395
                case '0':
2396
                    $stringU = 'Próprio';
2397
                    break;
2398
                case '1':
2399
                    $stringU = 'Mútuo';
2400
                    break;
2401
                case '2':
2402
                    $stringU = 'Rodoferroviário';
2403
                    break;
2404
                case '3':
2405
                    $stringU = 'Rodoviário';
2406
                    break;
2407
            }
2408
            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...
2409
        }
2410
    }
2411
2412
    /**
2413
     * multiUniPeso
2414
     * Fornece a imformação multiplicação de peso contida na CTe
2415
     *
2416
     * @param  interger $U Informação de peso extraida da CTe
2417
     * @return interger
2418
     */
2419
    protected function multiUniPeso($U = '')
2420
    {
2421
        if ($U === "01") {
2422
            // tonelada
2423
            //return 1000;
2424
            return 1;
2425
        }
2426
        return 1; // M3, KG, Unidade, litros, mmbtu
2427
    }
2428
2429
    protected function qrCodeDacteOs($y = 0)
2430
    {
2431
        $margemInterna = $this->margemInterna;
2432
        $barcode = new Barcode();
2433
        $bobj = $barcode->getBarcodeObj(
2434
            'QRCODE,M',
2435
            $this->qrCodMDFe,
2436
            -4,
2437
            -4,
2438
            'black',
2439
            array(-1, -1, -1, -1)
2440
        )->setBackgroundColor('white');
2441
        $qrcode = $bobj->getPngData();
2442
        $wQr = 36;
2443
        $hQr = 36;
2444
        $yQr = ($y + $margemInterna);
2445
        if ($this->orientacao == 'P') {
2446
            $xQr = 170;
2447
        } else {
2448
            $xQr = 250;
2449
        }
2450
        // prepare a base64 encoded "data url"
2451
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
2452
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
2453
    }
2454
2455
    /**
2456
     * Add the credits to the integrator in the footer message
2457
     * @param string $message
2458
     */
2459
    public function creditsIntegratorFooter($message = '')
2460
    {
2461
        $this->creditos = trim($message);
2462
    }
2463
}
2464