Completed
Push — master ( a9e3b8...b5002a )
by Roberto
13:10 queued 02:27
created

Danfce::montaDANFE()   F

Complexity

Conditions 12
Paths 448

Size

Total Lines 147
Code Lines 107

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 156

Importance

Changes 0
Metric Value
cc 12
eloc 107
c 0
b 0
f 0
nc 448
nop 5
dl 0
loc 147
ccs 0
cts 120
cp 0
crap 156
rs 3.5294

How to fix   Long Method    Complexity   

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\NFe;
4
5
/**
6
 * Classe para a impressão em PDF do Documento Auxiliar de NFe Consumidor
7
 * NOTA: Esta classe não é a indicada para quem faz uso de impressoras térmicas ESCPOS
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @copyright 2009-2016 NFePHP
12
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
13
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
14
 * @author    Roberto Spadim <roberto at spadim dot com dot br>
15
 */
16
use Exception;
17
use NFePHP\DA\Legacy\Dom;
18
use NFePHP\DA\Legacy\Pdf;
19
use NFePHP\DA\Legacy\Common;
20
use Com\Tecnick\Barcode\Barcode;
21
use DateTime;
22
23
class Danfce extends Common
24
{
25
    protected $papel;
26
    protected $xml; // string XML NFe
27
    protected $logomarca=''; // path para logomarca em jpg
28
    protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####";
29
    protected $debugMode=0; //ativa ou desativa o modo de debug
30
    protected $tpImp; //ambiente
31
    protected $fontePadrao='Times';
32
    protected $nfeProc;
33
    protected $nfe;
34
    protected $infNFe;
35
    protected $ide;
36
    protected $enderDest;
37
    protected $ICMSTot;
38
    protected $imposto;
39
    protected $emit;
40
    protected $enderEmit;
41
    protected $qrCode;
42
    protected $det;
43
    protected $infAdic;
44
    protected $textoAdic;
45
    protected $pag;
46
    protected $vTroco;
47
    protected $dest;
48
    protected $imgQRCode;
49
    protected $urlQR = '';
50
    protected $pdf;
51
    protected $margemInterna = 2;
52
    protected $hMaxLinha = 9;
53
    protected $hBoxLinha = 6;
54
    protected $hLinha = 3;
55
    /*
56
     * Retorna a sigla da UF
57
     * @var string
58
     */
59
    protected $UFSigla = [
60
        '12' => 'AC',
61
        '27' => 'AL',
62
        '13' => 'AM',
63
        '16' => 'AP',
64
        '29' => 'BA',
65
        '23' => 'CE',
66
        '53' => 'DF',
67
        '32' => 'ES',
68
        '52' => 'GO',
69
        '31' => 'MG',
70
        '50' => 'MS',
71
        '51' => 'MT',
72
        '21' => 'MA',
73
        '15' => 'PA',
74
        '25' => 'PB',
75
        '26' => 'PE',
76
        '22' => 'PI',
77
        '41' => 'PR',
78
        '33' => 'RJ',
79
        '11' => 'RO',
80
        '24' => 'RN',
81
        '14' => 'RR',
82
        '43' => 'RS',
83
        '42' => 'SC',
84
        '28' => 'SE',
85
        '35' => 'SP',
86
        '17' => 'TO'
87
    ];
88
    /*
89
     * Fonte: http://nfce.encat.org/consumidor/consulte-sua-nota/
90
     * URL referente a pagina de consulta da NFCe pela chave de acesso
91
     * @var string
92
     */
93
    protected $urlConsulta = [
94
        '1' => [
95
            'AC' => 'www.sefaznet.ac.gov.br/nfce/consulta',
96
            'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm',
97
            'AP' => 'https://www.sefaz.ap.gov.br/sate/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261',
98
            'AM' => 'sistemas.sefaz.am.gov.br/nfceweb/formConsulta.do',
99
            'BA' => 'nfe.sefaz.ba.gov.br/servicos/nfce/default.aspx',
100
            'CE' => '',
101
            'DF' => 'http://dec.fazenda.df.gov.br/NFCE/',
102
            'ES' => 'http://app.sefaz.es.gov.br/ConsultaNFCe',
103
            'GO' => '',
104
            'MA' => 'http://www.nfce.sefaz.ma.gov.br/portal/consultaNFe.do?method=preFilterCupom&',
105
            'MT' => 'http://www.sefaz.mt.gov.br/nfce/consultanfce',
106
            'MS' => 'http://www.dfe.ms.gov.br/nfce',
107
            'MG' => '',
108
            'PA' => 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam',
109
            'PB' => 'www.receita.pb.gov.br/nfce',
110
            'PR' => 'http://www.fazenda.pr.gov.br',
111
            'PE' => '',
112
            'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb/consultarNFCe.jsf',
113
            'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta',
114
            'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx',
115
            'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx',
116
            'RO' => 'http://www.nfce.sefin.ro.gov.br',
117
            'RR' => 'https://www.sefaz.rr.gov.br/nfce/servlet/wp_consulta_nfce',
118
            'SC' => '',
119
            'SP' => 'https://www.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx',
120
            'SE' => 'http://www.nfce.se.gov.br/portal/portalNoticias.jsp',
121
            'TO' => ''
122
        ],
123
        '2' => [
124
            'AC' => 'http://hml.sefaznet.ac.gov.br/nfce/consulta',
125
            'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm',
126
            'AP' => 'https://www.sefaz.ap.gov.br/sate1/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261',
127
            'AM' => 'homnfce.sefaz.am.gov.br/nfceweb/formConsulta.do',
128
            'BA' => 'http://hnfe.sefaz.ba.gov.br/servicos/nfce/default.aspx',
129
            'CE' => 'http://nfceh.sefaz.ce.gov.br/pages/consultaNota.jsf',
130
            'DF' => 'http://dec.fazenda.df.gov.br/NFCE/',
131
            'ES' => 'http://homologacao.sefaz.es.gov.br/ConsultaNFCe',
132
            'GO' => '',
133
            'MA' => 'http://www.hom.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp',
134
            'MT' => 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce',
135
            'MS' => 'http://www.dfe.ms.gov.br/nfce',
136
            'MG' => '',
137
            'PA' => 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/consultanfce.seam',
138
            'PB' => '',
139
            'PR' => 'http://www.fazenda.pr.gov.br',
140
            'PE' => '',
141
            'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb-homologacao/consultarNFCe.jsf',
142
            'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta',
143
            'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx',
144
            'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx',
145
            'RO' => 'http://www.nfce.sefin.ro.gov.br',
146
            'RR' => 'http://200.174.88.103:8080/nfce/servlet/wp_consulta_nfce',
147
            'SC' => '',
148
            'SP' => 'https://www.homologacao.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx',
149
            'SE' => 'http://www.hom.nfe.se.gov.br/portal/portalNoticias.jsp',
150
            'TO' => ''
151
        ],
152
    ];
153
    /**
154
     * __contruct
155
     *
156
     * @param string $docXML
157
     * @param string $sPathLogo
158
     * @param string $mododebug
159
     * @param string $idToken
160
     * @param string $Token
0 ignored issues
show
Bug introduced by
There is no parameter named $Token. 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...
161
     */
162
    public function __construct(
163
        $docXML = '',
164
        $sPathLogo = '',
165
        $mododebug = 0,
166
        // habilita os erros do sistema
167
        $idToken = '',
0 ignored issues
show
Unused Code introduced by
The parameter $idToken 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...
168
        $emitToken = '',
0 ignored issues
show
Unused Code introduced by
The parameter $emitToken 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...
169
        $urlQR = ''
0 ignored issues
show
Unused Code introduced by
The parameter $urlQR 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...
170
    ) {
171
        if (is_numeric($mododebug)) {
172
            $this->debugMode = $mododebug;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mododebug can also be of type double or string. However, the property $debugMode is declared as type integer. Maybe add an additional type check?

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

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

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

class Id
{
    public $id;

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

}

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

$account_id = false;

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

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
173
        }
174
        if ($this->debugMode) {
175
            //ativar modo debug
176
            error_reporting(E_ALL);
177
            ini_set('display_errors', 'On');
178
        } else {
179
            //desativar modo debug
180
            error_reporting(0);
181
            ini_set('display_errors', 'Off');
182
        }
183
        $this->xml = $docXML;
184
        $this->logomarca = $sPathLogo;
185
        if (empty($fonteDANFE)) {
0 ignored issues
show
Bug introduced by
The variable $fonteDANFE seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
186
            $this->fontePadrao = 'Times';
187
        } else {
188
            $this->fontePadrao = $fonteDANFE;
189
        }
190
        if (!empty($this->xml)) {
191
            $this->dom = new Dom();
0 ignored issues
show
Bug introduced by
The property dom 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...
192
            $this->dom->loadXML($this->xml);
193
            $this->nfeProc    = $this->dom->getElementsByTagName("nfeProc")->item(0);
194
            $this->nfe        = $this->dom->getElementsByTagName("NFe")->item(0);
195
            $this->infNFe     = $this->dom->getElementsByTagName("infNFe")->item(0);
196
            $this->ide        = $this->dom->getElementsByTagName("ide")->item(0);
197
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
198
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
199
            $this->det        = $this->dom->getElementsByTagName("det");
200
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
201
            $this->imposto    = $this->dom->getElementsByTagName("imposto")->item(0);
202
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
203
            $this->tpImp      = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue;
204
            $this->infAdic    = $this->dom->getElementsByTagName("infAdic")->item(0);
205
            
206
            //se for o layout 4.0 busca pelas tags de detalhe do pagamento
207
            //senao, busca pelas tags de pagamento principal
208
            if ($this->infNFe->getAttribute("versao") == "4.00") {
209
                $this->pag = $this->dom->getElementsByTagName("detPag");
210
                
211
                $tagPag = $this->dom->getElementsByTagName("pag")->item(0);
212
                $this->vTroco = $this->pSimpleGetValue($tagPag, "vTroco");
213
            } else {
214
                $this->pag = $this->dom->getElementsByTagName("pag");
215
            }
216
        }
217
        $this->qrCode = $this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue;
218
        if ($this->pSimpleGetValue($this->ide, "mod") != '65') {
219
            throw new nfephpException("O xml do DANFE deve ser uma NFC-e modelo 65");
220
        }
221
    }
222
    
223
    public function getPapel()
224
    {
225
        return $this->papel;
226
    }
227
    
228
    public function setPapel($aPap)
229
    {
230
        $this->papel = $aPap;
231
    }
232
    
233
    public function monta(
234
        $orientacao = 'P',
235
        $papel = '',
236
        $logoAlign = 'C',
237
        $classPdf = false,
238
        $depecNumReg = ''
239
    ) {
240
        $this->montaDANFE($orientacao, $papel, $logoAlign, $classPdf, $depecNumReg);
241
    }
242
    
243
    public function montaDANFE(
244
        $orientacao = 'P',
245
        $papel = '',
0 ignored issues
show
Unused Code introduced by
The parameter $papel 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...
246
        $logoAlign = 'C',
247
        $classPdf = false,
248
        $depecNumReg = ''
249
    ) {
250
        $qtdItens = $this->det->length;
251
        $qtdPgto = $this->pag->length;
252
        $hMaxLinha = $this->hMaxLinha;
253
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha is not used, you could remove the assignment.

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

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

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

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

Loading history...
254
        $hLinha = $this->hLinha;
255
        $tamPapelVert = 160 + 16 + (($qtdItens - 1) * $hMaxLinha) + ($qtdPgto * $hLinha);
256
        // verifica se existe informações adicionais
257
        $this->textoAdic = '';
258
        if (isset($this->infAdic)) {
259
            $this->textoAdic .= !empty($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue) ?
260
            'Inf. Contribuinte: '.
261
            trim($this->pAnfavea($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue)) : '';
262
            if (!empty($this->textoAdic)) {
263
                $this->textoAdic = str_replace(";", "\n", $this->textoAdic);
264
                $alinhas = explode("\n", $this->textoAdic);
265
                $numlinhasdados = 0;
266
                $tempPDF = new Pdf(); // cria uma instancia temporaria da class pdf
267
                $tempPDF->SetFont('Times', '', '8'); // seta a font do PDF
268
                foreach ($alinhas as $linha) {
269
                    $linha = trim($linha);
270
                    $numlinhasdados += $tempPDF->WordWrap($linha, 76 - 0.2);
0 ignored issues
show
Documentation introduced by
$linha is of type string, but the function expects a object<NFePHP\DA\Legacy\type>.

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...
Documentation introduced by
76 - 0.2 is of type double, but the function expects a object<NFePHP\DA\Legacy\type>.

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...
271
                }
272
                $hdadosadic = round(($numlinhasdados + 1) * $tempPDF->fontSize, 0);
273
                if ($hdadosadic < 5) {
274
                    $hdadosadic = 5;
275
                }
276
                // seta o tamanho do papel
277
                $tamPapelVert += $hdadosadic;
278
            }
279
        }
280
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
281
        if ($orientacao == '') {
282
            $orientacao = 'P';
283
        }
284
        $this->orientacao = $orientacao;
0 ignored issues
show
Bug introduced by
The property orientacao 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...
285
        $this->papel = array(80,$tamPapelVert);
286
        $this->logoAlign = $logoAlign;
0 ignored issues
show
Bug introduced by
The property logoAlign 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...
287
        //$this->situacao_externa = $situacaoExterna;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
288
        $this->numero_registro_dpec = $depecNumReg;
0 ignored issues
show
Bug introduced by
The property numero_registro_dpec 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...
289
        //instancia a classe pdf
290
        if ($classPdf) {
291
            $this->pdf = $classPdf;
292
        } else {
293
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|integer"}>, 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...
294
        }
295
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
296
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
297
        //apenas para controle se necessário ser maior do que a margem superior
298
        $margSup = 2;
299
        $margEsq = 2;
300
        $margInf = 2;
301
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
302
        $xInic = $margEsq;
303
        $yInic = $margSup;
304
        $maxW = 80;
305
        $maxH = $tamPapelVert;
306
        //total inicial de paginas
307
        $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...
308
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
309
        $this->wPrint = $maxW-($margEsq*2);
0 ignored issues
show
Bug introduced by
The property wPrint 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...
310
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
311
        //superior e inferior
312
        $this->hPrint = $maxH-$margSup-$margInf;
0 ignored issues
show
Bug introduced by
The property hPrint 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...
313
        // estabelece contagem de paginas
314
        $this->pdf->aliasNbPages();
315
        $this->pdf->setMargins($margEsq, $margSup); // fixa as margens
316
        $this->pdf->setDrawColor(0, 0, 0);
317
        $this->pdf->setFillColor(255, 255, 255);
318
        $this->pdf->open(); // inicia o documento
319
        $this->pdf->addPage($this->orientacao, $this->papel); // adiciona a primeira página
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|integer"}>, 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...
320
        $this->pdf->setLineWidth(0.1); // define a largura da linha
321
        $this->pdf->setTextColor(0, 0, 0);
322
        $this->pTextBox(0, 0, $maxW, $maxH); // POR QUE PRECISO DESA LINHA?
323
        $hcabecalho = 27;//para cabeçalho (dados emitente mais logomarca)  (FIXO)
324
        $hcabecalhoSecundario = 10;//para cabeçalho secundário (cabeçalho sefaz) (FIXO)
325
        $hprodutos = $hLinha + ($qtdItens*$hMaxLinha) ;//box poduto
326
        $hTotal = 12; //box total (FIXO)
327
        $hpagamentos = $hLinha + ($qtdPgto*$hLinha);//para pagamentos
328
        if (!empty($this->vTroco)) {
329
            $hpagamentos += $hLinha;
330
        }
331
        $hmsgfiscal = 21;// para imposto (FIXO)
332
        if (!isset($this->dest)) {
333
            $hcliente = 6;// para cliente (FIXO)
334
        } else {
335
            $hcliente = 12;
336
        }// para cliente (FIXO)};
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
337
        $hQRCode = 50;// para qrcode (FIXO)
338
        $hCabecItens = 4;//cabeçalho dos itens
339
        
340
        $hUsado = $hCabecItens;
0 ignored issues
show
Unused Code introduced by
$hUsado is not used, you could remove the assignment.

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

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

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

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

Loading history...
341
        $w2 = round($this->wPrint*0.31, 0);
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...
342
        $totPag = 1;
343
        $pag = 1;
344
        $x = $xInic;
345
        //COLOCA CABEÇALHO
346
        $y = $yInic;
347
        $y = $this->pCabecalhoDANFE($x, $y, $hcabecalho, $pag, $totPag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pCabecalhoDANFE($...becalho, $pag, $totPag) (which targets NFePHP\DA\NFe\Danfce::pCabecalhoDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
348
        //COLOCA CABEÇALHO SECUNDÁRIO
349
        $y = $hcabecalho;
350
        $y = $this->pCabecalhoSecundarioDANFE($x, $y, $hcabecalhoSecundario);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pCabecalhoSecunda... $hcabecalhoSecundario) (which targets NFePHP\DA\NFe\Danfce::pCabecalhoSecundarioDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
351
        //COLOCA PRODUTOS
352
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario;
353
        $y = $this->pProdutosDANFE($x, $y, $hprodutos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pProdutosDANFE($x, $y, $hprodutos) (which targets NFePHP\DA\NFe\Danfce::pProdutosDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
354
        //COLOCA TOTAL
355
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos;
356
        $y = $this->pTotalDANFE($x, $y, $hTotal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pTotalDANFE($x, $y, $hTotal) (which targets NFePHP\DA\NFe\Danfce::pTotalDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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
        //COLOCA PAGAMENTOS
358
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal;
359
        $y = $this->pPagamentosDANFE($x, $y, $hpagamentos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pPagamentosDANFE($x, $y, $hpagamentos) (which targets NFePHP\DA\NFe\Danfce::pPagamentosDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
360
        //COLOCA MENSAGEM FISCAL
361
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal+ $hpagamentos;
362
        $y = $this->pFiscalDANFE($x, $y, $hmsgfiscal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pFiscalDANFE($x, $y, $hmsgfiscal) (which targets NFePHP\DA\NFe\Danfce::pFiscalDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
363
        //COLOCA CONSUMIDOR
364
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal + $hpagamentos + $hmsgfiscal;
365
        $y = $this->pConsumidorDANFE($x, $y, $hcliente);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pConsumidorDANFE($x, $y, $hcliente) (which targets NFePHP\DA\NFe\Danfce::pConsumidorDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
366
        //COLOCA QRCODE
367
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
368
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente;
369
        $y = $this->pQRDANFE($x, $y, $hQRCode);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pQRDANFE($x, $y, $hQRCode) (which targets NFePHP\DA\NFe\Danfce::pQRDANFE()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
370
        
371
        //adiciona as informações opcionais
372
        if (!empty($this->textoAdic)) {
373
            $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
374
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente + $hQRCode;
375
            $hInfAdic = 0;
376
            $y = $this->pInfAdic($x, $y, $hInfAdic);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pInfAdic($x, $y, $hInfAdic) (which targets NFePHP\DA\NFe\Danfce::pInfAdic()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
377
        }
378
        
379
        //retorna o ID na NFe
380
        if ($classPdf!==false) {
381
            $aR = [
382
             'id'=>str_replace('NFe', '', $this->infNFe->getAttribute("Id")),
383
             'classe_PDF'=>$this->pdf
384
            ];
385
            return $aR;
386
        } else {
387
            return str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
388
        }
389
    }
390
    
391
    protected function pCabecalhoDANFE($x = 0, $y = 0, $h = 0, $pag = '1', $totPag = '1')
0 ignored issues
show
Unused Code introduced by
The parameter $x 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 $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 $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...
392
    {
393
        $emitRazao  = $this->pSimpleGetValue($this->emit, "xNome");
394
        $emitCnpj   = $this->pSimpleGetValue($this->emit, "CNPJ");
395
        $emitCnpj   = $this->pFormat($emitCnpj, "##.###.###/####-##");
396
        $emitIE     = $this->pSimpleGetValue($this->emit, "IE");
397
        $emitIM     = $this->pSimpleGetValue($this->emit, "IM");
398
        $emitFone = $this->pSimpleGetValue($this->enderEmit, "fone");
399
        $foneLen = strlen($emitFone);
400
        if ($foneLen>0) {
401
            $ddd = substr($emitFone, 0, 2);
402
            $fone1 = substr($emitFone, -8);
403
            $digito9 = ' ';
404
            if ($foneLen == 11) {
405
                $digito9 = substr($emitFone, 2, 1);
406
            }
407
            $emitFone = ' - ('.$ddd.') '.$digito9. ' ' . substr($fone1, 0, 4) . '-' . substr($fone1, -4);
408
        } else {
409
            $emitFone = '';
410
        }
411
        $emitLgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
412
        $emitNro = $this->pSimpleGetValue($this->enderEmit, "nro");
413
        $emitCpl = $this->pSimpleGetValue($this->enderEmit, "xCpl", "");
414
        $emitBairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
415
        $emitCEP = $this->pFormat($this->pSimpleGetValue($this->enderEmit, "CEP"), "#####-###");
416
        $emitMun = $this->pSimpleGetValue($this->enderEmit, "xMun");
417
        $emitUF = $this->pSimpleGetValue($this->enderEmit, "UF");
418
        // CONFIGURAÇÃO DE POSIÇÃO
419
        $margemInterna = $this->margemInterna;
420
        $maxW = $this->wPrint;
421
        $h = $h-($margemInterna);
422
        //COLOCA LOGOMARCA
423
        if (is_file($this->logomarca)) {
424
            $xImg = $margemInterna;
425
            $yImg = $margemInterna + 1;
426
            $this->pdf->Image($this->logomarca, $xImg, $yImg, 30, 22.5);
427
            $xRs = ($maxW*0.4) + $margemInterna;
428
            $wRs = ($maxW*0.6);
429
            $alignEmit = 'L';
430
        } else {
431
            $xRs = $margemInterna;
432
            $wRs = ($maxW*1);
433
            $alignEmit = 'L';
434
        }
435
        //COLOCA RAZÃO SOCIAL
436
        $texto = $emitRazao;
437
        $texto = $texto . "\nCNPJ:" . $emitCnpj;
438
        $texto = $texto . "\nIE:" . $emitIE;
439
        if (!empty($emitIM)) {
440
            $texto = $texto . " - IM:" . $emitIM;
441
        }
442
        $texto = $texto . "\n" . $emitLgr . "," . $emitNro . " " . $emitCpl . "," . $emitBairro
443
                . ". CEP:" . $emitCEP . ". " . $emitMun . "-" . $emitUF . $emitFone;
444
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
445
        $this->pTextBox($xRs, $y, $wRs, $h, $texto, $aFont, 'C', $alignEmit, 0, '', false);
446
    }
447
    
448
    protected function pCabecalhoSecundarioDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
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...
449
    {
450
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

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

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

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

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

Loading history...
451
        $maxW = $this->wPrint;
452
        $w = ($maxW*1);
453
        $hBox1 = 7;
454
        $texto = "DANFE NFC-e\nDocumento Auxiliar da Nota Fiscal de Consumidor Eletrônica";
455
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
456
        $this->pTextBox($x, $y, $w, $hBox1, $texto, $aFont, 'C', 'C', 0, '', false);
457
        $hBox2 = 4;
458
        $yBox2 = $y + $hBox1;
459
        $texto = "\nNFC-e não permite aproveitamento de crédito de ICMS";
460
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
461
        $this->pTextBox($x, $yBox2, $w, $hBox2, $texto, $aFont, 'C', 'C', 0, '', false);
462
    }
463
    
464
    protected function pProdutosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
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...
465
    {
466
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

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

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

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

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

Loading history...
467
        $maxW = $this->wPrint;
468
        $qtdItens = $this->det->length;
469
        $w = ($maxW*1);
470
        $hLinha = $this->hLinha;
471
        $aFontCabProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
472
        $wBoxCod = $w*0.17;
473
        $texto = "CÓDIGO";
474
        $this->pTextBox($x, $y, $wBoxCod, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
475
        $wBoxDescricao = $w*0.43;
476
        $xBoxDescricao = $wBoxCod + $x;
477
        $texto = "DESCRICÃO";
478
        $this->pTextBox(
479
            $xBoxDescricao,
480
            $y,
481
            $wBoxDescricao,
482
            $hLinha,
483
            $texto,
484
            $aFontCabProdutos,
485
            'T',
486
            'L',
487
            0,
488
            '',
489
            false
490
        );
491
        $wBoxQt = $w*0.08;
492
        $xBoxQt = $wBoxDescricao + $xBoxDescricao;
493
        $texto = "QT";
494
        $this->pTextBox($xBoxQt, $y, $wBoxQt, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
495
        $wBoxUn = $w*0.06;
496
        $xBoxUn = $wBoxQt + $xBoxQt;
497
        $texto = "UN";
498
        $this->pTextBox($xBoxUn, $y, $wBoxUn, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
499
        $wBoxVl = $w*0.13;
500
        $xBoxVl = $wBoxUn + $xBoxUn;
501
        $texto = "VALOR";
502
        $this->pTextBox($xBoxVl, $y, $wBoxVl, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
503
        $wBoxTotal = $w*0.13;
504
        $xBoxTotal = $wBoxVl + $xBoxVl;
505
        $texto = "TOTAL";
506
        $this->pTextBox($xBoxTotal, $y, $wBoxTotal, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
507
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha is not used, you could remove the assignment.

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

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

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

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

Loading history...
508
        $hMaxLinha = $this->hMaxLinha;
509
        $cont = 0;
510
        $aFontProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
511
        if ($qtdItens > 0) {
512
            foreach ($this->det as $detI) {
513
                $thisItem   = $detI;
514
                $prod       = $thisItem->getElementsByTagName("prod")->item(0);
515
                $nitem      = $thisItem->getAttribute("nItem");
0 ignored issues
show
Unused Code introduced by
$nitem is not used, you could remove the assignment.

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

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

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

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

Loading history...
516
                $cProd      = $this->pSimpleGetValue($prod, "cProd");
517
                $xProd      = $this->pSimpleGetValue($prod, "xProd");
518
                $qCom       = number_format($this->pSimpleGetValue($prod, "qCom"), 2, ",", ".");
519
                $uCom       = $this->pSimpleGetValue($prod, "uCom");
520
                $vUnCom     = number_format($this->pSimpleGetValue($prod, "vUnCom"), 2, ",", ".");
521
                $vProd      = number_format($this->pSimpleGetValue($prod, "vProd"), 2, ",", ".");
522
                //COLOCA PRODUTO
523
                $yBoxProd = $y + $hLinha + ($cont*$hMaxLinha);
524
                //COLOCA PRODUTO CÓDIGO
525
                $wBoxCod = $w*0.17;
526
                $texto = $cProd;
527
                $this->pTextBox($x, $yBoxProd, $wBoxCod, $hMaxLinha, $texto, $aFontProdutos, 'C', 'C', 0, '', false);
528
                //COLOCA PRODUTO DESCRIÇÃO
529
                $wBoxDescricao = $w*0.43;
530
                $xBoxDescricao = $wBoxCod + $x;
531
                $texto = $xProd;
532
                $this->pTextBox(
533
                    $xBoxDescricao,
534
                    $yBoxProd,
535
                    $wBoxDescricao,
536
                    $hMaxLinha,
537
                    $texto,
538
                    $aFontProdutos,
539
                    'C',
540
                    'L',
541
                    0,
542
                    '',
543
                    false
544
                );
545
                //COLOCA PRODUTO QUANTIDADE
546
                $wBoxQt = $w*0.08;
547
                $xBoxQt = $wBoxDescricao + $xBoxDescricao;
548
                $texto = $qCom;
549
                $this->pTextBox(
550
                    $xBoxQt,
551
                    $yBoxProd,
552
                    $wBoxQt,
553
                    $hMaxLinha,
554
                    $texto,
555
                    $aFontProdutos,
556
                    'C',
557
                    'C',
558
                    0,
559
                    '',
560
                    false
561
                );
562
                //COLOCA PRODUTO UNIDADE
563
                $wBoxUn = $w*0.06;
564
                $xBoxUn = $wBoxQt + $xBoxQt;
565
                $texto = $uCom;
566
                $this->pTextBox(
567
                    $xBoxUn,
568
                    $yBoxProd,
569
                    $wBoxUn,
570
                    $hMaxLinha,
571
                    $texto,
572
                    $aFontProdutos,
573
                    'C',
574
                    'C',
575
                    0,
576
                    '',
577
                    false
578
                );
579
                //COLOCA PRODUTO VL UNITÁRIO
580
                $wBoxVl = $w*0.13;
581
                $xBoxVl = $wBoxUn + $xBoxUn;
582
                $texto = $vUnCom;
583
                $this->pTextBox(
584
                    $xBoxVl,
585
                    $yBoxProd,
586
                    $wBoxVl,
587
                    $hMaxLinha,
588
                    $texto,
589
                    $aFontProdutos,
590
                    'C',
591
                    'R',
592
                    0,
593
                    '',
594
                    false
595
                );
596
                //COLOCA PRODUTO VL TOTAL
597
                $wBoxTotal = $w*0.13;
598
                $xBoxTotal = $wBoxVl + $xBoxVl;
599
                $texto = $vProd;
600
                $this->pTextBox(
601
                    $xBoxTotal,
602
                    $yBoxProd,
603
                    $wBoxTotal,
604
                    $hMaxLinha,
605
                    $texto,
606
                    $aFontProdutos,
607
                    'C',
608
                    'R',
609
                    0,
610
                    '',
611
                    false
612
                );
613
                
614
                $cont++;
615
            }
616
        }
617
    }
618
    
619
    protected function pTotalDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
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...
620
    {
621
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

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

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

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

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

Loading history...
622
        $maxW = $this->wPrint;
623
        $hLinha = 3;
624
        $wColEsq = ($maxW*0.7);
625
        $wColDir = ($maxW*0.3);
626
        $xValor = $x + $wColEsq;
627
        $qtdItens = $this->det->length;
628
        $vProd = $this->pSimpleGetValue($this->ICMSTot, "vProd");
629
        $vNF = $this->pSimpleGetValue($this->ICMSTot, "vNF");
630
        $vDesc  = $this->pSimpleGetValue($this->ICMSTot, "vDesc");
631
        $vFrete = $this->pSimpleGetValue($this->ICMSTot, "vFrete");
632
        $vTotTrib = $this->pSimpleGetValue($this->ICMSTot, "vTotTrib");
633
        $texto = "Qtd. Total de Itens";
634
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
635
        $this->pTextBox($x, $y, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
636
        $texto = $qtdItens;
637
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
638
        $this->pTextBox($xValor, $y, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
639
        $yTotal = $y + ($hLinha);
640
        $texto = "Total de Produtos";
641
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
642
        $this->pTextBox($x, $yTotal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
643
        $texto = "R$ " . number_format($vProd, 2, ",", ".");
644
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
645
        $this->pTextBox($xValor, $yTotal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
646
        $yDesconto = $y + ($hLinha*2);
647
        $texto = "Descontos";
648
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
649
        $this->pTextBox($x, $yDesconto, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
650
        $texto = "R$ " . $vDesc;
651
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
652
        $this->pTextBox($xValor, $yDesconto, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
653
        $yFrete= $y + ($hLinha*3);
654
        $texto = "Frete";
655
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
656
        $this->pTextBox($x, $yFrete, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
657
        $texto = "R$ " . $vFrete;
658
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
659
        $this->pTextBox($xValor, $yFrete, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
660
        $yTotalFinal = $y + ($hLinha*4);
661
        $texto = "Total";
662
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
663
        $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
664
        $texto = "R$ " . $vNF;
665
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
666
        $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
667
        $yTotalFinal = $y + ($hLinha*5);
668
        $texto = "Informação dos Tributos Totais Incidentes";
669
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
670
        $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
671
        $texto = "R$ " . $vTotTrib;
672
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
673
        $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
674
    }
675
    
676
    protected function pPagamentosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
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...
677
    {
678
        $y += 6;
679
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

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

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

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

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

Loading history...
680
        $maxW = $this->wPrint;
681
        $qtdPgto = $this->pag->length;
682
        $w = ($maxW*1);
683
        $hLinha = $this->hLinha;
684
        $wColEsq = ($maxW*0.7);
685
        $wColDir = ($maxW*0.3);
0 ignored issues
show
Unused Code introduced by
$wColDir is not used, you could remove the assignment.

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

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

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

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

Loading history...
686
        $xValor = $x + $wColEsq;
0 ignored issues
show
Unused Code introduced by
$xValor is not used, you could remove the assignment.

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

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

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

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

Loading history...
687
        $aFontPgto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
688
        $wBoxEsq = $w*0.7;
689
        $texto = "FORMA DE PAGAMENTO";
690
        $this->pTextBox($x, $y, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
691
        $wBoxDir = $w*0.3;
692
        $xBoxDescricao = $x + $wBoxEsq;
693
        $texto = "VALOR PAGO";
694
        $this->pTextBox($xBoxDescricao, $y, $wBoxDir, $hLinha, $texto, $aFontPgto, 'T', 'R', 0, '', false);
695
        $cont = 0;
696
        if ($qtdPgto > 0) {
697
            foreach ($this->pag as $pagI) {
698
                $tPag = $this->pSimpleGetValue($pagI, "tPag");
699
                $tPagNome = $this->tipoPag($tPag);
700
                $tPnome = $tPagNome;
0 ignored issues
show
Unused Code introduced by
$tPnome is not used, you could remove the assignment.

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

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

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

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

Loading history...
701
                $vPag = number_format($this->pSimpleGetValue($pagI, "vPag"), 2, ",", ".");
702
                $card = $pagI->getElementsByTagName("card")->item(0);
703
                $cardCNPJ = '';
0 ignored issues
show
Unused Code introduced by
$cardCNPJ is not used, you could remove the assignment.

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

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

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

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

Loading history...
704
                $tBand = '';
0 ignored issues
show
Unused Code introduced by
$tBand is not used, you could remove the assignment.

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

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

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

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

Loading history...
705
                $tBandNome = '';
0 ignored issues
show
Unused Code introduced by
$tBandNome is not used, you could remove the assignment.

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

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

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

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

Loading history...
706
                if (isset($card)) {
707
                    $cardCNPJ = $this->pSimpleGetValue($card, "CNPJ");
0 ignored issues
show
Unused Code introduced by
$cardCNPJ is not used, you could remove the assignment.

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

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

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

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

Loading history...
708
                    $tBand    = $this->pSimpleGetValue($card, "tBand");
709
                    $cAut = $this->pSimpleGetValue($card, "cAut");
0 ignored issues
show
Unused Code introduced by
$cAut is not used, you could remove the assignment.

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

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

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

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

Loading history...
710
                    $tBandNome = self::getCardName($tBand);
0 ignored issues
show
Unused Code introduced by
$tBandNome is not used, you could remove the assignment.

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

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

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

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

Loading history...
711
                }
712
                //COLOCA PRODUTO
713
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
714
                //COLOCA PRODUTO CÓDIGO
715
                $texto = $tPagNome;
716
                $this->pTextBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
717
                //COLOCA PRODUTO DESCRIÇÃO
718
                $xBoxDescricao = $wBoxEsq + $x;
719
                $texto = "R$ " . $vPag;
720
                $this->pTextBox(
721
                    $xBoxDescricao,
722
                    $yBoxProd,
723
                    $wBoxDir,
724
                    $hLinha,
725
                    $texto,
726
                    $aFontPgto,
727
                    'C',
728
                    'R',
729
                    0,
730
                    '',
731
                    false
732
                );
733
                $cont++;
734
            }
735
            
736
            if (!empty($this->vTroco)) {
737
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
738
                //COLOCA PRODUTO CÓDIGO
739
                $texto = 'Troco';
740
                $this->pTextBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
741
                //COLOCA PRODUTO DESCRIÇÃO
742
                $xBoxDescricao = $wBoxEsq + $x;
743
                $texto = "R$ " . number_format($this->vTroco, 2, ",", ".");
744
                $this->pTextBox(
745
                    $xBoxDescricao,
746
                    $yBoxProd,
747
                    $wBoxDir,
748
                    $hLinha,
749
                    $texto,
750
                    $aFontPgto,
751
                    'C',
752
                    'R',
753
                    0,
754
                    '',
755
                    false
756
                );
757
            }
758
        }
759
    }
760
    
761
    protected function pFiscalDANFE($x = 0, $y = 0, $h = 0)
762
    {
763
        $y += 6;
764
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

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

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

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

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

Loading history...
765
        $maxW = $this->wPrint;
766
        $w = ($maxW*1);
767
        $hLinha = $this->hLinha;
768
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
769
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
770
        $digVal = $this->pSimpleGetValue($this->nfe, "DigestValue");
0 ignored issues
show
Unused Code introduced by
$digVal is not used, you could remove the assignment.

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

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

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

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

Loading history...
771
        $chNFe = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
772
        $tpAmb = $this->pSimpleGetValue($this->ide, 'tpAmb');
773
        
774
        if ($this->pNotaCancelada()) {
775
            //101 Cancelamento
776
            $this->pdf->SetTextColor(255, 0, 0);
777
            $texto = "NFCe CANCELADA";
778
            $this->pTextBox($x, $y - 25, $w, $h, $texto, $aFontTit, 'C', 'C', 0, '');
779
            $this->pdf->SetTextColor(0, 0, 0);
780
        }
781
        
782
        if ($this->pNotaDenegada()) {
783
            //uso denegado
784
            $this->pdf->SetTextColor(255, 0, 0);
785
            $texto = "NFCe CANCELADA";
786
            $this->pTextBox($x, $y - 25, $w, $h, $texto, $aFontTit, 'C', 'C', 0, '');
787
            $this->pdf->SetTextColor(0, 0, 0);
788
        }
789
        
790
        $cUF = $this->pSimpleGetValue($this->ide, 'cUF');
791
        $nNF = $this->pSimpleGetValue($this->ide, 'nNF');
792
        $serieNF = str_pad($this->pSimpleGetValue($this->ide, "serie"), 3, "0", STR_PAD_LEFT);
793
        $dhEmi = $this->pSimpleGetValue($this->ide, "dhEmi");
794
        $urlChave = $this->urlConsulta[$tpAmb][$this->UFSigla[$cUF]];
795
        $texto = "ÁREA DE MENSAGEM FISCAL";
796
        $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
797
        $yTex1 = $y + ($hLinha*1);
798
        $hTex1 = $hLinha*2;
799
        $texto = "Número " . $nNF . " Série " . $serieNF . " " .$dhEmi . " - Via Consumidor";
800
        $this->pTextBox($x, $yTex1, $w, $hTex1, $texto, $aFontTex, 'C', 'C', 0, '', false);
801
        $yTex2 = $y + ($hLinha*3);
802
        $hTex2 = $hLinha*2;
803
        $texto = "Consulte pela Chave de Acesso em " . $urlChave;
804
        $this->pTextBox($x, $yTex2, $w, $hTex2, $texto, $aFontTex, 'C', 'C', 0, '', false);
805
        $texto = "CHAVE DE ACESSO";
806
        $yTit2 = $y + ($hLinha*5);
807
        $this->pTextBox($x, $yTit2, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
808
        $yTex3 = $y + ($hLinha*6);
809
        $texto = $chNFe;
810
        $this->pTextBox($x, $yTex3, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
811
    }
812
    
813
    protected function pConsumidorDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
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...
814
    {
815
        $y += 6;
816
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

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

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

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

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

Loading history...
817
        $maxW = $this->wPrint;
818
        $w = ($maxW*1);
819
        $hLinha = $this->hLinha;
820
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
821
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
822
        $texto = "CONSUMIDOR";
823
        $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
824
        if (isset($this->dest)) {
825
            $considEstrangeiro = !empty($this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue)
826
                    ? $this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue
827
                    : '';
828
            $consCPF = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
829
                    ? $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue
830
                    : '';
831
            $consCNPJ = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)
832
                    ? $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue
833
                    : '';
834
            $cDest = $consCPF.$consCNPJ.$considEstrangeiro; //documentos do consumidor
0 ignored issues
show
Unused Code introduced by
$cDest is not used, you could remove the assignment.

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

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

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

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

Loading history...
835
            $enderDest = $this->dest->getElementsByTagName("enderDest")->item(0);
836
            $consNome = $this->pSimpleGetValue($this->dest, "xNome");
837
            $consLgr = $this->pSimpleGetValue($enderDest, "xLgr");
838
            $consNro = $this->pSimpleGetValue($enderDest, "nro");
839
            $consCpl = $this->pSimpleGetValue($enderDest, "xCpl", " - ");
840
            $consBairro = $this->pSimpleGetValue($enderDest, "xBairro");
841
            $consCEP = $this->pFormat($this->pSimpleGetValue($enderDest, "CEP"));
842
            $consMun = $this->pSimpleGetValue($enderDest, "xMun");
843
            $consUF = $this->pSimpleGetValue($enderDest, "UF");
844
            $considEstrangeiro = $this->pSimpleGetValue($this->dest, "idEstrangeiro");
845
            $consCPF = $this->pSimpleGetValue($this->dest, "CPF");
846
            $consCNPJ = $this->pSimpleGetValue($this->dest, "CNPJ");
847
            $consDoc = "";
848
            if (!empty($consCNPJ)) {
849
                $consDoc = "CNPJ: $consCNPJ";
850
            } elseif (!empty($consCPF)) {
851
                $consDoc = "CPF: $consCPF";
852
            } elseif (!empty($considEstrangeiro)) {
853
                $consDoc = "id: $considEstrangeiro";
854
            }
855
            $consEnd = "";
856
            if (!empty($consLgr)) {
857
                $consEnd = $consLgr
858
                    . ","
859
                    . $consNro
860
                    . " "
861
                    . $consCpl
862
                    . ","
863
                    . $consBairro
864
                    . ". CEP:"
865
                    . $consCEP
866
                    . ". "
867
                    . $consMun
868
                    . "-"
869
                    . $consUF;
870
            }
871
            $yTex1 = $y + $hLinha;
872
            $texto = $consNome;
873
            if (!empty($consDoc)) {
874
                $texto .= " - ". $consDoc . "\n" . $consEnd;
875
                $this->pTextBox($x, $yTex1, $w, $hLinha*3, $texto, $aFontTex, 'C', 'C', 0, '', false);
876
            }
877
        } else {
878
            $yTex1 = $y + $hLinha;
879
            $texto = "Consumidor não identificado";
880
            $this->pTextBox($x, $yTex1, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
881
        }
882
    }
883
    
884
    protected function pQRDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
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...
885
    {
886
        $y += 6;
887
        $margemInterna = $this->margemInterna;
888
        $maxW = $this->wPrint;
889
        $w = ($maxW*1);
890
        $hLinha = $this->hLinha;
0 ignored issues
show
Unused Code introduced by
$hLinha is not used, you could remove the assignment.

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

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

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

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

Loading history...
891
        $hBoxLinha = $this->hBoxLinha;
892
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
0 ignored issues
show
Unused Code introduced by
$aFontTit is not used, you could remove the assignment.

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

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

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

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

Loading history...
893
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
894
        $dhRecbto = '';
895
        $nProt = '';
896
        if (isset($this->nfeProc)) {
897
            $nProt = $this->pSimpleGetValue($this->nfeProc, "nProt");
898
            $dhRecbto  = $this->pSimpleGetValue($this->nfeProc, "dhRecbto");
899
        }
900
        $barcode = new Barcode();
901
        $bobj = $barcode->getBarcodeObj(
902
            'QRCODE,M',
903
            $this->qrCode,
904
            -4,
905
            -4,
906
            'black',
907
            array(-2, -2, -2, -2)
908
        )->setBackgroundColor('white');
909
        $qrcode = $bobj->getPngData();
910
        $wQr = 50;
911
        $hQr = 50;
912
        $yQr = ($y+$margemInterna);
913
        $xQr = ($w/2) - ($wQr/2);
914
        // prepare a base64 encoded "data url"
915
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
916
        $info = getimagesize($pic);
0 ignored issues
show
Unused Code introduced by
$info is not used, you could remove the assignment.

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

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

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

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

Loading history...
917
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
918
        $dt = new DateTime($dhRecbto);
919
        $yQr = ($yQr+$hQr+$margemInterna);
920
        $this->pTextBox($x, $yQr, $w, $hBoxLinha, "Protocolo de Autorização: " . $nProt . "\n"
921
            . $dt->format('d/m/Y H:i:s'), $aFontTex, 'C', 'C', 0, '', false);
922
    }
923
   
924
    protected function pInfAdic($x = 0, $y = 0, $h = 0)
0 ignored issues
show
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...
925
    {
926
        $y += 17;
927
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna is not used, you could remove the assignment.

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

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

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

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

Loading history...
928
        $maxW = $this->wPrint;
929
        $w = ($maxW * 1);
930
        $hLinha = $this->hLinha;
931
        $aFontTit = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
932
        $aFontTex = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
933
        // seta o textbox do titulo
934
        $texto = "INFORMAÇÃO ADICIONAL";
935
        $heigthText = $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
0 ignored issues
show
Unused Code introduced by
$heigthText is not used, you could remove the assignment.

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

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

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

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

Loading history...
936
                
937
        // seta o textbox do texto adicional
938
        $this->pTextBox($x, $y+3, $w-2, $hLinha-3, $this->textoAdic, $aFontTex, 'T', 'L', 0, '', false);
939
    }
940
    
941
    /**
942
     * printDANFE
943
     * Esta função envia a DANFE em PDF criada para o dispositivo informado.
944
     * O destino da impressão pode ser :
945
     * I-browser
946
     * D-browser com download
947
     * F-salva em um arquivo local com o nome informado
948
     * S-retorna o documento como uma string e o nome é ignorado.
949
     * Para enviar o pdf diretamente para uma impressora indique o
950
     * nome da impressora e o destino deve ser 'S'.
951
     *
952
     * @param  string $nome    Path completo com o nome do arquivo pdf
953
     * @param  string $destino Direção do envio do PDF
954
     * @param  string $printer Identificação da impressora no sistema
955
     * @return string Caso o destino seja S o pdf é retornado como uma string
956
     * @todo   Rotina de impressão direta do arquivo pdf criado
957
     */
958
    public function printDANFE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer is not used and could be removed.

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

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

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

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

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

could be turned into

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

This is much more concise to read.

Loading history...
962
            //aqui pode entrar a rotina de impressão direta
963
        }
964
        return $arq;
965
    }
966
    /**
967
     * Dados brutos do PDF
968
     * @return string
969
     */
970
    public function render()
971
    {
972
        return $this->pdf->getPdf();
973
    }
974
    
975
    /**
976
     * anfavea
977
     * Função para transformar o campo cdata do padrão ANFAVEA para
978
     * texto imprimível
979
     *
980
     * @param  string $cdata campo CDATA
981
     * @return string conteúdo do campo CDATA como string
982
     */
983
    protected function pAnfavea($cdata = '')
984
    {
985
        if ($cdata == '') {
986
            return '';
987
        }
988
        //remove qualquer texto antes ou depois da tag CDATA
989
        $cdata = str_replace('<![CDATA[', '<CDATA>', $cdata);
990
        $cdata = str_replace(']]>', '</CDATA>', $cdata);
991
        $cdata = preg_replace('/\s\s+/', ' ', $cdata);
992
        $cdata = str_replace("> <", "><", $cdata);
993
        $len = strlen($cdata);
994
        $startPos = strpos($cdata, '<');
995
        if ($startPos === false) {
996
            return $cdata;
997
        }
998
        for ($x=$len; $x>0; $x--) {
999
            if (substr($cdata, $x, 1) == '>') {
1000
                $endPos = $x;
1001
                break;
1002
            }
1003
        }
1004
        if ($startPos > 0) {
1005
            $parte1 = substr($cdata, 0, $startPos);
1006
        } else {
1007
            $parte1 = '';
1008
        }
1009
        $parte2 = substr($cdata, $startPos, $endPos-$startPos+1);
0 ignored issues
show
Bug introduced by
The variable $endPos 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...
1010
        if ($endPos < $len) {
1011
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
1012
        } else {
1013
            $parte3 = '';
1014
        }
1015
        $texto = trim($parte1).' '.trim($parte3);
1016
        if (strpos($parte2, '<CDATA>') === false) {
1017
            $cdata = '<CDATA>'.$parte2.'</CDATA>';
1018
        } else {
1019
            $cdata = $parte2;
1020
        }
1021
        //carrega o xml CDATA em um objeto DOM
1022
        $dom = new Dom();
1023
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
1024
        //$xml = $dom->saveXML();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
1025
        //grupo CDATA infADprod
1026
        $id = $dom->getElementsByTagName('id')->item(0);
1027
        $div = $dom->getElementsByTagName('div')->item(0);
1028
        $entg = $dom->getElementsByTagName('entg')->item(0);
1029
        $dest = $dom->getElementsByTagName('dest')->item(0);
1030
        $ctl = $dom->getElementsByTagName('ctl')->item(0);
1031
        $ref = $dom->getElementsByTagName('ref')->item(0);
1032
        if (isset($id)) {
1033
            if ($id->hasAttributes()) {
1034
                foreach ($id->attributes as $attr) {
1035
                    $name = $attr->nodeName;
1036
                    $value = $attr->nodeValue;
1037
                    $texto .= " $name : $value";
1038
                }
1039
            }
1040
        }
1041
        if (isset($div)) {
1042
            if ($div->hasAttributes()) {
1043
                foreach ($div->attributes as $attr) {
1044
                    $name = $attr->nodeName;
1045
                    $value = $attr->nodeValue;
1046
                    $texto .= " $name : $value";
1047
                }
1048
            }
1049
        }
1050
        if (isset($entg)) {
1051
            if ($entg->hasAttributes()) {
1052
                foreach ($entg->attributes as $attr) {
1053
                    $name = $attr->nodeName;
1054
                    $value = $attr->nodeValue;
1055
                    $texto .= " $name : $value";
1056
                }
1057
            }
1058
        }
1059
        if (isset($dest)) {
1060
            if ($dest->hasAttributes()) {
1061
                foreach ($dest->attributes as $attr) {
1062
                    $name = $attr->nodeName;
1063
                    $value = $attr->nodeValue;
1064
                    $texto .= " $name : $value";
1065
                }
1066
            }
1067
        }
1068
        if (isset($ctl)) {
1069
            if ($ctl->hasAttributes()) {
1070
                foreach ($ctl->attributes as $attr) {
1071
                    $name = $attr->nodeName;
1072
                    $value = $attr->nodeValue;
1073
                    $texto .= " $name : $value";
1074
                }
1075
            }
1076
        }
1077
        if (isset($ref)) {
1078
            if ($ref->hasAttributes()) {
1079
                foreach ($ref->attributes as $attr) {
1080
                    $name = $attr->nodeName;
1081
                    $value = $attr->nodeValue;
1082
                    $texto .= " $name : $value";
1083
                }
1084
            }
1085
        }
1086
        //grupo CADATA infCpl
1087
        $t = $dom->getElementsByTagName('transmissor')->item(0);
1088
        $r = $dom->getElementsByTagName('receptor')->item(0);
1089
        $versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
1090
        'Versao:'.$dom->getElementsByTagName('versao')->item(0)->nodeValue.' ' : '';
1091
        $especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
1092
        'Especie:'.$dom->getElementsByTagName('especieNF')->item(0)->nodeValue.' ' : '';
1093
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
1094
        'Entrega:'.$dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue.' ' : '';
1095
        $dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
1096
        'dca:'.$dom->getElementsByTagName('dca')->item(0)->nodeValue.' ' : '';
1097
        $texto .= "".$versao.$especieNF.$fabEntrega.$dca;
1098
        if (isset($t)) {
1099
            if ($t->hasAttributes()) {
1100
                $texto .= " Transmissor ";
1101
                foreach ($t->attributes as $attr) {
1102
                    $name = $attr->nodeName;
1103
                    $value = $attr->nodeValue;
1104
                    $texto .= " $name : $value";
1105
                }
1106
            }
1107
        }
1108
        if (isset($r)) {
1109
            if ($r->hasAttributes()) {
1110
                $texto .= " Receptor ";
1111
                foreach ($r->attributes as $attr) {
1112
                    $name = $attr->nodeName;
1113
                    $value = $attr->nodeValue;
1114
                    $texto .= " $name : $value";
1115
                }
1116
            }
1117
        }
1118
        return $texto;
1119
    }
1120
    
1121
    /**
1122
     * str2Hex
1123
     * Converte string para haxadecimal ASCII
1124
     *
1125
     * @param  string $str
1126
     * @return string
1127
     */
1128
    protected static function str2Hex($str)
1129
    {
1130
        if ($str == '') {
1131
            return '';
1132
        }
1133
        $hex = "";
1134
        $iCount = 0;
1135
        do {
1136
            $hex .= sprintf("%02x", ord($str{$iCount}));
1137
            $iCount++;
1138
        } while ($iCount < strlen($str));
1139
        return $hex;
1140
    }//fim str2Hex
1141
    
1142
    protected static function getCardName($tBand)
1143
    {
1144
        switch ($tBand) {
1145
            case '01':
1146
                $tBandNome = 'VISA';
1147
                break;
1148
            case '02':
1149
                $tBandNome = 'MASTERCARD';
1150
                break;
1151
            case '03':
1152
                $tBandNome = 'AMERICAM EXPRESS';
1153
                break;
1154
            case '04':
1155
                $tBandNome = 'SOROCRED';
1156
                break;
1157
            case '99':
1158
                $tBandNome = 'OUTROS';
1159
        }
1160
        return $tBandNome;
0 ignored issues
show
Bug introduced by
The variable $tBandNome 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...
1161
    }
1162
    
1163
    /**
1164
     * hex2Str
1165
     * Converte hexadecimal ASCII para string
1166
     *
1167
     * @param  string $str
1168
     * @return string
1169
     */
1170
    protected static function hex2Str($str)
1171
    {
1172
        if ($str == '') {
1173
            return '';
1174
        }
1175
        $bin = "";
1176
        $iCount = 0;
1177
        do {
1178
            $bin .= chr(hexdec($str{$iCount}.$str{($iCount + 1)}));
1179
            $iCount += 2;
1180
        } while ($iCount < strlen($str));
1181
        return $bin;
1182
    }
1183
    
1184
    protected function makeQRCode(
1185
        $chNFe,
1186
        $url,
1187
        $tpAmb,
1188
        $cDest = '',
1189
        $dhEmi = '',
1190
        $vNF = '',
1191
        $vICMS = '',
1192
        $digVal = '',
1193
        $idToken = '000001',
1194
        $token = ''
1195
    ) {
1196
        $nVersao = '100';
1197
        $dhHex = self::str2Hex($dhEmi);
1198
        $digHex = self::str2Hex($digVal);
1199
        $seq = '';
1200
        $seq .= 'chNFe=' . $chNFe;
1201
        $seq .= '&nVersao=' . $nVersao;
1202
        $seq .= '&tpAmb=' . $tpAmb;
1203
        if ($cDest != '') {
1204
            $seq .= '&cDest=' . $cDest;
1205
        }
1206
        $seq .= '&dhEmi=' . strtolower($dhHex);
1207
        $seq .= '&vNF=' . $vNF;
1208
        $seq .= '&vICMS=' . $vICMS;
1209
        $seq .= '&digVal=' . strtolower($digHex);
1210
        $seq .= '&cIdToken=' . $idToken;
1211
        //o hash code é calculado com o Token incluso
1212
        $hash = sha1($seq.$token);
1213
        $seq .= '&cHashQRCode='. strtoupper($hash);
1214
        if (strpos($url, '?') === false) {
1215
            $seq = $url.'?'.$seq;
1216
        } else {
1217
            $seq = $url.''.$seq;
1218
        }
1219
        return $seq;
1220
    }
1221
    
1222
    protected function pNotaCancelada()
1223
    {
1224
        if (!isset($this->nfeProc)) {
1225
            return false;
1226
        }
1227
        $cStat = $this->pSimpleGetValue($this->nfeProc, "cStat");
1228
        return $cStat == '101' ||
1229
                $cStat == '151' ||
1230
                $cStat == '135' ||
1231
                $cStat == '155';
1232
    }
1233
1234
    protected function pNotaDenegada()
1235
    {
1236
        if (!isset($this->nfeProc)) {
1237
            return false;
1238
        }
1239
        //NÃO ERA NECESSÁRIO ESSA FUNÇÃO POIS SÓ SE USA
1240
        //1 VEZ NO ARQUIVO INTEIRO
1241
        $cStat = $this->pSimpleGetValue($this->nfeProc, "cStat");
1242
        return $cStat == '110' ||
1243
               $cStat == '301' ||
1244
               $cStat == '302';
1245
    }
1246
}
1247