Passed
Push — master ( 7218ce...2bcb05 )
by Roberto
01:11
created
src/MDFe/Damdfe.php 1 patch
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -22,25 +22,25 @@  discard block
 block discarded – undo
22 22
 class Damdfe extends Common
23 23
 {
24 24
     //publicas
25
-    public $logoAlign='L'; //alinhamento do logo
26
-    public $yDados=0;
27
-    public $debugMode=0; //ativa ou desativa o modo de debug
25
+    public $logoAlign = 'L'; //alinhamento do logo
26
+    public $yDados = 0;
27
+    public $debugMode = 0; //ativa ou desativa o modo de debug
28 28
     //privadas
29 29
     protected $pdf; // objeto fpdf()
30 30
     protected $xml; // string XML NFe
31
-    protected $logomarca=''; // path para logomarca em jpg
32
-    protected $errMsg=''; // mesagens de erro
33
-    protected $errStatus=false;// status de erro TRUE um erro ocorreu false sem erros
34
-    protected $orientacao='P'; //orientação da DANFE P-Retrato ou L-Paisagem
35
-    protected $papel='A4'; //formato do papel
31
+    protected $logomarca = ''; // path para logomarca em jpg
32
+    protected $errMsg = ''; // mesagens de erro
33
+    protected $errStatus = false; // status de erro TRUE um erro ocorreu false sem erros
34
+    protected $orientacao = 'P'; //orientação da DANFE P-Retrato ou L-Paisagem
35
+    protected $papel = 'A4'; //formato do papel
36 36
     //destivo do arquivo pdf I-borwser, S-retorna o arquivo, D-força download, F-salva em arquivo local
37 37
     protected $destino = 'I';
38
-    protected $pdfDir=''; //diretorio para salvar o pdf com a opção de destino = F
39
-    protected $fontePadrao='Times'; //Nome da Fonte para gerar o DANFE
38
+    protected $pdfDir = ''; //diretorio para salvar o pdf com a opção de destino = F
39
+    protected $fontePadrao = 'Times'; //Nome da Fonte para gerar o DANFE
40 40
     protected $version = '1.0.0';
41 41
     protected $wPrint; //largura imprimivel
42 42
     protected $hPrint; //comprimento imprimivel
43
-    protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####";
43
+    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
44 44
     //variaveis da carta de correção
45 45
     protected $id;
46 46
     protected $chMDFe;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     ) {
86 86
         //define o caminho base da instalação do sistema
87 87
         if (!defined('PATH_ROOT')) {
88
-            define('PATH_ROOT', dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR);
88
+            define('PATH_ROOT', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
89 89
         }
90 90
 //ajuste do tempo limite de resposta do processo
91 91
         set_time_limit(1800);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             $this->infMDFe->getAttribute("Id")
192 192
         );
193 193
         if (is_object($this->mdfeProc)) {
194
-            $this->nProt = ! empty($this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ?
194
+            $this->nProt = !empty($this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ?
195 195
                     $this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : '';
196 196
             $this->dhRecbto = $this->mdfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue;
197 197
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             // posição inicial do relatorio
212 212
             $xInic = 7;
213 213
             $yInic = 7;
214
-            if ($this->papel =='A4') { //A4 210x297mm
214
+            if ($this->papel == 'A4') { //A4 210x297mm
215 215
                 $maxW = 210;
216 216
                 $maxH = 297;
217 217
             }
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
             // posição inicial do relatorio
224 224
             $xInic = 7;
225 225
             $yInic = 7;
226
-            if ($this->papel =='A4') { //A4 210x297mm
226
+            if ($this->papel == 'A4') { //A4 210x297mm
227 227
                 $maxH = 210;
228 228
                 $maxW = 297;
229 229
             }
230 230
         }//orientação
231 231
         //largura imprimivel em mm
232
-        $this->wPrint = $maxW-($margEsq+$xInic);
232
+        $this->wPrint = $maxW - ($margEsq + $xInic);
233 233
         //comprimento imprimivel em mm
234
-        $this->hPrint = $maxH-($margSup+$yInic);
234
+        $this->hPrint = $maxH - ($margSup + $yInic);
235 235
         // estabelece contagem de paginas
236 236
         $this->pdf->AliasNbPages();
237 237
         // fixa as margens
@@ -276,67 +276,67 @@  discard block
 block discarded – undo
276 276
         $w = $maxW; //round($maxW*0.41, 0);// 80;
277 277
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
278 278
         $w1 = $w;
279
-        $h=30;
279
+        $h = 30;
280 280
         $oldY += $h;
281 281
         $this->pTextBox($x, $y, $w, $h);
282 282
         if (is_file($this->logomarca)) {
283 283
             $logoInfo = getimagesize($this->logomarca);
284 284
             //largura da imagem em mm
285
-            $logoWmm = ($logoInfo[0]/72)*25.4;
285
+            $logoWmm = ($logoInfo[0] / 72) * 25.4;
286 286
             //altura da imagem em mm
287
-            $logoHmm = ($logoInfo[1]/72)*25.4;
288
-            if ($this->logoAlign=='L') {
289
-                $nImgW = round($w/4.5, 0);
290
-                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
291
-                $xImg = $x+1;
292
-                $yImg = round(($h-$nImgH)/2, 0)+$y;
287
+            $logoHmm = ($logoInfo[1] / 72) * 25.4;
288
+            if ($this->logoAlign == 'L') {
289
+                $nImgW = round($w / 4.5, 0);
290
+                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
291
+                $xImg = $x + 1;
292
+                $yImg = round(($h - $nImgH) / 2, 0) + $y;
293 293
                 //estabelecer posições do texto
294
-                $x1 = round($xImg + $nImgW +1, 0);
295
-                $y1 = round($y+2, 0);
296
-                $tw = round(2*$w/3, 0);
294
+                $x1 = round($xImg + $nImgW + 1, 0);
295
+                $y1 = round($y + 2, 0);
296
+                $tw = round(2 * $w / 3, 0);
297 297
             }
298
-            if ($this->logoAlign=='C') {
299
-                $nImgH = round($h/3, 0);
300
-                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
301
-                $xImg = round(($w-$nImgW)/2+$x, 0);
302
-                $yImg = $y+3;
298
+            if ($this->logoAlign == 'C') {
299
+                $nImgH = round($h / 3, 0);
300
+                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
301
+                $xImg = round(($w - $nImgW) / 2 + $x, 0);
302
+                $yImg = $y + 3;
303 303
                 $x1 = $x;
304 304
                 $y1 = round($yImg + $nImgH + 1, 0);
305 305
                 $tw = $w;
306 306
             }
307
-            if ($this->logoAlign=='R') {
308
-                $nImgW = round($w/3, 0);
309
-                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
310
-                $xImg = round($x+($w-(1+$nImgW)), 0);
311
-                $yImg = round(($h-$nImgH)/2, 0)+$y;
307
+            if ($this->logoAlign == 'R') {
308
+                $nImgW = round($w / 3, 0);
309
+                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
310
+                $xImg = round($x + ($w - (1 + $nImgW)), 0);
311
+                $yImg = round(($h - $nImgH) / 2, 0) + $y;
312 312
                 $x1 = $x;
313
-                $y1 = round($h/3+$y, 0);
314
-                $tw = round(2*$w/3, 0);
313
+                $y1 = round($h / 3 + $y, 0);
314
+                $tw = round(2 * $w / 3, 0);
315 315
             }
316 316
             $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
317 317
         } else {
318 318
             $x1 = $x;
319
-            $y1 = round($h/3+$y, 0);
319
+            $y1 = round($h / 3 + $y, 0);
320 320
             $tw = $w;
321 321
         }
322 322
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
323 323
         $razao = $this->xNome;
324
-        $cnpj = 'CNPJ: '.$this->pFormat($this->CNPJ, "###.###.###/####-##");
325
-        $ie = 'IE: '.$this->pFormat($this->IE, '##/########');
326
-        $lgr = 'Logradouro: '.$this->xLgr;
327
-        $nro = 'Nº: '.$this->nro;
328
-        $bairro = 'Bairro: '.$this->xBairro;
324
+        $cnpj = 'CNPJ: ' . $this->pFormat($this->CNPJ, "###.###.###/####-##");
325
+        $ie = 'IE: ' . $this->pFormat($this->IE, '##/########');
326
+        $lgr = 'Logradouro: ' . $this->xLgr;
327
+        $nro = 'Nº: ' . $this->nro;
328
+        $bairro = 'Bairro: ' . $this->xBairro;
329 329
         $CEP = $this->CEP;
330
-        $CEP = 'CEP: '.$this->pFormat($CEP, "##.###-###");
331
-        $UF = 'UF: '.$this->UF;
332
-        $mun = 'Municipio: '.$this->xMun;
330
+        $CEP = 'CEP: ' . $this->pFormat($CEP, "##.###-###");
331
+        $UF = 'UF: ' . $this->UF;
332
+        $mun = 'Municipio: ' . $this->xMun;
333 333
         
334 334
         $texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n";
335 335
         $texto .= $lgr . ' - ' . $nro . "\n";
336 336
         $texto .= $bairro . "\n";
337 337
         $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
338
-        $this->pTextBox($x1, $y1+5, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
339
-        $x = $x+$maxW/2;
338
+        $this->pTextBox($x1, $y1 + 5, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
339
+        $x = $x + $maxW / 2;
340 340
         $w = $maxW / 2;
341 341
         $this->pTextBox($x, $y, $w, $h);
342 342
         $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'I');
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         $bH = 13;
357 357
         $bW = round(($w), 0);
358 358
         $this->pdf->SetFillColor(0, 0, 0);
359
-        $this->pdf->Code128($x+5, $y+7.5, $this->chMDFe, $bW-10, $bH);
359
+        $this->pdf->Code128($x + 5, $y + 7.5, $this->chMDFe, $bW - 10, $bH);
360 360
         $this->pdf->SetFillColor(255, 255, 255);
361 361
         $y = $y + 22;
362 362
         $this->pTextBox($x, $y, $w, 8);
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $this->pTextBox($x, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, '');
367 367
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
368 368
         $texto = $this->pFormat($this->chMDFe, $this->formatoChave);
369
-        $this->pTextBox($x, $y+3, $w, 6, $texto, $aFont, 'T', 'C', 0, '');
369
+        $this->pTextBox($x, $y + 3, $w, 6, $texto, $aFont, 'T', 'C', 0, '');
370 370
         $y = $y + 11;
371 371
         $this->pTextBox($x, $y, $w, 12);
372 372
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
@@ -376,37 +376,37 @@  discard block
 block discarded – undo
376 376
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
377 377
         if (is_object($this->mdfeProc)) {
378 378
             $tsHora = $this->pConvertTime($this->dhRecbto);
379
-            $texto = $this->nProt.' - '.date('d/m/Y   H:i:s', $tsHora);
379
+            $texto = $this->nProt . ' - ' . date('d/m/Y   H:i:s', $tsHora);
380 380
         } else {
381
-            $texto = 'DAMDFE impresso em contingência - '.date('d/m/Y   H:i:s');
381
+            $texto = 'DAMDFE impresso em contingência - ' . date('d/m/Y   H:i:s');
382 382
         }
383
-        $this->pTextBox($x, $y+4, $w, 8, $texto, $aFont, 'T', 'C', 0, '');
383
+        $this->pTextBox($x, $y + 4, $w, 8, $texto, $aFont, 'T', 'C', 0, '');
384 384
         if ($this->tpAmb != 1) {
385 385
             $x = 10;
386 386
             if ($this->orientacao == 'P') {
387
-                $yy = round($this->hPrint*2/3, 0);
387
+                $yy = round($this->hPrint * 2 / 3, 0);
388 388
             } else {
389
-                $yy = round($this->hPrint/2, 0);
389
+                $yy = round($this->hPrint / 2, 0);
390 390
             }
391 391
             $h = 5;
392
-            $w = $maxW-(2*$x);
392
+            $w = $maxW - (2 * $x);
393 393
             $this->pdf->SetTextColor(90, 90, 90);
394 394
             $texto = "SEM VALOR FISCAL";
395 395
             $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
396 396
             $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
397 397
             $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
398 398
             $texto = "AMBIENTE DE HOMOLOGAÇÃO";
399
-            $this->pTextBox($x, $yy+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
399
+            $this->pTextBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
400 400
             $this->pdf->SetTextColor(0, 0, 0);
401 401
         } else {
402 402
             $x = 10;
403 403
             if ($this->orientacao == 'P') {
404
-                $yy = round($this->hPrint*2/3, 0);
404
+                $yy = round($this->hPrint * 2 / 3, 0);
405 405
             } else {
406
-                $yy = round($this->hPrint/2, 0);
406
+                $yy = round($this->hPrint / 2, 0);
407 407
             }//fim orientacao
408 408
             $h = 5;
409
-            $w = $maxW-(2*$x);
409
+            $w = $maxW - (2 * $x);
410 410
             $this->pdf->SetTextColor(90, 90, 90);
411 411
             //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
412 412
             if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                 $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
417 417
                 $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
418 418
                 $texto = "devido à problemas técnicos";
419
-                $this->pTextBox($x, $yy+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
419
+                $this->pTextBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
420 420
             }
421 421
             $this->pdf->SetTextColor(0, 0, 0);
422 422
         }
@@ -441,60 +441,60 @@  discard block
 block discarded – undo
441 441
         $w = $maxW; //round($maxW*0.41, 0);// 80;
442 442
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I');
443 443
         $w1 = $w;
444
-        $h=20;
444
+        $h = 20;
445 445
         $oldY += $h;
446 446
         $this->pTextBox($x, $y, $w, $h);
447 447
         if (is_file($this->logomarca)) {
448 448
             $logoInfo = getimagesize($this->logomarca);
449 449
             //largura da imagem em mm
450
-            $logoWmm = ($logoInfo[0]/72)*25.4;
450
+            $logoWmm = ($logoInfo[0] / 72) * 25.4;
451 451
             //altura da imagem em mm
452
-            $logoHmm = ($logoInfo[1]/72)*25.4;
453
-            if ($this->logoAlign=='L') {
454
-                $nImgW = round($w/8, 0);
455
-                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
456
-                $xImg = $x+1;
457
-                $yImg = round(($h-$nImgH)/2, 0)+$y;
452
+            $logoHmm = ($logoInfo[1] / 72) * 25.4;
453
+            if ($this->logoAlign == 'L') {
454
+                $nImgW = round($w / 8, 0);
455
+                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
456
+                $xImg = $x + 1;
457
+                $yImg = round(($h - $nImgH) / 2, 0) + $y;
458 458
                 //estabelecer posições do texto
459
-                $x1 = round($xImg + $nImgW +1, 0);
460
-                $y1 = round($y+2, 0);
461
-                $tw = round(2*$w/3, 0);
459
+                $x1 = round($xImg + $nImgW + 1, 0);
460
+                $y1 = round($y + 2, 0);
461
+                $tw = round(2 * $w / 3, 0);
462 462
             }
463
-            if ($this->logoAlign=='C') {
464
-                $nImgH = round($h/3, 0);
465
-                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
466
-                $xImg = round(($w-$nImgW)/2+$x, 0);
467
-                $yImg = $y+3;
463
+            if ($this->logoAlign == 'C') {
464
+                $nImgH = round($h / 3, 0);
465
+                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
466
+                $xImg = round(($w - $nImgW) / 2 + $x, 0);
467
+                $yImg = $y + 3;
468 468
                 $x1 = $x;
469 469
                 $y1 = round($yImg + $nImgH + 1, 0);
470 470
                 $tw = $w;
471 471
             }
472
-            if ($this->logoAlign=='R') {
473
-                $nImgW = round($w/3, 0);
474
-                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
475
-                $xImg = round($x+($w-(1+$nImgW)), 0);
476
-                $yImg = round(($h-$nImgH)/2, 0)+$y;
472
+            if ($this->logoAlign == 'R') {
473
+                $nImgW = round($w / 3, 0);
474
+                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
475
+                $xImg = round($x + ($w - (1 + $nImgW)), 0);
476
+                $yImg = round(($h - $nImgH) / 2, 0) + $y;
477 477
                 $x1 = $x;
478
-                $y1 = round($h/3+$y, 0);
479
-                $tw = round(2*$w/3, 0);
478
+                $y1 = round($h / 3 + $y, 0);
479
+                $tw = round(2 * $w / 3, 0);
480 480
             }
481 481
             $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
482 482
         } else {
483
-            $x1 = $x+40;
483
+            $x1 = $x + 40;
484 484
             $y1 = $y;
485 485
             $tw = $w;
486 486
         }
487 487
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
488 488
         $razao = $this->xNome;
489
-        $cnpj = 'CNPJ: '.$this->pFormat($this->CNPJ, "###.###.###/####-##");
490
-        $ie = 'IE: '.$this->pFormat($this->IE, '###/#######');
491
-        $lgr = 'Logradouro: '.$this->xLgr;
492
-        $nro = 'Nº: '.$this->nro;
493
-        $bairro = 'Bairro: '.$this->xBairro;
489
+        $cnpj = 'CNPJ: ' . $this->pFormat($this->CNPJ, "###.###.###/####-##");
490
+        $ie = 'IE: ' . $this->pFormat($this->IE, '###/#######');
491
+        $lgr = 'Logradouro: ' . $this->xLgr;
492
+        $nro = 'Nº: ' . $this->nro;
493
+        $bairro = 'Bairro: ' . $this->xBairro;
494 494
         $CEP = $this->CEP;
495
-        $CEP = 'CEP: '.$this->pFormat($CEP, "##.###-###");
496
-        $mun = 'Municipio: '.$this->xMun;
497
-        $UF = 'UF: '.$this->UF;
495
+        $CEP = 'CEP: ' . $this->pFormat($CEP, "##.###-###");
496
+        $mun = 'Municipio: ' . $this->xMun;
497
+        $UF = 'UF: ' . $this->UF;
498 498
         $texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n";
499 499
         $texto .= $lgr . ' - ' . $nro . "\n";
500 500
         $texto .= $bairro . "\n";
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
         $bH = 16;
522 522
         $w = $maxW;
523 523
         $this->pdf->SetFillColor(0, 0, 0);
524
-        $this->pdf->Code128($x + 5, $y+2, $this->chMDFe, $maxW - 10, $bH);
524
+        $this->pdf->Code128($x + 5, $y + 2, $this->chMDFe, $maxW - 10, $bH);
525 525
         $this->pdf->SetFillColor(255, 255, 255);
526 526
         $y = $y + 22;
527 527
         $this->pTextBox($x, $y, $maxW, 10);
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         $this->pTextBox($x, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, '');
532 532
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
533 533
         $texto = $this->pFormat($this->chMDFe, $this->formatoChave);
534
-        $this->pTextBox($x, $y+4, $maxW, 6, $texto, $aFont, 'T', 'C', 0, '');
534
+        $this->pTextBox($x, $y + 4, $maxW, 6, $texto, $aFont, 'T', 'C', 0, '');
535 535
         $y = $y + 12;
536 536
         $this->pTextBox($x, $y, $maxW, 10);
537 537
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
@@ -540,37 +540,37 @@  discard block
 block discarded – undo
540 540
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
541 541
         if (is_object($this->mdfeProc)) {
542 542
             $tsHora = $this->pConvertTime($this->dhRecbto);
543
-            $texto = $this->nProt.' - '.date('d/m/Y   H:i:s', $tsHora);
543
+            $texto = $this->nProt . ' - ' . date('d/m/Y   H:i:s', $tsHora);
544 544
         } else {
545
-            $texto = 'DAMDFE impresso em contingência - '.date('d/m/Y   H:i:s');
545
+            $texto = 'DAMDFE impresso em contingência - ' . date('d/m/Y   H:i:s');
546 546
         }
547
-        $this->pTextBox($x, $y+4, $maxW, 8, $texto, $aFont, 'T', 'C', 0, '');
547
+        $this->pTextBox($x, $y + 4, $maxW, 8, $texto, $aFont, 'T', 'C', 0, '');
548 548
         if ($this->tpAmb != 1) {
549 549
             $x = 10;
550 550
             if ($this->orientacao == 'P') {
551
-                $yy = round($this->hPrint*2/3, 0);
551
+                $yy = round($this->hPrint * 2 / 3, 0);
552 552
             } else {
553
-                $yy = round($this->hPrint/2, 0);
553
+                $yy = round($this->hPrint / 2, 0);
554 554
             }
555 555
             $h = 5;
556
-            $w = $maxW-(2*$x);
556
+            $w = $maxW - (2 * $x);
557 557
             $this->pdf->SetTextColor(90, 90, 90);
558 558
             $texto = "SEM VALOR FISCAL";
559 559
             $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
560 560
             $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
561 561
             $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
562 562
             $texto = "AMBIENTE DE HOMOLOGAÇÃO";
563
-            $this->pTextBox($x, $yy+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
563
+            $this->pTextBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
564 564
             $this->pdf->SetTextColor(0, 0, 0);
565 565
         } else {
566 566
             $x = 10;
567 567
             if ($this->orientacao == 'P') {
568
-                $yy = round($this->hPrint*2/3, 0);
568
+                $yy = round($this->hPrint * 2 / 3, 0);
569 569
             } else {
570
-                $yy = round($this->hPrint/2, 0);
570
+                $yy = round($this->hPrint / 2, 0);
571 571
             }//fim orientacao
572 572
             $h = 5;
573
-            $w = $maxW-(2*$x);
573
+            $w = $maxW - (2 * $x);
574 574
             $this->pdf->SetTextColor(90, 90, 90);
575 575
             //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
576 576
             if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
@@ -580,11 +580,11 @@  discard block
 block discarded – undo
580 580
                 $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
581 581
                 $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
582 582
                 $texto = "devido à problemas técnicos";
583
-                $this->pTextBox($x, $yy+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
583
+                $this->pTextBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
584 584
             }
585 585
             $this->pdf->SetTextColor(0, 0, 0);
586 586
         }
587
-        return $y+12;
587
+        return $y + 12;
588 588
     }// fim headerMDFe
589 589
     
590 590
     /**
@@ -603,64 +603,64 @@  discard block
 block discarded – undo
603 603
         }
604 604
         $x2 = ($maxW / 6);
605 605
         $x1 = $x2;
606
-        $this->pTextBox($x, $y, $x2-7, 12);
606
+        $this->pTextBox($x, $y, $x2 - 7, 12);
607 607
         $texto = 'Modelo';
608 608
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
609
-        $this->pTextBox($x, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
609
+        $this->pTextBox($x, $y, $x2 - 7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
610 610
         $texto = $this->mod;
611 611
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
612
-        $this->pTextBox($x, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
612
+        $this->pTextBox($x, $y + 4, $x2 - 7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
613 613
         $x1 = $x2;
614
-        $this->pTextBox($x1, $y, $x2-7, 12);
614
+        $this->pTextBox($x1, $y, $x2 - 7, 12);
615 615
         $texto = 'Série';
616 616
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
617
-        $this->pTextBox($x1, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
617
+        $this->pTextBox($x1, $y, $x2 - 7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
618 618
         $texto = $this->serie;
619 619
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
620
-        $this->pTextBox($x1, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
621
-        $x1 += $x2-7;
622
-        $this->pTextBox($x1, $y, $x2+5, 12);
620
+        $this->pTextBox($x1, $y + 4, $x2 - 7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
621
+        $x1 += $x2 - 7;
622
+        $this->pTextBox($x1, $y, $x2 + 5, 12);
623 623
         $texto = 'Número';
624 624
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
625
-        $this->pTextBox($x1, $y, $x2+5, 8, $texto, $aFont, 'T', 'L', 0, '', false);
625
+        $this->pTextBox($x1, $y, $x2 + 5, 8, $texto, $aFont, 'T', 'L', 0, '', false);
626 626
         $texto = $this->pFormat(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###');
627 627
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
628
-        $this->pTextBox($x1, $y+4, $x2+5, 10, $texto, $aFont, 'T', 'C', 0, '', false);
629
-        $x1 += $x2+5;
630
-        $this->pTextBox($x1, $y, $x2-7, 12);
628
+        $this->pTextBox($x1, $y + 4, $x2 + 5, 10, $texto, $aFont, 'T', 'C', 0, '', false);
629
+        $x1 += $x2 + 5;
630
+        $this->pTextBox($x1, $y, $x2 - 7, 12);
631 631
         $texto = 'FL';
632 632
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
633
-        $this->pTextBox($x1, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
633
+        $this->pTextBox($x1, $y, $x2 - 7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
634 634
         $texto = '1';
635 635
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
636
-        $this->pTextBox($x1, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
637
-        $x1 += $x2-7;
638
-        $this->pTextBox($x1, $y, $x2+11, 12);
636
+        $this->pTextBox($x1, $y + 4, $x2 - 7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
637
+        $x1 += $x2 - 7;
638
+        $this->pTextBox($x1, $y, $x2 + 11, 12);
639 639
         $texto = 'Data e Hora de Emissão';
640 640
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
641
-        $this->pTextBox($x1, $y, $x2+11, 8, $texto, $aFont, 'T', 'L', 0, '', false);
641
+        $this->pTextBox($x1, $y, $x2 + 11, 8, $texto, $aFont, 'T', 'L', 0, '', false);
642 642
         $data = explode('T', $this->dhEmi);
643
-        $texto = $this->pYmd2dmy($data[0]).' - '.$data[1];
643
+        $texto = $this->pYmd2dmy($data[0]) . ' - ' . $data[1];
644 644
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
645
-        $this->pTextBox($x1, $y+4, $x2+11, 10, $texto, $aFont, 'T', 'C', 0, '', false);
646
-        $x1 += $x2+11;
647
-        $this->pTextBox($x1, $y, $x2-15, 12);
645
+        $this->pTextBox($x1, $y + 4, $x2 + 11, 10, $texto, $aFont, 'T', 'C', 0, '', false);
646
+        $x1 += $x2 + 11;
647
+        $this->pTextBox($x1, $y, $x2 - 15, 12);
648 648
         $texto = 'UF Carreg.';
649 649
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
650
-        $this->pTextBox($x1, $y, $x2-15, 8, $texto, $aFont, 'T', 'L', 0, '', false);
650
+        $this->pTextBox($x1, $y, $x2 - 15, 8, $texto, $aFont, 'T', 'L', 0, '', false);
651 651
         $texto = $this->UFIni;
652 652
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
653
-        $this->pTextBox($x1, $y+4, $x2-15, 10, $texto, $aFont, 'T', 'C', 0, '', false);
653
+        $this->pTextBox($x1, $y + 4, $x2 - 15, 10, $texto, $aFont, 'T', 'C', 0, '', false);
654 654
         $maxW = $this->wPrint;
655 655
 
656
-        $x1 += $x2-15;
657
-        $this->pTextBox($x1, $y, $x2-13, 12);
656
+        $x1 += $x2 - 15;
657
+        $this->pTextBox($x1, $y, $x2 - 13, 12);
658 658
         $texto = 'UF Descar.';
659 659
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
660
-        $this->pTextBox($x1, $y, $x2-13, 8, $texto, $aFont, 'T', 'L', 0, '', false);
660
+        $this->pTextBox($x1, $y, $x2 - 13, 8, $texto, $aFont, 'T', 'L', 0, '', false);
661 661
         $texto = $this->UFFim;
662 662
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
663
-        $this->pTextBox($x1, $y+4, $x2-13, 10, $texto, $aFont, 'T', 'C', 0, '', false);
663
+        $this->pTextBox($x1, $y + 4, $x2 - 13, 10, $texto, $aFont, 'T', 'C', 0, '', false);
664 664
         $maxW = $this->wPrint;
665 665
 
666 666
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
         $this->pTextBox($x1, $y, $x2, 23);
672 672
         $texto = 'Modal Rodoviário de Carga';
673 673
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
674
-        $this->pTextBox($x1, $y+1, $x2, 8, $texto, $aFont, 'T', 'C', 0, '', false);
674
+        $this->pTextBox($x1, $y + 1, $x2, 8, $texto, $aFont, 'T', 'C', 0, '', false);
675 675
         $x1 = $x;
676 676
         $x2 = ($maxW / 6);
677 677
         $y += 6;
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
682 682
         $texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT);
683 683
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
684
-        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
684
+        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
685 685
         $x1 += $x2;
686 686
         $this->pTextBox($x1, $y, $x2, 12);
687 687
         $texto = 'Qtd. NF-e';
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
690 690
         $texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT);
691 691
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
692
-        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
692
+        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
693 693
         $x1 += $x2;
694 694
         $this->pTextBox($x1, $y, $x2, 12);
695 695
         $texto = 'Peso Total (Kg)';
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
698 698
         $texto = number_format($this->qCarga, 4, ', ', '.');
699 699
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
700
-        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
700
+        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
701 701
         $x1 = $x;
702 702
         $y += 12;
703 703
         $yold = $y;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
715 715
         $texto = $this->veicTracao->getElementsByTagName("placa")->item(0)->nodeValue;
716 716
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
717
-        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
717
+        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
718 718
         $altura = $y + 4;
719 719
         /** @var \DOMNodeList $veicReboque */
720 720
         $veicReboque = $this->veicReboque;
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
             $texto = "";
737 737
         }
738 738
         $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
739
-        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
739
+        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
740 740
         $altura = $y + 4;
741 741
         /** @var \DOMNodeList $veicReboque */
742 742
         $veicReboque = $this->veicReboque;
@@ -762,46 +762,46 @@  discard block
 block discarded – undo
762 762
         if (!$temVales) {
763 763
             $valesPedagios = 0;
764 764
         }
765
-        $this->pTextBox($x1, $y, $x2, 11+$tamanho/2);
765
+        $this->pTextBox($x1, $y, $x2, 11 + $tamanho / 2);
766 766
         $texto = 'Vale Pedágio';
767 767
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
768 768
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
769 769
         $y += 5;
770 770
         $x2 = ($x2 / 3);
771
-        $this->pTextBox($x1, $y, $x2-3, 6+($tamanho/2));
771
+        $this->pTextBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2));
772 772
         $texto = 'Responsável CNPJ';
773 773
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
774
-        $this->pTextBox($x1, $y, $x2-4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
774
+        $this->pTextBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
775 775
         $altura = $y;
776 776
         for ($i = 0; $i < $valesPedagios; $i++) {
777 777
             $altura += 4;
778 778
             $texto = $this->valePed->item($i)->getElementsByTagName('CNPJForn')->item(0)->nodeValue;
779 779
             $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
780
-            $this->pTextBox($x1 + 1, $altura, $x2-5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
780
+            $this->pTextBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
781 781
         }
782
-        $x1 += $x2-3;
783
-        $this->pTextBox($x1, $y, $x2-3, 6+($tamanho/2));
782
+        $x1 += $x2 - 3;
783
+        $this->pTextBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2));
784 784
         $texto = 'Fornecedora CNPJ';
785 785
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
786
-        $this->pTextBox($x1, $y, $x2-4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
786
+        $this->pTextBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
787 787
         $altura = $y;
788 788
         for ($i = 0; $i < $valesPedagios; $i++) {
789 789
             $altura += 4;
790 790
             $texto = $this->valePed->item($i)->getElementsByTagName('CNPJPg')->item(0)->nodeValue;
791 791
             $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
792
-            $this->pTextBox($x1 + 1, $altura, $x2-5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
792
+            $this->pTextBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
793 793
         }
794
-        $x1 += $x2-3;
795
-        $this->pTextBox($x1, $y, $x2+6, 6+($tamanho/2));
794
+        $x1 += $x2 - 3;
795
+        $this->pTextBox($x1, $y, $x2 + 6, 6 + ($tamanho / 2));
796 796
         $texto = 'Nº Comprovante';
797 797
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
798
-        $this->pTextBox($x1, $y, $x2+6, 8, $texto, $aFont, 'T', 'L', 0, '', false);
798
+        $this->pTextBox($x1, $y, $x2 + 6, 8, $texto, $aFont, 'T', 'L', 0, '', false);
799 799
         $altura = $y;
800 800
         for ($i = 0; $i < $valesPedagios; $i++) {
801 801
             $altura += 4;
802 802
             $texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue;
803 803
             $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
804
-            $this->pTextBox($x1 + 1, $altura, $x2+5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
804
+            $this->pTextBox($x1 + 1, $altura, $x2 + 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
805 805
         }
806 806
         if (!$temVales) {
807 807
             $altura += 4;
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
816 816
         $y += 5;
817 817
         $x2 = ($maxW / 4);
818
-        $this->pTextBox($x1, $y, $x2, 33+($tamanho/2));
818
+        $this->pTextBox($x1, $y, $x2, 33 + ($tamanho / 2));
819 819
         $texto = 'CPF';
820 820
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
821 821
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
         }
829 829
         $y = $yold;
830 830
         $x1 += $x2;
831
-        $this->pTextBox($x1, $y, $x2, 33+($tamanho/2));
831
+        $this->pTextBox($x1, $y, $x2, 33 + ($tamanho / 2));
832 832
         $texto = 'Nome';
833 833
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
834 834
         $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
@@ -855,9 +855,9 @@  discard block
 block discarded – undo
855 855
         '.$this->infCpl;
856 856
         $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
857 857
         $this->pTextBox($x, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
858
-        $y = $this->hPrint -4;
859
-        $texto = "Impresso em  ". date('d/m/Y   H:i:s');
860
-        $w = $this->wPrint-4;
858
+        $y = $this->hPrint - 4;
859
+        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
860
+        $w = $this->wPrint - 4;
861 861
         $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I');
862 862
         $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
863 863
     }//fim footerCCe
@@ -874,9 +874,9 @@  discard block
 block discarded – undo
874 874
         //monta
875 875
         $command = '';
876 876
         if ($nome == '') {
877
-            $file = $this->pdfDir.'mdfe.pdf';
877
+            $file = $this->pdfDir . 'mdfe.pdf';
878 878
         } else {
879
-            $file = $this->pdfDir.$nome;
879
+            $file = $this->pdfDir . $nome;
880 880
         }
881 881
         if ($destino != 'I' && $destino != 'S' && $destino != 'F') {
882 882
             $destino = 'I';
Please login to merge, or discard this patch.