|
1
|
|
|
<?php |
|
2
|
|
|
namespace NFePHP\DA\NFe\Traits; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Bloco VII informações do consumidor e dados da NFCe |
|
6
|
|
|
*/ |
|
7
|
|
|
trait TraitBlocoVII |
|
8
|
|
|
{ |
|
9
|
|
|
protected function blocoVII($y) |
|
10
|
|
|
{ |
|
11
|
|
|
$nome = $this->getTagValue($this->dest, "xNome"); |
|
|
|
|
|
|
12
|
|
|
$cnpj = $this->getTagValue($this->dest, "CNPJ"); |
|
|
|
|
|
|
13
|
|
|
$cpf = $this->getTagValue($this->dest, "CPF"); |
|
|
|
|
|
|
14
|
|
|
$rua = $this->getTagValue($this->enderDest, "xLgr"); |
|
|
|
|
|
|
15
|
|
|
$numero = $this->getTagValue($this->enderDest, "nro"); |
|
|
|
|
|
|
16
|
|
|
$complemento = $this->getTagValue($this->enderDest, "xCpl"); |
|
|
|
|
|
|
17
|
|
|
$bairro = $this->getTagValue($this->enderDest, "xBairro"); |
|
|
|
|
|
|
18
|
|
|
$mun = $this->getTagValue($this->enderDest, "xMun"); |
|
|
|
|
|
|
19
|
|
|
$uf = $this->getTagValue($this->enderDest, "UF"); |
|
|
|
|
|
|
20
|
|
|
$texto = ''; |
|
|
|
|
|
|
21
|
|
|
$yPlus = 0; |
|
22
|
|
|
if (!empty($cnpj)) { |
|
23
|
|
|
$texto = "CONSUMIDOR - CNPJ " |
|
24
|
|
|
. $this->formatField($cnpj, "##.###.###/####-##") . " - " . $nome; |
|
|
|
|
|
|
25
|
|
|
$texto .= "\n {$rua}, {$numero} {$complemento} {$bairro} {$mun}-{$uf}"; |
|
26
|
|
|
} elseif (!empty($cpf)) { |
|
27
|
|
|
$texto = "CONSUMIDOR - CPF " |
|
28
|
|
|
. $this->formatField($cpf, "###.###.###-##") . " = " . $nome; |
|
|
|
|
|
|
29
|
|
|
$texto .= "\n {$rua}, {$numero} {$complemento} {$bairro} {$mun}-{$uf}"; |
|
30
|
|
|
} else { |
|
31
|
|
|
$texto = 'CONSUMIDOR NÃO IDENTIFICADO'; |
|
32
|
|
|
$yPlus = 1; |
|
33
|
|
|
} |
|
34
|
|
|
if ($this->getTagValue($this->nfeProc, "xMsg")) { |
|
|
|
|
|
|
35
|
|
|
$texto .= "\n {$this->getTagValue($this->nfeProc, "xMsg")}"; |
|
|
|
|
|
|
36
|
|
|
$this->bloco7H += 4; |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
$subSize = 0; |
|
39
|
|
|
if ($this->paperwidth < 70) { |
|
|
|
|
|
|
40
|
|
|
$subSize = 1.5; |
|
41
|
|
|
} |
|
42
|
|
|
if ($this->tpEmis == 9) { |
|
43
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (7-$subSize), 'style' => '']; |
|
|
|
|
|
|
44
|
|
|
$y += 2*$yPlus; |
|
45
|
|
|
$y1 = $this->pdf->textBox( |
|
|
|
|
|
|
46
|
|
|
$this->margem, |
|
|
|
|
|
|
47
|
|
|
$y, |
|
48
|
|
|
$this->wPrint, |
|
|
|
|
|
|
49
|
|
|
$this->bloco7H, |
|
50
|
|
|
$texto, |
|
51
|
|
|
$aFont, |
|
52
|
|
|
'T', |
|
53
|
|
|
'C', |
|
54
|
|
|
false, |
|
55
|
|
|
'', |
|
56
|
|
|
false |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
|
|
$y1 += 2*$yPlus; |
|
60
|
|
|
$num = str_pad($this->getTagValue($this->ide, "nNF"), 9, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
61
|
|
|
$serie = str_pad($this->getTagValue($this->ide, "serie"), 3, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
62
|
|
|
$data = (new \DateTime($this->getTagValue($this->ide, "dhEmi")))->format('d/m/Y H:i:s'); |
|
|
|
|
|
|
63
|
|
|
$texto = "NFCe n. {$num} Série {$serie} {$data}"; |
|
64
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => 8, 'style' => 'B']; |
|
65
|
|
|
$y2 = $this->pdf->textBox( |
|
66
|
|
|
$this->margem, |
|
67
|
|
|
$y+$y1, |
|
68
|
|
|
$this->wPrint, |
|
69
|
|
|
4, |
|
70
|
|
|
$texto, |
|
71
|
|
|
$aFont, |
|
72
|
|
|
'T', |
|
73
|
|
|
'C', |
|
74
|
|
|
false, |
|
75
|
|
|
'', |
|
76
|
|
|
true |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
$texto = $this->via; |
|
|
|
|
|
|
80
|
|
|
$y3 = $this->pdf->textBox( |
|
81
|
|
|
$this->margem, |
|
82
|
|
|
$y+$y1+$y2, |
|
83
|
|
|
$this->wPrint, |
|
84
|
|
|
4, |
|
85
|
|
|
$texto, |
|
86
|
|
|
$aFont, |
|
87
|
|
|
'T', |
|
88
|
|
|
'C', |
|
89
|
|
|
false, |
|
90
|
|
|
'', |
|
91
|
|
|
true |
|
92
|
|
|
); |
|
93
|
|
|
|
|
94
|
|
|
//contingencia offline |
|
95
|
|
|
$texto = "EMITIDA EM CONTINGÊNCIA"; |
|
96
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => 10, 'style' => 'B']; |
|
97
|
|
|
$y4 = $this->pdf->textBox( |
|
98
|
|
|
$this->margem, |
|
99
|
|
|
$y+$y1+$y2+$y3, |
|
100
|
|
|
$this->wPrint, |
|
101
|
|
|
4, |
|
102
|
|
|
$texto, |
|
103
|
|
|
$aFont, |
|
104
|
|
|
'B', |
|
105
|
|
|
'C', |
|
106
|
|
|
false, |
|
107
|
|
|
'', |
|
108
|
|
|
true |
|
109
|
|
|
); |
|
110
|
|
|
|
|
111
|
|
|
$texto = "Pendente de autorização"; |
|
112
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => 8, 'style' => 'I']; |
|
113
|
|
|
$y5 = $this->pdf->textBox( |
|
|
|
|
|
|
114
|
|
|
$this->margem, |
|
115
|
|
|
$y+$y1+$y2+$y3+$y4, |
|
116
|
|
|
$this->wPrint, |
|
117
|
|
|
3, |
|
118
|
|
|
$texto, |
|
119
|
|
|
$aFont, |
|
120
|
|
|
'B', |
|
121
|
|
|
'C', |
|
122
|
|
|
false, |
|
123
|
|
|
'', |
|
124
|
|
|
true |
|
125
|
|
|
); |
|
126
|
|
|
} elseif ($this->tpEmis == 4) { |
|
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
129
|
|
|
$y1 = $this->pdf->textBox( |
|
130
|
|
|
$this->margem, |
|
131
|
|
|
$y+1, |
|
132
|
|
|
$this->wPrint, |
|
133
|
|
|
$this->bloco7H, |
|
134
|
|
|
$texto, |
|
135
|
|
|
$aFont, |
|
136
|
|
|
'T', |
|
137
|
|
|
'C', |
|
138
|
|
|
false, |
|
139
|
|
|
'', |
|
140
|
|
|
false |
|
141
|
|
|
); |
|
142
|
|
|
|
|
143
|
|
|
$num = str_pad($this->getTagValue($this->ide, "nNF"), 9, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
144
|
|
|
$serie = str_pad($this->getTagValue($this->ide, "serie"), 3, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
145
|
|
|
$data = (new \DateTime($this->getTagValue($this->ide, "dhEmi")))->format('d/m/Y H:i:s'); |
|
|
|
|
|
|
146
|
|
|
$texto = "NFCe n. {$num} Série {$serie} {$data}"; |
|
147
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => '']; |
|
148
|
|
|
$y2 = $this->pdf->textBox( |
|
|
|
|
|
|
149
|
|
|
$this->margem, |
|
150
|
|
|
$y+1+$y1, |
|
151
|
|
|
$this->wPrint, |
|
152
|
|
|
4, |
|
153
|
|
|
$texto, |
|
154
|
|
|
$aFont, |
|
155
|
|
|
'T', |
|
156
|
|
|
'C', |
|
157
|
|
|
false, |
|
158
|
|
|
'', |
|
159
|
|
|
true |
|
160
|
|
|
); |
|
161
|
|
|
$texto = "DANFE-NFC-e Impresso em contingência - EPEC"; |
|
162
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (10-$subSize), 'style' => 'B']; |
|
163
|
|
|
$y2 = $this->pdf->textBox( |
|
164
|
|
|
$this->margem, |
|
165
|
|
|
$y+1+$y1+3, |
|
166
|
|
|
$this->wPrint, |
|
167
|
|
|
4, |
|
168
|
|
|
$texto, |
|
169
|
|
|
$aFont, |
|
170
|
|
|
'T', |
|
171
|
|
|
'C', |
|
172
|
|
|
false, |
|
173
|
|
|
'', |
|
174
|
|
|
true |
|
175
|
|
|
); |
|
176
|
|
|
|
|
177
|
|
|
$texto = "Regularmente recebido pela administração tributária autorizadora"; |
|
178
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => '']; |
|
179
|
|
|
$y2 = $this->pdf->textBox( |
|
180
|
|
|
$this->margem, |
|
181
|
|
|
$y+1+$y1+$y2+3, |
|
182
|
|
|
$this->wPrint, |
|
183
|
|
|
4, |
|
184
|
|
|
$texto, |
|
185
|
|
|
$aFont, |
|
186
|
|
|
'T', |
|
187
|
|
|
'C', |
|
188
|
|
|
false, |
|
189
|
|
|
'', |
|
190
|
|
|
true |
|
191
|
|
|
); |
|
192
|
|
|
if (!empty($this->dom->getElementsByTagName('dhCont'))) { |
|
193
|
|
|
$dhCont = $this->dom->getElementsByTagName('dhCont')->item(0)->nodeValue; |
|
|
|
|
|
|
194
|
|
|
$dt = \DateTime::createFromFormat('Y-m-d\TH:i:sP', $dhCont); |
|
195
|
|
|
$texto = "Data de entrada em contingência : " . $dt->format('d/m/Y H:i:s'); |
|
196
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (7-$subSize), 'style' => '']; |
|
197
|
|
|
$y2 = $this->pdf->textBox( |
|
|
|
|
|
|
198
|
|
|
$this->margem, |
|
199
|
|
|
$y+1+$y1+$y2+6, |
|
200
|
|
|
$this->wPrint, |
|
201
|
|
|
4, |
|
202
|
|
|
$texto, |
|
203
|
|
|
$aFont, |
|
204
|
|
|
'B', |
|
205
|
|
|
'C', |
|
206
|
|
|
false, |
|
207
|
|
|
'', |
|
208
|
|
|
true |
|
209
|
|
|
); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
|
|
213
|
|
|
} else { |
|
214
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => 7, 'style' => '']; |
|
215
|
|
|
$y1 = $this->pdf->textBox( |
|
216
|
|
|
$this->margem, |
|
217
|
|
|
$y+1, |
|
218
|
|
|
$this->wPrint, |
|
219
|
|
|
$this->bloco7H, |
|
220
|
|
|
$texto, |
|
221
|
|
|
$aFont, |
|
222
|
|
|
'T', |
|
223
|
|
|
'C', |
|
224
|
|
|
false, |
|
225
|
|
|
'', |
|
226
|
|
|
false |
|
227
|
|
|
); |
|
228
|
|
|
|
|
229
|
|
|
$num = str_pad($this->getTagValue($this->ide, "nNF"), 9, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
230
|
|
|
$serie = str_pad($this->getTagValue($this->ide, "serie"), 3, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
231
|
|
|
$data = (new \DateTime($this->getTagValue($this->ide, "dhEmi")))->format('d/m/Y H:i:s'); |
|
|
|
|
|
|
232
|
|
|
$texto = "NFCe n. {$num} Série {$serie} {$data}"; |
|
233
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => 'B']; |
|
234
|
|
|
$y2 = $this->pdf->textBox( |
|
235
|
|
|
$this->margem, |
|
236
|
|
|
$y+1+$y1, |
|
237
|
|
|
$this->wPrint, |
|
238
|
|
|
4, |
|
239
|
|
|
$texto, |
|
240
|
|
|
$aFont, |
|
241
|
|
|
'T', |
|
242
|
|
|
'C', |
|
243
|
|
|
false, |
|
244
|
|
|
'', |
|
245
|
|
|
true |
|
246
|
|
|
); |
|
247
|
|
|
|
|
248
|
|
|
$protocolo = ''; |
|
249
|
|
|
$data = ''; |
|
250
|
|
|
if (!empty($this->nfeProc)) { |
|
251
|
|
|
$protocolo = $this->formatField($this->getTagValue($this->nfeProc, 'nProt'), '### ########## ##'); |
|
|
|
|
|
|
252
|
|
|
$data = (new \DateTime($this->getTagValue($this->nfeProc, "dhRecbto")))->format('d/m/Y H:i:s'); |
|
|
|
|
|
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
$texto = "Protocolo de Autorização: {$protocolo}"; |
|
256
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => '']; |
|
257
|
|
|
$y3 = $this->pdf->textBox( |
|
258
|
|
|
$this->margem, |
|
259
|
|
|
$y+1+$y1+$y2, |
|
260
|
|
|
$this->wPrint, |
|
261
|
|
|
4, |
|
262
|
|
|
$texto, |
|
263
|
|
|
$aFont, |
|
264
|
|
|
'T', |
|
265
|
|
|
'C', |
|
266
|
|
|
false, |
|
267
|
|
|
'', |
|
268
|
|
|
true |
|
269
|
|
|
); |
|
270
|
|
|
|
|
271
|
|
|
$texto = "Data de Autorização: {$data}"; |
|
272
|
|
|
$aFont = ['font'=> $this->fontePadrao, 'size' => (8-$subSize), 'style' => '']; |
|
273
|
|
|
$y4 = $this->pdf->textBox( |
|
|
|
|
|
|
274
|
|
|
$this->margem, |
|
275
|
|
|
$y+1+$y1+$y2+$y3, |
|
276
|
|
|
$this->wPrint, |
|
277
|
|
|
4, |
|
278
|
|
|
$texto, |
|
279
|
|
|
$aFont, |
|
280
|
|
|
'T', |
|
281
|
|
|
'C', |
|
282
|
|
|
false, |
|
283
|
|
|
'', |
|
284
|
|
|
true |
|
285
|
|
|
); |
|
286
|
|
|
} |
|
287
|
|
|
$this->pdf->dashedHLine($this->margem, $this->bloco7H+$y, $this->wPrint, 0.1, 30); |
|
288
|
|
|
return $this->bloco7H + $y; |
|
289
|
|
|
} |
|
290
|
|
|
} |
|
291
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: