1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eFinanc\Factories; |
4
|
|
|
|
5
|
|
|
use NFePHP\eFinanc\Common\Factory; |
6
|
|
|
use NFePHP\eFinanc\Common\FactoryInterface; |
7
|
|
|
use NFePHP\eFinanc\Common\FactoryId; |
8
|
|
|
use NFePHP\Common\Certificate; |
9
|
|
|
use stdClass; |
10
|
|
|
|
11
|
|
|
class EvtAberturaeFinanceira extends Factory implements FactoryInterface |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Constructor |
15
|
|
|
* @param string $config |
16
|
|
|
* @param stdClass $std |
17
|
|
|
* @param Certificate $certificate |
18
|
|
|
* @param string $data |
19
|
|
|
*/ |
20
|
|
|
public function __construct( |
21
|
|
|
$config, |
22
|
|
|
stdClass $std, |
23
|
|
|
Certificate $certificate = null, |
24
|
|
|
$data = '' |
25
|
|
|
) { |
26
|
|
|
$params = new \stdClass(); |
27
|
|
|
$params->evtName = 'evtAberturaeFinanceira'; |
28
|
|
|
$params->evtTag = 'evtAberturaeFinanceira'; |
29
|
|
|
$params->evtAlias = 'F-1000'; |
30
|
|
|
parent::__construct($config, $std, $params, $certificate, $data); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
protected function toNode() |
34
|
|
|
{ |
35
|
|
|
$ideDeclarante = $this->node->getElementsByTagName('ideDeclarante')->item(0); |
36
|
|
|
//o idEvento pode variar de evento para evento |
37
|
|
|
//então cada factory individualmente terá de construir o seu |
38
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
39
|
|
|
$this->dom->addChild( |
40
|
|
|
$ideEvento, |
41
|
|
|
"indRetificacao", |
42
|
|
|
$this->std->indretificacao, |
43
|
|
|
true |
44
|
|
|
); |
45
|
|
|
$this->dom->addChild( |
46
|
|
|
$ideEvento, |
47
|
|
|
"nrRecibo", |
48
|
|
|
isset($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
49
|
|
|
false |
50
|
|
|
); |
51
|
|
|
$this->dom->addChild( |
52
|
|
|
$ideEvento, |
53
|
|
|
"tpAmb", |
54
|
|
|
(string) $this->tpAmb, |
55
|
|
|
true |
56
|
|
|
); |
57
|
|
|
$this->dom->addChild( |
58
|
|
|
$ideEvento, |
59
|
|
|
"aplicEmi", |
60
|
|
|
'1', |
61
|
|
|
true |
62
|
|
|
); |
63
|
|
|
$this->dom->addChild( |
64
|
|
|
$ideEvento, |
65
|
|
|
"verAplic", |
66
|
|
|
$this->verAplic, |
67
|
|
|
true |
68
|
|
|
); |
69
|
|
|
$this->node->insertBefore($ideEvento, $ideDeclarante); |
70
|
|
|
|
71
|
|
|
$infoAbertura = $this->dom->createElement("infoAbertura"); |
72
|
|
|
$this->dom->addChild( |
73
|
|
|
$infoAbertura, |
74
|
|
|
"dtInicio", |
75
|
|
|
$this->std->dtinicio, |
76
|
|
|
true |
77
|
|
|
); |
78
|
|
|
$this->dom->addChild( |
79
|
|
|
$infoAbertura, |
80
|
|
|
"dtFim", |
81
|
|
|
$this->std->dtfim, |
82
|
|
|
true |
83
|
|
|
); |
84
|
|
|
$this->node->appendChild($infoAbertura); |
85
|
|
|
|
86
|
|
|
if (!empty($this->std->aberturapp)) { |
87
|
|
|
$AberturaPP = $this->dom->createElement("AberturaPP"); |
88
|
|
|
$pp = $this->std->aberturapp; |
89
|
|
|
foreach ($pp->tpempresa as $tpe) { |
90
|
|
|
$tpEmpresa = $this->dom->createElement("tpEmpresa"); |
91
|
|
|
$this->dom->addChild( |
92
|
|
|
$tpEmpresa, |
93
|
|
|
"tpPrevPriv", |
94
|
|
|
$tpe->tpprevpriv, |
95
|
|
|
true |
96
|
|
|
); |
97
|
|
|
$AberturaPP->appendChild($tpEmpresa); |
98
|
|
|
} |
99
|
|
|
$this->node->appendChild($AberturaPP); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
if (!empty($this->std->aberturamovopfin)) { |
103
|
|
|
$AberturaMovOpFin = $this->dom->createElement("AberturaMovOpFin"); |
104
|
|
|
$rmf = $this->std->aberturamovopfin->responsavelrmf; |
105
|
|
|
$ResponsavelRMF = $this->dom->createElement("ResponsavelRMF"); |
106
|
|
|
$this->dom->addChild( |
107
|
|
|
$ResponsavelRMF, |
108
|
|
|
"CPF", |
109
|
|
|
$rmf->cpf, |
110
|
|
|
true |
111
|
|
|
); |
112
|
|
|
$this->dom->addChild( |
113
|
|
|
$ResponsavelRMF, |
114
|
|
|
"Nome", |
115
|
|
|
$rmf->nome, |
116
|
|
|
true |
117
|
|
|
); |
118
|
|
|
$this->dom->addChild( |
119
|
|
|
$ResponsavelRMF, |
120
|
|
|
"Setor", |
121
|
|
|
$rmf->setor, |
122
|
|
|
true |
123
|
|
|
); |
124
|
|
|
$Telefone = $this->dom->createElement("Telefone"); |
125
|
|
|
$this->dom->addChild( |
126
|
|
|
$Telefone, |
127
|
|
|
"DDD", |
128
|
|
|
$rmf->telefone->ddd, |
129
|
|
|
true |
130
|
|
|
); |
131
|
|
|
$this->dom->addChild( |
132
|
|
|
$Telefone, |
133
|
|
|
"Numero", |
134
|
|
|
$rmf->telefone->numero, |
135
|
|
|
true |
136
|
|
|
); |
137
|
|
|
$this->dom->addChild( |
138
|
|
|
$Telefone, |
139
|
|
|
"Ramal", |
140
|
|
|
isset($rmf->telefone->ramal) ? $rmf->telefone->ramal : null, |
141
|
|
|
false |
142
|
|
|
); |
143
|
|
|
$ResponsavelRMF->appendChild($Telefone); |
144
|
|
|
$end = $rmf->endereco; |
145
|
|
|
$endereco = $this->dom->createElement("Endereco"); |
146
|
|
|
$this->dom->addChild( |
147
|
|
|
$endereco, |
148
|
|
|
"Logradouro", |
149
|
|
|
$end->logradouro, |
150
|
|
|
true |
151
|
|
|
); |
152
|
|
|
$this->dom->addChild( |
153
|
|
|
$endereco, |
154
|
|
|
"Numero", |
155
|
|
|
$end->numero, |
156
|
|
|
true |
157
|
|
|
); |
158
|
|
|
$this->dom->addChild( |
159
|
|
|
$endereco, |
160
|
|
|
"Complemento", |
161
|
|
|
isset($end->complemento) ? $end->complemento : null, |
162
|
|
|
false |
163
|
|
|
); |
164
|
|
|
$this->dom->addChild( |
165
|
|
|
$endereco, |
166
|
|
|
"Bairro", |
167
|
|
|
$end->bairro, |
168
|
|
|
true |
169
|
|
|
); |
170
|
|
|
$this->dom->addChild( |
171
|
|
|
$endereco, |
172
|
|
|
"CEP", |
173
|
|
|
$end->cep, |
174
|
|
|
true |
175
|
|
|
); |
176
|
|
|
$this->dom->addChild( |
177
|
|
|
$endereco, |
178
|
|
|
"Municipio", |
179
|
|
|
$end->municipio, |
180
|
|
|
true |
181
|
|
|
); |
182
|
|
|
$this->dom->addChild( |
183
|
|
|
$endereco, |
184
|
|
|
"UF", |
185
|
|
|
$end->uf, |
186
|
|
|
true |
187
|
|
|
); |
188
|
|
|
$ResponsavelRMF->appendChild($endereco); |
189
|
|
|
$AberturaMovOpFin->appendChild($ResponsavelRMF); |
190
|
|
|
foreach ($this->std->aberturamovopfin->respefin as $rf) { |
191
|
|
|
$RespeFin = $this->dom->createElement("RespeFin"); |
192
|
|
|
$this->dom->addChild( |
193
|
|
|
$RespeFin, |
194
|
|
|
"CPF", |
195
|
|
|
$rf->cpf, |
196
|
|
|
true |
197
|
|
|
); |
198
|
|
|
$this->dom->addChild( |
199
|
|
|
$RespeFin, |
200
|
|
|
"Nome", |
201
|
|
|
$rf->nome, |
202
|
|
|
true |
203
|
|
|
); |
204
|
|
|
$this->dom->addChild( |
205
|
|
|
$RespeFin, |
206
|
|
|
"Setor", |
207
|
|
|
$rf->setor, |
208
|
|
|
true |
209
|
|
|
); |
210
|
|
|
$Telefone = $this->dom->createElement("Telefone"); |
211
|
|
|
$this->dom->addChild( |
212
|
|
|
$Telefone, |
213
|
|
|
"DDD", |
214
|
|
|
$rf->telefone->ddd, |
215
|
|
|
true |
216
|
|
|
); |
217
|
|
|
$this->dom->addChild( |
218
|
|
|
$Telefone, |
219
|
|
|
"Numero", |
220
|
|
|
$rf->telefone->numero, |
221
|
|
|
true |
222
|
|
|
); |
223
|
|
|
$this->dom->addChild( |
224
|
|
|
$Telefone, |
225
|
|
|
"Ramal", |
226
|
|
|
isset($rf->telefone->ramal) ? $rf->telefone->ramal : null, |
227
|
|
|
false |
228
|
|
|
); |
229
|
|
|
$RespeFin->appendChild($Telefone); |
230
|
|
|
$end = $rf->endereco; |
231
|
|
|
$endereco = $this->dom->createElement("Endereco"); |
232
|
|
|
$this->dom->addChild( |
233
|
|
|
$endereco, |
234
|
|
|
"Logradouro", |
235
|
|
|
$end->logradouro, |
236
|
|
|
true |
237
|
|
|
); |
238
|
|
|
$this->dom->addChild( |
239
|
|
|
$endereco, |
240
|
|
|
"Numero", |
241
|
|
|
$end->numero, |
242
|
|
|
true |
243
|
|
|
); |
244
|
|
|
$this->dom->addChild( |
245
|
|
|
$endereco, |
246
|
|
|
"Complemento", |
247
|
|
|
isset($end->complemento) ? $end->complemento : null, |
248
|
|
|
false |
249
|
|
|
); |
250
|
|
|
$this->dom->addChild( |
251
|
|
|
$endereco, |
252
|
|
|
"Bairro", |
253
|
|
|
$end->bairro, |
254
|
|
|
true |
255
|
|
|
); |
256
|
|
|
$this->dom->addChild( |
257
|
|
|
$endereco, |
258
|
|
|
"CEP", |
259
|
|
|
$end->cep, |
260
|
|
|
true |
261
|
|
|
); |
262
|
|
|
$this->dom->addChild( |
263
|
|
|
$endereco, |
264
|
|
|
"Municipio", |
265
|
|
|
$end->municipio, |
266
|
|
|
true |
267
|
|
|
); |
268
|
|
|
$this->dom->addChild( |
269
|
|
|
$endereco, |
270
|
|
|
"UF", |
271
|
|
|
$end->uf, |
272
|
|
|
true |
273
|
|
|
); |
274
|
|
|
$RespeFin->appendChild($endereco); |
275
|
|
|
$this->dom->addChild( |
276
|
|
|
$RespeFin, |
277
|
|
|
"Email", |
278
|
|
|
$rf->email, |
279
|
|
|
true |
280
|
|
|
); |
281
|
|
|
$AberturaMovOpFin->appendChild($RespeFin); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
$RepresLegal = $this->dom->createElement("RepresLegal"); |
285
|
|
|
$rl = $this->std->aberturamovopfin->represlegal; |
286
|
|
|
$this->dom->addChild( |
287
|
|
|
$RepresLegal, |
288
|
|
|
"CPF", |
289
|
|
|
$rl->cpf, |
290
|
|
|
true |
291
|
|
|
); |
292
|
|
|
$this->dom->addChild( |
293
|
|
|
$RepresLegal, |
294
|
|
|
"Setor", |
295
|
|
|
$rl->setor, |
296
|
|
|
true |
297
|
|
|
); |
298
|
|
|
$Telefone = $this->dom->createElement("Telefone"); |
299
|
|
|
$this->dom->addChild( |
300
|
|
|
$Telefone, |
301
|
|
|
"DDD", |
302
|
|
|
$rl->telefone->ddd, |
303
|
|
|
true |
304
|
|
|
); |
305
|
|
|
$this->dom->addChild( |
306
|
|
|
$Telefone, |
307
|
|
|
"Numero", |
308
|
|
|
$rl->telefone->numero, |
309
|
|
|
true |
310
|
|
|
); |
311
|
|
|
$this->dom->addChild( |
312
|
|
|
$Telefone, |
313
|
|
|
"Ramal", |
314
|
|
|
isset($rl->telefone->ramal) ? $rl->telefone->ramal : null, |
315
|
|
|
false |
316
|
|
|
); |
317
|
|
|
$RepresLegal->appendChild($Telefone); |
318
|
|
|
$AberturaMovOpFin->appendChild($RepresLegal); |
319
|
|
|
|
320
|
|
|
$this->node->appendChild($AberturaMovOpFin); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
//finalização do xml |
324
|
|
|
$this->eFinanceira->appendChild($this->node); |
325
|
|
|
//$this->xml = $this->dom->saveXML($this->eFinanceira); |
326
|
|
|
$this->sign($this->evtTag); |
327
|
|
|
} |
328
|
|
|
} |
329
|
|
|
|