Passed
Push — master ( 62cd76...600996 )
by Roberto
46s queued 10s
created

src/CTe/Dacte.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace NFePHP\DA\CTe;
4
5
/**
6
 * Classe para ageração do PDF da CTe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Dacte .php
12
 * @copyright 2009-2019 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Com\Tecnick\Barcode\Barcode;
19
use Exception;
20
use NFePHP\DA\Legacy\Dom;
21
use NFePHP\DA\Legacy\Pdf;
22
use NFePHP\DA\Legacy\Common;
23
24
class Dacte extends Common
25
{
26
27
    protected $logoAlign = 'C';
28
    protected $yDados = 0;
29
    protected $numero_registro_dpec = '';
30
    protected $pdf;
31
    protected $xml;
32
    protected $logomarca = '';
33
    protected $errMsg = '';
34
    protected $errStatus = false;
35
    protected $orientacao = 'P';
36
    protected $papel = 'A4';
37
    protected $fontePadrao = 'Times';
38
    protected $wPrint;
39
    protected $hPrint;
40
    protected $dom;
41
    protected $infCte;
42
    protected $infCteComp;
43
    protected $infCteAnu;
44
    protected $chaveCTeRef;
45
    protected $tpCTe;
46
    protected $ide;
47
    protected $emit;
48
    protected $enderEmit;
49
    protected $rem;
50
    protected $enderReme;
51
    protected $dest;
52
    protected $enderDest;
53
    protected $exped;
54
    protected $enderExped;
55
    protected $receb;
56
    protected $enderReceb;
57
    protected $infCarga;
58
    protected $infQ;
59
    protected $seg;
60
    protected $modal;
61
    protected $rodo;
62
    protected $moto;
63
    protected $veic;
64
    protected $ferrov;
65
    protected $Comp;
66
    protected $infNF;
67
    protected $infNFe;
68
    protected $compl;
69
    protected $ICMS;
70
    protected $ICMSSN;
71
    protected $ICMSOutraUF;
72
    protected $imp;
73
    protected $toma4;
74
    protected $toma03;
75
    protected $tpEmis;
76
    protected $tpImp;
77
    protected $tpAmb;
78
    protected $vPrest;
79
    protected $wAdic = 150;
80
    protected $textoAdic = '';
81
    protected $debugmode = false;
82
    protected $formatPadrao;
83
    protected $formatNegrito;
84
    protected $aquav;
85
    protected $preVisualizar;
86
    protected $flagDocOrigContinuacao;
87
    protected $arrayNFe = array();
88
    protected $totPag;
89
    protected $idDocAntEle = [];
90
    protected $qrCodCTe;
91
    protected $margemInterna = 0;
92
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
93
    private $creditos;
94
95
    /**
96
     * __construct
97
     *
98
     * @param string $xml Arquivo XML da CTe
99
     */
100
    public function __construct(
101
        $xml = ''
102
    ) {
103
        $this->debugMode();
104
        $this->loadDoc($xml);
105
    }
106
107
    /**
108
     * Ativa ou desativa o modo debug
109
     * @param bool $activate
110
     * @return bool
111
     */
112
    public function debugMode($activate = null)
113
    {
114
        if (isset($activate) && is_bool($activate)) {
115
            $this->debugmode = $activate;
116
        }
117
        if ($this->debugmode) {
118
            error_reporting(E_ALL);
119
            ini_set('display_errors', 'On');
120
        } else {
121
            error_reporting(0);
122
            ini_set('display_errors', 'Off');
123
        }
124
        return $this->debugmode;
125
    }
126
127
    private function loadDoc($xml)
128
    {
129
        $this->xml = $xml;
130
        if (!empty($xml)) {
131
            $this->dom = new Dom();
132
            $this->dom->loadXML($this->xml);
133
            $this->cteProc = $this->dom->getElementsByTagName("cteProc")->item(0);
134
            if (empty($this->dom->getElementsByTagName("infCte")->item(0))) {
135
                throw new \Exception('Isso não é um CT-e.');
136
            }
137
            $this->infCte = $this->dom->getElementsByTagName("infCte")->item(0);
138
            $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
139
            if ($this->getTagValue($this->ide, "mod") != '57') {
140
                throw new \Exception("O xml deve ser CT-e modelo 57.");
141
            }
142
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
143
            $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
144
            $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
145
            $this->rem = $this->dom->getElementsByTagName("rem")->item(0);
146
            $this->enderReme = $this->dom->getElementsByTagName("enderReme")->item(0);
147
            $this->dest = $this->dom->getElementsByTagName("dest")->item(0);
148
            $this->enderDest = $this->dom->getElementsByTagName("enderDest")->item(0);
149
            $this->exped = $this->dom->getElementsByTagName("exped")->item(0);
150
            $this->enderExped = $this->dom->getElementsByTagName("enderExped")->item(0);
151
            $this->receb = $this->dom->getElementsByTagName("receb")->item(0);
152
            $this->enderReceb = $this->dom->getElementsByTagName("enderReceb")->item(0);
153
            $this->infCarga = $this->dom->getElementsByTagName("infCarga")->item(0);
154
            $this->infQ = $this->dom->getElementsByTagName("infQ");
155
            $this->seg = $this->dom->getElementsByTagName("seg")->item(0);
156
            $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
157
            $this->aereo = $this->dom->getElementsByTagName("aereo")->item(0);
158
            $this->lota = $this->getTagValue($this->rodo, "lota");
159
            $this->moto = $this->dom->getElementsByTagName("moto")->item(0);
160
            $this->veic = $this->dom->getElementsByTagName("veic");
161
            $this->ferrov = $this->dom->getElementsByTagName("ferrov")->item(0);
162
            // adicionar outros modais
163
            $this->infCteComp = $this->dom->getElementsByTagName("infCteComp")->item(0);
164
            $this->infCteAnu = $this->dom->getElementsByTagName("infCteAnu")->item(0);
165
            if ($this->tpCTe == 1) {
166
                $this->chaveCTeRef = $this->getTagValue($this->infCteComp, "chCTe");
167
            } else {
168
                $this->chaveCTeRef = $this->getTagValue($this->infCteAnu, "chCte");
169
            }
170
            $this->vPrest = $this->dom->getElementsByTagName("vPrest")->item(0);
171
            $this->Comp = $this->dom->getElementsByTagName("Comp");
172
            $this->infNF = $this->dom->getElementsByTagName("infNF");
173
            $this->infNFe = $this->dom->getElementsByTagName("infNFe");
174
            $this->infOutros = $this->dom->getElementsByTagName("infOutros");
175
            $this->compl = $this->dom->getElementsByTagName("compl");
176
            $this->ICMS = $this->dom->getElementsByTagName("ICMS")->item(0);
177
            $this->ICMSSN = $this->dom->getElementsByTagName("ICMSSN")->item(0);
178
            $this->ICMSOutraUF = $this->dom->getElementsByTagName("ICMSOutraUF")->item(0);
179
            $this->imp = $this->dom->getElementsByTagName("imp")->item(0);
180
            if (!empty($this->getTagValue($this->imp, "vTotTrib"))) {
181
                $textoAdic = number_format($this->getTagValue($this->imp, "vTotTrib"), 2, ",", ".");
182
                $this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
183
                    . $textoAdic;
184
            }
185
            $this->toma4 = $this->dom->getElementsByTagName("toma4")->item(0);
186
            $this->toma03 = $this->dom->getElementsByTagName("toma3")->item(0);
187
            //Tag tomador é identificado por toma03 na versão 2.00
188
            if ($this->infCte->getAttribute("versao") == "2.00") {
189
                $this->toma03 = $this->dom->getElementsByTagName("toma03")->item(0);
190
            }
191
            //modal aquaviário
192
            $this->aquav = $this->dom->getElementsByTagName("aquav")->item(0);
193
            $tomador = $this->getTagValue($this->toma03, "toma");
194
            //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4-Outros
195
            switch ($tomador) {
196
                case '0':
197
                    $this->toma = $this->rem;
198
                    $this->enderToma = $this->enderReme;
199
                    break;
200
                case '1':
201
                    $this->toma = $this->exped;
202
                    $this->enderToma = $this->enderExped;
203
                    break;
204
                case '2':
205
                    $this->toma = $this->receb;
206
                    $this->enderToma = $this->enderReceb;
207
                    break;
208
                case '3':
209
                    $this->toma = $this->dest;
210
                    $this->enderToma = $this->enderDest;
211
                    break;
212
                default:
213
                    $this->toma = $this->toma4;
214
                    $this->enderToma = $this->getTagValue($this->toma4, "enderToma");
215
                    break;
216
            }
217
            $this->tpEmis = $this->getTagValue($this->ide, "tpEmis");
218
            $this->tpImp = $this->getTagValue($this->ide, "tpImp");
219
            $this->tpAmb = $this->getTagValue($this->ide, "tpAmb");
220
            $this->tpCTe = $this->getTagValue($this->ide, "tpCTe");
221
            $this->qrCodCTe = $this->dom->getElementsByTagName('qrCodCTe')->item(0) ?
222
                $this->dom->getElementsByTagName('qrCodCTe')->item(0)->nodeValue : 'SEM INFORMAÇÃO DE QRCODE';
223
            $this->protCTe = $this->dom->getElementsByTagName("protCTe")->item(0);
224
            //01-Rodoviário; //02-Aéreo; //03-Aquaviário; //04-Ferroviário;//05-Dutoviário
225
            $this->modal = $this->getTagValue($this->ide, "modal");
226
        }
227
    }
228
229
    /**
230
     * Dados brutos do PDF
231
     * @return string
232
     */
233
    public function render()
234
    {
235
        if (empty($this->pdf)) {
236
            $this->monta();
237
        }
238
        return $this->pdf->getPdf();
239
    }
240
241
    protected function cteDPEC()
242
    {
243
        return $this->numero_registro_dpec != '';
244
    }
245
246
    /**
247
     * montaDACTE
248
     * Esta função monta a DACTE conforme as informações fornecidas para a classe
249
     * durante sua construção.
250
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
251
     * pelo conteúdo da funçao e podem ser modificados.
252
     *
253
     * @param  string $orientacao (Opcional) Estabelece a orientação da
254
     *                impressão (ex. P-retrato), se nada for fornecido será
255
     *                usado o padrão da NFe
256
     * @param  string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
257
     * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML
258
     */
259
    public function monta(
260
        $logo = '',
261
        $orientacao = '',
262
        $papel = 'A4',
263
        $logoAlign = 'C'
264
    ) {
265
        $this->pdf = '';
266
        $this->logomarca = $logo;
267
        //se a orientação estiver em branco utilizar o padrão estabelecido no CTe
268
        if ($orientacao == '') {
269
            if ($this->tpImp == '1') {
270
                $orientacao = 'P';
271
            } else {
272
                $orientacao = 'P';
273
            }
274
        }
275
        $this->orientacao = $orientacao;
276
        $this->papel = $papel;
277
        $this->logoAlign = $logoAlign;
278
        //instancia a classe pdf
279
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
280
        // verifica se foi passa a fonte a ser usada
281
        $this->formatPadrao = array(
282
            'font' => $this->fontePadrao,
283
            'size' => 6,
284
            'style' => '');
285
        $this->formatNegrito = array(
286
            'font' => $this->fontePadrao,
287
            'size' => 7,
288
            'style' => 'B');
289
        if ($this->orientacao == 'P') {
290
            // margens do PDF
291
            $margSup = 2;
292
            $margEsq = 2;
293
            $margDir = 2;
294
            // posição inicial do relatorio
295
            $xInic = 1;
296
            $yInic = 1;
297
            if ($papel == 'A4') {
298
                //A4 210x297mm
299
                $maxW = 210;
300
                $maxH = 297;
301
            }
302
        } else {
303
            // margens do PDF
304
            $margSup = 3;
305
            $margEsq = 3;
306
            $margDir = 3;
307
            // posição inicial do relatorio
308
            $xInic = 5;
309
            $yInic = 5;
310
            if ($papel == 'A4') {
311
                //A4 210x297mm
312
                $maxH = 210;
313
                $maxW = 297;
314
                $this->wCanhoto = 25;
315
            }
316
        }
317
        //total inicial de paginas
318
        $totPag = 1;
319
        //largura imprimivel em mm
320
        $this->wPrint = $maxW - ($margEsq + $xInic);
321
        //comprimento imprimivel em mm
322
        $this->hPrint = $maxH - ($margSup + $yInic);
323
        // estabelece contagem de paginas
324
        $this->pdf->aliasNbPages();
325
        // fixa as margens
326
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
327
        $this->pdf->setDrawColor(0, 0, 0);
328
        $this->pdf->setFillColor(255, 255, 255);
329
        // inicia o documento
330
        $this->pdf->Open();
331
        // adiciona a primeira página
332
        $this->pdf->addPage($this->orientacao, $this->papel);
333
        $this->pdf->setLineWidth(0.1);
334
        $this->pdf->setTextColor(0, 0, 0);
335
        //calculo do numero de páginas ???
336
        $totPag = 1;
337
        //montagem da primeira página
338
        $pag = 1;
339
        $x = $xInic;
340
        $y = $yInic;
341
        //coloca o cabeçalho
342
        $y = $this->canhoto($x, $y);
343
        $y += 24;
344
        $r = $this->cabecalho($x, $y, $pag, $totPag);
345
        $y += 70;
346
        $r = $this->remetente($x, $y);
347
        $x = $this->wPrint * 0.5 + 2;
348
        $r = $this->destinatario($x, $y);
349
        $y += 19;
350
        $x = $xInic;
351
        $r = $this->expedidor($x, $y);
352
        $x = $this->wPrint * 0.5 + 2;
353
        $r = $this->recebedor($x, $y);
354
        $y += 19;
355
        $x = $xInic;
356
        $r = $this->tomador($x, $y);
357
        if ($this->tpCTe == '0') {
358
            //Normal
359
            $y += 10;
360
            $x = $xInic;
361
            $r = $this->descricaoCarga($x, $y);
362
            $y += 17;
363
            $x = $xInic;
364
            $r = $this->compValorServ($x, $y);
365
            $y += 25;
366
            $x = $xInic;
367
            $r = $this->impostos($x, $y);
368
            $y += 13;
369
            $x = $xInic;
370
            $r = $this->docOrig($x, $y);
371
            if ($this->modal == '1') {
372
                if ($this->lota == 1) {
373
                    //$y += 24.95;
374
                    $y += 35;
375
                } else {
376
                    $y += 53;
377
                }
378
            } elseif ($this->modal == '2') {
379
                $y += 53;
380
            } elseif ($this->modal == '3') {
381
                $y += 37.75;
382
            } else {
383
                $y += 24.95;
384
            }
385
            $x = $xInic;
386
            $r = $this->observacao($x, $y);
387
            $y = $y - 6;
388
            switch ($this->modal) {
389
                case '1':
390
                    $y += 25.9;
391
                    $x = $xInic;
392
                    $r = $this->modalRod($x, $y);
393
                    break;
394
                case '2':
395
                    $y += 25.9;
396
                    $x = $xInic;
397
                    $r = $this->modalAereo($x, $y);
398
                    break;
399
                case '3':
400
                    $y += 17.9;
401
                    $x = $xInic;
402
                    $r = $this->modalAquaviario($x, $y);
403
                    break;
404
                case '4':
405
                    $y += 17.9;
406
                    $x = $xInic;
407
                    $r = $this->modalFerr($x, $y);
408
                    break;
409
                case '5':
410
                    $y += 17.9;
411
                    $x = $xInic;
412
                    // TODO fmertins 31/10/14: este método não existe...
413
                    $r = $this->modalDutoviario($x, $y);
414
                    break;
415
            }
416
            if ($this->modal == '1') {
417
                if ($this->lota == 1) {
418
                    $y += 37;
419
                } else {
420
                    $y += 8.9;
421
                }
422
            } elseif ($this->modal == '2') {
423
                $y += 8.9;
424
            } elseif ($this->modal == '3') {
425
                $y += 24.15;
426
            } else {
427
                $y += 37;
428
            }
429
        } else {
430
            //$r = $this->cabecalho(1, 1, $pag, $totPag);
431
            //Complementado
432
            $y += 10;
433
            $x = $xInic;
434
            $r = $this->docCompl($x, $y);
435
            $y += 80;
436
            $x = $xInic;
437
            $r = $this->compValorServ($x, $y);
438
            $y += 25;
439
            $x = $xInic;
440
            $r = $this->impostos($x, $y);
441
            $y += 13;
442
            $x = $xInic;
443
            $r = $this->observacao($x, $y);
444
            $y += 15;
445
        }
446
        $x = $xInic;
447
        $r = $this->dadosAdic($x, $y, $pag, $totPag);
448
        //$y += 19;
449
        //$y += 11;
450
        //$y = $this->canhoto($x, $y);
451
        //coloca o rodapé da página
452
        if ($this->orientacao == 'P') {
453
            $this->rodape(2, $this->hPrint - 2);
454
        } else {
455
            $this->rodape($xInic, $this->hPrint + 2.3);
456
        }
457
        if ($this->flagDocOrigContinuacao == 1) {
458
            $this->docOrigContinuacao(1, 71);
459
        }
460
    }
461
462
    /**
463
     * cabecalho
464
     * Monta o cabelhalho da DACTE ( retrato e paisagem )
465
     *
466
     * @param  number $x Posição horizontal inicial, canto esquerdo
467
     * @param  number $y Posição vertical inicial, canto superior
468
     * @param  number $pag Número da Página
469
     * @param  number $totPag Total de páginas
470
     * @return number Posição vertical final
471
     */
472
    protected function cabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
473
    {
474
        $oldX = $x;
475
        $oldY = $y;
476
        if ($this->orientacao == 'P') {
477
            $maxW = $this->wPrint;
478
        } else {
479
            if ($pag == 1) {
480
                // primeira página
481
                $maxW = $this->wPrint - $this->wCanhoto;
482
            } else {
483
                // páginas seguintes
484
                $maxW = $this->wPrint;
485
            }
486
        }
487
        //##################################################################
488
        //coluna esquerda identificação do emitente
489
        //$w = round($maxW * 0.42);
490
        $w = round($maxW * 0.32);
491
        if ($this->orientacao == 'P') {
492
            $aFont = array(
493
                'font' => $this->fontePadrao,
494
                'size' => 6,
495
                'style' => '');
496
        } else {
497
            $aFont = $this->formatNegrito;
498
        }
499
        $w1 = $w;
500
        $h = 35;
501
        $oldY += $h;
502
        //desenha a caixa
503
        $this->pdf->textBox($x, $y, $w + 2, $h + 1);
504
        // coloca o logo
505
        if (!empty($this->logomarca)) {
506
            $logoInfo = getimagesize($this->logomarca);
507
            //largura da imagem em mm
508
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
509
            //altura da imagem em mm
510
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
511
            if ($this->logoAlign == 'L') {
512
                $nImgW = round($w / 3, 0);
513
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
514
                $xImg = $x + 1;
515
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
516
                //estabelecer posições do texto
517
                $x1 = round($xImg + $nImgW + 1, 0);
518
                $y1 = round($h / 3 + $y, 0);
519
                $tw = round(2 * $w / 3, 0);
520
            } elseif ($this->logoAlign == 'C') {
521
                $nImgH = round($h / 3, 0);
522
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
523
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
524
                $yImg = $y + 3;
525
                $x1 = $x;
526
                $y1 = round($yImg + $nImgH + 1, 0);
527
                $tw = $w;
528
            } elseif ($this->logoAlign == 'R') {
529
                $nImgW = round($w / 3, 0);
530
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
531
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
532
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
533
                $x1 = $x;
534
                $y1 = round($h / 3 + $y, 0);
535
                $tw = round(2 * $w / 3, 0);
536
            }
537
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
538
        } else {
539
            $x1 = $x;
540
            $y1 = round($h / 3 + $y, 0);
541
            $tw = $w;
542
        }
543
        //Nome emitente
544
        $aFont = array(
545
            'font' => $this->fontePadrao,
546
            'size' => 9,
547
            'style' => 'B');
548
        $texto = $this->getTagValue($this->emit, "xNome");
549
        $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
550
        //endereço
551
        $y1 = $y1 + 3;
552
        $aFont = array(
553
            'font' => $this->fontePadrao,
554
            'size' => 7,
555
            'style' => '');
556
        $fone = $this->getTagValue($this->enderEmit, "fone") != "" ? $this->formatFone($this->enderEmit) : '';
557
        $lgr = $this->getTagValue($this->enderEmit, "xLgr");
558
        $nro = $this->getTagValue($this->enderEmit, "nro");
559
        $cpl = $this->getTagValue($this->enderEmit, "xCpl");
560
        $bairro = $this->getTagValue($this->enderEmit, "xBairro");
561
        $CEP = $this->getTagValue($this->enderEmit, "CEP");
562
        $CEP = $this->formatField($CEP, "#####-###");
563
        $mun = $this->getTagValue($this->enderEmit, "xMun");
564
        $UF = $this->getTagValue($this->enderEmit, "UF");
565
        $xPais = $this->getTagValue($this->enderEmit, "xPais");
566
        $texto = $lgr . "," . $nro . "\n" . $bairro . " - "
567
            . $CEP . " - " . $mun . " - " . $UF . " " . $xPais
568
            . "\n  Fone/Fax: " . $fone;
569
        $this->pdf->textBox($x1 - 5, $y1 + 2, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
570
        //CNPJ/CPF IE
571
        $cpfCnpj = $this->formatCNPJCPF($this->emit);
572
        $ie = $this->getTagValue($this->emit, "IE");
573
        $texto = 'CNPJ/CPF:  ' . $cpfCnpj . '     Insc.Estadual: ' . $ie;
574
        $this->pdf->textBox($x1 - 1, $y1 + 12, $tw + 5, 8, $texto, $aFont, 'T', 'C', 0, '');
575
        //outra caixa
576
        $h1 = 17.5;
577
        $y1 = $y + $h + 1;
578
        $this->pdf->textBox($x, $y1, $w + 2, $h1);
579
        //TIPO DO CT-E
580
        $texto = 'TIPO DO CTE';
581
        //$wa = 37;
582
        $wa = 34;
583
        $aFont = array(
584
            'font' => $this->fontePadrao,
585
            'size' => 8,
586
            'style' => '');
587
        $this->pdf->textBox($x, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
588
        $tpCTe = $this->getTagValue($this->ide, "tpCTe");
589
        //0 - CT-e Normal,1 - CT-e de Complemento de Valores,
590
        //2 - CT-e de Anulação de Valores,3 - CT-e Substituto
591
        switch ($tpCTe) {
592
            case '0':
593
                $texto = 'Normal';
594
                break;
595
            case '1':
596
                $texto = 'Complemento de Valores';
597
                break;
598
            case '2':
599
                $texto = 'Anulação de Valores';
600
                break;
601
            case '3':
602
                $texto = 'Substituto';
603
                break;
604
            default:
605
                $texto = 'ERRO' . $tpCTe . $tpServ;
606
        }
607
        $aFont = $this->formatNegrito;
608
        $this->pdf->textBox($x, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
609
        //TIPO DO SERVIÇO
610
        $texto = 'TIPO DO SERVIÇO';
611
        $wb = 36;
612
        $aFont = array(
613
            'font' => $this->fontePadrao,
614
            'size' => 8,
615
            'style' => '');
616
        $this->pdf->textBox($x + $wa, $y1, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
617
        $tpServ = $this->getTagValue($this->ide, "tpServ");
618
        //0 - Normal;1 - Subcontratação;2 - Redespacho;3 - Redespacho Intermediário
619
        switch ($tpServ) {
620
            case '0':
621
                $texto = 'Normal';
622
                break;
623
            case '1':
624
                $texto = 'Subcontratação';
625
                break;
626
            case '2':
627
                $texto = 'Redespacho';
628
                break;
629
            case '3':
630
                $texto = 'Redespacho Intermediário';
631
                break;
632
            default:
633
                $texto = 'ERRO' . $tpServ;
634
        }
635
        $aFont = $this->formatNegrito;
636
        $this->pdf->textBox($x + $wa, $y1 + 3, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '', false);
637
        $this->pdf->line($w * 0.5, $y1, $w * 0.5, $y1 + $h1);
638
        //TOMADOR DO SERVIÇO
639
        $texto = 'IND.DO CT-E GLOBALIZADO';
640
        $wc = 37;
641
        $y2 = $y1 + 8;
642
        $aFont = array(
643
            'font' => $this->fontePadrao,
644
            'size' => 6,
645
            'style' => '');
646
        $this->pdf->textBox($x, $y2, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
647
        $this->pdf->line($x, $y1 + 8, $w + 3, $y1 + 8);
648
        $toma = $this->getTagValue($this->ide, "indGlobalizado");
649
        //0-Remetente;1-Expedidor;2-Recebedor;3-Destinatário;4 - Outros
650
        if ($toma == 1) {
651
            $aFont = array(
652
                'font' => $this->fontePadrao,
653
                'size' => 11,
654
                'style' => '');
655
            $this->pdf->textBox($x - 14.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
656
        } else {
657
            $aFont = array(
658
                'font' => $this->fontePadrao,
659
                'size' => 11,
660
                'style' => '');
661
            $this->pdf->textBox($x + 3.5, $y2 + 3.5, $w * 0.5, $h1, 'X', $aFont, 'T', 'C', 0, '', false);
662
        }
663
        $aFont = $this->formatNegrito;
664
        $this->pdf->line($x + 3, $x + 71, $x + 3, $x + 75);
665
        $this->pdf->line($x + 8, $x + 71, $x + 8, $x + 75);
666
        $this->pdf->line($x + 3, $x + 71, $x + 8, $x + 71);
667
        $this->pdf->line($x + 3, $x + 75, $x + 8, $x + 75);
668
        $this->pdf->textBox($x - 6, $y2 + 1.4 + 3, $w * 0.5, $h1, 'SIM', $aFont, 'T', 'C', 0, '', false);
669
        $this->pdf->line($x + 18, $x + 71, $x + 18, $x + 75);
670
        $this->pdf->line($x + 23, $x + 71, $x + 23, $x + 75);
671
        $this->pdf->line($x + 18, $x + 71, $x + 23, $x + 71);
672
        $this->pdf->line($x + 18, $x + 75, $x + 23, $x + 75);
673
        $this->pdf->textBox($x + 9.8, $y2 + 1.4 + 3, $w * 0.5, $h1, 'NÃO', $aFont, 'T', 'C', 0, '', false);
674
        //FORMA DE PAGAMENTO
675
        $texto = 'INF.DO CT-E GLOBALIZADO';
676
        $wd = 36;
677
        $aFont = array(
678
            'font' => $this->fontePadrao,
679
            'size' => 8,
680
            'style' => '');
681
        $this->pdf->textBox($x + $wa, $y2 - 0.5, $w * 0.5, $h1, $texto, $aFont, 'T', 'C', 0, '');
682
        $forma = $this->getTagValue($this->ide, "forPag");
683
        //##################################################################
684
        //coluna direita
685
        $x += $w + 2;
686
        $w = round($maxW * 0.212);
687
        $w1 = $w;
688
        $h = 11;
689
        $this->pdf->textBox($x, $y, $w + 48.5, $h + 1);
690
        $texto = "DACTE";
691
        $aFont = array(
692
            'font' => $this->fontePadrao,
693
            'size' => 10,
694
            'style' => 'B');
695
        $this->pdf->textBox($x + 25, $y + 2, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
696
        $aFont = array(
697
            'font' => $this->fontePadrao,
698
            'size' => 9,
699
            'style' => '');
700
        $texto = "Documento Auxiliar do Conhecimento de Transporte Eletrônico";
701
        $h = 10;
702
        $this->pdf->textBox($x + 5, $y + 6, $w + 40, $h, $texto, $aFont, 'T', 'C', 0, '', false);
703
        $x1 = $x + $w + 2;
704
        $w = round($maxW * 0.22, 0);
705
        $w2 = $w;
706
        $h = 11;
707
        $this->pdf->textBox($x1 + 46.5, $y, $w - 0.5, $h + 1);
708
        $texto = "MODAL";
709
        $aFont = array(
710
            'font' => $this->fontePadrao,
711
            'size' => 8,
712
            'style' => '');
713
        $this->pdf->textBox($x1 + 47, $y + 1, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
714
        switch ($this->modal) {
715
            case '1':
716
                $texto = 'Rodoviário';
717
                break;
718
            case '2':
719
                $texto = 'Aéreo';
720
                break;
721
            case '3':
722
                $texto = 'Aquaviário';
723
                break;
724
            case '4':
725
                $texto = 'Ferroviário';
726
                break;
727
            case '5':
728
                $texto = 'Dutoviário';
729
                break;
730
        }
731
        $aFont = array(
732
            'font' => $this->fontePadrao,
733
            'size' => 10,
734
            'style' => 'B');
735
        $this->pdf->textBox($x1 + 47, $y + 5, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
736
        //outra caixa
737
        $y += 12;
738
        $h = 9;
739
        $w = $w1 + $w2 + 2;
740
        $this->pdf->textBox($x, $y, $w + 0.5, $h + 1);
741
        //modelo
742
        $wa = 12;
743
        $xa = $x;
744
        $texto = 'MODELO';
745
        $aFont = array(
746
            'font' => $this->fontePadrao,
747
            'size' => 8,
748
            'style' => '');
749
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
750
        $texto = $this->getTagValue($this->ide, "mod");
751
        $aFont = $this->formatNegrito;
752
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
753
        $this->pdf->line($x + $wa, $y, $x + $wa, $y + $h + 1);
754
        //serie
755
        $wa = 11;
756
        $xa += $wa;
757
        $texto = 'SÉRIE';
758
        $aFont = array(
759
            'font' => $this->fontePadrao,
760
            'size' => 8,
761
            'style' => '');
762
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
763
        $texto = $this->getTagValue($this->ide, "serie");
764
        $aFont = $this->formatNegrito;
765
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
766
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
767
        //numero
768
        $xa += $wa;
769
        $wa = 14;
770
        $texto = 'NÚMERO';
771
        $aFont = array(
772
            'font' => $this->fontePadrao,
773
            'size' => 8,
774
            'style' => '');
775
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
776
        $texto = $this->getTagValue($this->ide, "nCT");
777
        $aFont = $this->formatNegrito;
778
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
779
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
780
        //folha
781
        $xa += $wa;
782
        $wa = 6;
783
        $texto = 'FL';
784
        $aFont = array(
785
            'font' => $this->fontePadrao,
786
            'size' => 8,
787
            'style' => '');
788
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
789
        //$texto = '1/1';
790
        $texto = $pag . "/" . $totPag;
791
        $aFont = $this->formatNegrito;
792
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
793
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
794
        //data  hora de emissão
795
        $xa += $wa;
796
        $wa = 28;
797
        $texto = 'DATA E HORA DE EMISSÃO';
798
        $aFont = array(
799
            'font' => $this->fontePadrao,
800
            'size' => 8,
801
            'style' => '');
802
        $this->pdf->textBox($xa, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
803
        $texto = !empty($this->ide->getElementsByTagName("dhEmi")->item(0)->nodeValue) ?
804
            date('d/m/Y H:i:s', $this->convertTime($this->getTagValue($this->ide, "dhEmi"))) : '';
0 ignored issues
show
The method convertTime() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

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

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

Loading history...
805
        $aFont = $this->formatNegrito;
806
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
807
        $this->pdf->line($xa + $wa, $y, $xa + $wa, $y + $h + 1);
808
        //ISUF
809
        $xa += $wa;
810
        $wa = 30;
811
        $texto = 'INSC.SUF.DO DEST';
812
        $aFont = $this->formatPadrao;
813
        $this->pdf->textBox($xa - 5, $y + 1, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
814
        $texto = $this->getTagValue($this->dest, "ISUF");
815
        $aFont = array(
816
            'font' => $this->fontePadrao,
817
            'size' => 7,
818
            'style' => 'B');
819
        $this->pdf->textBox($xa, $y + 5, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
820
        //outra caixa
821
        $y += $h + 1;
822
        $h = 23;
823
        $h1 = 14;
824
        $this->pdf->textBox($x, $y, $w + 0.5, $h1);
825
        //CODIGO DE BARRAS
826
        $chave_acesso = str_replace('CTe', '', $this->infCte->getAttribute("Id"));
827
        $bW = 85;
828
        $bH = 10;
829
        //codigo de barras
830
        $this->pdf->setFillColor(0, 0, 0);
831
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $chave_acesso, $bW, $bH);
832
        $this->pdf->textBox($x, $y + $h1, $w + 0.5, $h1 - 6);
833
        $texto = 'CHAVE DE ACESSO';
834
        $aFont = $this->formatPadrao;
835
        $this->pdf->textBox($x, $y + $h1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
836
        $aFont = $this->formatNegrito;
837
        $texto = $this->formatField($chave_acesso, $this->formatoChave);
838
        $this->pdf->textBox($x, $y + $h1 + 3, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
839
        $this->pdf->textBox($x, $y + $h1 + 8, $w + 0.5, $h1 - 4.5);
840
        $texto = "Consulta em http://www.cte.fazenda.gov.br/portal";
841
        if ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
842
            $texto = "";
843
            $this->pdf->setFillColor(0, 0, 0);
844
            if ($this->tpEmis == 5) {
845
                $chaveContingencia = $this->geraChaveAdicCont();
846
                $this->pdf->code128($x + 20, $y1 + 10, $chaveContingencia, $bW * .9, $bH / 2);
847
            } else {
848
                $chaveContingencia = $this->getTagValue($this->protCTe, "nProt");
849
                $this->pdf->Code128($x + 40, $y1 + 10, $chaveContingencia, $bW * .4, $bH / 2);
850
            }
851
            //codigo de barras
852
        }
853
        $aFont = array(
854
            'font' => $this->fontePadrao,
855
            'size' => 8,
856
            'style' => '');
857
        $this->pdf->textBox($x, $y + $h1 + 11, $w, $h, $texto, $aFont, 'T', 'C', 0, '');
858
        //outra caixa
859
        $y += $h + 1;
860
        $h = 8.5;
861
        $wa = $w;
862
        $this->pdf->textBox($x, $y + 7.5, $w + 0.5, $h);
863
        if ($this->cteDPEC()) {
864
            $texto = 'NÚMERO DE REGISTRO DPEC';
865
        } elseif ($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) {
866
            $texto = "DADOS DO CT-E";
867
        } else {
868
            $texto = 'PROTOCOLO DE AUTORIZAÇÃO DE USO';
869
        }
870
        $aFont = $this->formatPadrao;
871
        $this->pdf->textBox($x, $y + 7.5, $wa, $h, $texto, $aFont, 'T', 'L', 0, '');
872
        if ($this->cteDPEC()) {
873
            $texto = $this->numero_registro_dpec;
874
        } elseif ($this->tpEmis == 5) {
875
            $chaveContingencia = $this->geraChaveAdicCont();
876
            $aFont = array(
877
                'font' => $this->fontePadrao,
878
                'size' => 8,
879
                'style' => 'B');
880
            $texto = $this->formatField($chaveContingencia, "#### #### #### #### #### #### #### #### ####");
881
            $cStat = '';
882
        } else {
883
            $texto = $this->getTagValue($this->protCTe, "nProt") . " - ";
884
            if (!empty($this->protCTe)
885
                && !empty($this->protCTe->getElementsByTagName("dhRecbto")->item(0)->nodeValue)
886
            ) {
887
                $texto .= date(
888
                    'd/m/Y   H:i:s',
889
                    $this->convertTime($this->getTagValue($this->protCTe, "dhRecbto"))
0 ignored issues
show
The method convertTime() does not seem to exist on object<NFePHP\DA\CTe\Dacte>.

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

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

Loading history...
890
                );
891
            }
892
            $texto = $this->getTagValue($this->protCTe, "nProt") == '' ? '' : $texto;
893
        }
894
        $aFont = $this->formatNegrito;
895
        $this->pdf->textBox($x, $y + 12, $wa, $h, $texto, $aFont, 'T', 'C', 0, '');
896
        if ($this->qrCodCTe !== null) {
897
            $this->qrCodeDacte($y - 27);
898
            $w = 45;
899
            $x += 92.5;
900
            $this->pdf->textBox($x, $y - 34, $w + 0.5, $h + 41.5);
901
        }
902
        //CFOP
903
        $x = $oldX;
904
        $h = 8.5;
905
        $w = round($maxW * 0.32);
906
        $y1 = $y + 7.5;
907
        $this->pdf->textBox($x, $y1, $w + 2, $h);
908
        $texto = 'CFOP - NATUREZA DA PRESTAÇÃO';
909
        $aFont = array(
910
            'font' => $this->fontePadrao,
911
            'size' => 8,
912
            'style' => '');
913
        $this->pdf->textBox($x, $y1, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
914
        $texto = $this->getTagValue($this->ide, "CFOP") . ' - ' . $this->getTagValue($this->ide, "natOp");
915
        $aFont = $this->formatNegrito;
916
        $this->pdf->textBox($x, $y1 + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
917
        //ORIGEM DA PRESTAÇÃO
918
        $y += $h + 7.5;
919
        $x = $oldX;
920
        $h = 8;
921
        $w = ($maxW * 0.5);
922
        $this->pdf->textBox($x, $y, $w + 0.5, $h);
923
        $texto = 'INÍCIO DA PRESTAÇÃO';
924
        $aFont = array(
925
            'font' => $this->fontePadrao,
926
            'size' => 8,
927
            'style' => '');
928
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
929
        $texto = $this->getTagValue($this->ide, "xMunIni") . ' - ' . $this->getTagValue($this->ide, "UFIni");
930
        $aFont = $this->formatNegrito;
931
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
932
        //DESTINO DA PRESTAÇÃO
933
        $x = $oldX + $w + 1;
934
        $h = 8;
935
        $w = $w - 1.3;
936
        $this->pdf->textBox($x - 0.5, $y, $w + 0.5, $h);
937
        $texto = 'TÉRMINO DA PRESTAÇÃO';
938
        $aFont = array(
939
            'font' => $this->fontePadrao,
940
            'size' => 8,
941
            'style' => '');
942
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
943
        $texto = $this->getTagValue($this->ide, "xMunFim") . ' - ' . $this->getTagValue($this->ide, "UFFim");
944
        $aFont = $this->formatNegrito;
945
        $this->pdf->textBox($x, $y + 3.5, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
946
        //#########################################################################
947
        //Indicação de CTe Homologação, cancelamento e falta de protocolo
948
        $tpAmb = $this->ide->getElementsByTagName('tpAmb')->item(0)->nodeValue;
949
        //indicar cancelamento
950
        $cStat = $this->getTagValue($this->cteProc, "cStat");
951
        if ($cStat == '101' || $cStat == '135') {
952
            //101 Cancelamento
953
            $x = 10;
954
            $y = $this->hPrint - 130;
955
            $h = 25;
956
            $w = $maxW - (2 * $x);
957
            $this->pdf->setTextColor(90, 90, 90);
958
            $texto = "CTe CANCELADO";
959
            $aFont = array(
960
                'font' => $this->fontePadrao,
961
                'size' => 48,
962
                'style' => 'B');
963
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
964
            $this->pdf->setTextColor(0, 0, 0);
965
        }
966
        $cStat = $this->getTagValue($this->cteProc, "cStat");
967
        if ($cStat == '110' ||
968
            $cStat == '301' ||
969
            $cStat == '302'
970
        ) {
971
            //110 Denegada
972
            $x = 10;
973
            $y = $this->hPrint - 130;
974
            $h = 25;
975
            $w = $maxW - (2 * $x);
976
            $this->pdf->setTextColor(90, 90, 90);
977
            $texto = "CTe USO DENEGADO";
978
            $aFont = array(
979
                'font' => $this->fontePadrao,
980
                'size' => 48,
981
                'style' => 'B');
982
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
983
            $y += $h;
984
            $h = 5;
985
            $w = $maxW - (2 * $x);
986
            $texto = "SEM VALOR FISCAL";
987
            $aFont = array(
988
                'font' => $this->fontePadrao,
989
                'size' => 48,
990
                'style' => 'B');
991
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
992
            $this->pdf->setTextColor(0, 0, 0);
993
        }
994
        //indicar sem valor
995
        if ($tpAmb != 1 && $this->preVisualizar == '0') { // caso não seja uma DA de produção
996
            $x = 10;
997
            if ($this->orientacao == 'P') {
998
                $y = round($this->hPrint * 2 / 3, 0);
999
            } else {
1000
                $y = round($this->hPrint / 2, 0);
1001
            }
1002
            $h = 5;
1003
            $w = $maxW - (2 * $x);
1004
            $this->pdf->setTextColor(90, 90, 90);
1005
            $texto = "SEM VALOR FISCAL";
1006
            $aFont = array(
1007
                'font' => $this->fontePadrao,
1008
                'size' => 48,
1009
                'style' => 'B');
1010
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1011
            $aFont = array(
1012
                'font' => $this->fontePadrao,
1013
                'size' => 30,
1014
                'style' => 'B');
1015
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
1016
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1017
            $this->pdf->setTextColor(0, 0, 0);
1018
        } elseif ($this->preVisualizar == '1') { // caso seja uma DA de Pré-Visualização
1019
            $h = 5;
1020
            $w = $maxW - (2 * 10);
1021
            $x = 55;
1022
            $y = 240;
1023
            $this->pdf->setTextColor(255, 100, 100);
1024
            $aFont = array(
1025
                'font' => $this->fontePadrao,
1026
                'size' => 40,
1027
                'style' => 'B');
1028
            $texto = "Pré-visualização";
1029
            $this->pTextBox90($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1030
            $this->pdf->setTextColor(255, 100, 100);
1031
            $aFont = array(
1032
                'font' => $this->fontePadrao,
1033
                'size' => 41,
1034
                'style' => 'B');
1035
            $texto = "Sem Validade Jurídica";
1036
            $this->pTextBox90($x + 20, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1037
            $this->pdf->setTextColor(90, 90, 90);
1038
            $texto = "SEM VALOR FISCAL";
1039
            $aFont = array(
1040
                'font' => $this->fontePadrao,
1041
                'size' => 48,
1042
                'style' => 'B');
1043
            $this->pTextBox90($x + 40, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1044
            $this->pdf->setTextColor(0, 0, 0); // voltar a cor default
1045
        } else {
1046
            $x = 10;
1047
            if ($this->orientacao == 'P') {
1048
                $y = round($this->hPrint * 2 / 3, 0);
1049
            } else {
1050
                $y = round($this->hPrint / 2, 0);
1051
            } //fim orientacao
1052
            $h = 5;
1053
            $w = $maxW - (2 * $x);
1054
            $this->pdf->setTextColor(90, 90, 90);
1055
            //indicar FALTA DO PROTOCOLO se NFe não for em contingência
1056
            if (($this->tpEmis == 5 || $this->tpEmis == 7 || $this->tpEmis == 8) && !$this->cteDPEC()) {
1057
                //Contingência
1058
                $texto = "DACTE Emitido em Contingência";
1059
                $aFont = array(
1060
                    'font' => $this->fontePadrao,
1061
                    'size' => 48,
1062
                    'style' => 'B');
1063
                $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1064
                $aFont = array(
1065
                    'font' => $this->fontePadrao,
1066
                    'size' => 30,
1067
                    'style' => 'B');
1068
                $texto = "devido à problemas técnicos";
1069
                $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1070
            } else {
1071
                if (!isset($this->protCTe)) {
1072
                    if (!$this->cteDPEC()) {
1073
                        $texto = "SEM VALOR FISCAL";
1074
                        $aFont = array(
1075
                            'font' => $this->fontePadrao,
1076
                            'size' => 48,
1077
                            'style' => 'B');
1078
                        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1079
                    }
1080
                    $aFont = array(
1081
                        'font' => $this->fontePadrao,
1082
                        'size' => 30,
1083
                        'style' => 'B');
1084
                    $texto = "FALTA PROTOCOLO DE APROVAÇÃO DA SEFAZ";
1085
                    if (!$this->cteDPEC()) {
1086
                        $this->pdf->textBox($x, $y + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1087
                    } else {
1088
                        $this->pdf->textBox($x, $y + 25, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1089
                    }
1090
                } //fim cteProc
1091
                if ($this->tpEmis == 4) {
1092
                    //DPEC
1093
                    $x = 10;
1094
                    $y = $this->hPrint - 130;
1095
                    $h = 25;
1096
                    $w = $maxW - (2 * $x);
1097
                    $this->pdf->setTextColor(200, 200, 200); // 90,90,90 é muito escuro
1098
                    $texto = "DACTE impresso em contingência -\n"
1099
                        . "DPEC regularmente recebido pela Receita\n"
1100
                        . "Federal do Brasil";
1101
                    $aFont = array(
1102
                        'font' => $this->fontePadrao,
1103
                        'size' => 48,
1104
                        'style' => 'B');
1105
                    $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
1106
                    $this->pdf->setTextColor(0, 0, 0);
1107
                }
1108
            } //fim tpEmis
1109
            $this->pdf->setTextColor(0, 0, 0);
1110
        }
1111
        return $oldY;
1112
    }
1113
1114
    /**
1115
     * rodapeDACTE
1116
     * Monta o rodape no final da DACTE ( retrato e paisagem )
1117
     *
1118
     * @param number $xInic Posição horizontal canto esquerdo
1119
     * @param number $yFinal Posição vertical final para impressão
1120
     */
1121
    protected function rodape($x, $y)
1122
    {
1123
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
1124
        $w = $this->wPrint - 4;
1125
        $aFont = array(
1126
            'font' => $this->fontePadrao,
1127
            'size' => 6,
1128
            'style' => '');
1129
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
1130
        $texto = $this->creditos .  "  Powered by NFePHP®";
1131
        $aFont = array(
1132
            'font' => $this->fontePadrao,
1133
            'size' => 6,
1134
            'style' => '');
1135
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', false, '');
1136
    }
1137
1138
    /**
1139
     * remetente
1140
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1141
     *
1142
     * @param  number $x Posição horizontal canto esquerdo
1143
     * @param  number $y Posição vertical canto superior
1144
     * @return number Posição vertical final
1145
     */
1146
    protected function remetente($x = 0, $y = 0)
1147
    {
1148
        $oldX = $x;
1149
        $oldY = $y;
1150
        if ($this->orientacao == 'P') {
1151
            $maxW = $this->wPrint;
1152
        } else {
1153
            $maxW = $this->wPrint - $this->wCanhoto;
1154
        }
1155
        $w = $maxW * 0.5 + 0.5;
1156
        $h = 19;
1157
        $x1 = $x + 16;
1158
        $texto = 'REMETENTE';
1159
        $aFont = $this->formatPadrao;
1160
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1161
        $aFont = $this->formatNegrito;
1162
        $texto = $this->getTagValue($this->rem, "xNome");
1163
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1164
        $y += 3;
1165
        $texto = 'ENDEREÇO';
1166
        $aFont = $this->formatPadrao;
1167
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1168
        $aFont = $this->formatNegrito;
1169
        $texto = $this->getTagValue($this->enderReme, "xLgr") . ',';
1170
        $texto .= $this->getTagValue($this->enderReme, "nro");
1171
        $texto .= ($this->getTagValue($this->enderReme, "xCpl") != "") ?
1172
            ' - ' . $this->getTagValue($this->enderReme, "xCpl") : '';
1173
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1174
        $y += 3;
1175
        $texto = $this->getTagValue($this->enderReme, "xBairro");
1176
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1177
        $y += 3;
1178
        $texto = 'MUNICÍPIO';
1179
        $aFont = $this->formatPadrao;
1180
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1181
        $texto = $this->getTagValue($this->enderReme, "xMun") . ' - ';
1182
        $texto .= $this->getTagValue($this->enderReme, "UF");
1183
        $aFont = $this->formatNegrito;
1184
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1185
        $x = $w - 18;
1186
        $texto = 'CEP';
1187
        $aFont = $this->formatPadrao;
1188
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1189
        $texto = $this->formatField($this->getTagValue($this->enderReme, "CEP"), "#####-###");
1190
        $aFont = $this->formatNegrito;
1191
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1192
        $x = $oldX;
1193
        $y += 3;
1194
        $texto = 'CNPJ/CPF';
1195
        $aFont = $this->formatPadrao;
1196
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1197
        $cpfCnpj = $this->formatCNPJCPF($this->rem);
1198
        $aFont = $this->formatNegrito;
1199
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1200
        $x = $w - 45;
1201
        $texto = 'INSCRIÇÃO ESTADUAL';
1202
        $aFont = $this->formatPadrao;
1203
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1204
        $texto = $this->getTagValue($this->rem, "IE");
1205
        $aFont = $this->formatNegrito;
1206
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1207
        $x = $oldX;
1208
        $y += 3;
1209
        $texto = 'PAÍS';
1210
        $aFont = $this->formatPadrao;
1211
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1212
        $texto = $this->getTagValue($this->rem, "xPais") != "" ?
1213
            $this->getTagValue($this->rem, "xPais") : 'BRASIL';
1214
        $aFont = $this->formatNegrito;
1215
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1216
        $x = $w - 25;
1217
        $texto = 'FONE';
1218
        $aFont = $this->formatPadrao;
1219
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1220
        //$texto = $this->formatFone($this->rem);
1221
        $texto = $this->getTagValue($this->rem, "fone") != "" ? $this->formatFone($this->rem) : '';
1222
        $aFont = $this->formatNegrito;
1223
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1224
    }
1225
1226
    /**
1227
     * destinatario
1228
     * Monta o campo com os dados do destinatário na DACTE.
1229
     *
1230
     * @param  number $x Posição horizontal canto esquerdo
1231
     * @param  number $y Posição vertical canto superior
1232
     * @return number Posição vertical final
1233
     */
1234
    protected function destinatario($x = 0, $y = 0)
1235
    {
1236
        $oldX = $x;
1237
        $oldY = $y;
1238
        if ($this->orientacao == 'P') {
1239
            $maxW = $this->wPrint;
1240
        } else {
1241
            $maxW = $this->wPrint - $this->wCanhoto;
1242
        }
1243
        $w = ($maxW * 0.5) - 0.7;
1244
        $h = 19;
1245
        $x1 = $x + 19;
1246
        $texto = 'DESTINATÁRIO';
1247
        $aFont = $this->formatPadrao;
1248
        $this->pdf->textBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1249
        $aFont = $this->formatNegrito;
1250
        $texto = $this->getTagValue($this->dest, "xNome");
1251
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1252
        $y += 3;
1253
        $texto = 'ENDEREÇO';
1254
        $aFont = $this->formatPadrao;
1255
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1256
        $aFont = $this->formatNegrito;
1257
        $texto = $this->getTagValue($this->enderDest, "xLgr") . ',';
1258
        $texto .= $this->getTagValue($this->enderDest, "nro");
1259
        $texto .= $this->getTagValue($this->enderDest, "xCpl") != "" ?
1260
            ' - ' . $this->getTagValue($this->enderDest, "xCpl") : '';
1261
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1262
        $y += 3;
1263
        $texto = $this->getTagValue($this->enderDest, "xBairro");
1264
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1265
        $y += 3;
1266
        $texto = 'MUNICÍPIO';
1267
        $aFont = $this->formatPadrao;
1268
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1269
        $texto = $this->getTagValue($this->enderDest, "xMun") . ' - ';
1270
        $texto .= $this->getTagValue($this->enderDest, "UF");
1271
        $aFont = $this->formatNegrito;
1272
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1273
        $x = $w - 19 + $oldX;
1274
        $texto = 'CEP';
1275
        $aFont = $this->formatPadrao;
1276
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1277
        $texto = $this->formatField($this->getTagValue($this->enderDest, "CEP"), "#####-###");
1278
        $aFont = $this->formatNegrito;
1279
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1280
        $x = $oldX;
1281
        $y += 3;
1282
        $texto = 'CNPJ/CPF';
1283
        $aFont = $this->formatPadrao;
1284
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1285
        $cpfCnpj = $this->formatCNPJCPF($this->dest);
1286
        $aFont = $this->formatNegrito;
1287
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1288
        $x = $w - 47.5 + $oldX;
1289
        $texto = 'INSCRIÇÃO ESTADUAL';
1290
        $aFont = $this->formatPadrao;
1291
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1292
        $texto = $this->getTagValue($this->dest, "IE");
1293
        $aFont = $this->formatNegrito;
1294
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1295
        $x = $oldX;
1296
        $y += 3;
1297
        $texto = 'PAÍS';
1298
        $aFont = $this->formatPadrao;
1299
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1300
        $texto = $this->getTagValue($this->dest, "xPais");
1301
        $aFont = $this->formatNegrito;
1302
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1303
        $x = $w - 27 + $oldX;
1304
        $texto = 'FONE';
1305
        $aFont = $this->formatPadrao;
1306
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1307
        //$texto = $this->formatFone($this->dest);
1308
        $texto = $this->getTagValue($this->dest, "fone") != "" ? $this->formatFone($this->dest) : '';
1309
        $aFont = $this->formatNegrito;
1310
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1311
    }
1312
1313
    /**
1314
     * expedidor
1315
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1316
     *
1317
     * @param  number $x Posição horizontal canto esquerdo
1318
     * @param  number $y Posição vertical canto superior
1319
     * @return number Posição vertical final
1320
     */
1321
    protected function expedidor($x = 0, $y = 0)
1322
    {
1323
        $oldX = $x;
1324
        $oldY = $y;
1325
        if ($this->orientacao == 'P') {
1326
            $maxW = $this->wPrint;
1327
        } else {
1328
            $maxW = $this->wPrint - $this->wCanhoto;
1329
        }
1330
        $w = $maxW * 0.5 + 0.5;
1331
        $h = 19;
1332
        $x1 = $x + 16;
1333
        $texto = 'EXPEDIDOR';
1334
        $aFont = $this->formatPadrao;
1335
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1336
        $aFont = $this->formatNegrito;
1337
        $texto = $this->getTagValue($this->exped, "xNome");
1338
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1339
        $y += 3;
1340
        $texto = 'ENDEREÇO';
1341
        $aFont = $this->formatPadrao;
1342
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1343
        $aFont = $this->formatNegrito;
1344
        if (isset($this->enderExped)) {
1345
            $texto = $this->getTagValue($this->enderExped, "xLgr") . ', ';
1346
            $texto .= $this->getTagValue($this->enderExped, "nro");
1347
            $texto .= $this->getTagValue($this->enderExped, "xCpl") != "" ?
1348
                ' - ' . $this->getTagValue($this->enderExped, "xCpl") :
1349
                '';
1350
        } else {
1351
            $texto = '';
1352
        }
1353
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1354
        $y += 3;
1355
        $texto = $this->getTagValue($this->enderExped, "xBairro");
1356
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1357
        $y += 3;
1358
        $texto = 'MUNICÍPIO';
1359
        $aFont = $this->formatPadrao;
1360
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1361
        if (isset($this->enderExped)) {
1362
            $texto = $this->getTagValue($this->enderExped, "xMun") . ' - ';
1363
            $texto .= $this->getTagValue($this->enderExped, "UF");
1364
        } else {
1365
            $texto = '';
1366
        }
1367
        $aFont = $this->formatNegrito;
1368
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1369
        $x = $w - 18;
1370
        $texto = 'CEP';
1371
        $aFont = $this->formatPadrao;
1372
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1373
        $texto = $this->formatField($this->getTagValue($this->enderExped, "CEP"), "#####-###");
1374
        $aFont = $this->formatNegrito;
1375
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1376
        $x = $oldX;
1377
        $y += 3;
1378
        $texto = 'CNPJ/CPF';
1379
        $aFont = $this->formatPadrao;
1380
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1381
        $cpfCnpj = $this->formatCNPJCPF($this->exped);
1382
        $aFont = $this->formatNegrito;
1383
        $this->pdf->textBox($x1, $y, $w, $h, $cpfCnpj, $aFont, 'T', 'L', 0, '');
1384
        $x = $w - 45;
1385
        $texto = 'INSCRIÇÃO ESTADUAL';
1386
        $aFont = $this->formatPadrao;
1387
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1388
        $texto = $this->getTagValue($this->exped, "IE");
1389
        $aFont = $this->formatNegrito;
1390
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1391
        $x = $oldX;
1392
        $y += 3;
1393
        $texto = 'PAÍS';
1394
        $aFont = $this->formatPadrao;
1395
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1396
        $texto = $this->getTagValue($this->exped, "xPais");
1397
        $aFont = $this->formatNegrito;
1398
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1399
        $x = $w - 25;
1400
        $texto = 'FONE';
1401
        $aFont = $this->formatPadrao;
1402
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1403
        if (isset($this->exped)) {
1404
            $texto = $this->getTagValue($this->exped, "fone") != "" ? $this->formatFone($this->exped) : '';
1405
            $aFont = $this->formatNegrito;
1406
            $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1407
        }
1408
    }
1409
1410
    /**
1411
     * recebedor
1412
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1413
     *
1414
     * @param  number $x Posição horizontal canto esquerdo
1415
     * @param  number $y Posição vertical canto superior
1416
     * @return number Posição vertical final
1417
     */
1418
    protected function recebedor($x = 0, $y = 0)
1419
    {
1420
        $oldX = $x;
1421
        $oldY = $y;
1422
        if ($this->orientacao == 'P') {
1423
            $maxW = $this->wPrint;
1424
        } else {
1425
            $maxW = $this->wPrint - $this->wCanhoto;
1426
        }
1427
        $w = ($maxW * 0.5) - 0.7;
1428
        $h = 19;
1429
        $x1 = $x + 19;
1430
        $texto = 'RECEBEDOR';
1431
        $aFont = $this->formatPadrao;
1432
        $this->pdf->textBox($x - 0.5, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1433
        $aFont = $this->formatNegrito;
1434
        $texto = $this->getTagValue($this->receb, "xNome");
1435
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1436
        $y += 3;
1437
        $texto = 'ENDEREÇO';
1438
        $aFont = $this->formatPadrao;
1439
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1440
        $aFont = $this->formatNegrito;
1441
        if (isset($this->enderReceb)) {
1442
            $texto = $this->getTagValue($this->enderReceb, "xLgr") . ', ';
1443
            $texto .= $this->getTagValue($this->enderReceb, "nro");
1444
            $texto .= ($this->getTagValue($this->enderReceb, "xCpl") != "") ?
1445
                ' - ' . $this->getTagValue($this->enderReceb, "xCpl") :
1446
                '';
1447
        } else {
1448
            $texto = '';
1449
        }
1450
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1451
        $y += 3;
1452
        $texto = $this->getTagValue($this->enderReceb, "xBairro");
1453
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1454
        $y += 3;
1455
        $texto = 'MUNICÍPIO';
1456
        $aFont = $this->formatPadrao;
1457
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1458
        if (isset($this->enderReceb)) {
1459
            $texto = $this->getTagValue($this->enderReceb, "xMun") . ' - ';
1460
            $texto .= $this->getTagValue($this->enderReceb, "UF");
1461
        } else {
1462
            $texto = '';
1463
        }
1464
        $aFont = $this->formatNegrito;
1465
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1466
        $x = $w - 19 + $oldX;
1467
        $texto = 'CEP';
1468
        $aFont = $this->formatPadrao;
1469
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1470
        $texto = $this->formatField($this->getTagValue($this->enderReceb, "CEP"), "#####-###");
1471
        $aFont = $this->formatNegrito;
1472
        $this->pdf->textBox($x + 5, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1473
        $x = $oldX;
1474
        $y += 3;
1475
        $texto = 'CNPJ/CPF';
1476
        $aFont = $this->formatPadrao;
1477
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1478
        $texto = $this->formatCNPJCPF($this->receb);
1479
        $aFont = $this->formatNegrito;
1480
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1481
        $x = $w - 47 + $oldX;
1482
        $texto = 'INSCRIÇÃO ESTADUAL';
1483
        $aFont = $this->formatPadrao;
1484
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1485
        $texto = $this->getTagValue($this->receb, "IE");
1486
        $aFont = $this->formatNegrito;
1487
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1488
        $x = $oldX;
1489
        $y += 3;
1490
        $texto = 'PAÍS';
1491
        $aFont = $this->formatPadrao;
1492
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1493
        $texto = $this->getTagValue($this->receb, "xPais");
1494
        $aFont = $this->formatNegrito;
1495
        $this->pdf->textBox($x1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1496
        $x = $w - 27 + $oldX;
1497
        $texto = 'FONE';
1498
        $aFont = $this->formatPadrao;
1499
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1500
        if (isset($this->receb)) {
1501
            $texto = $this->getTagValue($this->receb, "fone") != "" ? $this->formatFone($this->receb) : '';
1502
            $aFont = $this->formatNegrito;
1503
            $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1504
        }
1505
    }
1506
1507
    /**
1508
     * tomador
1509
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1510
     *
1511
     * @param  number $x Posição horizontal canto esquerdo
1512
     * @param  number $y Posição vertical canto superior
1513
     * @return number Posição vertical final
1514
     */
1515
    protected function tomador($x = 0, $y = 0)
1516
    {
1517
        $oldX = $x;
1518
        $oldY = $y;
1519
        if ($this->orientacao == 'P') {
1520
            $maxW = $this->wPrint;
1521
        } else {
1522
            $maxW = $this->wPrint - $this->wCanhoto;
1523
        }
1524
        $w = $maxW;
1525
        $h = 10;
1526
        $texto = 'TOMADOR DO SERVIÇO';
1527
        $aFont = $this->formatPadrao;
1528
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1529
        $aFont = $this->formatNegrito;
1530
        $texto = $this->getTagValue($this->toma, "xNome");
1531
        $this->pdf->textBox($x + 29, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1532
        $x = $maxW * 0.60;
1533
        $texto = 'MUNICÍPIO';
1534
        $aFont = $this->formatPadrao;
1535
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1536
        $texto = $this->getTagValue($this->toma, "xMun");
1537
        $aFont = $this->formatNegrito;
1538
        $this->pdf->textBox($x + 15, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1539
        $x = $maxW * 0.85;
1540
        $texto = 'UF';
1541
        $aFont = $this->formatPadrao;
1542
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1543
        $texto = $this->getTagValue($this->toma, "UF");
1544
        $aFont = $this->formatNegrito;
1545
        $this->pdf->textBox($x + 4, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1546
        $x = $w - 18;
1547
        $texto = 'CEP';
1548
        $aFont = $this->formatPadrao;
1549
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1550
        $texto = $this->formatField($this->getTagValue($this->toma, "CEP"), "#####-###");
1551
        $aFont = $this->formatNegrito;
1552
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1553
        $y += 3;
1554
        $x = $oldX;
1555
        $texto = 'ENDEREÇO';
1556
        $aFont = $this->formatPadrao;
1557
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1558
        $aFont = $this->formatNegrito;
1559
        $texto = $this->getTagValue($this->toma, "xLgr") . ',';
1560
        $texto .= $this->getTagValue($this->toma, "nro");
1561
        $texto .= ($this->getTagValue($this->toma, "xCpl") != "") ?
1562
            ' - ' . $this->getTagValue($this->toma, "xCpl") : '';
1563
        $texto .= ' - ' . $this->getTagValue($this->toma, "xBairro");
1564
        $this->pdf->textBox($x + 16, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1565
        $y += 3;
1566
        $texto = 'CNPJ/CPF';
1567
        $aFont = $this->formatPadrao;
1568
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1569
        $texto = $this->formatCNPJCPF($this->toma);
1570
        $aFont = $this->formatNegrito;
1571
        $this->pdf->textBox($x + 13, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1572
        $x = $x + 65;
1573
        $texto = 'INSCRIÇÃO ESTADUAL';
1574
        $aFont = $this->formatPadrao;
1575
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1576
        $texto = $this->getTagValue($this->toma, "IE");
1577
        $aFont = $this->formatNegrito;
1578
        $this->pdf->textBox($x + 28, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1579
        $x = $w * 0.75;
1580
        $texto = 'PAÍS';
1581
        $aFont = $this->formatPadrao;
1582
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1583
        $texto = $this->getTagValue($this->toma, "xPais") != "" ?
1584
            $this->getTagValue($this->toma, "xPais") : 'BRASIL';
1585
        $aFont = $this->formatNegrito;
1586
        $this->pdf->textBox($x + 6, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1587
        $x = $w - 27;
1588
        $texto = 'FONE';
1589
        $aFont = $this->formatPadrao;
1590
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1591
        $texto = $this->getTagValue($this->toma, "fone") != "" ? $this->formatFone($this->toma) : '';
1592
        $aFont = $this->formatNegrito;
1593
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1594
    }
1595
1596
    /**
1597
     * descricaoCarga
1598
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1599
     *
1600
     * @param  number $x Posição horizontal canto esquerdo
1601
     * @param  number $y Posição vertical canto superior
1602
     * @return number Posição vertical final
1603
     */
1604
    protected function descricaoCarga($x = 0, $y = 0)
1605
    {
1606
        $oldX = $x;
1607
        $oldY = $y;
1608
        if ($this->orientacao == 'P') {
1609
            $maxW = $this->wPrint;
1610
        } else {
1611
            $maxW = $this->wPrint - $this->wCanhoto;
1612
        }
1613
        $w = $maxW;
1614
        $h = 17;
1615
        $texto = 'PRODUTO PREDOMINANTE';
1616
        $aFont = array(
1617
            'font' => $this->fontePadrao,
1618
            'size' => 6,
1619
            'style' => '');
1620
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 1, '');
1621
        $texto = $this->getTagValue($this->infCarga, "proPred");
1622
        $aFont = $this->formatNegrito;
1623
        $this->pdf->textBox($x, $y + 2.8, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1624
        $x = $w * 0.56;
1625
        $this->pdf->line($x, $y, $x, $y + 8);
1626
        $aFont = $this->formatPadrao;
1627
        $texto = 'OUTRAS CARACTERÍSTICAS DA CARGA';
1628
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1629
        $texto = $this->getTagValue($this->infCarga, "xOutCat");
1630
        $aFont = $this->formatNegrito;
1631
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1632
        $x = $w * 0.8;
1633
        $this->pdf->line($x, $y, $x, $y + 8);
1634
        $aFont = $this->formatPadrao;
1635
        $texto = 'VALOR TOTAL DA CARGA';
1636
        $this->pdf->textBox($x + 1, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1637
        $texto = $this->getTagValue($this->infCarga, "vCarga") == "" ?
1638
            $this->getTagValue($this->infCarga, "vMerc") : $this->getTagValue($this->infCarga, "vCarga");
1639
        $texto = number_format($texto, 2, ",", ".");
1640
        $aFont = $this->formatNegrito;
1641
        $this->pdf->textBox($x + 1, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1642
        $y += 8;
1643
        $x = $oldX;
1644
        $this->pdf->line($x, $y, $w + 1, $y);
1645
        //Identifica código da unidade
1646
        //01 = KG (QUILOS)
1647
        $qCarga = 0;
1648
        foreach ($this->infQ as $infQ) {
1649
            if ($this->getTagValue($infQ, "cUnid") == '01') {
1650
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1651
            }
1652
        }
1653
        $texto = 'PESO BRUTO (KG)';
1654
        $aFont = array(
1655
            'font' => $this->fontePadrao,
1656
            'size' => 5,
1657
            'style' => '');
1658
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1659
        $texto = number_format($qCarga, 3, ",", ".");
1660
        $aFont = array(
1661
            'font' => $this->fontePadrao,
1662
            'size' => 7,
1663
            'style' => 'B');
1664
        $this->pdf->textBox($x + 2, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1665
        $x = $w * 0.12;
1666
        $this->pdf->line($x + 13.5, $y, $x + 13.5, $y + 9);
1667
        $texto = 'PESO BASE CÁLCULO (KG)';
1668
        $aFont = array(
1669
            'font' => $this->fontePadrao,
1670
            'size' => 5,
1671
            'style' => '');
1672
        $this->pdf->textBox($x + 20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1673
        $texto = number_format($qCarga, 3, ",", ".");
1674
        $aFont = array(
1675
            'font' => $this->fontePadrao,
1676
            'size' => 7,
1677
            'style' => 'B');
1678
        $this->pdf->textBox($x + 17, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1679
        $x = $w * 0.24;
1680
        $this->pdf->line($x + 25, $y, $x + 25, $y + 9);
1681
        $texto = 'PESO AFERIDO (KG)';
1682
        $aFont = array(
1683
            'font' => $this->fontePadrao,
1684
            'size' => 5,
1685
            'style' => '');
1686
        $this->pdf->textBox($x + 35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1687
        $texto = number_format($qCarga, 3, ",", ".");
1688
        $aFont = array(
1689
            'font' => $this->fontePadrao,
1690
            'size' => 7,
1691
            'style' => 'B');
1692
        $this->pdf->textBox($x + 28, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1693
        $x = $w * 0.36;
1694
        $this->pdf->line($x + 41.3, $y, $x + 41.3, $y + 9);
1695
        $texto = 'CUBAGEM(M3)';
1696
        $aFont = $this->formatPadrao;
1697
        $this->pdf->textBox($x + 60, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1698
        $qCarga = 0;
1699
        foreach ($this->infQ as $infQ) {
1700
            if ($this->getTagValue($infQ, "cUnid") == '00') {
1701
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1702
            }
1703
        }
1704
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1705
        $aFont = array(
1706
            'font' => $this->fontePadrao,
1707
            'size' => 7,
1708
            'style' => 'B');
1709
        $this->pdf->textBox($x + 50, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1710
        $x = $w * 0.45;
1711
        //$this->pdf->line($x+37, $y, $x+37, $y + 9);
1712
        $texto = 'QTDE(VOL)';
1713
        $aFont = $this->formatPadrao;
1714
        $this->pdf->textBox($x + 85, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1715
        $qCarga = 0;
1716
        foreach ($this->infQ as $infQ) {
1717
            if ($this->getTagValue($infQ, "cUnid") == '03') {
1718
                $qCarga += (float)$this->getTagValue($infQ, "qCarga");
1719
            }
1720
        }
1721
        $texto = !empty($qCarga) ? number_format($qCarga, 3, ",", ".") : '';
1722
        $aFont = array(
1723
            'font' => $this->fontePadrao,
1724
            'size' => 7,
1725
            'style' => 'B');
1726
        $this->pdf->textBox($x + 85, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1727
        $x = $w * 0.53;
1728
        $this->pdf->line($x + 56, $y, $x + 56, $y + 9);
1729
        /*$texto = 'NOME DA SEGURADORA';
1730
        $aFont = $this->formatPadrao;
1731
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1732
        $texto = $this->getTagValue($this->seg, "xSeg");
1733
        $aFont = array(
1734
            'font' => $this->fontePadrao,
1735
            'size' => 7,
1736
            'style' => 'B');
1737
        $this->pdf->textBox($x + 31, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1738
        $y += 3;
1739
        $this->pdf->line($x, $y, $w + 1, $y);
1740
        $texto = 'RESPONSÁVEL';
1741
        $aFont = $this->formatPadrao;
1742
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1743
        $texto = $this->respSeg;
1744
        $aFont = array(
1745
            'font' => $this->fontePadrao,
1746
            'size' => 7,
1747
            'style' => 'B');
1748
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1749
        $x = $w * 0.68;
1750
        $this->pdf->line($x, $y, $x, $y + 6);
1751
        $texto = 'NÚMERO DA APOLICE';
1752
        $aFont = $this->formatPadrao;
1753
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1754
        $texto = $this->getTagValue($this->seg, "nApol");
1755
        $aFont = array(
1756
            'font' => $this->fontePadrao,
1757
            'size' => 7,
1758
            'style' => 'B');
1759
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1760
        $x = $w * 0.85;
1761
        $this->pdf->line($x, $y, $x, $y + 6);
1762
        $texto = 'NÚMERO DA AVERBAÇÃO';
1763
        $aFont = $this->formatPadrao;
1764
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
1765
        $texto = $this->getTagValue($this->seg, "nAver");
1766
        $aFont = array(
1767
            'font' => $this->fontePadrao,
1768
            'size' => 7,
1769
            'style' => 'B');
1770
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');*/
1771
    }
1772
1773
    /**
1774
     * compValorServ
1775
     * Monta o campo com os componentes da prestação de serviços.
1776
     *
1777
     * @param  number $x Posição horizontal canto esquerdo
1778
     * @param  number $y Posição vertical canto superior
1779
     * @return number Posição vertical final
1780
     */
1781
    protected function compValorServ($x = 0, $y = 0)
1782
    {
1783
        $oldX = $x;
1784
        $oldY = $y;
1785
        if ($this->orientacao == 'P') {
1786
            $maxW = $this->wPrint;
1787
        } else {
1788
            $maxW = $this->wPrint - $this->wCanhoto;
1789
        }
1790
        $w = $maxW;
1791
        $h = 25;
1792
        $texto = 'COMPONENTES DO VALOR DA PRESTAÇÃO DO SERVIÇO';
1793
        $aFont = $this->formatPadrao;
1794
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1795
        $y += 3.4;
1796
        $this->pdf->line($x, $y, $w + 1, $y);
1797
        $texto = 'NOME';
1798
        $aFont = $this->formatPadrao;
1799
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1800
        $yIniDados = $y;
1801
        $x = $w * 0.14;
1802
        $texto = 'VALOR';
1803
        $aFont = $this->formatPadrao;
1804
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1805
        $x = $w * 0.28;
1806
        $this->pdf->line($x, $y, $x, $y + 21.5);
1807
        $texto = 'NOME';
1808
        $aFont = $this->formatPadrao;
1809
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1810
        $x = $w * 0.42;
1811
        $texto = 'VALOR';
1812
        $aFont = $this->formatPadrao;
1813
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1814
        $x = $w * 0.56;
1815
        $this->pdf->line($x, $y, $x, $y + 21.5);
1816
        $texto = 'NOME';
1817
        $aFont = $this->formatPadrao;
1818
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1819
        $x = $w * 0.70;
1820
        $texto = 'VALOR';
1821
        $aFont = $this->formatPadrao;
1822
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1823
        $x = $w * 0.86;
1824
        $this->pdf->line($x, $y, $x, $y + 21.5);
1825
        $y += 1;
1826
        $texto = 'VALOR TOTAL DO SERVIÇO';
1827
        $aFont = $this->formatPadrao;
1828
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1829
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
1830
        $aFont = array(
1831
            'font' => $this->fontePadrao,
1832
            'size' => 9,
1833
            'style' => 'B');
1834
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1835
        $y += 10;
1836
        $this->pdf->line($x, $y, $w + 1, $y);
1837
        $y += 1;
1838
        $texto = 'VALOR A RECEBER';
1839
        $aFont = $this->formatPadrao;
1840
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1841
        $texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
1842
        $aFont = array(
1843
            'font' => $this->fontePadrao,
1844
            'size' => 9,
1845
            'style' => 'B');
1846
        $this->pdf->textBox($x, $y + 4, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
1847
        $auxX = $oldX;
1848
        $yIniDados += 4;
1849
        foreach ($this->Comp as $k => $d) {
1850
            $nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
1851
            $valor = number_format(
1852
                $this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
1853
                2,
1854
                ",",
1855
                "."
1856
            );
1857
            if ($auxX > $w * 0.60) {
1858
                $yIniDados = $yIniDados + 4;
1859
                $auxX = $oldX;
1860
            }
1861
            $texto = $nome;
1862
            $aFont = $this->formatPadrao;
1863
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1864
            $auxX += $w * 0.14;
1865
            $texto = $valor;
1866
            $aFont = $this->formatPadrao;
1867
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1868
            $auxX += $w * 0.14;
1869
        }
1870
    }
1871
1872
    /**
1873
     * impostos
1874
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
1875
     *
1876
     * @param  number $x Posição horizontal canto esquerdo
1877
     * @param  number $y Posição vertical canto superior
1878
     * @return number Posição vertical final
1879
     */
1880
    protected function impostos($x = 0, $y = 0)
1881
    {
1882
        $oldX = $x;
1883
        $oldY = $y;
1884
        if ($this->orientacao == 'P') {
1885
            $maxW = $this->wPrint;
1886
        } else {
1887
            $maxW = $this->wPrint - $this->wCanhoto;
1888
        }
1889
        $w = $maxW;
1890
        $h = 13;
1891
        $texto = 'INFORMAÇÕES RELATIVAS AO IMPOSTO';
1892
        $aFont = $this->formatPadrao;
1893
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
1894
        $y += 3.4;
1895
        $this->pdf->line($x, $y, $w + 1, $y);
1896
        $texto = 'SITUAÇÃO TRIBUTÁRIA';
1897
        $aFont = $this->formatPadrao;
1898
        $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1899
        $x += $w * 0.26;
1900
        $this->pdf->line($x, $y, $x, $y + 9.5);
1901
        $texto = 'BASE DE CALCULO';
1902
        $aFont = $this->formatPadrao;
1903
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1904
        $wCol02 = 0.15;
1905
        $x += $w * $wCol02;
1906
        $this->pdf->line($x, $y, $x, $y + 9.5);
1907
        $texto = 'ALÍQ ICMS';
1908
        $aFont = $this->formatPadrao;
1909
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1910
        $x += $w * $wCol02;
1911
        $this->pdf->line($x, $y, $x, $y + 9.5);
1912
        $texto = 'VALOR ICMS';
1913
        $aFont = $this->formatPadrao;
1914
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1915
        $x += $w * $wCol02;
1916
        $this->pdf->line($x, $y, $x, $y + 9.5);
1917
        $texto = '% RED. BC ICMS';
1918
        $aFont = $this->formatPadrao;
1919
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1920
        $x += $w * $wCol02;
1921
        $this->pdf->line($x, $y, $x, $y + 9.5);
1922
        $texto = 'VALOR ICMS ST';
1923
        $aFont = $this->formatPadrao;
1924
        $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1925
        /*$x += $w * 0.14;
1926
        $this->pdf->line($x, $y, $x, $y + 9.5);
1927
        $texto = 'ICMS ST';
1928
        $aFont = $this->formatPadrao;
1929
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');
1930
         * */
1931
        $x = $oldX;
1932
        $y = $y + 4;
1933
        $texto = $this->getTagValue($this->ICMS, "CST");
1934
        switch ($texto) {
1935
            case '00':
1936
                $texto = "00 - Tributação normal ICMS";
1937
                break;
1938
            case '20':
1939
                $texto = "20 - Tributação com BC reduzida do ICMS";
1940
                break;
1941
            case '40':
1942
                $texto = "40 - ICMS isenção";
1943
                break;
1944
            case '41':
1945
                $texto = "41 - ICMS não tributada";
1946
                break;
1947
            case '51':
1948
                $texto = "51 - ICMS diferido";
1949
                break;
1950
            case '60':
1951
                $texto = "60 - ICMS cobrado anteriormente por substituição tributária";
1952
                break;
1953
            case '90':
1954
                if ($this->ICMSOutraUF) {
1955
                    $texto = "90 - ICMS Outra UF";
1956
                } else {
1957
                    $texto = "90 - ICMS Outros";
1958
                }
1959
                break;
1960
        }
1961
        if ($this->getTagValue($this->ICMS, "CST") == '60') {
1962
            $aFont = $this->formatNegrito;
1963
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
1964
            $x += $w * 0.26;
1965
            $texto = !empty($this->ICMS->getElementsByTagName("vBCSTRet")->item(0)->nodeValue) ?
1966
                number_format($this->getTagValue($this->ICMS, "vBCSTRet"), 2, ",", ".") : (
1967
                !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
1968
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
1969
                );
1970
            $aFont = $this->formatNegrito;
1971
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1972
            $x += $w * $wCol02;
1973
            $texto = !empty($this->ICMS->getElementsByTagName("pICMSSTRet")->item(0)->nodeValue) ?
1974
                number_format($this->getTagValue($this->ICMS, "pICMSSTRet"), 2, ",", ".") : (
1975
                !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
1976
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
1977
                );
1978
            $aFont = $this->formatNegrito;
1979
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1980
            $x += $w * $wCol02;
1981
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
1982
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
1983
                !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
1984
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
1985
                );
1986
            $aFont = $this->formatNegrito;
1987
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1988
            $x += $w * $wCol02;
1989
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
1990
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
1991
                !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
1992
                    number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
1993
                );
1994
            $aFont = $this->formatNegrito;
1995
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
1996
            $x += $w * $wCol02;
1997
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
1998
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
1999
            $aFont = $this->formatNegrito;
2000
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2001
        } else {
2002
            $texto = $this->getTagValue($this->ICMSSN, "indSN") == 1 ? 'Simples Nacional' : $texto;
2003
            $aFont = $this->formatNegrito;
2004
            $this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
2005
            $x += $w * 0.26;
2006
            $texto = !empty($this->ICMS->getElementsByTagName("vBC")->item(0)->nodeValue) ?
2007
                number_format($this->getTagValue($this->ICMS, "vBC"), 2, ",", ".") : (
2008
                !empty($this->ICMS->getElementsByTagName("vBCOutraUF")->item(0)->nodeValue) ?
2009
                    number_format($this->getTagValue($this->ICMS, "vBCOutraUF"), 2, ",", ".") : ''
2010
                );
2011
            $aFont = $this->formatNegrito;
2012
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2013
            $x += $w * $wCol02;
2014
            $texto = !empty($this->ICMS->getElementsByTagName("pICMS")->item(0)->nodeValue) ?
2015
                number_format($this->getTagValue($this->ICMS, "pICMS"), 2, ",", ".") : (
2016
                !empty($this->ICMS->getElementsByTagName("pICMSOutraUF")->item(0)->nodeValue) ?
2017
                    number_format($this->getTagValue($this->ICMS, "pICMSOutraUF"), 2, ",", ".") : ''
2018
                );
2019
            $aFont = $this->formatNegrito;
2020
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2021
            $x += $w * $wCol02;
2022
            $texto = !empty($this->ICMS->getElementsByTagName("vICMS")->item(0)->nodeValue) ?
2023
                number_format($this->getTagValue($this->ICMS, "vICMS"), 2, ",", ".") : (
2024
                !empty($this->ICMS->getElementsByTagName("vICMSOutraUF")->item(0)->nodeValue) ?
2025
                    number_format($this->getTagValue($this->ICMS, "vICMSOutraUF"), 2, ",", ".") : ''
2026
                );
2027
            $aFont = $this->formatNegrito;
2028
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2029
            $x += $w * $wCol02;
2030
            $texto = !empty($this->ICMS->getElementsByTagName("pRedBC")->item(0)->nodeValue) ?
2031
                number_format($this->getTagValue($this->ICMS, "pRedBC"), 2, ",", ".") : (
2032
                !empty($this->ICMS->getElementsByTagName("pRedBCOutraUF")->item(0)->nodeValue) ?
2033
                    number_format($this->getTagValue($this->ICMS, "pRedBCOutraUF"), 2, ",", ".") : ''
2034
                );
2035
            $aFont = $this->formatNegrito;
2036
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2037
            $x += $w * $wCol02;
2038
            $texto = !empty($this->ICMS->getElementsByTagName("vICMSSTRet")->item(0)->nodeValue) ?
2039
                number_format($this->getTagValue($this->ICMS, "vICMSSTRet"), 2, ",", ".") : '';
2040
            $aFont = $this->formatNegrito;
2041
            $this->pdf->textBox($x, $y, $w * $wCol02, $h, $texto, $aFont, 'T', 'L', 0, '');
2042
        }
2043
        /*$x += $w * 0.14;
2044
        $texto = '';
2045
        $aFont = $this->formatNegrito;
2046
        $this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'L', 0, '');*/
2047
    }
2048
2049
    /**
2050
     * geraChaveAdicCont
2051
     *
2052
     * @return string chave
2053
     */
2054
    protected function geraChaveAdicCont()
2055
    {
2056
        //cUF tpEmis CNPJ vNF ICMSp ICMSs DD  DV
2057
        // Quantidade de caracteres  02   01      14  14    01    01  02 01
2058
        $forma = "%02d%d%s%014d%01d%01d%02d";
2059
        $cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
2060
        $CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
2061
        $CNPJ = substr($CNPJ, -14);
2062
        $vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
2063
        $ICMS_CST = $this->getTagValue($this->ICMS, "CST");
2064
        switch ($ICMS_CST) {
2065
            case '00':
2066
            case '20':
2067
                $ICMSp = '1';
2068
                $ICMSs = '2';
2069
                break;
2070
            case '40':
2071
            case '41':
2072
            case '51':
2073
            case '90':
2074
                $ICMSp = '2';
2075
                $ICMSs = '2';
2076
                break;
2077
            case '60':
2078
                $ICMSp = '2';
2079
                $ICMSs = '1';
2080
                break;
2081
        }
2082
        $dd = $this->ide->getElementsByTagName('dhEmi')->item(0)->nodeValue;
2083
        $rpos = strrpos($dd, '-');
2084
        $dd = substr($dd, $rpos + 1);
2085
        $chave = sprintf($forma, $cUF, $this->tpEmis, $CNPJ, $vCT, $ICMSp, $ICMSs, $dd);
2086
        $chave = $chave . $this->modulo11($chave);
2087
        return $chave;
2088
    }
2089
2090
    /**
2091
     * docOrig
2092
     * Monta o campo com os documentos originarios.
2093
     *
2094
     * @param  number $x Posição horizontal canto esquerdo
2095
     * @param  number $y Posição vertical canto superior
2096
     * @return number Posição vertical final
2097
     */
2098
    protected function docOrig($x = 0, $y = 0)
2099
    {
2100
        $oldX = $x;
2101
        $oldY = $y;
2102
        if ($this->orientacao == 'P') {
2103
            $maxW = $this->wPrint;
2104
        } else {
2105
            $maxW = $this->wPrint - $this->wCanhoto;
2106
        }
2107
        $w = $maxW;
2108
        // SE FOR RODOVIARIO ( BTR-SEMPRE SERÁ )
2109
        if ($this->modal == '1') {
2110
            // 0 - Não; 1 - Sim Será lotação quando houver um único conhecimento de transporte por veículo,
2111
            // ou combinação veicular, e por viagem
2112
            $h = $this->lota == 1 ? 35 : 53;
2113
        } elseif ($this->modal == '2') {
2114
            $h = 53;
2115
        } elseif ($this->modal == '3') {
2116
            $h = 37.6;
2117
        } else {
2118
            $h = 35;
2119
        }
2120
        $texto = 'DOCUMENTOS ORIGINÁRIOS';
2121
        $aFont = $this->formatPadrao;
2122
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2123
        $descr1 = 'TIPO DOC';
2124
        $descr2 = 'CNPJ/CHAVE/OBS';
2125
        $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2126
        $y += 3.4;
2127
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAIXO DO TEXTO: "DOCUMENTOS ORIGINÁRIOS
2128
        $texto = $descr1;
2129
        $aFont = $this->formatPadrao;
2130
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2131
        $yIniDados = $y;
2132
        $x += $w * 0.07;
2133
        $texto = $descr2;
2134
        $aFont = $this->formatPadrao;
2135
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2136
        $x += $w * 0.28;
2137
        $texto = $descr3;
2138
        $aFont = $this->formatPadrao;
2139
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2140
        $x += $w * 0.14;
2141
        if ($this->modal == '1') {
2142
            if ($this->lota == 1) {
2143
                $this->pdf->line($x, $y, $x, $y + 31.5); // TESTE
2144
            } else {
2145
                $this->pdf->line($x, $y, $x, $y + 49.5); // TESTE
2146
            }
2147
        } elseif ($this->modal == '2') {
2148
            $this->pdf->line($x, $y, $x, $y + 49.5);
2149
        } elseif ($this->modal == '3') {
2150
            $this->pdf->line($x, $y, $x, $y + 34.1);
2151
        } else {
2152
            $this->pdf->line($x, $y, $x, $y + 21.5);
2153
        }
2154
        $texto = $descr1;
2155
        $aFont = $this->formatPadrao;
2156
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2157
        $x += $w * 0.08;
2158
        $texto = $descr2;
2159
        $aFont = $this->formatPadrao;
2160
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2161
        $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2162
        $texto = $descr3;
2163
        $aFont = $this->formatPadrao;
2164
        $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2165
        $auxX = $oldX;
2166
        $yIniDados += 3;
2167
        foreach ($this->infNF as $k => $d) {
2168
            $mod = $this->infNF->item($k)->getElementsByTagName('mod');
2169
            $tp = ($mod && $mod->length > 0) ? $mod->item(0)->nodeValue : '';
2170
            $cnpj = $this->formatCNPJCPF($this->rem);
2171
            $doc = $this->infNF->item($k)->getElementsByTagName('serie')->item(0)->nodeValue;
2172
            $doc .= '/' . $this->infNF->item($k)->getElementsByTagName('nDoc')->item(0)->nodeValue;
2173
            if ($auxX > $w * 0.90) {
2174
                $yIniDados = $yIniDados + 3;
2175
                $auxX = $oldX;
2176
            }
2177
            $texto = $tp;
2178
            $aFont = array(
2179
                'font' => $this->fontePadrao,
2180
                'size' => 8,
2181
                'style' => '');
2182
            //$this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2183
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2184
            //$auxX += $w * 0.09;
2185
            $auxX += $w * 0.07;
2186
            $texto = $cnpj;
2187
            $aFont = array(
2188
                'font' => $this->fontePadrao,
2189
                'size' => 8,
2190
                'style' => '');
2191
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2192
            $auxX += $w * 0.28;
2193
            $texto = $doc;
2194
            $aFont = array(
2195
                'font' => $this->fontePadrao,
2196
                'size' => 8,
2197
                'style' => '');
2198
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2199
            $auxX += $w * 0.15;
2200
        }
2201
        foreach ($this->infNFe as $k => $d) {
2202
            $chaveNFe = $this->infNFe->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2203
            $this->arrayNFe[] = $chaveNFe;
2204
        }
2205
        $qtdeNFe = 1;
2206
        if (count($this->arrayNFe) > 15) {
2207
            $this->flagDocOrigContinuacao = 1;
2208
            $qtdeNFe = count($this->arrayNFe);
2209
        }
2210
//        $totPag = count($this->arrayNFe) > 15 ? '2' : '1';
2211
        switch ($qtdeNFe) {
2212
            default:
2213
                $this->totPag = 1;
2214
            case ($qtdeNFe >= 1044):
2215
                $this->totPag = 11;
2216
                break;
2217
            case ($qtdeNFe > 928):
2218
                $this->totPag = 10;
2219
                break;
2220
            case ($qtdeNFe > 812):
2221
                $this->totPag = 9;
2222
                break;
2223
            case ($qtdeNFe > 696):
2224
                $this->totPag = 8;
2225
                break;
2226
            case ($qtdeNFe > 580):
2227
                $this->totPag = 7;
2228
                break;
2229
            case ($qtdeNFe > 464):
2230
                $this->totPag = 6;
2231
                break;
2232
            case ($qtdeNFe > 348):
2233
                $this->totPag = 5;
2234
                break;
2235
            case ($qtdeNFe > 232):
2236
                $this->totPag = 4;
2237
                break;
2238
            case ($qtdeNFe > 116):
2239
                $this->totPag = 3;
2240
                break;
2241
            case ($qtdeNFe > 16):
2242
                $this->totPag = 2;
2243
                break;
2244
            case ($qtdeNFe <= 16):
2245
                $this->totPag = 1;
2246
                break;
2247
        }
2248
        //$r = $this->cabecalho(1, 1, '1', $this->totPag);
2249
        $contador = 0;
2250
        while ($contador < count($this->arrayNFe)) {
2251
            if ($contador == 15) {
2252
                break;
2253
            }
2254
            $tp = 'NF-e';
2255
            $chaveNFe = $this->arrayNFe[$contador];
2256
            $numNFe = substr($chaveNFe, 25, 9);
2257
            $serieNFe = substr($chaveNFe, 22, 3);
2258
            $doc = $serieNFe . '/' . $numNFe;
2259
            if ($auxX > $w * 0.90) {
2260
                $yIniDados = $yIniDados + 3.5;
2261
                $auxX = $oldX;
2262
            }
2263
            $texto = $tp;
2264
            $aFont = array(
2265
                'font' => $this->fontePadrao,
2266
                'size' => 7,
2267
                'style' => '');
2268
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2269
            $auxX += $w * 0.07;
2270
            $texto = $chaveNFe;
2271
            $aFont = array(
2272
                'font' => $this->fontePadrao,
2273
                'size' => 7,
2274
                'style' => '');
2275
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2276
            $auxX += $w * 0.28;
2277
            $texto = $doc;
2278
            $aFont = array(
2279
                'font' => $this->fontePadrao,
2280
                'size' => 7,
2281
                'style' => '');
2282
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2283
            $auxX += $w * 0.15;
2284
            $contador++;
2285
        }
2286
        foreach ($this->infOutros as $k => $d) {
2287
            $temp = $this->infOutros->item($k);
2288
            $tpDoc = $this->getTagValue($temp, "tpDoc");
2289
            $descOutros = $this->getTagValue($temp, "descOutros");
2290
            $nDoc = $this->getTagValue($temp, "nDoc");
2291
            $dEmi = $this->pSimpleGetDate($temp, "dEmi", "Emissão: ");
2292
            $vDocFisc = $this->getTagValue($temp, "vDocFisc", "Valor: ");
2293
            $dPrev = $this->pSimpleGetDate($temp, "dPrev", "Entrega: ");
2294
            switch ($tpDoc) {
2295
                case "00":
2296
                    $tpDoc = "00 - Declaração";
2297
                    break;
2298
                case "10":
2299
                    $tpDoc = "10 - Dutoviário";
2300
                    break;
2301
                case "99":
2302
                    $tpDoc = "99 - Outros: [" . $descOutros . "]";
2303
                    break;
2304
                default:
2305
                    break;
2306
            }
2307
            $numeroDocumento = $nDoc;
2308
            $cnpjChave = $dEmi . " " . $vDocFisc . " " . $dPrev;
2309
            if ($auxX > $w * 0.90) {
2310
                $yIniDados = $yIniDados + 4;
2311
                $auxX = $oldX;
2312
            }
2313
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $tpDoc, $aFont, 'T', 'L', 0, '');
2314
            $auxX += $w * 0.09;
2315
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $cnpjChave, $aFont, 'T', 'L', 0, '');
2316
            $auxX += $w * 0.28;
2317
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $nDoc, $aFont, 'T', 'L', 0, '');
2318
            $auxX += $w * 0.14;
2319
        }
2320
        foreach ($this->idDocAntEle as $k => $d) {
2321
            $tp = 'CT-e';
2322
            $chaveCTe = $this->idDocAntEle->item($k)->getElementsByTagName('chave')->item(0)->nodeValue;
2323
            $numCTe = substr($chaveCTe, 25, 9);
2324
            $serieCTe = substr($chaveCTe, 22, 3);
2325
            $doc = $serieCTe . '/' . $numCTe;
2326
            if ($auxX > $w * 0.90) {
2327
                $yIniDados = $yIniDados + 4;
2328
                $auxX = $oldX;
2329
            }
2330
            $texto = $tp;
2331
            $aFont = array(
2332
                'font' => $this->fontePadrao,
2333
                'size' => 8,
2334
                'style' => '');
2335
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2336
            $auxX += $w * 0.09;
2337
            $texto = $chaveCTe;
2338
            $aFont = array(
2339
                'font' => $this->fontePadrao,
2340
                'size' => 8,
2341
                'style' => '');
2342
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2343
            $auxX += $w * 0.28;
2344
            $texto = $doc;
2345
            $aFont = array(
2346
                'font' => $this->fontePadrao,
2347
                'size' => 8,
2348
                'style' => '');
2349
            $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2350
            $auxX += $w * 0.14;
2351
        }
2352
    }
2353
2354
    /**
2355
     * docOrigContinuacao
2356
     * Monta o campo com os documentos originarios.
2357
     *
2358
     * @param  number $x Posição horizontal canto esquerdo
2359
     * @param  number $y Posição vertical canto superior
2360
     * @return number Posição vertical final
2361
     */
2362
    protected function docOrigContinuacao($x = 0, $y = 0)
2363
    {
2364
        $x2 = $x;
2365
        $y2 = $y;
2366
        $contador = 16;
2367
        for ($i = 2; $i <= $this->totPag; $i++) {
2368
            $x = $x2;
2369
            $y = $y2;
2370
            $this->pdf->AddPage($this->orientacao, $this->papel);
2371
            $r = $this->cabecalho(1, 1, $i, $this->totPag);
2372
            $oldX = $x;
2373
            $oldY = $y;
2374
            if ($this->orientacao == 'P') {
2375
                $maxW = $this->wPrint;
2376
            } else {
2377
                $maxW = $this->wPrint - $this->wCanhoto;
2378
            }
2379
            $w = $maxW;
2380
            //$h = 6; // de sub-titulo
2381
            //$h = 6 + 3; // de altura do texto (primeira linha
2382
            //$h = 9 + 3.5 ;// segunda linha
2383
            //$h = 9 + 3.5+ 3.5 ;// segunda linha
2384
            $h = (((count($this->arrayNFe) / 2) - 9) * 3.5) + 9;
2385
            if (count($this->arrayNFe) % 2 != 0) {
2386
                $h = $h + 3.5;
2387
            } // Caso tenha apenas 1 registro na ultima linha
2388
            $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO';
2389
            $aFont = $this->formatPadrao;
2390
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2391
            $descr1 = 'TIPO DOC';
2392
            $descr2 = 'CNPJ/CHAVE/OBS';
2393
            $descr3 = 'SÉRIE/NRO. DOCUMENTO';
2394
            $y += 3.4;
2395
            $this->pdf->line($x, $y, $w + 1, $y);
2396
            $texto = $descr1;
2397
            $aFont = $this->formatPadrao;
2398
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2399
            $yIniDados = $y;
2400
            $x += $w * 0.07; // COLUNA CNPJ/CHAVE/OBS
2401
            $texto = $descr2;
2402
            $aFont = $this->formatPadrao;
2403
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2404
            $x += $w * 0.28;
2405
            $texto = $descr3;
2406
            $aFont = $this->formatPadrao;
2407
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2408
            $x += $w * 0.14;
2409
            if ($this->modal == '1') {
2410
                if ($this->lota == 1) {
2411
                    $this->pdf->line($x, $y, $x, $y + 31.5);
2412
                } else {
2413
                    $this->pdf->line($x, $y, $x, $y + 49.5);
2414
                }
2415
            } elseif ($this->modal == '2') {
2416
                $this->pdf->line($x, $y, $x, $y + 49.5);
2417
            } elseif ($this->modal == '3') {
2418
                $this->pdf->line($x, $y, $x, $y + 34.1);
2419
            } else {
2420
                $this->pdf->line($x, $y, $x, $y + 21.5);
2421
            }
2422
            $texto = $descr1;
2423
            $aFont = $this->formatPadrao;
2424
            $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2425
            $x += $w * 0.08;
2426
            $texto = $descr2;
2427
            $aFont = $this->formatPadrao;
2428
            $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2429
            $x += $w * 0.28; // COLUNA SÉRIE/NRO.DOCUMENTO DA DIREITA
2430
            $texto = $descr3;
2431
            $aFont = $this->formatPadrao;
2432
            $this->pdf->textBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, '');
2433
            $auxX = $oldX;
2434
            $yIniDados += 3;
2435
            while ($contador < (count($this->arrayNFe))) {
2436
                if ($contador % (116 * ($i - 1)) == 0) {
2437
//                    $contador++;
2438
                    break;
2439
                }
2440
                $tp = 'NF-e';
2441
                $chaveNFe = $this->arrayNFe[$contador];
2442
                $numNFe = substr($chaveNFe, 25, 9);
2443
                $serieNFe = substr($chaveNFe, 22, 3);
2444
                $doc = $serieNFe . '/' . $numNFe;
2445
                if ($auxX > $w * 0.90) {
2446
                    $yIniDados = $yIniDados + 3.5;
2447
                    $auxX = $oldX;
2448
                }
2449
                $texto = $tp;
2450
                $aFont = array(
2451
                    'font' => $this->fontePadrao,
2452
                    'size' => 7,
2453
                    'style' => '');
2454
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2455
                $auxX += $w * 0.07;
2456
                $texto = $chaveNFe;
2457
                $aFont = array(
2458
                    'font' => $this->fontePadrao,
2459
                    'size' => 7,
2460
                    'style' => '');
2461
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.27, $h, $texto, $aFont, 'T', 'L', 0, '');
2462
                $auxX += $w * 0.28;
2463
                $texto = $doc;
2464
                $aFont = array(
2465
                    'font' => $this->fontePadrao,
2466
                    'size' => 7,
2467
                    'style' => '');
2468
                $this->pdf->textBox($auxX, $yIniDados, $w * 0.30, $h, $texto, $aFont, 'T', 'L', 0, '');
2469
                $auxX += $w * 0.15;
2470
                $contador++;
2471
            }
2472
        }
2473
    }
2474
2475
    /**
2476
     * docCompl
2477
     * Monta o campo com os dados do remetente na DACTE.
2478
     *
2479
     * @param number $x Posição horizontal canto esquerdo
2480
     * @param number $y Posição vertical canto superior
2481
     * @return number Posição vertical final
2482
     */
2483
    protected function docCompl($x = 0, $y = 0)
2484
    {
2485
        $oldX = $x;
2486
        $oldY = $y;
2487
        if ($this->orientacao == 'P') {
2488
            $maxW = $this->wPrint;
2489
        } else {
2490
            $maxW = $this->wPrint - $this->wCanhoto;
2491
        }
2492
        $w = $maxW;
2493
        $h = 80;
2494
        if ($this->tpCTe == 1) {
2495
            $texto = 'DETALHAMENTO DO CT-E COMPLEMENTADO';
2496
            $descr1 = 'CHAVE DO CT-E COMPLEMENTADO';
2497
            $descr2 = 'VALOR COMPLEMENTADO';
2498
        } else {
2499
            $texto = 'DETALHAMENTO DO CT-E ANULADO';
2500
            $descr1 = 'CHAVE DO CT-E ANULADO';
2501
            $descr2 = 'VALOR ANULADO';
2502
        }
2503
        $aFont = $this->formatPadrao;
2504
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2505
        $y += 3.4;
2506
        $this->pdf->line($x, $y, $w + 1, $y);
2507
        $texto = $descr1;
2508
        $aFont = $this->formatPadrao;
2509
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2510
        $yIniDados = $y;
2511
        $x += $w * 0.37;
2512
        $texto = $descr2;
2513
        $aFont = $this->formatPadrao;
2514
        $this->pdf->textBox($x - 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2515
        $x += $w * 0.13;
2516
        $this->pdf->line($x, $y, $x, $y + 76.5);
2517
        $texto = $descr1;
2518
        $aFont = $this->formatPadrao;
2519
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2520
        $x += $w * 0.3;
2521
        $texto = $descr2;
2522
        $aFont = $this->formatPadrao;
2523
        $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2524
        $auxX = $oldX;
2525
        $yIniDados += 4;
2526
        if ($auxX > $w * 0.90) {
2527
            $yIniDados = $yIniDados + 4;
2528
            $auxX = $oldX;
2529
        }
2530
        $texto = $this->chaveCTeRef;
2531
        $aFont = array(
2532
            'font' => $this->fontePadrao,
2533
            'size' => 8,
2534
            'style' => '');
2535
        $this->pdf->textBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2536
        $texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
2537
        $aFont = array(
2538
            'font' => $this->fontePadrao,
2539
            'size' => 8,
2540
            'style' => '');
2541
        $this->pdf->textBox($w * 0.40, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
2542
    }
2543
2544
    /**
2545
     * observacao
2546
     * Monta o campo com os dados do remetente na DACTE.
2547
     *
2548
     * @param  number $x Posição horizontal canto esquerdo
2549
     * @param  number $y Posição vertical canto superior
2550
     * @return number Posição vertical final
2551
     */
2552
    protected function observacao($x = 0, $y = 0)
2553
    {
2554
        $oldX = $x;
2555
        $oldY = $y;
2556
        if ($this->orientacao == 'P') {
2557
            $maxW = $this->wPrint;
2558
        } else {
2559
            $maxW = $this->wPrint - $this->wCanhoto;
2560
        }
2561
        $w = $maxW;
2562
        //$h = 18;
2563
        $h = 18.8;
2564
        $texto = 'OBSERVAÇÕES';
2565
        $aFont = $this->formatPadrao;
2566
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2567
        $y += 3.4;
2568
        $this->pdf->line($x, $y, $w + 1, $y);
2569
        $auxX = $oldX;
2570
        $yIniDados = $y;
2571
        $texto = '';
2572
        foreach ($this->compl as $k => $d) {
2573
            $xObs = $this->getTagValue($this->compl->item($k), "xObs");
2574
            $texto .= $xObs;
2575
        }
2576
        $textoObs = explode("Motorista:", $texto);
2577
        $textoObs[1] = isset($textoObs[1]) ? "Motorista: " . $textoObs[1] : '';
2578
        $texto .= $this->getTagValue($this->imp, "infAdFisco", "\r\n");
2579
        $aFont = array(
2580
            'font' => $this->fontePadrao,
2581
            'size' => 7.5,
2582
            'style' => '');
2583
        $this->pdf->textBox($x, $y, $w, $h, $textoObs[0], $aFont, 'T', 'L', 0, '', false);
2584
        $this->pdf->textBox($x, $y + 11.5, $w, $h, $textoObs[1], $aFont, 'T', 'L', 0, '', false);
2585
    }
2586
2587
    /**
2588
     * modalRod
2589
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2590
     *
2591
     * @param  number $x Posição horizontal canto esquerdo
2592
     * @param  number $y Posição vertical canto superior
2593
     * @return number Posição vertical final
2594
     */
2595
    protected function modalRod($x = 0, $y = 0)
2596
    {
2597
        $oldX = $x;
2598
        $oldY = $y;
2599
        $lotacao = '';
2600
        if ($this->orientacao == 'P') {
2601
            $maxW = $this->wPrint;
2602
        } else {
2603
            $maxW = $this->wPrint - $this->wCanhoto;
2604
        }
2605
        $w = $maxW;
2606
        $h = 3;
2607
        $texto = 'DADOS ESPECÍFICOS DO MODAL RODOVIÁRIO';
2608
        $aFont = $this->formatPadrao;
2609
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2610
        if ($this->lota == 1) {
2611
            $this->pdf->line($x, $y + 12, $w + 1, $y + 12); // LINHA DE BAIXO
2612
        }
2613
        $y += 3.4;
2614
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2615
        $texto = 'RNTRC DA EMPRESA';
2616
        $aFont = $this->formatPadrao;
2617
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2618
        $texto = $this->getTagValue($this->rodo, "RNTRC");
2619
        $aFont = $this->formatNegrito;
2620
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2621
        $x += $w * 0.23;
2622
        $this->pdf->line($x - 20, $y, $x - 20, $y + 6); // LINHA A FRENTE DA RNTRC DA EMPRESA
2623
        $texto = 'ESTE CONHECIMENTO DE TRANSPORTE ATENDE À LEGISLAÇÃO DE TRANSPORTE RODOVIÁRIO EM VIGOR';
2624
        $aFont = $this->formatPadrao;
2625
        $this->pdf->textBox($x - 20, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'C', 0, '');
2626
    }
2627
2628
    /**
2629
     * modalAereo
2630
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2631
     *
2632
     * @param  number $x Posição horizontal canto esquerdo
2633
     * @param  number $y Posição vertical canto superior
2634
     * @return number Posição vertical final
2635
     */
2636
    protected function modalAereo($x = 0, $y = 0)
2637
    {
2638
        $oldX = $x;
2639
        $oldY = $y;
2640
        $lotacao = '';
2641
        if ($this->orientacao == 'P') {
2642
            $maxW = $this->wPrint;
2643
        } else {
2644
            $maxW = $this->wPrint - $this->wCanhoto;
2645
        }
2646
        $w = $maxW;
2647
        $h = 3;
2648
        $texto = 'DADOS ESPECÍFICOS DO MODAL AÉREO';
2649
        $aFont = $this->formatPadrao;
2650
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2651
        $y += 3.4;
2652
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA DE CIMA
2653
        $texto = 'NÚMERO OPERACIONAL DO CONHECIMENTO AÉREO';
2654
        $aFont = $this->formatPadrao;
2655
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2656
        $texto = 'CLASSE DA TARIFA';
2657
        $aFont = $this->formatPadrao;
2658
        $this->pdf->textBox($x + 50, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2659
        $texto = 'CÓDIGO DA TARIFA';
2660
        $aFont = $this->formatPadrao;
2661
        $this->pdf->textBox($x + 80, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2662
        $texto = 'VALOR DA TARIFA';
2663
        $aFont = $this->formatPadrao;
2664
        $this->pdf->textBox($x + 110, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2665
        $texto = $this->getTagValue($this->aereo, "nOCA");
2666
        $aFont = $this->formatNegrito;
2667
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2668
        $x += $w * 0.23;
2669
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS NÚMERO OP. DO CT-E AEREO
2670
        $texto = $this->getTagValue($this->aereo, "CL");
2671
        $aFont = $this->formatNegrito;
2672
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2673
        $x += 30;
2674
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS CLASSE DA TARIFA
2675
        $texto = $this->getTagValue($this->aereo, "cTar");
2676
        $aFont = $this->formatNegrito;
2677
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2678
        $x += 30;
2679
        $this->pdf->line($x, $y, $x, $y + 6); // LINHA APÓS COD DA TARIFA
2680
        $texto = $this->getTagValue($this->aereo, "vTar");
2681
        $aFont = $this->formatNegrito;
2682
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2683
    }
2684
2685
    /**
2686
     * modalAquaviario
2687
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2688
     *
2689
     * @param  number $x Posição horizontal canto esquerdo
2690
     * @param  number $y Posição vertical canto superior
2691
     * @return number Posição vertical final
2692
     */
2693
    protected function modalAquaviario($x = 0, $y = 0)
2694
    {
2695
        $oldX = $x;
2696
        $oldY = $y;
2697
        if ($this->orientacao == 'P') {
2698
            $maxW = $this->wPrint;
2699
        } else {
2700
            $maxW = $this->wPrint - $this->wCanhoto;
2701
        }
2702
        $w = $maxW;
2703
        $h = 8.5;
2704
        $texto = 'DADOS ESPECÍFICOS DO MODAL AQUAVIÁRIO';
2705
        $aFont = $this->formatPadrao;
2706
        $this->pdf->textBox($x, $y, $w, $h * 3.2, $texto, $aFont, 'T', 'C', 1, '');
2707
        $y += 3.4;
2708
        $this->pdf->line($x, $y, $w + 1, $y);
2709
        $texto = 'PORTO DE EMBARQUE';
2710
        $aFont = $this->formatPadrao;
2711
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2712
        $texto = $this->getTagValue($this->aquav, "prtEmb");
2713
        $aFont = $this->formatNegrito;
2714
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2715
        $x += $w * 0.50;
2716
        $this->pdf->line($x, $y, $x, $y + 7.7);
2717
        $texto = 'PORTO DE DESTINO';
2718
        $aFont = $this->formatPadrao;
2719
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2720
        $texto = $this->getTagValue($this->aquav, "prtDest");
2721
        $aFont = $this->formatNegrito;
2722
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2723
        $y += 8;
2724
        $this->pdf->line(208, $y, 1, $y);
2725
        $x = 1;
2726
        $texto = 'IDENTIFICAÇÃO DO NAVIO / REBOCADOR';
2727
        $aFont = $this->formatPadrao;
2728
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2729
        $texto = $this->getTagValue($this->aquav, "xNavio");
2730
        $aFont = $this->formatNegrito;
2731
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2732
        $x += $w * 0.50;
2733
        $this->pdf->line($x, $y, $x, $y + 7.7);
2734
        $texto = 'VR DA B. DE CALC. AFRMM';
2735
        $aFont = $this->formatPadrao;
2736
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2737
        $texto = $this->getTagValue($this->aquav, "vPrest");
2738
        $aFont = $this->formatNegrito;
2739
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2740
        $x += $w * 0.17;
2741
        $this->pdf->line($x, $y, $x, $y + 7.7);
2742
        $texto = 'VALOR DO AFRMM';
2743
        $aFont = $this->formatPadrao;
2744
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2745
        $texto = $this->getTagValue($this->aquav, "vAFRMM");
2746
        $aFont = $this->formatNegrito;
2747
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2748
        $x += $w * 0.12;
2749
        $this->pdf->line($x, $y, $x, $y + 7.7);
2750
        $texto = 'TIPO DE NAVEGAÇÃO';
2751
        $aFont = $this->formatPadrao;
2752
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2753
        $texto = $this->getTagValue($this->aquav, "tpNav");
2754
        switch ($texto) {
2755
            case '0':
2756
                $texto = 'INTERIOR';
2757
                break;
2758
            case '1':
2759
                $texto = 'CABOTAGEM';
2760
                break;
2761
        }
2762
        $aFont = $this->formatNegrito;
2763
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2764
        $x += $w * 0.14;
2765
        $this->pdf->line($x, $y, $x, $y + 7.7);
2766
        $texto = 'DIREÇÃO';
2767
        $aFont = $this->formatPadrao;
2768
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2769
        $texto = $this->getTagValue($this->aquav, "direc");
2770
        switch ($texto) {
2771
            case 'N':
2772
                $texto = 'NORTE';
2773
                break;
2774
            case 'L':
2775
                $texto = 'LESTE';
2776
                break;
2777
            case 'S':
2778
                $texto = 'SUL';
2779
                break;
2780
            case 'O':
2781
                $texto = 'OESTE';
2782
                break;
2783
        }
2784
        $aFont = $this->formatNegrito;
2785
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2786
        $y += 8;
2787
        $this->pdf->line(208, $y, 1, $y);
2788
        $x = 1;
2789
        $texto = 'IDENTIFICAÇÃO DOS CONTEINERS';
2790
        $aFont = $this->formatPadrao;
2791
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2792
        if ($this->infNF->item(0) !== null && $this->infNF->item(0)->getElementsByTagName('infUnidCarga') !== null) {
2793
            $texto = $this->infNF
2794
                ->item(0)
2795
                ->getElementsByTagName('infUnidCarga')
2796
                ->item(0)
2797
                ->getElementsByTagName('idUnidCarga')
2798
                ->item(0)->nodeValue;
2799
        } elseif ($this->infNFe->item(0) !== null
2800
            && $this->infNFe->item(0)->getElementsByTagName('infUnidCarga') !== null
2801
        ) {
2802
            $texto = $this->infNFe
2803
                ->item(0)
2804
                ->getElementsByTagName('infUnidCarga')
2805
                ->item(0)
2806
                ->getElementsByTagName('idUnidCarga')
2807
                ->item(0)
2808
                ->nodeValue;
2809
        } elseif ($this->infOutros->item(0) !== null
2810
            && $this->infOutros->item(0)->getElementsByTagName('infUnidCarga') !== null
2811
        ) {
2812
            $texto = $this->infOutros
2813
                ->item(0)
2814
                ->getElementsByTagName('infUnidCarga')
2815
                ->item(0)
2816
                ->getElementsByTagName('idUnidCarga')
2817
                ->item(0)
2818
                ->nodeValue;
2819
        } else {
2820
            $texto = '';
2821
        }
2822
        $aFont = $this->formatNegrito;
2823
        $this->pdf->textBox($x, $y + 3, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2824
        $x += $w * 0.50;
2825
        $this->pdf->line($x, $y, $x, $y + 7.7);
2826
        $texto = 'IDENTIFICAÇÃO DAS BALSAS';
2827
        $aFont = $this->formatPadrao;
2828
        $this->pdf->textBox($x, $y, $w * 0.23, $h, $texto, $aFont, 'T', 'L', 0, '');
2829
        $texto = '';
2830
        if ($this->getTagValue($this->aquav, "balsa") !== '') {
2831
            foreach ($this->aquav->getElementsByTagName('balsa') as $k => $d) {
2832
                if ($k == 0) {
2833
                    $texto = $this->aquav
2834
                        ->getElementsByTagName('balsa')
2835
                        ->item($k)
2836
                        ->getElementsByTagName('xBalsa')
2837
                        ->item(0)
2838
                        ->nodeValue;
2839
                } else {
2840
                    $texto = $texto
2841
                        . ' / '
2842
                        . $this->aquav
2843
                            ->getElementsByTagName('balsa')
2844
                            ->item($k)
2845
                            ->getElementsByTagName('xBalsa')
2846
                            ->item(0)
2847
                            ->nodeValue;
2848
                }
2849
            }
2850
        }
2851
        $aFont = $this->formatNegrito;
2852
        $this->pdf->textBox($x, $y + 3, $w * 0.50, $h, $texto, $aFont, 'T', 'L', 0, '');
2853
    }
2854
2855
    /**
2856
     * modalFerr
2857
     * Monta o campo com os dados do remetente na DACTE. ( retrato  e paisagem  )
2858
     *
2859
     * @param  number $x Posição horizontal canto esquerdo
2860
     * @param  number $y Posição vertical canto superior
2861
     * @return number Posição vertical final
2862
     */
2863
    protected function modalFerr($x = 0, $y = 0)
2864
    {
2865
        $oldX = $x;
2866
        $oldY = $y;
2867
        if ($this->orientacao == 'P') {
2868
            $maxW = $this->wPrint;
2869
        } else {
2870
            $maxW = $this->wPrint - $this->wCanhoto;
2871
        }
2872
        $w = $maxW;
2873
        $h = 19.6;
2874
        $texto = 'DADOS ESPECÍFICOS DO MODAL FERROVIÁRIO';
2875
        $aFont = $this->formatPadrao;
2876
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
2877
        $y += 3.4;
2878
        $this->pdf->line($x, $y, $w + 1, $y);
2879
        $texto = 'DCL';
2880
        $aFont = array(
2881
            'font' => $this->fontePadrao,
2882
            'size' => 7,
2883
            'style' => 'B');
2884
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'C', 0, '');
2885
        $this->pdf->line($x + 49.6, $y, $x + 49.6, $y + 3.5);
2886
        $texto = 'VAGÕES';
2887
        $aFont = array(
2888
            'font' => $this->fontePadrao,
2889
            'size' => 7,
2890
            'style' => 'B');
2891
        $this->pdf->textBox($x + 50, $y, $w * 0.5, $h, $texto, $aFont, 'T', 'C', 0, '');
2892
        $y += 3.4;
2893
        $this->pdf->line($x, $y, $w + 1, $y);
2894
        // DCL
2895
        $texto = 'ID TREM';
2896
        $aFont = array(
2897
            'font' => $this->fontePadrao,
2898
            'size' => 6,
2899
            'style' => '');
2900
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2901
        $texto = $this->getTagValue($this->ferrov, "idTrem");
2902
        $aFont = array(
2903
            'font' => $this->fontePadrao,
2904
            'size' => 6,
2905
            'style' => 'B');
2906
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2907
        $x += $w * 0.06;
2908
        $y1 = $y + 12.5;
2909
        $this->pdf->line($x, $y, $x, $y1);
2910
        $texto = 'NUM';
2911
        $aFont = array(
2912
            'font' => $this->fontePadrao,
2913
            'size' => 6,
2914
            'style' => '');
2915
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2916
        $texto = $this->getTagValue($this->rem, "nDoc");
2917
        $aFont = array(
2918
            'font' => $this->fontePadrao,
2919
            'size' => 6,
2920
            'style' => 'B');
2921
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2922
        $x += $w * 0.06;
2923
        $this->pdf->line($x, $y, $x, $y1);
2924
        $texto = 'SÉRIE';
2925
        $aFont = array(
2926
            'font' => $this->fontePadrao,
2927
            'size' => 6,
2928
            'style' => '');
2929
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2930
        $texto = $this->getTagValue($this->rem, "serie");
2931
        $aFont = array(
2932
            'font' => $this->fontePadrao,
2933
            'size' => 6,
2934
            'style' => 'B');
2935
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2936
        $x += $w * 0.06;
2937
        $this->pdf->line($x, $y, $x, $y1);
2938
        $texto = 'EMISSÃO';
2939
        $aFont = array(
2940
            'font' => $this->fontePadrao,
2941
            'size' => 6,
2942
            'style' => '');
2943
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2944
        $texto = $this->ymdTodmy($this->getTagValue($this->rem, "dEmi"));
2945
        $aFont = array(
2946
            'font' => $this->fontePadrao,
2947
            'size' => 6,
2948
            'style' => 'B');
2949
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2950
        // VAGOES
2951
        $x += $w * 0.06;
2952
        $this->pdf->line($x, $y, $x, $y1);
2953
        $texto = 'NUM';
2954
        $aFont = array(
2955
            'font' => $this->fontePadrao,
2956
            'size' => 6,
2957
            'style' => '');
2958
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2959
        $texto = $this->getTagValue($this->ferrov, "nVag");
2960
        $aFont = array(
2961
            'font' => $this->fontePadrao,
2962
            'size' => 6,
2963
            'style' => 'B');
2964
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2965
        $x += $w * 0.06;
2966
        $this->pdf->line($x, $y, $x, $y1);
2967
        $texto = 'TIPO';
2968
        $aFont = array(
2969
            'font' => $this->fontePadrao,
2970
            'size' => 6,
2971
            'style' => '');
2972
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2973
        $texto = $this->getTagValue($this->ferrov, "tpVag");
2974
        $aFont = array(
2975
            'font' => $this->fontePadrao,
2976
            'size' => 6,
2977
            'style' => 'B');
2978
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2979
        $x += $w * 0.06;
2980
        $this->pdf->line($x, $y, $x, $y1);
2981
        $texto = 'CAPACIDADE';
2982
        $aFont = array(
2983
            'font' => $this->fontePadrao,
2984
            'size' => 6,
2985
            'style' => '');
2986
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2987
        $texto = $this->getTagValue($this->ferrov, "cap");
2988
        $aFont = array(
2989
            'font' => $this->fontePadrao,
2990
            'size' => 6,
2991
            'style' => 'B');
2992
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
2993
        $x += $w * 0.08;
2994
        $this->pdf->line($x, $y, $x, $y1);
2995
        $texto = 'PESO REAL/TON';
2996
        $aFont = array(
2997
            'font' => $this->fontePadrao,
2998
            'size' => 6,
2999
            'style' => '');
3000
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3001
        $texto = $this->getTagValue($this->ferrov, "pesoR");
3002
        $aFont = array(
3003
            'font' => $this->fontePadrao,
3004
            'size' => 6,
3005
            'style' => 'B');
3006
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3007
        $x += $w * 0.09;
3008
        $this->pdf->line($x, $y, $x, $y1);
3009
        $texto = 'PESO BRUTO/TON';
3010
        $aFont = array(
3011
            'font' => $this->fontePadrao,
3012
            'size' => 6,
3013
            'style' => '');
3014
        $this->pdf->textBox($x, $y, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3015
        $texto = $this->getTagValue($this->ferrov, "pesoBC");
3016
        $aFont = array(
3017
            'font' => $this->fontePadrao,
3018
            'size' => 6,
3019
            'style' => 'B');
3020
        $this->pdf->textBox($x, $y + 3, $w * 0.10, $h, $texto, $aFont, 'T', 'L', 0, '');
3021
        $x += $w * 0.1;
3022
        $this->pdf->line($x, $y, $x, $y1);
3023
        $texto = 'IDENTIFICAÇÃO DOS CONTÊINERES';
3024
        $aFont = array(
3025
            'font' => $this->fontePadrao,
3026
            'size' => 6,
3027
            'style' => '');
3028
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3029
        $texto = $this->getTagValue($this->ferrov, "nCont");
3030
        $aFont = array(
3031
            'font' => $this->fontePadrao,
3032
            'size' => 6,
3033
            'style' => 'B');
3034
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3035
        // FLUXO
3036
        $x = 1;
3037
        $y += 12.9;
3038
        $h1 = $h * 0.5 + 0.27;
3039
        $wa = round($w * 0.103) + 0.5;
3040
        $texto = 'FLUXO FERROVIARIO';
3041
        $aFont = $this->formatPadrao;
3042
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3043
        $texto = $this->getTagValue($this->ferrov, "fluxo");
3044
        $aFont = array(
3045
            'font' => $this->fontePadrao,
3046
            'size' => 7,
3047
            'style' => 'B');
3048
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3049
        $y += 10;
3050
        $texto = 'TIPO DE TRÁFEGO';
3051
        $aFont = $this->formatPadrao;
3052
        $this->pdf->textBox($x, $y, $wa, $h1, $texto, $aFont, 'T', 'C', 1, '');
3053
        $texto = $this->convertUnidTrafego($this->getTagValue($this->ferrov, "tpTraf"));
3054
        $aFont = array(
3055
            'font' => $this->fontePadrao,
3056
            'size' => 7,
3057
            'style' => 'B');
3058
        $this->pdf->textBox($x, $y + 3, $wa, $h1, $texto, $aFont, 'T', 'C', 0, '');
3059
        // Novo Box Relativo a Modal Ferroviário
3060
        $x = 22.5;
3061
        $y += -10.2;
3062
        $texto = 'INFORMAÇÕES DAS FERROVIAS ENVOLVIDAS';
3063
        $aFont = $this->formatPadrao;
3064
        $this->pdf->textBox($x, $y, $w - 21.5, $h1 * 2.019, $texto, $aFont, 'T', 'C', 1, '');
3065
        $y += 3.4;
3066
        $this->pdf->line($x, $y, $w + 1, $y);
3067
        $w = $w * 0.2;
3068
        $h = $h * 1.04;
3069
        $texto = 'CÓDIGO INTERNO';
3070
        $aFont = array(
3071
            'font' => $this->fontePadrao,
3072
            'size' => 6,
3073
            'style' => '');
3074
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3075
        $texto = $this->getTagValue($this->ferrov, "cInt");
3076
        $aFont = array(
3077
            'font' => $this->fontePadrao,
3078
            'size' => 6,
3079
            'style' => 'B');
3080
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3081
        $texto = 'CNPJ';
3082
        $aFont = array(
3083
            'font' => $this->fontePadrao,
3084
            'size' => 6,
3085
            'style' => '');
3086
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3087
        $texto = $this->getTagValue($this->ferrov, "CNPJ");
3088
        $aFont = array(
3089
            'font' => $this->fontePadrao,
3090
            'size' => 6,
3091
            'style' => 'B');
3092
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3093
        $x += 50;
3094
        $texto = 'NOME';
3095
        $aFont = array(
3096
            'font' => $this->fontePadrao,
3097
            'size' => 6,
3098
            'style' => '');
3099
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3100
        $texto = $this->getTagValue($this->ferrov, "xNome");
3101
        $aFont = array(
3102
            'font' => $this->fontePadrao,
3103
            'size' => 6,
3104
            'style' => 'B');
3105
        $this->pdf->textBox($x, $y + 3, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3106
        $texto = 'INSCRICAO ESTADUAL';
3107
        $aFont = array(
3108
            'font' => $this->fontePadrao,
3109
            'size' => 6,
3110
            'style' => '');
3111
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3112
        $texto = $this->getTagValue($this->ferrov, "IE");
3113
        $aFont = array(
3114
            'font' => $this->fontePadrao,
3115
            'size' => 6,
3116
            'style' => 'B');
3117
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3118
        $x += 50;
3119
        $texto = 'PARTICIPAÇÃO OUTRA FERROVIA';
3120
        $aFont = array(
3121
            'font' => $this->fontePadrao,
3122
            'size' => 6,
3123
            'style' => '');
3124
        $this->pdf->textBox($x, $y + 6, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3125
        $texto = '';
3126
        $aFont = array(
3127
            'font' => $this->fontePadrao,
3128
            'size' => 6,
3129
            'style' => 'B');
3130
        $this->pdf->textBox($x, $y + 9, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
3131
    }
3132
3133
    /**
3134
     * canhoto
3135
     * Monta o campo com os dados do remetente na DACTE.
3136
     *
3137
     * @param  number $x Posição horizontal canto esquerdo
3138
     * @param  number $y Posição vertical canto superior
3139
     * @return number Posição vertical final
3140
     */
3141
    protected function canhoto($x = 0, $y = 0)
3142
    {
3143
        $oldX = $x;
3144
        $oldY = $y;
3145
        if ($this->orientacao == 'P') {
3146
            $maxW = $this->wPrint;
3147
        } else {
3148
            $maxW = $this->wPrint - $this->wCanhoto;
3149
        }
3150
        $w = $maxW - 1;
3151
        $h = 20;
3152
        $y = $y + 1;
3153
        $texto = 'DECLARO QUE RECEBI OS VOLUMES DESTE CONHECIMENTO EM PERFEITO ESTADO ';
3154
        $texto .= 'PELO QUE DOU POR CUMPRIDO O PRESENTE CONTRATO DE TRANSPORTE';
3155
        $aFont = $this->formatPadrao;
3156
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3157
        $y += 3.4;
3158
        $this->pdf->line($x, $y, $w + 1, $y); // LINHA ABAICO DO TEXTO DECLARO QUE RECEBI...
3159
        $texto = 'NOME';
3160
        $aFont = array(
3161
            'font' => $this->fontePadrao,
3162
            'size' => 6,
3163
            'style' => '');
3164
        $this->pdf->textBox($x, $y, $w * 0.25, $h, $texto, $aFont, 'T', 'L', 0, '');
3165
        $x += $w * 0.25;
3166
        $this->pdf->line($x, $y, $x, $y + 16.5);
3167
        $texto = 'ASSINATURA / CARIMBO';
3168
        $aFont = array(
3169
            'font' => $this->fontePadrao,
3170
            'size' => 6,
3171
            'style' => '');
3172
        $this->pdf->textBox($x, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'B', 'C', 0, '');
3173
        $x += $w * 0.25;
3174
        $this->pdf->line($x, $y, $x, $y + 16.5);
3175
        $texto = 'TÉRMINO DA PRESTAÇÃO - DATA/HORA' . "\r\n" . "\r\n" . "\r\n" . "\r\n";
3176
        $texto .= ' INÍCIO DA PRESTAÇÃO - DATA/HORA';
3177
        $aFont = array(
3178
            'font' => $this->fontePadrao,
3179
            'size' => 6,
3180
            'style' => '');
3181
        $this->pdf->textBox($x + 10, $y, $w * 0.25, $h - 3.4, $texto, $aFont, 'T', 'C', 0, '');
3182
        $x = $oldX;
3183
        $y = $y + 5;
3184
        $this->pdf->line($x, $y + 3, $w * 0.255, $y + 3); // LINHA HORIZONTAL ACIMA DO RG ABAIXO DO NOME
3185
        $texto = 'RG';
3186
        $aFont = array(
3187
            'font' => $this->fontePadrao,
3188
            'size' => 6,
3189
            'style' => '');
3190
        $this->pdf->textBox($x, $y + 3, $w * 0.33, $h, $texto, $aFont, 'T', 'L', 0, '');
3191
        $x += $w * 0.85;
3192
        $this->pdf->line($x, $y + 11.5, $x, $y - 5); // LINHA VERTICAL PROXIMO AO CT-E
3193
        $texto = "CT-E";
3194
        $aFont = $this->formatNegrito;
3195
        $this->pdf->textBox($x, $y - 5, $w * 0.15, $h, $texto, $aFont, 'T', 'C', 0, '');
3196
        $texto = "\r\n Nº. DOCUMENTO  " . $this->getTagValue($this->ide, "nCT") . " \n";
3197
        $texto .= "\r\n SÉRIE  " . $this->getTagValue($this->ide, "serie");
3198
        $aFont = array(
3199
            'font' => $this->fontePadrao,
3200
            'size' => 6,
3201
            'style' => '');
3202
        $this->pdf->textBox($x, $y - 8, $w * 0.15, $h, $texto, $aFont, 'C', 'C', 0, '');
3203
        $x = $oldX;
3204
        $this->pdf->dashedHLine($x, $y + 12.7, $this->wPrint, 0.1, 80);
3205
    }
3206
3207
    /**
3208
     * dadosAdic
3209
     * Coloca o grupo de dados adicionais da DACTE.
3210
     *
3211
     * @param  number $x Posição horizontal canto esquerdo
3212
     * @param  number $y Posição vertical canto superior
3213
     * @param  number $h altura do campo
3214
     * @return number Posição vertical final
3215
     */
3216
    protected function dadosAdic($x, $y, $pag, $h)
3217
    {
3218
        $oldX = $x;
3219
        //###########################################################################
3220
        //DADOS ADICIONAIS DACTE
3221
        if ($this->orientacao == 'P') {
3222
            $w = $this->wPrint;
3223
        } else {
3224
            $w = $this->wPrint - $this->wCanhoto;
3225
        }
3226
        //INFORMAÇÕES COMPLEMENTARES
3227
        $texto = "USO EXCLUSIVO DO EMISSOR DO CT-E";
3228
        $y += 3;
3229
        $w = $this->wAdic;
3230
        $h = 8; //mudar
3231
        $aFont = array(
3232
            'font' => $this->fontePadrao,
3233
            'size' => 6,
3234
            'style' => '');
3235
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3236
        //$this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3237
        $this->pdf->line($x, $y + 3, $w * 1.385, $y + 3);
3238
        //o texto com os dados adicionais foi obtido na função xxxxxx
3239
        //e carregado em uma propriedade privada da classe
3240
        //$this->wAdic com a largura do campo
3241
        //$this->textoAdic com o texto completo do campo
3242
        $y += 1;
3243
        $aFont = $this->formatPadrao;
3244
        $this->pdf->textBox($x, $y + 3, $w - 2, $h - 3, $this->textoAdic, $aFont, 'T', 'L', 0, '', false);
3245
        //RESERVADO AO FISCO
3246
        $texto = "RESERVADO AO FISCO";
3247
        $x += $w;
3248
        $y -= 1;
3249
        if ($this->orientacao == 'P') {
3250
            $w = $this->wPrint - $w;
3251
        } else {
3252
            $w = $this->wPrint - $w - $this->wCanhoto;
3253
        }
3254
        $aFont = array(
3255
            'font' => $this->fontePadrao,
3256
            'size' => 6,
3257
            'style' => '');
3258
        $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, '');
3259
        //inserir texto informando caso de contingência
3260
        //1 – Normal – emissão normal;
3261
        //2 – Contingência FS – emissão em contingência com impressão do DACTE em Formulário de Segurança;
3262
        //3 – Contingência SCAN – emissão em contingência  – SCAN;
3263
        //4 – Contingência DPEC - emissão em contingência com envio da Declaração Prévia de
3264
        //Emissão em Contingência – DPEC;
3265
        //5 – Contingência FS-DA - emissão em contingência com impressão do DACTE em Formulário de
3266
        //Segurança para Impressão de Documento Auxiliar de Documento Fiscal Eletrônico (FS-DA).
3267
        $xJust = $this->getTagValue($this->ide, 'xJust', 'Justificativa: ');
3268
        $dhCont = $this->getTagValue($this->ide, 'dhCont', ' Entrada em contingência : ');
3269
        $texto = '';
3270
        switch ($this->tpEmis) {
3271
            case 2:
3272
                $texto = 'CONTINGÊNCIA FS' . $dhCont . $xJust;
3273
                break;
3274
            case 3:
3275
                $texto = 'CONTINGÊNCIA SCAN' . $dhCont . $xJust;
3276
                break;
3277
            case 4:
3278
                $texto = 'CONTINGÊNCIA DPEC' . $dhCont . $xJust;
3279
                break;
3280
            case 5:
3281
                $texto = 'CONTINGÊNCIA FSDA' . $dhCont . $xJust;
3282
                break;
3283
        }
3284
        $y += 2;
3285
        $aFont = $this->formatPadrao;
3286
        $this->pdf->textBox($x, $y + 2, $w - 2, $h - 3, $texto, $aFont, 'T', 'L', 0, '', false);
3287
        return $y + $h;
3288
    }
3289
3290
    /**
3291
     * formatCNPJCPF
3292
     * Formata campo CnpjCpf contida na CTe
3293
     *
3294
     * @param  string $field campo cnpjCpf da CT-e
3295
     * @return string
3296
     */
3297
    protected function formatCNPJCPF($field)
3298
    {
3299
        if (!isset($field)) {
3300
            return '';
3301
        }
3302
        $cnpj = !empty($field->getElementsByTagName("CNPJ")->item(0)->nodeValue) ?
3303
            $field->getElementsByTagName("CNPJ")->item(0)->nodeValue : "";
3304
        if ($cnpj != "" && $cnpj != "00000000000000") {
3305
            $cnpj = $this->formatField($cnpj, '###.###.###/####-##');
3306
        } else {
3307
            $cnpj = !empty($field->getElementsByTagName("CPF")->item(0)->nodeValue) ?
3308
                $this->formatField($field->getElementsByTagName("CPF")->item(0)->nodeValue, '###.###.###.###-##') : '';
3309
        }
3310
        return $cnpj;
3311
    }
3312
3313
    /**
3314
     * formatFone
3315
     * Formata campo fone contida na CTe
3316
     *
3317
     * @param  string $field campo fone da CT-e
3318
     * @return string
3319
     */
3320
    protected function formatFone($field)
3321
    {
3322
        try {
3323
            $fone = !empty($field->getElementsByTagName("fone")->item(0)->nodeValue) ?
3324
                $field->getElementsByTagName("fone")->item(0)->nodeValue : '';
3325
            $foneLen = strlen($fone);
3326
            if ($foneLen > 0) {
3327
                $fone2 = substr($fone, 0, $foneLen - 4);
3328
                $fone1 = substr($fone, 0, $foneLen - 8);
3329
                $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
3330
            } else {
3331
                $fone = '';
3332
            }
3333
            return $fone;
3334
        } catch (Exception $exc) {
3335
            return '';
3336
        }
3337
    }
3338
3339
    /**
3340
     * unidade
3341
     * Converte a imformação de peso contida na CTe
3342
     *
3343
     * @param  string $c unidade de trafego extraida da CTe
3344
     * @return string
3345
     */
3346
    protected function unidade($c = '')
3347
    {
3348
        switch ($c) {
3349
            case '00':
3350
                $r = 'M3';
3351
                break;
3352
            case '01':
3353
                $r = 'KG';
3354
                break;
3355
            case '02':
3356
                $r = 'TON';
3357
                break;
3358
            case '03':
3359
                $r = 'UN';
3360
                break;
3361
            case '04':
3362
                $r = 'LT';
3363
                break;
3364
            case '05':
3365
                $r = 'MMBTU';
3366
                break;
3367
            default:
3368
                $r = '';
3369
        }
3370
        return $r;
3371
    }
3372
3373
    /**
3374
     * convertUnidTrafego
3375
     * Converte a imformação de peso contida na CTe
3376
     *
3377
     * @param  string $U Informação de trafego extraida da CTe
3378
     * @return string
3379
     */
3380
    protected function convertUnidTrafego($U = '')
3381
    {
3382
        if ($U) {
3383
            switch ($U) {
3384
                case '0':
3385
                    $stringU = 'Próprio';
3386
                    break;
3387
                case '1':
3388
                    $stringU = 'Mútuo';
3389
                    break;
3390
                case '2':
3391
                    $stringU = 'Rodoferroviário';
3392
                    break;
3393
                case '3':
3394
                    $stringU = 'Rodoviário';
3395
                    break;
3396
            }
3397
            return $stringU;
3398
        }
3399
    }
3400
3401
    /**
3402
     * multiUniPeso
3403
     * Fornece a imformação multiplicação de peso contida na CTe
3404
     *
3405
     * @param  interger $U Informação de peso extraida da CTe
3406
     * @return interger
3407
     */
3408
    protected function multiUniPeso($U = '')
3409
    {
3410
        if ($U === "01") {
3411
            // tonelada
3412
            //return 1000;
3413
            return 1;
3414
        }
3415
        return 1; // M3, KG, Unidade, litros, mmbtu
3416
    }
3417
3418
    protected function qrCodeDacte($y = 0)
3419
    {
3420
        $margemInterna = $this->margemInterna;
3421
        $barcode = new Barcode();
3422
        $bobj = $barcode->getBarcodeObj(
3423
            'QRCODE,M',
3424
            $this->qrCodCTe,
3425
            -4,
3426
            -4,
3427
            'black',
3428
            array(-2, -2, -2, -2)
3429
        )->setBackgroundColor('white');
3430
        $qrcode = $bobj->getPngData();
3431
        $wQr = 36;
3432
        $hQr = 36;
3433
        $yQr = ($y + $margemInterna);
3434
        if ($this->orientacao == 'P') {
3435
            $xQr = 170;
3436
        } else {
3437
            $xQr = 250;
3438
        }
3439
        // prepare a base64 encoded "data url"
3440
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
3441
        $this->pdf->image($pic, $xQr - 3, $yQr, $wQr, $hQr, 'PNG');
3442
    }
3443
3444
    /**
3445
     * Add the credits to the integrator in the footer message
3446
     * @param string $message
3447
     */
3448
    public function creditsIntegratorFooter($message = '')
3449
    {
3450
        $this->creditos = trim($message);
3451
    }
3452
}
3453