1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
4
|
|
|
|
5
|
|
|
trait TraitS1010 |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* builder for version 2.5.0 |
9
|
|
|
*/ |
10
|
|
|
protected function toNode250() |
11
|
|
|
{ |
12
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
|
|
|
|
13
|
|
|
//o idEvento pode variar de evento para evento |
14
|
|
|
//então cada factory individualmente terá de construir o seu |
15
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
|
|
|
|
16
|
|
|
$this->dom->addChild( |
17
|
|
|
$ideEvento, |
18
|
|
|
"tpAmb", |
19
|
|
|
$this->tpAmb, |
|
|
|
|
20
|
|
|
true |
21
|
|
|
); |
22
|
|
|
$this->dom->addChild( |
23
|
|
|
$ideEvento, |
24
|
|
|
"procEmi", |
25
|
|
|
$this->procEmi, |
|
|
|
|
26
|
|
|
true |
27
|
|
|
); |
28
|
|
|
$this->dom->addChild( |
29
|
|
|
$ideEvento, |
30
|
|
|
"verProc", |
31
|
|
|
$this->verProc, |
|
|
|
|
32
|
|
|
true |
33
|
|
|
); |
34
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
35
|
|
|
|
36
|
|
|
//tag deste evento em particular |
37
|
|
|
$infoRubrica = $this->dom->createElement("infoRubrica"); |
38
|
|
|
//tag comum a todos os modos |
39
|
|
|
$ideRubrica = $this->dom->createElement("ideRubrica"); |
40
|
|
|
$this->dom->addChild( |
41
|
|
|
$ideRubrica, |
42
|
|
|
"codRubr", |
43
|
|
|
$this->std->codrubr, |
|
|
|
|
44
|
|
|
true |
45
|
|
|
); |
46
|
|
|
$this->dom->addChild( |
47
|
|
|
$ideRubrica, |
48
|
|
|
"ideTabRubr", |
49
|
|
|
$this->std->idetabrubr, |
50
|
|
|
true |
51
|
|
|
); |
52
|
|
|
$this->dom->addChild( |
53
|
|
|
$ideRubrica, |
54
|
|
|
"iniValid", |
55
|
|
|
$this->std->inivalid, |
56
|
|
|
true |
57
|
|
|
); |
58
|
|
|
$this->dom->addChild( |
59
|
|
|
$ideRubrica, |
60
|
|
|
"fimValid", |
61
|
|
|
! empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
62
|
|
|
false |
63
|
|
|
); |
64
|
|
|
//seleção do modo |
65
|
|
|
if ($this->std->modo == 'INC') { |
66
|
|
|
$node = $this->dom->createElement("inclusao"); |
67
|
|
|
} elseif ($this->std->modo == 'ALT') { |
68
|
|
|
$node = $this->dom->createElement("alteracao"); |
69
|
|
|
} else { |
70
|
|
|
$node = $this->dom->createElement("exclusao"); |
71
|
|
|
} |
72
|
|
|
$node->appendChild($ideRubrica); |
73
|
|
|
|
74
|
|
|
if (!empty($this->std->dadosrubrica) && $this->std->modo != 'EXC') { |
75
|
|
|
$dadosRubrica = $this->dom->createElement("dadosRubrica"); |
76
|
|
|
$this->dom->addChild( |
77
|
|
|
$dadosRubrica, |
78
|
|
|
"dscRubr", |
79
|
|
|
$this->std->dadosrubrica->dscrubr, |
80
|
|
|
true |
81
|
|
|
); |
82
|
|
|
$this->dom->addChild( |
83
|
|
|
$dadosRubrica, |
84
|
|
|
"natRubr", |
85
|
|
|
$this->std->dadosrubrica->natrubr, |
86
|
|
|
true |
87
|
|
|
); |
88
|
|
|
$this->dom->addChild( |
89
|
|
|
$dadosRubrica, |
90
|
|
|
"tpRubr", |
91
|
|
|
$this->std->dadosrubrica->tprubr, |
92
|
|
|
true |
93
|
|
|
); |
94
|
|
|
$this->dom->addChild( |
95
|
|
|
$dadosRubrica, |
96
|
|
|
"codIncCP", |
97
|
|
|
$this->std->dadosrubrica->codinccp, |
98
|
|
|
true |
99
|
|
|
); |
100
|
|
|
$this->dom->addChild( |
101
|
|
|
$dadosRubrica, |
102
|
|
|
"codIncIRRF", |
103
|
|
|
$this->std->dadosrubrica->codincirrf, |
104
|
|
|
true |
105
|
|
|
); |
106
|
|
|
$this->dom->addChild( |
107
|
|
|
$dadosRubrica, |
108
|
|
|
"codIncFGTS", |
109
|
|
|
$this->std->dadosrubrica->codincfgts, |
110
|
|
|
true |
111
|
|
|
); |
112
|
|
|
$this->dom->addChild( |
113
|
|
|
$dadosRubrica, |
114
|
|
|
"codIncSIND", |
115
|
|
|
$this->std->dadosrubrica->codincsind, |
116
|
|
|
true |
117
|
|
|
); |
118
|
|
|
$this->dom->addChild( |
119
|
|
|
$dadosRubrica, |
120
|
|
|
"observacao", |
121
|
|
|
! empty($this->std->dadosrubrica->observacao) |
122
|
|
|
? $this->std->dadosrubrica->observacao |
123
|
|
|
: null, |
124
|
|
|
false |
125
|
|
|
); |
126
|
|
|
|
127
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessocp)) { |
128
|
|
|
foreach ($this->std->dadosrubrica->ideprocessocp as $cp) { |
129
|
|
|
$ideProcessoCP = $this->dom->createElement("ideProcessoCP"); |
130
|
|
|
$this->dom->addChild( |
131
|
|
|
$ideProcessoCP, |
132
|
|
|
"tpProc", |
133
|
|
|
$cp->tpproc, |
134
|
|
|
true |
135
|
|
|
); |
136
|
|
|
$this->dom->addChild( |
137
|
|
|
$ideProcessoCP, |
138
|
|
|
"nrProc", |
139
|
|
|
$cp->nrproc, |
140
|
|
|
true |
141
|
|
|
); |
142
|
|
|
$this->dom->addChild( |
143
|
|
|
$ideProcessoCP, |
144
|
|
|
"extDecisao", |
145
|
|
|
$cp->extdecisao, |
146
|
|
|
true |
147
|
|
|
); |
148
|
|
|
$this->dom->addChild( |
149
|
|
|
$ideProcessoCP, |
150
|
|
|
"codSusp", |
151
|
|
|
$cp->codsusp, |
152
|
|
|
true |
153
|
|
|
); |
154
|
|
|
$dadosRubrica->appendChild($ideProcessoCP); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessoirrf)) { |
159
|
|
|
foreach ($this->std->dadosrubrica->ideprocessoirrf as $irrf) { |
160
|
|
|
$ideProcessoIRRF = $this->dom->createElement("ideProcessoIRRF"); |
161
|
|
|
$this->dom->addChild( |
162
|
|
|
$ideProcessoIRRF, |
163
|
|
|
"nrProc", |
164
|
|
|
$irrf->nrproc, |
165
|
|
|
true |
166
|
|
|
); |
167
|
|
|
$this->dom->addChild( |
168
|
|
|
$ideProcessoIRRF, |
169
|
|
|
"codSusp", |
170
|
|
|
$irrf->codsusp, |
171
|
|
|
true |
172
|
|
|
); |
173
|
|
|
$dadosRubrica->appendChild($ideProcessoIRRF); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessofgts)) { |
177
|
|
|
foreach ($this->std->dadosrubrica->ideprocessofgts as $fgts) { |
178
|
|
|
$ideProcessoFGTS = $this->dom->createElement("ideProcessoFGTS"); |
179
|
|
|
$this->dom->addChild( |
180
|
|
|
$ideProcessoFGTS, |
181
|
|
|
"nrProc", |
182
|
|
|
$fgts->nrproc, |
183
|
|
|
true |
184
|
|
|
); |
185
|
|
|
$dadosRubrica->appendChild($ideProcessoFGTS); |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessosind)) { |
189
|
|
|
foreach ($this->std->dadosrubrica->ideprocessosind as $sind) { |
190
|
|
|
$ideProcessoSIND = $this->dom->createElement("ideProcessoSIND"); |
191
|
|
|
$this->dom->addChild( |
192
|
|
|
$ideProcessoSIND, |
193
|
|
|
"nrProc", |
194
|
|
|
$sind->nrproc, |
195
|
|
|
true |
196
|
|
|
); |
197
|
|
|
$dadosRubrica->appendChild($ideProcessoSIND); |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
$node->appendChild($dadosRubrica); |
201
|
|
|
} |
202
|
|
|
if (! empty($this->std->novavalidade) && $this->std->modo == 'ALT') { |
203
|
|
|
$newVal = $this->std->novavalidade; |
204
|
|
|
$novaValidade = $this->dom->createElement("novaValidade"); |
205
|
|
|
$this->dom->addChild( |
206
|
|
|
$novaValidade, |
207
|
|
|
"iniValid", |
208
|
|
|
$newVal->inivalid, |
209
|
|
|
true |
210
|
|
|
); |
211
|
|
|
$this->dom->addChild( |
212
|
|
|
$novaValidade, |
213
|
|
|
"fimValid", |
214
|
|
|
! empty($newVal->fimvalid) ? $newVal->fimvalid : null, |
215
|
|
|
false |
216
|
|
|
); |
217
|
|
|
$node->appendChild($novaValidade); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
//finalização do xml |
221
|
|
|
$infoRubrica->appendChild($node); |
222
|
|
|
$this->node->appendChild($infoRubrica); |
223
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
224
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
225
|
|
|
$this->sign(); |
|
|
|
|
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* builder for version S.1.0.0 |
230
|
|
|
*/ |
231
|
|
|
protected function toNodeS100() |
232
|
|
|
{ |
233
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
234
|
|
|
//o idEvento pode variar de evento para evento |
235
|
|
|
//então cada factory individualmente terá de construir o seu |
236
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
237
|
|
|
$this->dom->addChild( |
238
|
|
|
$ideEvento, |
239
|
|
|
"tpAmb", |
240
|
|
|
$this->tpAmb, |
241
|
|
|
true |
242
|
|
|
); |
243
|
|
|
$this->dom->addChild( |
244
|
|
|
$ideEvento, |
245
|
|
|
"procEmi", |
246
|
|
|
$this->procEmi, |
247
|
|
|
true |
248
|
|
|
); |
249
|
|
|
$this->dom->addChild( |
250
|
|
|
$ideEvento, |
251
|
|
|
"verProc", |
252
|
|
|
$this->verProc, |
253
|
|
|
true |
254
|
|
|
); |
255
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
256
|
|
|
|
257
|
|
|
//tag deste evento em particular |
258
|
|
|
$infoRubrica = $this->dom->createElement("infoRubrica"); |
259
|
|
|
//tag comum a todos os modos |
260
|
|
|
$ideRubrica = $this->dom->createElement("ideRubrica"); |
261
|
|
|
$this->dom->addChild( |
262
|
|
|
$ideRubrica, |
263
|
|
|
"codRubr", |
264
|
|
|
$this->std->codrubr, |
265
|
|
|
true |
266
|
|
|
); |
267
|
|
|
$this->dom->addChild( |
268
|
|
|
$ideRubrica, |
269
|
|
|
"ideTabRubr", |
270
|
|
|
$this->std->idetabrubr, |
271
|
|
|
true |
272
|
|
|
); |
273
|
|
|
$this->dom->addChild( |
274
|
|
|
$ideRubrica, |
275
|
|
|
"iniValid", |
276
|
|
|
$this->std->inivalid, |
277
|
|
|
true |
278
|
|
|
); |
279
|
|
|
$this->dom->addChild( |
280
|
|
|
$ideRubrica, |
281
|
|
|
"fimValid", |
282
|
|
|
! empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
283
|
|
|
false |
284
|
|
|
); |
285
|
|
|
//seleção do modo |
286
|
|
|
if ($this->std->modo == 'INC') { |
287
|
|
|
$node = $this->dom->createElement("inclusao"); |
288
|
|
|
} elseif ($this->std->modo == 'ALT') { |
289
|
|
|
$node = $this->dom->createElement("alteracao"); |
290
|
|
|
} else { |
291
|
|
|
$node = $this->dom->createElement("exclusao"); |
292
|
|
|
} |
293
|
|
|
$node->appendChild($ideRubrica); |
294
|
|
|
|
295
|
|
|
if (!empty($this->std->dadosrubrica) && $this->std->modo != 'EXC') { |
296
|
|
|
$dadosRubrica = $this->dom->createElement("dadosRubrica"); |
297
|
|
|
$this->dom->addChild( |
298
|
|
|
$dadosRubrica, |
299
|
|
|
"dscRubr", |
300
|
|
|
$this->std->dadosrubrica->dscrubr, |
301
|
|
|
true |
302
|
|
|
); |
303
|
|
|
$this->dom->addChild( |
304
|
|
|
$dadosRubrica, |
305
|
|
|
"natRubr", |
306
|
|
|
$this->std->dadosrubrica->natrubr, |
307
|
|
|
true |
308
|
|
|
); |
309
|
|
|
$this->dom->addChild( |
310
|
|
|
$dadosRubrica, |
311
|
|
|
"tpRubr", |
312
|
|
|
$this->std->dadosrubrica->tprubr, |
313
|
|
|
true |
314
|
|
|
); |
315
|
|
|
$this->dom->addChild( |
316
|
|
|
$dadosRubrica, |
317
|
|
|
"codIncCP", |
318
|
|
|
$this->std->dadosrubrica->codinccp, |
319
|
|
|
true |
320
|
|
|
); |
321
|
|
|
$this->dom->addChild( |
322
|
|
|
$dadosRubrica, |
323
|
|
|
"codIncIRRF", |
324
|
|
|
$this->std->dadosrubrica->codincirrf, |
325
|
|
|
true |
326
|
|
|
); |
327
|
|
|
$this->dom->addChild( |
328
|
|
|
$dadosRubrica, |
329
|
|
|
"codIncFGTS", |
330
|
|
|
$this->std->dadosrubrica->codincfgts, |
331
|
|
|
true |
332
|
|
|
); |
333
|
|
|
$this->dom->addChild( |
334
|
|
|
$dadosRubrica, |
335
|
|
|
"observacao", |
336
|
|
|
! empty($this->std->dadosrubrica->observacao) |
337
|
|
|
? $this->std->dadosrubrica->observacao |
338
|
|
|
: null, |
339
|
|
|
false |
340
|
|
|
); |
341
|
|
|
|
342
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessocp)) { |
343
|
|
|
foreach ($this->std->dadosrubrica->ideprocessocp as $cp) { |
344
|
|
|
$ideProcessoCP = $this->dom->createElement("ideProcessoCP"); |
345
|
|
|
$this->dom->addChild( |
346
|
|
|
$ideProcessoCP, |
347
|
|
|
"tpProc", |
348
|
|
|
$cp->tpproc, |
349
|
|
|
true |
350
|
|
|
); |
351
|
|
|
$this->dom->addChild( |
352
|
|
|
$ideProcessoCP, |
353
|
|
|
"nrProc", |
354
|
|
|
$cp->nrproc, |
355
|
|
|
true |
356
|
|
|
); |
357
|
|
|
$this->dom->addChild( |
358
|
|
|
$ideProcessoCP, |
359
|
|
|
"extDecisao", |
360
|
|
|
$cp->extdecisao, |
361
|
|
|
true |
362
|
|
|
); |
363
|
|
|
$this->dom->addChild( |
364
|
|
|
$ideProcessoCP, |
365
|
|
|
"codSusp", |
366
|
|
|
$cp->codsusp, |
367
|
|
|
true |
368
|
|
|
); |
369
|
|
|
$dadosRubrica->appendChild($ideProcessoCP); |
370
|
|
|
} |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessoirrf)) { |
374
|
|
|
foreach ($this->std->dadosrubrica->ideprocessoirrf as $irrf) { |
375
|
|
|
$ideProcessoIRRF = $this->dom->createElement("ideProcessoIRRF"); |
376
|
|
|
$this->dom->addChild( |
377
|
|
|
$ideProcessoIRRF, |
378
|
|
|
"nrProc", |
379
|
|
|
$irrf->nrproc, |
380
|
|
|
true |
381
|
|
|
); |
382
|
|
|
$this->dom->addChild( |
383
|
|
|
$ideProcessoIRRF, |
384
|
|
|
"codSusp", |
385
|
|
|
$irrf->codsusp, |
386
|
|
|
true |
387
|
|
|
); |
388
|
|
|
$dadosRubrica->appendChild($ideProcessoIRRF); |
389
|
|
|
} |
390
|
|
|
} |
391
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessofgts)) { |
392
|
|
|
foreach ($this->std->dadosrubrica->ideprocessofgts as $fgts) { |
393
|
|
|
$ideProcessoFGTS = $this->dom->createElement("ideProcessoFGTS"); |
394
|
|
|
$this->dom->addChild( |
395
|
|
|
$ideProcessoFGTS, |
396
|
|
|
"nrProc", |
397
|
|
|
$fgts->nrproc, |
398
|
|
|
true |
399
|
|
|
); |
400
|
|
|
$dadosRubrica->appendChild($ideProcessoFGTS); |
401
|
|
|
} |
402
|
|
|
} |
403
|
|
|
if (! empty($this->std->dadosrubrica->ideprocessosind)) { |
404
|
|
|
foreach ($this->std->dadosrubrica->ideprocessosind as $sind) { |
405
|
|
|
$ideProcessoSIND = $this->dom->createElement("ideProcessoSIND"); |
406
|
|
|
$this->dom->addChild( |
407
|
|
|
$ideProcessoSIND, |
408
|
|
|
"nrProc", |
409
|
|
|
$sind->nrproc, |
410
|
|
|
true |
411
|
|
|
); |
412
|
|
|
$dadosRubrica->appendChild($ideProcessoSIND); |
413
|
|
|
} |
414
|
|
|
} |
415
|
|
|
$node->appendChild($dadosRubrica); |
416
|
|
|
} |
417
|
|
|
if (! empty($this->std->novavalidade) && $this->std->modo == 'ALT') { |
418
|
|
|
$newVal = $this->std->novavalidade; |
419
|
|
|
$novaValidade = $this->dom->createElement("novaValidade"); |
420
|
|
|
$this->dom->addChild( |
421
|
|
|
$novaValidade, |
422
|
|
|
"iniValid", |
423
|
|
|
$newVal->inivalid, |
424
|
|
|
true |
425
|
|
|
); |
426
|
|
|
$this->dom->addChild( |
427
|
|
|
$novaValidade, |
428
|
|
|
"fimValid", |
429
|
|
|
! empty($newVal->fimvalid) ? $newVal->fimvalid : null, |
430
|
|
|
false |
431
|
|
|
); |
432
|
|
|
$node->appendChild($novaValidade); |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
//finalização do xml |
436
|
|
|
$infoRubrica->appendChild($node); |
437
|
|
|
$this->node->appendChild($infoRubrica); |
438
|
|
|
$this->eSocial->appendChild($this->node); |
439
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
440
|
|
|
$this->sign(); |
|
|
|
|
441
|
|
|
} |
442
|
|
|
} |
443
|
|
|
|
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: