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

src/NFe/Daevento.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\NFe;
4
5
/**
6
 * Esta classe gera a representação em PDF de um evento de NFe
7
 * NOTA: Esse documento NÃO É 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 $chNFe;
26
    
27
    protected $logoAlign = 'C';
28
    protected $yDados = 0;
29
    protected $debugmode = false;
30
    protected $aEnd = 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.4';
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 $procEventoNFe;
63
    private $evento;
64
    private $infEvento;
65
    private $retEvento;
66
    private $rinfEvento;
67
68
    /**
69
     * __construct
70
     *
71
     * @param string $docXML      Arquivo XML (diretório ou string)
72
     * @param string $sOrientacao (Opcional) Orientação da impressão P-retrato L-Paisagem
73
     * @param string $sPapel      Tamanho do papel (Ex. A4)
74
     * @param string $sPathLogo   Caminho para o arquivo do logo
75
     * @param string $sDestino    Destino do PDF I-browser D-download S-string F-salva
76
     * @param string $sDirPDF     Caminho para o diretorio de armazenamento dos arquivos PDF
77
     * @param string $fonteDANFE  Nome da fonte alternativa
78
     * @param array  $aEnd        array com o endereço do emitente
79
     * @param number $mododebug   0-Não 1-Sim e 2-nada (2 default)
80
     */
81
    public function __construct($xml, $dadosEmitente)
82
    {
83
        $this->dadosEmitente = $dadosEmitente;
84
        $this->debugMode();
85
        $this->loadDoc($xml);
86
    }
87
    
88
    /**
89
     * Ativa ou desativa o modo debug
90
     * @param bool $activate
91
     * @return bool
92
     */
93
    public function debugMode($activate = null)
94
    {
95
        if (isset($activate) && is_bool($activate)) {
96
            $this->debugmode = $activate;
97
        }
98
        if ($this->debugmode) {
99
            //ativar modo debug
100
            error_reporting(E_ALL);
101
            ini_set('display_errors', 'On');
102
        } else {
103
            //desativar modo debug
104
            error_reporting(0);
105
            ini_set('display_errors', 'Off');
106
        }
107
        return $this->debugmode;
108
    }
109
    
110
    /**
111
     * Add the credits to the integrator in the footer message
112
     * @param string $message
113
     */
114
    public function creditsIntegratorFooter($message = '')
115
    {
116
        $this->creditos = trim($message);
117
    }
118
    
119
    /**
120
     * Dados brutos do PDF
121
     * @return string
122
     */
123
    public function render()
124
    {
125
        if (empty($this->pdf)) {
126
            $this->monta();
127
        }
128
        return $this->pdf->getPdf();
129
    }
130
    
131
    protected function loadDoc($xml)
132
    {
133
        $this->dom = new Dom();
134
        $this->dom->loadXML($xml);
135
        $this->procEventoNFe = $this->dom->getElementsByTagName("procEventoNFe")->item(0);
136
        $this->evento = $this->dom->getElementsByTagName("evento")->item(0);
137
        $this->infEvento = $this->evento->getElementsByTagName("infEvento")->item(0);
138
        $this->retEvento = $this->dom->getElementsByTagName("retEvento")->item(0);
139
        $this->rinfEvento = $this->retEvento->getElementsByTagName("infEvento")->item(0);
140
        $this->tpEvento = $this->infEvento->getElementsByTagName("tpEvento")->item(0)->nodeValue;
141
        if (!in_array($this->tpEvento, ['110110','110111'])) {
142
            $this->errMsg = 'Evento não implementado ' . $tpEvento . ' !!';
143
            $this->errStatus = true;
144
            return false;
145
        }
146
        $this->id = str_replace('ID', '', $this->infEvento->getAttribute("Id"));
147
        $this->chNFe = $this->infEvento->getElementsByTagName("chNFe")->item(0)->nodeValue;
148
        $this->dadosEmitente['CNPJ'] = $this->infEvento->getElementsByTagName("CNPJ")->item(0)->nodeValue;
149
        $this->tpAmb = $this->infEvento->getElementsByTagName("tpAmb")->item(0)->nodeValue;
150
        $this->cOrgao = $this->infEvento->getElementsByTagName("cOrgao")->item(0)->nodeValue;
151
        $this->xCorrecao = $this->infEvento->getElementsByTagName("xCorrecao")->item(0);
152
        $this->xCorrecao = (empty($this->xCorrecao) ? '' : $this->xCorrecao->nodeValue);
153
        $this->xCondUso = $this->infEvento->getElementsByTagName("xCondUso")->item(0);
154
        $this->xCondUso = (empty($this->xCondUso) ? '' : $this->xCondUso->nodeValue);
155
        $this->xJust = $this->infEvento->getElementsByTagName("xJust")->item(0);
156
        $this->xJust = (empty($this->xJust) ? '' : $this->xJust->nodeValue);
157
        $this->dhEvento = $this->infEvento->getElementsByTagName("dhEvento")->item(0)->nodeValue;
158
        $this->cStat = $this->rinfEvento->getElementsByTagName("cStat")->item(0)->nodeValue;
159
        $this->xMotivo = $this->rinfEvento->getElementsByTagName("xMotivo")->item(0)->nodeValue;
160
        $this->CNPJDest = !empty($this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue) ?
161
            $this->rinfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue :
162
            '';
163
        $this->CPFDest = !empty($this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue) ?
164
            $this->rinfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue :
165
            '';
166
        $this->dhRegEvento = $this->rinfEvento->getElementsByTagName("dhRegEvento")->item(0)->nodeValue;
167
        $this->nProt = $this->rinfEvento->getElementsByTagName("nProt")->item(0)->nodeValue;
168
    }
169
170
    /**
171
     * monta
172
     *
173
     * Esta função monta a DaEventoNFe conforme as informações fornecidas para a classe
174
     * durante sua construção.
175
     * A definição de margens e posições iniciais para a impressão são estabelecidas no
176
     * pelo conteúdo da funçao e podem ser modificados.
177
     *
178
     * @param  string $orientacao (Opcional) Estabelece a orientação da impressão (ex. P-retrato),
179
     *  se nada for fornecido será usado o padrão da NFe
180
     * @param  string $papel      (Opcional) Estabelece o tamanho do papel (ex. A4)
181
     * @return string O ID do evento extraido do arquivo XML
182
     */
183
    public function monta(
184
        $logo = null,
185
        $orientacao = 'P',
186
        $papel = 'A4',
187
        $logoAlign = 'C'
188
    ) {
189
        $this->logomarca = $logo;
190
        $this->fontePadrao = 'Times';
191
        $this->orientacao = $orientacao;
192
        $this->papel = $papel;
193
        $this->logoAlign = $logoAlign;
194
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
195
        if ($this->orientacao == 'P') {
196
            // margens do PDF
197
            $margSup = 2;
198
            $margEsq = 2;
199
            $margDir = 2;
200
            // posição inicial do relatorio
201
            $xInic = 1;
202
            $yInic = 1;
203
            if ($this->papel == 'A4') { // A4 210x297mm
204
                $maxW = 210;
205
                $maxH = 297;
206
            }
207
        } else {
208
            // margens do PDF
209
            $margSup = 3;
210
            $margEsq = 3;
211
            $margDir = 3;
212
            // posição inicial do relatorio
213
            $xInic = 5;
214
            $yInic = 5;
215
            if ($papel == 'A4') { // A4 210x297mm
216
                $maxH = 210;
217
                $maxW = 297;
218
            }
219
        }
220
        // largura imprimivel em mm
221
        $this->wPrint = $maxW - ($margEsq + $xInic);
222
        // comprimento imprimivel em mm
223
        $this->hPrint = $maxH - ($margSup + $yInic);
224
        // estabelece contagem de paginas
225
        $this->pdf->aliasNbPages();
226
        // fixa as margens
227
        $this->pdf->setMargins($margEsq, $margSup, $margDir);
228
        $this->pdf->setDrawColor(0, 0, 0);
229
        $this->pdf->setFillColor(255, 255, 255);
230
        // inicia o documento
231
        $this->pdf->open();
232
        // adiciona a primeira página
233
        $this->pdf->addPage($this->orientacao, $this->papel);
234
        $this->pdf->setLineWidth(0.1);
235
        $this->pdf->setTextColor(0, 0, 0);
236
        // montagem da página
237
        $pag = 1;
238
        $x = $xInic;
239
        $y = $yInic;
240
        // coloca o cabeçalho
241
        $y = $this->header($x, $y, $pag);
242
        // coloca os dados da CCe
243
        $y = $this->body($x, $y + 15);
244
        // coloca os dados da CCe
245
        $y = $this->footer($x, $y + $this->hPrint - 20);
246
    }
247
248
    /**
249
     * header
250
     * @param  number $x
251
     * @param  number $y
252
     * @param  number $pag
253
     * @return number
254
     */
255
    private function header($x, $y, $pag)
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 = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I'];
265
        } else {
266
            $aFont = ['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 (is_file($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(
316
            'font' => $this->fontePadrao,
317
            'size' => 12,
318
            'style' => 'B'
319
        );
320
        $texto = (isset($this->dadosEmitente['razao']) ? $this->dadosEmitente['razao'] : '');
321
        $this->pdf->textBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
322
        // endereço
323
        $y1 = $y1 + 6;
324
        $aFont = array(
325
            'font' => $this->fontePadrao,
326
            'size' => 8,
327
            'style' => ''
328
        );
329
        $lgr = (isset($this->dadosEmitente['logradouro']) ? $this->dadosEmitente['logradouro'] : '');
330
        $nro = (isset($this->dadosEmitente['numero']) ? $this->dadosEmitente['numero'] : '');
331
        $cpl = (isset($this->dadosEmitente['complemento']) ? $this->dadosEmitente['complemento'] : '');
332
        $bairro = (isset($this->dadosEmitente['bairro']) ? $this->dadosEmitente['bairro'] : '');
333
        $CEP = (isset($this->dadosEmitente['CEP']) ? $this->dadosEmitente['CEP'] : '');
334
        $CEP = $this->formatField($CEP, "#####-###");
335
        $mun = (isset($this->dadosEmitente['municipio']) ? $this->dadosEmitente['municipio'] : '');
336
        $UF = (isset($this->dadosEmitente['UF']) ? $this->dadosEmitente['UF'] : '');
337
        $fone = (isset($this->dadosEmitente['telefone']) ? $this->dadosEmitente['telefone'] : '');
338
        $email = (isset($this->dadosEmitente['email']) ? $this->dadosEmitente['email'] : '');
339
        $foneLen = strlen($fone);
340
        if ($foneLen > 0) {
341
            $fone2 = substr($fone, 0, $foneLen - 4);
342
            $fone1 = substr($fone, 0, $foneLen - 8);
343
            $fone = '(' . $fone1 . ') ' . substr($fone2, - 4) . '-' . substr($fone, - 4);
344
        } else {
345
            $fone = '';
346
        }
347
        if ($email != '') {
348
            $email = 'Email: ' . $email;
349
        }
350
        $texto = "";
351
        $tmp_txt = trim(($lgr != '' ? "$lgr, " : '') . ($nro != 0 ? $nro : "SN") . ($cpl != '' ? " - $cpl" : ''));
352
        $tmp_txt = ($tmp_txt == 'SN' ? '' : $tmp_txt);
353
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
354
        $tmp_txt = trim($bairro . ($bairro != '' && $CEP != '' ? " - " : '') . $CEP);
355
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
356
        $tmp_txt = $mun;
357
        $tmp_txt .= ($tmp_txt != '' && $UF != '' ? " - " : '') . $UF;
358
        $tmp_txt .= ($tmp_txt != '' && $fone != '' ? " " : '') . $fone;
359
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
360
        $tmp_txt = $email;
361
        $texto .= ($texto != '' && $tmp_txt != '' ? "\n" : '') . $tmp_txt;
362
        $this->pdf->textBox($x1, $y1 - 2, $tw, 8, $texto, $aFont, 'T', 'C', 0, '');
363
        // ##################################################
364
        $w2 = round($maxW - $w, 0);
365
        $x += $w;
366
        $this->pdf->textBox($x, $y, $w2, $h);
367
        $y1 = $y + $h;
368
        $aFont = array(
369
            'font' => $this->fontePadrao,
370
            'size' => 16,
371
            'style' => 'B'
372
        );
373
        if ($this->tpEvento == '110110') {
374
            $texto = 'Representação Gráfica de CC-e';
375
        } else {
376
            $texto = 'Representação Gráfica de Evento';
377
        }
378
        $this->pdf->textBox($x, $y + 2, $w2, 8, $texto, $aFont, 'T', 'C', 0, '');
379
        $aFont = array(
380
            'font' => $this->fontePadrao,
381
            'size' => 12,
382
            'style' => 'I'
383
        );
384
        if ($this->tpEvento == '110110') {
385
            $texto = '(Carta de Correção Eletrônica)';
386
        } elseif ($this->tpEvento == '110111') {
387
            $texto = '(Cancelamento de NFe)';
388
        }
389
        $this->pdf->textBox($x, $y + 7, $w2, 8, $texto, $aFont, 'T', 'C', 0, '');
390
        $texto = 'ID do Evento: ' . $this->id;
391
        $aFont = array(
392
            'font' => $this->fontePadrao,
393
            'size' => 10,
394
            'style' => ''
395
        );
396
        $this->pdf->textBox($x, $y + 15, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
397
        $tsHora = $this->convertTime($this->dhEvento);
0 ignored issues
show
The method convertTime() does not seem to exist on object<NFePHP\DA\NFe\Daevento>.

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...
398
        $texto = 'Criado em : ' . date('d/m/Y   H:i:s', $tsHora);
399
        $this->pdf->textBox($x, $y + 20, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
400
        $tsHora = $this->convertTime($this->dhRegEvento);
0 ignored issues
show
The method convertTime() does not seem to exist on object<NFePHP\DA\NFe\Daevento>.

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...
401
        $texto = 'Prococolo: ' . $this->nProt . '  -  Registrado na SEFAZ em: ' . date('d/m/Y   H:i:s', $tsHora);
402
        $this->pdf->textBox($x, $y + 25, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
403
        // ####################################################
404
        $x = $oldX;
405
        $this->pdf->textBox($x, $y1, $maxW, 40);
406
        $sY = $y1 + 40;
407
        if ($this->tpEvento == '110110') {
408
            $texto = 'De acordo com as determinações legais vigentes, vimos por meio desta '
409
                . 'comunicar-lhe que a Nota Fiscal, abaixo referenciada, contém irregularidades'
410
                . ' que estão destacadas e suas respectivas correções, solicitamos que sejam aplicadas '
411
                . 'essas correções ao executar seus lançamentos fiscais.';
412
        } elseif ($this->tpEvento == '110111') {
413
            $texto = 'De acordo com as determinações legais vigentes, '
414
                    . 'vimos por meio desta comunicar-lhe que a Nota Fiscal, '
415
                    . 'abaixo referenciada, está cancelada, solicitamos que sejam '
416
                    . 'aplicadas essas correções ao executar seus lançamentos fiscais.';
417
        }
418
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => ''];
419
        $this->pdf->textBox($x + 5, $y1, $maxW - 5, 20, $texto, $aFont, 'T', 'L', 0, '', false);
420
        // ############################################
421
        $x = $oldX;
422
        $y = $y1;
423
        if ($this->CNPJDest != '') {
424
            $texto = 'CNPJ do Destinatário: ' . $this->formatField($this->CNPJDest, "##.###.###/####-##");
425
        }
426
        if ($this->CPFDest != '') {
427
            $texto = 'CPF do Destinatário: ' . $this->formatField($this->CPFDest, "###.###.###-##");
428
        }
429
        $aFont = ['font' => $this->fontePadrao,'size' => 12,'style' => 'B'];
430
        $this->pdf->textBox($x + 2, $y + 13, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
431
        $numNF = substr($this->chNFe, 25, 9);
432
        $serie = substr($this->chNFe, 22, 3);
433
        $numNF = $this->formatField($numNF, "###.###.###");
434
        $texto = "Nota Fiscal: " . $numNF . '  -   Série: ' . $serie;
435
        $this->pdf->textBox($x + 2, $y + 19, $w2, 8, $texto, $aFont, 'T', 'L', 0, '');
436
        $bW = 87;
437
        $bH = 15;
438
        $x = 55;
439
        $y = $y1 + 13;
440
        $w = $maxW;
441
        $this->pdf->setFillColor(0, 0, 0);
442
        $this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $this->chNFe, $bW, $bH);
443
        $this->pdf->setFillColor(255, 255, 255);
444
        $y1 = $y + 2 + $bH;
445
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => ''];
446
        $texto = $this->formatField($this->chNFe, $this->formatoChave);
447
        $this->pdf->textBox($x, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, '');
448
        $retVal = $sY + 2;
449
        if ($this->tpEvento == '110110') {
450
            $x = $oldX;
451
            $this->pdf->textBox($x, $sY, $maxW, 15);
452
            $texto = $this->xCondUso;
453
            $aFont = ['font' => $this->fontePadrao,'size' => 8,'style' => 'I'];
454
            $this->pdf->textBox($x + 2, $sY + 2, $maxW - 2, 15, $texto, $aFont, 'T', 'L', 0, '', false);
455
            $retVal = $sY + 2;
456
        }
457
        // indicar sem valor
458
        if ($this->tpAmb != 1) {
459
            $x = 10;
460
            if ($this->orientacao == 'P') {
461
                $y = round($this->hPrint * 2 / 3, 0);
462
            } else {
463
                $y = round($this->hPrint / 2, 0);
464
            }
465
            $h = 5;
466
            $w = $maxW - (2 * $x);
467
            $this->pdf->setTextColor(90, 90, 90);
468
            $texto = "SEM VALOR FISCAL";
469
            $aFont = ['font' => $this->fontePadrao,'size' => 48,'style' => 'B'];
470
            $this->pdf->textBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
471
            $aFont = ['font' => $this->fontePadrao,'size' => 30,'style' => 'B'];
472
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
473
            $this->pdf->textBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
474
            $this->pdf->setTextColor(0, 0, 0);
475
        }
476
        return $retVal;
477
    }
478
479
    /**
480
     * body
481
     *
482
     * @param number $x
483
     * @param number $y
484
     */
485
    private function body($x, $y)
486
    {
487
        $maxW = $this->wPrint;
488
        if ($this->tpEvento == '110110') {
489
            $texto = 'CORREÇÕES A SEREM CONSIDERADAS';
490
        } else {
491
            $texto = 'JUSTIFICATIVA DO CANCELAMENTO';
492
        }
493
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => 'B'];
494
        $this->pdf->textBox($x, $y, $maxW, 5, $texto, $aFont, 'T', 'L', 0, '', false);
495
        $y += 5;
496
        $this->pdf->textBox($x, $y, $maxW, 190);
497
        if ($this->tpEvento == '110110') {
498
            $texto = $this->xCorrecao;
499
        } elseif ($this->tpEvento == '110111') {
500
            $texto = $this->xJust;
501
        }
502
        $aFont = ['font' => $this->fontePadrao,'size' => 12,'style' => 'B'];
503
        $this->pdf->textBox($x + 2, $y + 2, $maxW - 2, 150, $texto, $aFont, 'T', 'L', 0, '', false);
504
    }
505
506
    /**
507
     * footer
508
     *
509
     * @param number $x
510
     * @param number $y
511
     */
512
    private function footer($x, $y)
513
    {
514
        $w = $this->wPrint;
515
        if ($this->tpEvento == '110110') {
516
            $texto = "Este documento é uma representação gráfica da CC-e "
517
                    . "e foi impresso apenas para sua informação e não possui validade "
518
                    . "fiscal.\n A CC-e deve ser recebida e mantida em arquivo eletrônico XML "
519
                    . "e pode ser consultada através dos Portais das SEFAZ.";
520
        } elseif ($this->tpEvento == '110111') {
521
            $texto = "Este documento é uma representação gráfica do evento de NFe e "
522
                    . "foi impresso apenas para sua informação e não possui validade "
523
                    . "fiscal.\n O Evento deve ser recebido e mantido em arquivo "
524
                    . "eletrônico XML e pode ser consultada através dos Portais "
525
                    . "das SEFAZ.";
526
        }
527
        $aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => 'I'];
528
        $this->pdf->textBox($x, $y, $w, 20, $texto, $aFont, 'T', 'C', 0, '', false);
529
        $y = $this->hPrint - 4;
530
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
531
        $w = $this->wPrint - 4;
532
        $aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I'];
533
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
534
        $texto = "Daevento ver. " . $this->version . "  Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org";
535
        $aFont = ['font' => $this->fontePadrao,'size' => 6,'style' => 'I'];
536
        $this->pdf->textBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org');
537
    }
538
}
539