|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\DA\NFe; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Esta classe gera a carta de correção em PDF |
|
7
|
|
|
* NOTA: Esse documento NÃO É NORMALIZADO, nem requerido pela SEFAZ |
|
8
|
|
|
* |
|
9
|
|
|
* @category Library |
|
10
|
|
|
* @package nfephp-org/sped-da |
|
11
|
|
|
* @name Dacce.php |
|
12
|
|
|
* @copyright 2009-2016 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 Dacce extends Common |
|
24
|
|
|
{ |
|
25
|
|
|
public $chNFe; |
|
26
|
|
|
|
|
27
|
|
|
protected $logoAlign = 'C'; |
|
28
|
|
|
protected $yDados = 0; |
|
29
|
|
|
protected $debugMode = 0; |
|
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.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 $CNPJDest = ''; |
|
55
|
|
|
protected $CPFDest = ''; |
|
56
|
|
|
protected $dhRegEvento; |
|
57
|
|
|
protected $nProt; |
|
58
|
|
|
|
|
59
|
|
|
private $dom; |
|
60
|
|
|
private $procEventoNFe; |
|
61
|
|
|
private $evento; |
|
62
|
|
|
private $infEvento; |
|
63
|
|
|
private $retEvento; |
|
64
|
|
|
private $retInfEvento; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Construtor recebe parametro pra impressao |
|
68
|
|
|
* @param string $docXML conteudo do Arquivo XML |
|
69
|
|
|
* @param string $sOrientacao (Opcional) Orientação da impressão P-retrato L-Paisagem |
|
70
|
|
|
* @param string $sPapel Tamanho do papel (Ex. A4) |
|
71
|
|
|
* @param string $sPathLogo Caminho para o arquivo do logo |
|
72
|
|
|
* @param string $sDestino Destino do PDF I-browser D-download S-string F-salva |
|
73
|
|
|
* @param array $aEnd array com o endereço do emitente |
|
74
|
|
|
* @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF |
|
75
|
|
|
* @param string $fonteDANFE Nome da fonte alternativa do DAnfe |
|
|
|
|
|
|
76
|
|
|
* @param number $mododebug 0-Não 1-Sim e 2-nada (2 default) |
|
77
|
|
|
*/ |
|
78
|
|
|
public function __construct( |
|
79
|
|
|
$docXML = '', |
|
80
|
|
|
$sOrientacao = '', |
|
81
|
|
|
$sPapel = '', |
|
82
|
|
|
$sPathLogo = '', |
|
83
|
|
|
$sDestino = 'I', |
|
84
|
|
|
$aEnd = '', |
|
85
|
|
|
$sDirPDF = '', |
|
86
|
|
|
$fontePDF = '', |
|
87
|
|
|
$mododebug = 0 |
|
88
|
|
|
) { |
|
89
|
|
|
if (is_numeric($mododebug)) { |
|
90
|
|
|
$this->debugMode = (int) $mododebug; |
|
91
|
|
|
} |
|
92
|
|
|
if ($this->debugMode === 1) { |
|
93
|
|
|
// ativar modo debug |
|
94
|
|
|
error_reporting(E_ALL); |
|
95
|
|
|
ini_set('display_errors', 'On'); |
|
96
|
|
|
} elseif ($this->debugMode === 0) { |
|
97
|
|
|
// desativar modo debug |
|
98
|
|
|
error_reporting(0); |
|
99
|
|
|
ini_set('display_errors', 'Off'); |
|
100
|
|
|
} |
|
101
|
|
|
if (is_array($aEnd)) { |
|
102
|
|
|
$this->aEnd = $aEnd; |
|
103
|
|
|
} |
|
104
|
|
|
$this->orientacao = $sOrientacao; |
|
105
|
|
|
$this->papel = $sPapel; |
|
106
|
|
|
$this->pdf = ''; |
|
107
|
|
|
$this->xml = $docXML; |
|
108
|
|
|
$this->logomarca = $sPathLogo; |
|
109
|
|
|
$this->destino = $sDestino; |
|
110
|
|
|
$this->pdfDir = $sDirPDF; |
|
111
|
|
|
// verifica se foi passa a fonte a ser usada |
|
112
|
|
|
if (empty($fontePDF)) { |
|
113
|
|
|
$this->fontePadrao = 'Times'; |
|
114
|
|
|
} else { |
|
115
|
|
|
$this->fontePadrao = $fontePDF; |
|
116
|
|
|
} |
|
117
|
|
|
// se for passado o xml |
|
118
|
|
|
if (!empty($this->xml)) { |
|
119
|
|
|
$this->dom = new Dom(); |
|
120
|
|
|
$this->dom->loadXML($this->xml); |
|
121
|
|
|
$this->procEventoNFe = $this->dom->getElementsByTagName("procEventoNFe")->item(0); |
|
122
|
|
|
$this->evento = $this->procEventoNFe->getElementsByTagName("evento")->item(0); |
|
123
|
|
|
$this->retEvento = $this->procEventoNFe->getElementsByTagName("retEvento")->item(0); |
|
124
|
|
|
$this->infEvento = $this->evento->getElementsByTagName("infEvento")->item(0); |
|
125
|
|
|
$this->retInfEvento = $this->retEvento->getElementsByTagName("infEvento")->item(0); |
|
126
|
|
|
$tpEvento = $this->infEvento->getElementsByTagName("tpEvento")->item(0)->nodeValue; |
|
127
|
|
|
if ($tpEvento != '110110') { |
|
128
|
|
|
$this->errMsg = 'Um evento de CC-e deve ser passado.'; |
|
129
|
|
|
$this->errStatus = true; |
|
130
|
|
|
throw new Exception($this->errMsg); |
|
131
|
|
|
} |
|
132
|
|
|
$this->id = str_replace('ID', '', $this->infEvento->getAttribute("Id")); |
|
133
|
|
|
$this->chNFe = $this->infEvento->getElementsByTagName("chNFe")->item(0)->nodeValue; |
|
134
|
|
|
$this->tpAmb = $this->infEvento->getElementsByTagName("tpAmb")->item(0)->nodeValue; |
|
135
|
|
|
$this->cOrgao = $this->infEvento->getElementsByTagName("cOrgao")->item(0)->nodeValue; |
|
136
|
|
|
$this->xCorrecao = $this->infEvento->getElementsByTagName("xCorrecao")->item(0)->nodeValue; |
|
137
|
|
|
$this->xCondUso = $this->infEvento->getElementsByTagName("xCondUso")->item(0)->nodeValue; |
|
138
|
|
|
$this->dhEvento = $this->infEvento->getElementsByTagName("dhEvento")->item(0)->nodeValue; |
|
139
|
|
|
$this->cStat = $this->retInfEvento->getElementsByTagName("cStat")->item(0)->nodeValue; |
|
140
|
|
|
$this->xMotivo = $this->retInfEvento->getElementsByTagName("xMotivo")->item(0)->nodeValue; |
|
141
|
|
|
$this->CNPJDest = !empty($this->retInfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue) |
|
142
|
|
|
? $this->retInfEvento->getElementsByTagName("CNPJDest")->item(0)->nodeValue |
|
143
|
|
|
: ''; |
|
144
|
|
|
$this->CPFDest = !empty($this->retInfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue) |
|
145
|
|
|
? $this->retInfEvento->getElementsByTagName("CPFDest")->item(0)->nodeValue |
|
146
|
|
|
: ''; |
|
147
|
|
|
$this->dhRegEvento = $this->retInfEvento->getElementsByTagName("dhRegEvento")->item(0)->nodeValue; |
|
148
|
|
|
$this->nProt = $this->retInfEvento->getElementsByTagName("nProt")->item(0)->nodeValue; |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Monta o pdf |
|
154
|
|
|
* @param string $orientacao |
|
155
|
|
|
* @param string $papel |
|
156
|
|
|
* @param string $logoAlign |
|
157
|
|
|
*/ |
|
158
|
|
|
public function monta($orientacao = '', $papel = 'A4', $logoAlign = 'C') |
|
159
|
|
|
{ |
|
160
|
|
|
$this->orientacao = $orientacao; |
|
161
|
|
|
$this->papel = $papel; |
|
162
|
|
|
$this->logoAlign = $logoAlign; |
|
163
|
|
|
$this->pBuildDACCE(); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* pBuildDACCE |
|
168
|
|
|
*/ |
|
169
|
|
|
private function pBuildDACCE() |
|
170
|
|
|
{ |
|
171
|
|
|
$this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
172
|
|
|
if ($this->orientacao == 'P') { |
|
173
|
|
|
// margens do PDF |
|
174
|
|
|
$margSup = 2; |
|
175
|
|
|
$margEsq = 2; |
|
176
|
|
|
$margDir = 2; |
|
177
|
|
|
// posição inicial do relatorio |
|
178
|
|
|
$xInic = 1; |
|
179
|
|
|
$yInic = 1; |
|
180
|
|
|
if ($this->papel == 'A4') { // A4 210x297mm |
|
181
|
|
|
$maxW = 210; |
|
182
|
|
|
$maxH = 297; |
|
183
|
|
|
} |
|
184
|
|
|
} else { |
|
185
|
|
|
// margens do PDF |
|
186
|
|
|
$margSup = 3; |
|
187
|
|
|
$margEsq = 3; |
|
188
|
|
|
$margDir = 3; |
|
189
|
|
|
// posição inicial do relatorio |
|
190
|
|
|
$xInic = 5; |
|
191
|
|
|
$yInic = 5; |
|
192
|
|
|
if ($papel == 'A4') { // A4 210x297mm |
|
|
|
|
|
|
193
|
|
|
$maxH = 210; |
|
194
|
|
|
$maxW = 297; |
|
195
|
|
|
} |
|
196
|
|
|
} // orientação |
|
197
|
|
|
|
|
198
|
|
|
// largura imprimivel em mm |
|
199
|
|
|
$this->wPrint = $maxW - ($margEsq + $xInic); |
|
|
|
|
|
|
200
|
|
|
// comprimento imprimivel em mm |
|
201
|
|
|
$this->hPrint = $maxH - ($margSup + $yInic); |
|
|
|
|
|
|
202
|
|
|
// estabelece contagem de paginas |
|
203
|
|
|
$this->pdf->aliasNbPages(); |
|
204
|
|
|
// fixa as margens |
|
205
|
|
|
$this->pdf->setMargins($margEsq, $margSup, $margDir); |
|
206
|
|
|
$this->pdf->setDrawColor(0, 0, 0); |
|
207
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
|
208
|
|
|
// inicia o documento |
|
209
|
|
|
$this->pdf->open(); |
|
210
|
|
|
// adiciona a primeira página |
|
211
|
|
|
$this->pdf->addPage($this->orientacao, $this->papel); |
|
212
|
|
|
$this->pdf->setLineWidth(0.1); |
|
213
|
|
|
$this->pdf->setTextColor(0, 0, 0); |
|
214
|
|
|
// montagem da página |
|
215
|
|
|
$pag = 1; |
|
216
|
|
|
$x = $xInic; |
|
217
|
|
|
$y = $yInic; |
|
218
|
|
|
// coloca o cabeçalho |
|
219
|
|
|
$y = $this->pHeader($x, $y, $pag); |
|
220
|
|
|
// coloca os dados da CCe |
|
221
|
|
|
$y = $this->pBody($x, $y + 15); |
|
|
|
|
|
|
222
|
|
|
// coloca os dados da CCe |
|
223
|
|
|
$y = $this->pFooter($x, $y + $this->hPrint - 20); |
|
|
|
|
|
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* Monta o cabeçalho |
|
228
|
|
|
* @param number $x |
|
229
|
|
|
* @param number $y |
|
230
|
|
|
* @param number $pag |
|
231
|
|
|
* @return number |
|
232
|
|
|
*/ |
|
233
|
|
|
private function pHeader($x, $y, $pag) |
|
|
|
|
|
|
234
|
|
|
{ |
|
235
|
|
|
$oldX = $x; |
|
236
|
|
|
$oldY = $y; |
|
237
|
|
|
$maxW = $this->wPrint; |
|
238
|
|
|
// #################################################################################### |
|
239
|
|
|
// coluna esquerda identificação do emitente |
|
240
|
|
|
$w = round($maxW * 0.41, 0); // 80; |
|
241
|
|
|
if ($this->orientacao == 'P') { |
|
242
|
|
|
$aFont = array( |
|
243
|
|
|
'font' => $this->fontePadrao, |
|
244
|
|
|
'size' => 6, |
|
245
|
|
|
'style' => 'I' |
|
246
|
|
|
); |
|
247
|
|
|
} else { |
|
248
|
|
|
$aFont = array( |
|
249
|
|
|
'font' => $this->fontePadrao, |
|
250
|
|
|
'size' => 8, |
|
251
|
|
|
'style' => 'B' |
|
252
|
|
|
); |
|
253
|
|
|
} |
|
254
|
|
|
$w1 = $w; |
|
|
|
|
|
|
255
|
|
|
$h = 32; |
|
256
|
|
|
$oldY += $h; |
|
257
|
|
|
$this->pTextBox($x, $y, $w, $h); |
|
258
|
|
|
$texto = 'IDENTIFICAÇÃO DO EMITENTE'; |
|
259
|
|
|
$this->pTextBox($x, $y, $w, 5, $texto, $aFont, 'T', 'C', 0, ''); |
|
260
|
|
|
if (is_file($this->logomarca)) { |
|
261
|
|
|
$logoInfo = getimagesize($this->logomarca); |
|
262
|
|
|
// largura da imagem em mm |
|
263
|
|
|
$logoWmm = ($logoInfo[0] / 72) * 25.4; |
|
264
|
|
|
// altura da imagem em mm |
|
265
|
|
|
$logoHmm = ($logoInfo[1] / 72) * 25.4; |
|
266
|
|
|
if ($this->logoAlign == 'L') { |
|
267
|
|
|
$nImgW = round($w / 3, 0); |
|
268
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
269
|
|
|
$xImg = $x + 1; |
|
270
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
271
|
|
|
// estabelecer posições do texto |
|
272
|
|
|
$x1 = round($xImg + $nImgW + 1, 0); |
|
273
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
274
|
|
|
$tw = round(2 * $w / 3, 0); |
|
275
|
|
|
} |
|
276
|
|
|
if ($this->logoAlign == 'C') { |
|
277
|
|
|
$nImgH = round($h / 3, 0); |
|
278
|
|
|
$nImgW = round($logoWmm * ($nImgH / $logoHmm), 0); |
|
279
|
|
|
$xImg = round(($w - $nImgW) / 2 + $x, 0); |
|
280
|
|
|
$yImg = $y + 3; |
|
281
|
|
|
$x1 = $x; |
|
282
|
|
|
$y1 = round($yImg + $nImgH + 1, 0); |
|
283
|
|
|
$tw = $w; |
|
284
|
|
|
} |
|
285
|
|
|
if ($this->logoAlign == 'R') { |
|
286
|
|
|
$nImgW = round($w / 3, 0); |
|
287
|
|
|
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0); |
|
288
|
|
|
$xImg = round($x + ($w - (1 + $nImgW)), 0); |
|
289
|
|
|
$yImg = round(($h - $nImgH) / 2, 0) + $y; |
|
290
|
|
|
$x1 = $x; |
|
291
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
292
|
|
|
$tw = round(2 * $w / 3, 0); |
|
293
|
|
|
} |
|
294
|
|
|
$this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH); |
|
|
|
|
|
|
295
|
|
|
} else { |
|
296
|
|
|
$x1 = $x; |
|
297
|
|
|
$y1 = round($h / 3 + $y, 0); |
|
298
|
|
|
$tw = $w; |
|
299
|
|
|
} |
|
300
|
|
|
// Nome emitente |
|
301
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 12,'style' => 'B']; |
|
302
|
|
|
$texto = $this->aEnd['razao']; |
|
303
|
|
|
$this->pTextBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
|
|
|
|
|
304
|
|
|
// endereço |
|
305
|
|
|
$y1 = $y1 + 6; |
|
306
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 8,'style' => '']; |
|
307
|
|
|
$lgr = $this->aEnd['logradouro']; |
|
308
|
|
|
$nro = $this->aEnd['numero']; |
|
309
|
|
|
$cpl = $this->aEnd['complemento']; |
|
310
|
|
|
$bairro = $this->aEnd['bairro']; |
|
311
|
|
|
$CEP = $this->aEnd['CEP']; |
|
312
|
|
|
$CEP = $this->pFormat($CEP, "#####-###"); |
|
313
|
|
|
$mun = $this->aEnd['municipio']; |
|
314
|
|
|
$UF = $this->aEnd['UF']; |
|
315
|
|
|
$fone = $this->aEnd['telefone']; |
|
316
|
|
|
$email = $this->aEnd['email']; |
|
317
|
|
|
$foneLen = strlen($fone); |
|
318
|
|
|
if ($foneLen > 0) { |
|
319
|
|
|
$fone2 = substr($fone, 0, $foneLen - 4); |
|
320
|
|
|
$fone1 = substr($fone, 0, $foneLen - 8); |
|
321
|
|
|
$fone = '(' . $fone1 . ') ' . substr($fone2, - 4) . '-' . substr($fone, - 4); |
|
322
|
|
|
} else { |
|
323
|
|
|
$fone = ''; |
|
324
|
|
|
} |
|
325
|
|
|
if ($email != '') { |
|
326
|
|
|
$email = 'Email: ' . $email; |
|
327
|
|
|
} |
|
328
|
|
|
$texto = $lgr . ", " . $nro . $cpl . "\n" . $bairro . " - " . $CEP . "\n" |
|
329
|
|
|
. $mun . " - " . $UF . " " . $fone . "\n" . $email; |
|
330
|
|
|
$this->pTextBox($x1, $y1 - 2, $tw, 8, $texto, $aFont, 'T', 'C', 0, ''); |
|
331
|
|
|
// ################################################## |
|
332
|
|
|
$w2 = round($maxW - $w, 0); |
|
333
|
|
|
$x += $w; |
|
334
|
|
|
$this->pTextBox($x, $y, $w2, $h); |
|
335
|
|
|
$y1 = $y + $h; |
|
336
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 16,'style' => 'B']; |
|
337
|
|
|
$this->pTextBox($x, $y + 2, $w2, 8, 'Representação Gráfica de CC-e', $aFont, 'T', 'C', 0, ''); |
|
338
|
|
|
$aFont = array( |
|
339
|
|
|
'font' => $this->fontePadrao, |
|
340
|
|
|
'size' => 12, |
|
341
|
|
|
'style' => 'I' |
|
342
|
|
|
); |
|
343
|
|
|
$this->pTextBox($x, $y + 7, $w2, 8, '(Carta de Correção Eletrônica)', $aFont, 'T', 'C', 0, ''); |
|
344
|
|
|
$texto = 'ID do Evento: ' . $this->id; |
|
345
|
|
|
$aFont = ['font' => $this->fontePadrao,'size' => 10,'style' => '']; |
|
346
|
|
|
$this->pTextBox($x, $y + 15, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
347
|
|
|
$tsHora = $this->pConvertTime($this->dhEvento); |
|
348
|
|
|
$texto = 'Criado em : ' . date('d/m/Y H:i:s', $tsHora); |
|
349
|
|
|
$this->pTextBox($x, $y + 20, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
350
|
|
|
$tsHora = $this->pConvertTime($this->dhRegEvento); |
|
351
|
|
|
$texto = 'Prococolo: ' . $this->nProt . ' - Registrado na SEFAZ em: ' . date('d/m/Y H:i:s', $tsHora); |
|
352
|
|
|
$this->pTextBox($x, $y + 25, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
353
|
|
|
// #################################################### |
|
354
|
|
|
$x = $oldX; |
|
355
|
|
|
$this->pTextBox($x, $y1, $maxW, 40); |
|
356
|
|
|
$sY = $y1 + 40; |
|
357
|
|
|
$texto = 'De acordo com as determinações legais vigentes, vimos por meio desta comunicar-lhe'. |
|
358
|
|
|
' que a Nota Fiscal, abaixo referenciada, contêm irregularidades que estão destacadas e' . |
|
359
|
|
|
' suas respectivas correções, solicitamos que sejam aplicadas essas correções ao executar'. |
|
360
|
|
|
' seus lançamentos fiscais.'; |
|
361
|
|
|
$aFont = array( |
|
362
|
|
|
'font' => $this->fontePadrao, |
|
363
|
|
|
'size' => 10, |
|
364
|
|
|
'style' => '' |
|
365
|
|
|
); |
|
366
|
|
|
$this->pTextBox($x + 5, $y1, $maxW - 5, 20, $texto, $aFont, 'T', 'L', 0, '', false); |
|
367
|
|
|
// ############################################ |
|
368
|
|
|
$x = $oldX; |
|
369
|
|
|
$y = $y1; |
|
370
|
|
|
$texto = ''; |
|
371
|
|
|
if ($this->CNPJDest != '') { |
|
372
|
|
|
$texto = 'CNPJ do Destinatário: ' . $this->pFormat($this->CNPJDest, "##.###.###/####-##"); |
|
373
|
|
|
} |
|
374
|
|
|
if ($this->CPFDest != '') { |
|
375
|
|
|
$texto = 'CPF do Destinatário: ' . $this->pFormat($this->CPFDest, "###.###.###-##"); |
|
376
|
|
|
} |
|
377
|
|
|
$aFont = array( |
|
378
|
|
|
'font' => $this->fontePadrao, |
|
379
|
|
|
'size' => 12, |
|
380
|
|
|
'style' => 'B' |
|
381
|
|
|
); |
|
382
|
|
|
$this->pTextBox($x + 2, $y + 13, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
383
|
|
|
$numNF = substr($this->chNFe, 25, 9); |
|
384
|
|
|
$serie = substr($this->chNFe, 22, 3); |
|
385
|
|
|
$numNF = $this->pFormat($numNF, "###.###.###"); |
|
386
|
|
|
$texto = "Nota Fiscal: " . $numNF . ' - Série: ' . $serie; |
|
387
|
|
|
$this->pTextBox($x + 2, $y + 19, $w2, 8, $texto, $aFont, 'T', 'L', 0, ''); |
|
388
|
|
|
$bW = 87; |
|
389
|
|
|
$bH = 15; |
|
390
|
|
|
$x = 55; |
|
391
|
|
|
$y = $y1 + 13; |
|
392
|
|
|
$w = $maxW; |
|
393
|
|
|
$this->pdf->setFillColor(0, 0, 0); |
|
394
|
|
|
$this->pdf->code128($x + (($w - $bW) / 2), $y + 2, $this->chNFe, $bW, $bH); |
|
395
|
|
|
$this->pdf->setFillColor(255, 255, 255); |
|
396
|
|
|
$y1 = $y + 2 + $bH; |
|
397
|
|
|
$aFont = array( |
|
398
|
|
|
'font' => $this->fontePadrao, |
|
399
|
|
|
'size' => 10, |
|
400
|
|
|
'style' => '' |
|
401
|
|
|
); |
|
402
|
|
|
$texto = $this->pFormat($this->chNFe, $this->formatoChave); |
|
403
|
|
|
$this->pTextBox($x, $y1, $w - 2, $h, $texto, $aFont, 'T', 'C', 0, ''); |
|
404
|
|
|
$x = $oldX; |
|
405
|
|
|
$this->pTextBox($x, $sY, $maxW, 15); |
|
406
|
|
|
$texto = $this->xCondUso; |
|
407
|
|
|
$aFont = array( |
|
408
|
|
|
'font' => $this->fontePadrao, |
|
409
|
|
|
'size' => 8, |
|
410
|
|
|
'style' => 'I' |
|
411
|
|
|
); |
|
412
|
|
|
$this->pTextBox($x + 2, $sY + 2, $maxW - 2, 15, $texto, $aFont, 'T', 'L', 0, '', false); |
|
413
|
|
|
return $sY + 2; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
/** |
|
417
|
|
|
* Monta o corpo da pagina |
|
418
|
|
|
* @param number $x |
|
419
|
|
|
* @param number $y |
|
420
|
|
|
*/ |
|
421
|
|
|
private function pBody($x, $y) |
|
422
|
|
|
{ |
|
423
|
|
|
$maxW = $this->wPrint; |
|
424
|
|
|
$texto = 'CORREÇÕES A SEREM CONSIDERADAS'; |
|
425
|
|
|
$aFont = array( |
|
426
|
|
|
'font' => $this->fontePadrao, |
|
427
|
|
|
'size' => 10, |
|
428
|
|
|
'style' => 'B' |
|
429
|
|
|
); |
|
430
|
|
|
$this->pTextBox($x, $y, $maxW, 5, $texto, $aFont, 'T', 'L', 0, '', false); |
|
431
|
|
|
$y += 5; |
|
432
|
|
|
$this->pTextBox($x, $y, $maxW, 190); |
|
433
|
|
|
$texto = str_replace(";", PHP_EOL, $this->xCorrecao); |
|
434
|
|
|
$aFont = array( |
|
435
|
|
|
'font' => $this->fontePadrao, |
|
436
|
|
|
'size' => 12, |
|
437
|
|
|
'style' => 'B' |
|
438
|
|
|
); |
|
439
|
|
|
$this->pTextBox($x + 2, $y + 2, $maxW - 2, 150, $texto, $aFont, 'T', 'L', 0, '', false); |
|
440
|
|
|
if ($this->tpAmb != 1) { |
|
441
|
|
|
$x = 10; |
|
442
|
|
|
if ($this->orientacao == 'P') { |
|
443
|
|
|
$y = round($this->hPrint * 2 / 3, 0); |
|
444
|
|
|
} else { |
|
445
|
|
|
$y = round($this->hPrint / 2, 0); |
|
446
|
|
|
} |
|
447
|
|
|
$h = 5; |
|
448
|
|
|
$w = $maxW - (2 * $x); |
|
449
|
|
|
$this->pdf->SetTextColor(90, 90, 90); |
|
450
|
|
|
$texto = "SEM VALOR FISCAL"; |
|
451
|
|
|
$aFont = array( |
|
452
|
|
|
'font' => $this->fontePadrao, |
|
453
|
|
|
'size' => 48, |
|
454
|
|
|
'style' => 'B' |
|
455
|
|
|
); |
|
456
|
|
|
$this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
457
|
|
|
$aFont = array( |
|
458
|
|
|
'font' => $this->fontePadrao, |
|
459
|
|
|
'size' => 30, |
|
460
|
|
|
'style' => 'B' |
|
461
|
|
|
); |
|
462
|
|
|
$texto = "AMBIENTE DE HOMOLOGAÇÃO"; |
|
463
|
|
|
$this->pTextBox($x, $y + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, ''); |
|
464
|
|
|
$this->pdf->SetTextColor(0, 0, 0); |
|
465
|
|
|
} |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
/** |
|
469
|
|
|
* Monta o rodapé |
|
470
|
|
|
* @param number $x |
|
471
|
|
|
* @param number $y |
|
472
|
|
|
*/ |
|
473
|
|
|
protected function pFooter($x, $y) |
|
474
|
|
|
{ |
|
475
|
|
|
$w = $this->wPrint; |
|
476
|
|
|
$texto = "Este documento é uma representação gráfica da CC-e e foi impresso apenas para sua" |
|
477
|
|
|
. " informação e não possue validade fiscal.\n A CC-e deve ser recebida e mantida em" |
|
478
|
|
|
. " arquivo eletrônico XML e pode ser consultada através dos Portais das SEFAZ."; |
|
479
|
|
|
$aFont = array( |
|
480
|
|
|
'font' => $this->fontePadrao, |
|
481
|
|
|
'size' => 10, |
|
482
|
|
|
'style' => 'I' |
|
483
|
|
|
); |
|
484
|
|
|
$this->pTextBox($x, $y, $w, 20, $texto, $aFont, 'T', 'C', 0, '', false); |
|
485
|
|
|
$y = $this->hPrint - 4; |
|
486
|
|
|
$texto = "Impresso em " . date('d/m/Y H:i:s'); |
|
487
|
|
|
$w = $this->wPrint - 4; |
|
488
|
|
|
$aFont = array( |
|
489
|
|
|
'font' => $this->fontePadrao, |
|
490
|
|
|
'size' => 6, |
|
491
|
|
|
'style' => 'I' |
|
492
|
|
|
); |
|
493
|
|
|
$this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, ''); |
|
494
|
|
|
$texto = "Dacce ver. " . $this->version . " Powered by NFePHP (GNU/GPLv3 GNU/LGPLv3) © www.nfephp.org"; |
|
495
|
|
|
$aFont = array( |
|
496
|
|
|
'font' => $this->fontePadrao, |
|
497
|
|
|
'size' => 6, |
|
498
|
|
|
'style' => 'I' |
|
499
|
|
|
); |
|
500
|
|
|
$this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'R', 0, 'http://www.nfephp.org'); |
|
501
|
|
|
} |
|
502
|
|
|
|
|
503
|
|
|
/** |
|
504
|
|
|
* Gera a saida |
|
505
|
|
|
* @param string $nome |
|
506
|
|
|
* @param string $destino |
|
507
|
|
|
* @param string $printer |
|
508
|
|
|
* @return mixed |
|
509
|
|
|
*/ |
|
510
|
|
|
public function printDocument($nome = '', $destino = 'I', $printer = '') |
|
511
|
|
|
{ |
|
512
|
|
|
return $this->printDACCE($nome, $destino, $printer); |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
/** |
|
516
|
|
|
* Gera a saida |
|
517
|
|
|
* @param string $nome |
|
518
|
|
|
* @param string $destino |
|
519
|
|
|
* @param string $printer |
|
520
|
|
|
* @return mixed |
|
521
|
|
|
*/ |
|
522
|
|
|
public function printDACCE($nome = '', $destino = 'I', $printer = '') |
|
|
|
|
|
|
523
|
|
|
{ |
|
524
|
|
|
if ($this->pdf == null) { |
|
525
|
|
|
$this->pBuildDACCE(); |
|
526
|
|
|
} |
|
527
|
|
|
return $this->pdf->Output($nome, $destino); |
|
528
|
|
|
} |
|
529
|
|
|
} |
|
530
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.