Passed
Push — master ( 969f54...b0574b )
by Roberto
44s queued 11s
created

src/CTe/Daevento.php (3 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 geração do envento do CTe em PDF
7
 * NOTA: Este documento não está NORMALIZADO, nem é requerido pela SEFAZ
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Daevento.php
12
 * @copyright 2009-2019 NFePHP
13
 * @license   http://www.gnu.org/licenses/lgpl.html GNU/LGPL v.3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
16
 */
17
18
use Exception;
19
use NFePHP\DA\Legacy\Dom;
20
use NFePHP\DA\Legacy\Pdf;
21
use NFePHP\DA\Legacy\Common;
22
23
class Daevento extends Common
24
{
25
    public $chCTe;
26
27
    protected $logoAlign = 'C';
28
    protected $yDados = 0;
29
    protected $debugMode = 0;
30
    protected $dadosEmitente = array();
31
    protected $pdf;
32
    protected $xml;
33
    protected $logomarca = '';
34
    protected $errMsg = '';
35
    protected $errStatus = false;
36
    protected $orientacao = 'P';
37
    protected $papel = 'A4';
38
    protected $destino = 'I';
39
    protected $pdfDir = '';
40
    protected $fontePadrao = 'Times';
41
    protected $version = '0.1.1';
42
    protected $wPrint;
43
    protected $hPrint;
44
    protected $wCanhoto;
45
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
46
    protected $id;
47
    protected $tpAmb;
48
    protected $cOrgao;
49
    protected $xCorrecao;
50
    protected $xCondUso;
51
    protected $dhEvento;
52
    protected $cStat;
53
    protected $xMotivo;
54
    protected $xJust;
55
    protected $CNPJDest = '';
56
    protected $CPFDest = '';
57
    protected $dhRegEvento;
58
    protected $nProt;
59
    protected $tpEvento;
60
61
    private $dom;
62
    private $procEventoCTe;
63
    private $evento;
64
    private $infEvento;
65
    private $retEvento;
66
    private $rinfEvento;
67
    private $creditos;
68
69
    /**
70
     * __construct
71
     *
72
     * @param string $xml Arquivo XML (diretório ou string)
73
     * @param array $dadosEmitente Dados do endereço do emitente
74
     */
75
    public function __construct($xml, $dadosEmitente)
76
    {
77
        $this->dadosEmitente = $dadosEmitente;
78
        $this->debugMode();
79
        $this->loadDoc($xml);
80
    }
81
82
    /**
83
     * Ativa ou desativa o modo debug
84
     * @param bool $activate
85
     * @return bool
86
     */
87
    public function debugMode($activate = null)
88
    {
89
        if (isset($activate) && is_bool($activate)) {
90
            $this->debugmode = $activate;
0 ignored issues
show
The property debugmode does not seem to exist. Did you mean debugMode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
91
        }
92
        if ($this->debugmode) {
0 ignored issues
show
The property debugmode does not seem to exist. Did you mean debugMode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
93
            error_reporting(E_ALL);
94
            ini_set('display_errors', 'On');
95
        } else {
96
            error_reporting(0);
97
            ini_set('display_errors', 'Off');
98
        }
99
        return $this->debugmode;
0 ignored issues
show
The property debugmode does not seem to exist. Did you mean debugMode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
100
    }
101
102
    protected function loadDoc($xml)
103
    {
104
        $this->dom = new \DomDocument;
105
        $this->dom->loadXML($xml);
106
        $this->procEventoCTe = $this->dom->getElementsByTagName("procEventoCTe")->item(0);
107
        $this->evento = $this->dom->getElementsByTagName("eventoCTe")->item(0);
108
        $this->infEvento = $this->evento->getElementsByTagName("infEvento")->item(0);
109
        $this->retEvento = $this->dom->getElementsByTagName("retEventoCTe")->item(0);
110
        $this->rinfEvento = $this->retEvento->getElementsByTagName("infEvento")->item(0);
111
        $this->tpEvento = $this->infEvento->getElementsByTagName("tpEvento")->item(0)->nodeValue;
112
        if (!in_array($this->tpEvento, array('110110', '110111'))) {
113
            $this->errMsg = 'Evento não implementado ' . $tpEvento . ' !!';
114
            $this->errStatus = true;
115
            return false;
116
        }
117
        $this->id = str_replace('ID', '', $this->infEvento->getAttribute("Id"));
118
        $this->chCTe = $this->infEvento->getElementsByTagName("chCTe")->item(0)->nodeValue;
119
        $this->dadosEmitente['CNPJ'] = substr($this->chCTe, 6, 14);
120
        $this->tpAmb = $this->infEvento->getElementsByTagName("tpAmb")->item(0)->nodeValue;
121
        $this->cOrgao = $this->infEvento->getElementsByTagName("cOrgao")->item(0)->nodeValue;
122
        $this->xCorrecao = $this->infEvento->getElementsByTagName("xCorrecao")->item(0);
123
        $this->xCorrecao = (empty($this->xCorrecao) ? '' : $this->xCorrecao->nodeValue);
124
        $this->xCondUso = $this->infEvento->getElementsByTagName("xCondUso")->item(0);
125
        $this->xCondUso = (empty($this->xCondUso) ? '' : $this->xCondUso->nodeValue);
126
        $this->xJust = $this->infEvento->getElementsByTagName("xJust")->item(0);
127
        $this->xJust = (empty($this->xJust) ? '' : $this->xJust->nodeValue);
128
        $this->dhEvento = $this->infEvento->getElementsByTagName("dhEvento")->item(0)->nodeValue;
129
        $this->cStat = $this->rinfEvento->getElementsByTagName("cStat")->item(0)->nodeValue;
130
        $this->xMotivo = $this->rinfEvento->getElementsByTagName("xMotivo")->item(0)->nodeValue;
131
        $this->CNPJDest = !empty($this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue) ?
132
            $this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue : '';
133
        $this->CPFDest = !empty($this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue) ?
134
            $this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue : '';
135
        $this->dhRegEvento = $this->rinfEvento->getElementsByTagName("dhRegEvento")->item(0)->nodeValue;
136
        $this->nProt = $this->rinfEvento->getElementsByTagName("nProt")->item(0)->nodeValue;
137
    }
138
139
    /**
140
     * Dados brutos do PDF
141
     * @return string
142
     */
143
    public function render()
144
    {
145
        if (empty($this->pdf)) {
146
            $this->monta();
147
        }
148
        return $this->pdf->getPdf();
149
    }
150
151
    /**
152
     * Add the credits to the integrator in the footer message
153
     * @param string $message
154
     */
155
    public function creditsIntegratorFooter($message = '')
156
    {
157
        $this->creditos = trim($message);
158
    }
159
160
    /**
161
     * monta
162
     * Esta função monta a DAEventoCTe conforme as informações fornecidas para a classe
163
     * durante sua construção.
164
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
165
     * pelo conteúdo da funçao e podem ser modificados.
166
     *
167
     * @param string $logo base64 da logomarca
168
     * @param string $orientacao (Opcional) Estabelece a orientação da impressão (ex. P-retrato),
169
     *               se nada for fornecido será usado o padrão da CTe
170
     * @param string $papel (Opcional) Estabelece o tamanho do papel (ex. A4)
171
     * @return string O ID do evento extraido do arquivo XML
172
     */
173
    public function monta(
174
        $logo = '',
175
        $orientacao = '',
176
        $papel = 'A4',
177
        $logoAlign = 'C'
178
    )
179
    {
180
        if ($orientacao == '') {
181
            $orientacao = 'P';
182
        }
183
        $this->logomarca = $logo;
184
        $this->orientacao = $orientacao;
185
        $this->papel = $papel;
186
        $this->logoAlign = $logoAlign;
187
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
188
        if ($this->orientacao == 'P') {
189
            // margens do PDF
190
            $margSup = 2;
191
            $margEsq = 2;
192
            $margDir = 2;
193
            // posição inicial do relatorio
194
            $xInic = 1;
195
            $yInic = 1;
196
            if ($this->papel == 'A4') { //A4 210x297mm
197
                $maxW = 210;
198
                $maxH = 297;
199
            }
200
        } else {
201
            // margens do PDF
202
            $margSup = 3;
203
            $margEsq = 3;
204
            $margDir = 3;
205
            // posição inicial do relatorio
206
            $xInic = 5;
207
            $yInic = 5;
208
            if ($papel == 'A4') {
209
                //A4 210x297mm
210
                $maxH = 210;
211
                $maxW = 297;
212
            }
213
        }
214
        //largura imprimivel em mm
215
        $this->wPrint = $maxW - ($margEsq + $xInic);
216
        //comprimento imprimivel em mm
217
        $this->hPrint = $maxH - ($margSup + $yInic);
218
        // estabelece contagem de paginas
219
        $this->pdf->aliasNbPages();
220
        // fixa as margens
221
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
222
        $this->pdf->setDrawColor(0, 0, 0);
223
        $this->pdf->setFillColor(255, 255, 255);
224
        // inicia o documento
225
        $this->pdf->open();
226
        // adiciona a primeira página
227
        $this->pdf->addPage($this->orientacao, $this->papel);
228
        $this->pdf->setLineWidth(0.1);
229
        $this->pdf->setTextColor(0, 0, 0);
230
        //montagem da página
231
        $pag = 1;
232
        $x = $xInic;
233
        $y = $yInic;
234
        //coloca o cabeçalho
235
        $y = $this->header($x, $y, $pag, $situacao_externa);
236
        //coloca os dados da CCe
237
        $y = $this->body($x, $y + 15);
238
        //coloca os dados da CCe
239
        $y = $this->footer($x, $y + $this->hPrint - 20);
240
        //retorna o ID do evento
241
        return $this->id;
242
    }
243
244
    /**
245
     * header
246
     * @param integer $x
247
     * @param integer $y
248
     * @param integer $pag
249
     * @return integer
250
     */
251
    private function header(
252
        $x,
253
        $y,
254
        $pag
255
    )
256
    {
257
        $oldX = $x;
258
        $oldY = $y;
259
        $maxW = $this->wPrint;
260
        //####################################################################################
261
        //coluna esquerda identificação do emitente
262
        $w = round($maxW * 0.41, 0);// 80;
263
        if ($this->orientacao == 'P') {
264
            $aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I');
265
        } else {
266
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
267
        }
268
        $w1 = $w;
269
        $h = 32;
270
        $oldY += $h;
271
        $this->pdf->textBox($x, $y, $w, $h);
272
        $texto = 'IDENTIFICAÇÃO DO EMITENTE';
273
        $this->pdf->textBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, '');
274
        if (!empty($this->logomarca)) {
275
            $logoInfo = getimagesize($this->logomarca);
276
            //largura da imagem em mm
277
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
278
            //altura da imagem em mm
279
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
280
            if ($this->logoAlign == 'L') {
281
                $nImgW = round($w / 3, 0);
282
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
283
                $xImg = $x + 1;
284
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
285
                //estabelecer posições do texto
286
                $x1 = round($xImg + $nImgW + 1, 0);
287
                $y1 = round($h / 3 + $y, 0);
288
                $tw = round(2 * $w / 3, 0);
289
            }
290
            if ($this->logoAlign == 'C') {
291
                $nImgH = round($h / 3, 0);
292
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
293
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
294
                $yImg = $y + 3;
295
                $x1 = $x;
296
                $y1 = round($yImg + $nImgH + 1, 0);
297
                $tw = $w;
298
            }
299
            if ($this->logoAlign == 'R') {
300
                $nImgW = round($w / 3, 0);
301
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
302
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
303
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
304
                $x1 = $x;
305
                $y1 = round($h / 3 + $y, 0);
306
                $tw = round(2 * $w / 3, 0);
307
            }
308
            $this->pdf->image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
309
        } else {
310
            $x1 = $x;
311
            $y1 = round($h / 3 + $y, 0);
312
            $tw = $w;
313
        }
314
        //Nome emitente
315
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B');
316
        $texto = (isset($this->dadosEmitente['razao']) ? $this->dadosEmitente['razao'] : '');
317
        $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
318
        //endereço
319
        $y1 = $y1 + 6;
320
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
321
        $lgr = (isset($this->dadosEmitente['logradouro']) ? $this->dadosEmitente['logradouro'] : '');
322
        $nro = (isset($this->dadosEmitente['numero']) ? $this->dadosEmitente['numero'] : '');
323
        $cpl = (isset($this->dadosEmitente['complemento']) ? $this->dadosEmitente['complemento'] : '');
324
        $bairro = (isset($this->dadosEmitente['bairro']) ? $this->dadosEmitente['bairro'] : '');
325
        $CEP = (isset($this->dadosEmitente['CEP']) ? $this->dadosEmitente['CEP'] : '');
326
        $CEP = $this->formatField($CEP, "#####-###");
327
        $mun = (isset($this->dadosEmitente['municipio']) ? $this->dadosEmitente['municipio'] : '');
328
        $UF = (isset($this->dadosEmitente['UF']) ? $this->dadosEmitente['UF'] : '');
329
        $fone = (isset($this->dadosEmitente['telefone']) ? $this->dadosEmitente['telefone'] : '');
330
        $email = (isset($this->dadosEmitente['email']) ? $this->dadosEmitente['email'] : '');
331
        $foneLen = strlen($fone);
332
        if ($foneLen > 0) {
333
            $fone2 = substr($fone, 0, $foneLen - 4);
334
            $fone1 = substr($fone, 0, $foneLen - 8);
335
            $fone = '(' . $fone1 . ') ' . substr($fone2, -4) . '-' . substr($fone, -4);
336
        } else {
337
            $fone = '';
338
        }
339
        if ($email != '') {
340
            $email = 'Email: ' . $email;
341
        }
342
        $texto = "";
343
        $tmp_txt = trim(($lgr != '' ? "$lgr, " : '') . ($nro != 0 ? $nro : "SN") . ($cpl != '' ? " - $cpl" : ''));
344
        $tmp_txt = ($tmp_txt == 'SN' ? '' : $tmp_txt);
345
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
346
        $tmp_txt = trim($bairro . ($bairro != '' && $CEP != '' ? " - " : '') . $CEP);
347
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
348
        $tmp_txt = $mun;
349
        $tmp_txt .= ($tmp_txt != '' && $UF != '' ? " - " : '') . $UF;
350
        $tmp_txt .= ($tmp_txt != '' && $fone != '' ? " - " : '') . $fone;
351
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
352
        $tmp_txt = $email;
353
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
354
        $this->pdf->textBox($x1, $y1 - 2, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
355
        //##################################################
356
        $w2 = round($maxW - $w, 0);
357
        $x += $w;
358
        $this->pdf->textBox($x, $y, $w2, $h);
359
        $y1 = $y + $h;
360
        $aFont = array('font' => $this->fontePadrao, 'size' => 16, 'style' => 'B');
361
        if ($this->tpEvento == '110110') {
362
            $texto = 'Representação Gráfica de CCe';
363
        } else {
364
            $texto = 'Representação Gráfica de Evento';
365
        }
366
        $this->pdf->textBox($x, $y + 2, $w2, 8, $texto, $aFont, 'T', 'C', 0, '');
367
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I');
368
        if ($this->tpEvento == '110110') {
369
            $texto = '(Carta de Correção Eletrônica)';
370
        } elseif ($this->tpEvento == '110111') {
371
            $texto = '(Cancelamento de CTe)';
372
        }
373
        $this->pdf->textBox($x, $y + 7, $w2, 8, $texto, $aFont, 'T', 'C', 0, '');
374
        $texto = 'ID do Evento: ' . $this->id;
375
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
376
        $this->pdf->textBox($x, $y + 15, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
377
        $tsHora = $this->toTimestamp($this->dhEvento);
378
        $texto = 'Criado em : ' . date('d/m/Y   H:i:s', $tsHora);
379
        $this->pdf->textBox($x, $y + 20, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
380
        $tsHora = $this->toTimestamp($this->dhRegEvento);
381
        $texto = 'Prococolo: ' . $this->nProt . '  -  Registrado na SEFAZ em: ' . date('d/m/Y   H:i:s', $tsHora);
382
        $this->pdf->textBox($x, $y + 25, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
383
        //####################################################
384
        $x = $oldX;
385
        $this->pdf->textBox($x, $y1, $maxW, 40);
386
        $sY = $y1 + 40;
387
        if ($this->tpEvento == '110110') {
388
            $texto = 'De acordo com as determinações legais vigentes, vimos por meio '
389
                . 'desta comunicar-lhe que o Conhecimento de Transporte, abaixo referenciado, '
390
                . 'contêm irregularidades que estão destacadas e suas respectivas '
391
                . 'correções, solicitamos que sejam aplicadas essas correções ao '
392
                . 'executar seus lançamentos fiscais.';
393
        } elseif ($this->tpEvento == '110111') {
394
            $texto = 'De acordo com as determinações legais vigentes, vimos por meio '
395
                . 'desta comunicar-lhe que o  Conhecimento de Transporte, abaixo referenciado, está '
396
                . 'cancelado, solicitamos que sejam aplicadas essas correções ao '
397
                . 'executar seus lançamentos fiscais.';
398
        }
399
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
400
        $this->pdf->textBox($x + 5, $y1, $maxW - 5, 20, $texto, $aFont, 'T', 'L', 0, '', false);
401
        //############################################
402
        $x = $oldX;
403
        $y = $y1;
404
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B');
405
        $numNF = substr($this->chCTe, 25, 9);
406
        $serie = substr($this->chCTe, 22, 3);
407
        $numNF = $this->formatField($numNF, "###.###.###");
408
        $texto = "Conhecimento: " . $numNF . '  -   Série: ' . $serie;
409
        $this->pdf->textBox($x + 2, $y + 19, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
410
        $bW = 87;
411
        $bH = 15;
412
        $x = 55;
413
        $y = $y1 + 13;
414
        $w = $maxW;
415
        $this->pdf->setFillColor(0, 0, 0);
416
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $this->chCTe, $bW, $bH);
417
        $this->pdf->setFillColor(255, 255, 255);
418
        $y1 = $y + 2 + $bH;
419
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
420
        $texto = $this->formatField($this->chCTe, $this->formatoChave);
421
        $this->pdf->textBox($x, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, '');
422
        $retVal = $sY + 2;
423
        if ($this->tpEvento == '110110') {
424
            $x = $oldX;
425
            $this->pdf->textBox($x, $sY, $maxW, 15);
426
            $texto = $this->xCondUso;
427
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I');
428
            $this->pdf->textBox($x + 2, $sY + 2, $maxW - 2, 15, $texto, $aFont, 'T', 'L', 0, '', false);
429
            $retVal = $sY + 2;
430
        }
431
        if ($this->tpAmb != 1) {
432
            $x = 10;
433
            if ($this->orientacao == 'P') {
434
                $y = round($this->hPrint * 2 / 3, 0);
435
            } else {
436
                $y = round($this->hPrint / 2, 0);
437
            }
438
            $h = 5;
439
            $w = $maxW - (2 * $x);
440
            $this->pdf->setTextColor(90, 90, 90);
441
            $texto = "SEM VALOR FISCAL";
442
            $aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B');
443
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
444
            $aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B');
445
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
446
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
447
            $this->pdf->setTextColor(0, 0, 0);
448
        }
449
        return $retVal;
450
    }
451
452
    /**
453
     * body
454
     * @param integer $x
455
     * @param integer $y
456
     */
457
    private function body($x, $y)
458
    {
459
        $maxW = $this->wPrint;
460
        if ($this->tpEvento == '110110') {
461
            $texto = 'CORREÇÕES A SEREM CONSIDERADAS';
462
        } else {
463
            $texto = 'JUSTIFICATIVA DO CANCELAMENTO';
464
        }
465
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
466
        $this->pdf->textBox($x, $y, $maxW, 5, $texto, $aFont, 'T', 'L', 0, '', false);
467
        $y += 5;
468
        $this->pdf->textBox($x, $y, $maxW, 190);
469
        if ($this->tpEvento == '110110') {
470
            $texto = $this->xCorrecao;
471
        } elseif ($this->tpEvento == '110111') {
472
            $texto = $this->xJust;
473
        }
474
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B');
475
        $this->pdf->textBox($x + 2, $y + 2, $maxW - 2, 150, $texto, $aFont, 'T', 'L', 0, '', false);
476
    }
477
478
    /**
479
     * footer
480
     * @param integer $x
481
     * @param integer $y
482
     */
483
    private function footer($x, $y)
484
    {
485
        $w = $this->wPrint;
486
        if ($this->tpEvento == '110110') {
487
            $texto = "Este documento é uma representação gráfica da CCe e foi "
488
                . "impresso apenas para sua informação e não possue validade fiscal."
489
                . "\n A CCe deve ser recebida e mantida em arquivo eletrônico XML e "
490
                . "pode ser consultada através dos Portais das SEFAZ.";
491
        } elseif ($this->tpEvento == '110111') {
492
            $texto = "Este documento é uma representação gráfica do evento de CTe e foi "
493
                . "impresso apenas para sua informação e não possue validade fiscal."
494
                . "\n O Evento deve ser recebido e mantido em arquivo eletrônico XML e "
495
                . "pode ser consultada através dos Portais das SEFAZ.";
496
        }
497
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'I');
498
        $this->pdf->textBox($x, $y, $w, 20, $texto, $aFont, 'T', 'C', 0, '', false);
499
        $y = $this->hPrint - 4;
500
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
501
        $w = $this->wPrint - 4;
502
        $aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I');
503
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
504
        $texto = $this->creditos . "  Powered by NFePHP®";
505
        $aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I');
506
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org');
507
    }
508
509
    /**
510
     * printDAEventoCTe
511
     * @param string $nome
512
     * @param string $destino
513
     * @param string $printer
514
     * @return type
515
     */
516
    public function printDAEventoCTe($nome = '', $destino = 'I', $printer = '')
517
    {
518
        $arq = $this->pdf->Output($nome, $destino);
519
        if ($destino == 'S') {
520
            //aqui pode entrar a rotina de impressão direta
521
        }
522
        return $arq;
523
    }
524
}
525