1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
4
|
|
|
|
5
|
|
|
trait TraitS2220 |
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
|
|
|
"indRetif", |
19
|
|
|
$this->std->indretif, |
|
|
|
|
20
|
|
|
true |
21
|
|
|
); |
22
|
|
|
$this->dom->addChild( |
23
|
|
|
$ideEvento, |
24
|
|
|
"tpAmb", |
25
|
|
|
$this->tpAmb, |
|
|
|
|
26
|
|
|
true |
27
|
|
|
); |
28
|
|
|
$this->dom->addChild( |
29
|
|
|
$ideEvento, |
30
|
|
|
"procEmi", |
31
|
|
|
$this->procEmi, |
|
|
|
|
32
|
|
|
true |
33
|
|
|
); |
34
|
|
|
$this->dom->addChild( |
35
|
|
|
$ideEvento, |
36
|
|
|
"verProc", |
37
|
|
|
$this->verProc, |
|
|
|
|
38
|
|
|
true |
39
|
|
|
); |
40
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
41
|
|
|
$ideVinculo = $this->dom->createElement("ideVinculo"); |
42
|
|
|
$this->dom->addChild( |
43
|
|
|
$ideVinculo, |
44
|
|
|
"cpfTrab", |
45
|
|
|
$this->std->idevinculo->cpftrab, |
46
|
|
|
true |
47
|
|
|
); |
48
|
|
|
$this->dom->addChild( |
49
|
|
|
$ideVinculo, |
50
|
|
|
"nisTrab", |
51
|
|
|
$this->std->idevinculo->nistrab, |
52
|
|
|
true |
53
|
|
|
); |
54
|
|
|
$this->dom->addChild( |
55
|
|
|
$ideVinculo, |
56
|
|
|
"matricula", |
57
|
|
|
!empty($this->std->idevinculo->matricula) ? $this->std->idevinculo->matricula : null, |
58
|
|
|
false |
59
|
|
|
); |
60
|
|
|
$this->node->appendChild($ideVinculo); |
61
|
|
|
|
62
|
|
|
if ($this->layoutStr !== 'v02_05_00') { |
|
|
|
|
63
|
|
|
$aso = $this->dom->createElement("aso"); |
64
|
|
|
$this->dom->addChild( |
65
|
|
|
$aso, |
66
|
|
|
"dtAso", |
67
|
|
|
$this->std->aso->dtaso, |
68
|
|
|
true |
69
|
|
|
); |
70
|
|
|
$this->dom->addChild( |
71
|
|
|
$aso, |
72
|
|
|
"resAso", |
73
|
|
|
$this->std->aso->resaso, |
74
|
|
|
true |
75
|
|
|
); |
76
|
|
|
if (isset($this->std->aso->exame)) { |
77
|
|
|
foreach ($this->std->aso->exame as $exa) { |
78
|
|
|
$exame = $this->dom->createElement("exame"); |
79
|
|
|
$this->dom->addChild( |
80
|
|
|
$exame, |
81
|
|
|
"dtExm", |
82
|
|
|
$exa->dtexm, |
83
|
|
|
true |
84
|
|
|
); |
85
|
|
|
$this->dom->addChild( |
86
|
|
|
$exame, |
87
|
|
|
"procRealizado", |
88
|
|
|
!empty($exa->procrealizado) ? $exa->procrealizado : null, |
89
|
|
|
false |
90
|
|
|
); |
91
|
|
|
$this->dom->addChild( |
92
|
|
|
$exame, |
93
|
|
|
"obsProc", |
94
|
|
|
!empty($exa->obsproc) ? $exa->obsproc : null, |
95
|
|
|
false |
96
|
|
|
); |
97
|
|
|
$this->dom->addChild( |
98
|
|
|
$exame, |
99
|
|
|
"interprExm", |
100
|
|
|
$exa->interprexm, |
101
|
|
|
true |
102
|
|
|
); |
103
|
|
|
$this->dom->addChild( |
104
|
|
|
$exame, |
105
|
|
|
"ordExame", |
106
|
|
|
$exa->ordexame, |
107
|
|
|
true |
108
|
|
|
); |
109
|
|
|
$this->dom->addChild( |
110
|
|
|
$exame, |
111
|
|
|
"dtIniMonit", |
112
|
|
|
$exa->dtinimonit, |
113
|
|
|
true |
114
|
|
|
); |
115
|
|
|
$this->dom->addChild( |
116
|
|
|
$exame, |
117
|
|
|
"dtFimMonit", |
118
|
|
|
!empty($exa->dtfimmonit) ? $exa->dtfimmonit : null, |
119
|
|
|
false |
120
|
|
|
); |
121
|
|
|
$this->dom->addChild( |
122
|
|
|
$exame, |
123
|
|
|
"indResult", |
124
|
|
|
!empty($exa->indresult) ? $exa->indresult : null, |
125
|
|
|
false |
126
|
|
|
); |
127
|
|
|
$respMonit = $this->dom->createElement("respMonit"); |
128
|
|
|
$resm = $exa->respmonit; |
129
|
|
|
$this->dom->addChild( |
130
|
|
|
$respMonit, |
131
|
|
|
"nisResp", |
132
|
|
|
$resm->nisresp, |
133
|
|
|
true |
134
|
|
|
); |
135
|
|
|
$this->dom->addChild( |
136
|
|
|
$respMonit, |
137
|
|
|
"nrConsClasse", |
138
|
|
|
$resm->nrconsclasse, |
139
|
|
|
true |
140
|
|
|
); |
141
|
|
|
$this->dom->addChild( |
142
|
|
|
$respMonit, |
143
|
|
|
"ufConsClasse", |
144
|
|
|
!empty($resm->ufconsclasse) ? $resm->ufconsclasse : null, |
145
|
|
|
false |
146
|
|
|
); |
147
|
|
|
$exame->appendChild($respMonit); |
148
|
|
|
$aso->appendChild($exame); |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
$ideServSaude = $this->dom->createElement("ideServSaude"); |
152
|
|
|
$sers = $this->std->aso->ideservsaude; |
153
|
|
|
$this->dom->addChild( |
154
|
|
|
$ideServSaude, |
155
|
|
|
"codCNES", |
156
|
|
|
!empty($sers->codcnes) ? $sers->codcnes : null, |
157
|
|
|
false |
158
|
|
|
); |
159
|
|
|
$this->dom->addChild( |
160
|
|
|
$ideServSaude, |
161
|
|
|
"frmCtt", |
162
|
|
|
$sers->frmctt, |
163
|
|
|
true |
164
|
|
|
); |
165
|
|
|
$this->dom->addChild( |
166
|
|
|
$ideServSaude, |
167
|
|
|
"email", |
168
|
|
|
!empty($sers->email) ? $sers->email : null, |
169
|
|
|
false |
170
|
|
|
); |
171
|
|
|
$medico = $this->dom->createElement("medico"); |
172
|
|
|
$med = $sers->medico; |
173
|
|
|
$this->dom->addChild( |
174
|
|
|
$medico, |
175
|
|
|
"nmMed", |
176
|
|
|
$med->nmmed, |
177
|
|
|
true |
178
|
|
|
); |
179
|
|
|
$crm = $this->dom->createElement("crm"); |
180
|
|
|
$this->dom->addChild( |
181
|
|
|
$crm, |
182
|
|
|
"nrCRM", |
183
|
|
|
$med->nrcrm, |
184
|
|
|
true |
185
|
|
|
); |
186
|
|
|
$this->dom->addChild( |
187
|
|
|
$crm, |
188
|
|
|
"ufCRM", |
189
|
|
|
$med->ufcrm, |
190
|
|
|
true |
191
|
|
|
); |
192
|
|
|
$medico->appendChild($crm); |
193
|
|
|
$ideServSaude->appendChild($medico); |
194
|
|
|
$aso->appendChild($ideServSaude); |
195
|
|
|
$this->node->appendChild($aso); |
196
|
|
|
} else { |
197
|
|
|
$this->v020500(); |
198
|
|
|
} |
199
|
|
|
//finalização do xml |
200
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
201
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
202
|
|
|
$this->sign(); |
|
|
|
|
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
protected function v020500() |
206
|
|
|
{ |
207
|
|
|
$exMedOcup = $this->dom->createElement("exMedOcup"); |
208
|
|
|
$this->dom->addChild( |
209
|
|
|
$exMedOcup, |
210
|
|
|
"tpExameOcup", |
211
|
|
|
$this->std->exmedocup->tpexameocup, |
212
|
|
|
true |
213
|
|
|
); |
214
|
|
|
$stdaso = $this->std->exmedocup->aso; |
215
|
|
|
$aso = $this->dom->createElement("aso"); |
216
|
|
|
$this->dom->addChild( |
217
|
|
|
$aso, |
218
|
|
|
"dtAso", |
219
|
|
|
$stdaso->dtaso, |
220
|
|
|
true |
221
|
|
|
); |
222
|
|
|
$this->dom->addChild( |
223
|
|
|
$aso, |
224
|
|
|
"resAso", |
225
|
|
|
$stdaso->resaso, |
226
|
|
|
true |
227
|
|
|
); |
228
|
|
|
|
229
|
|
|
foreach ($this->std->exmedocup->aso->exame as $exa) { |
230
|
|
|
$exame = $this->dom->createElement("exame"); |
231
|
|
|
$this->dom->addChild( |
232
|
|
|
$exame, |
233
|
|
|
"dtExm", |
234
|
|
|
$exa->dtexm, |
235
|
|
|
true |
236
|
|
|
); |
237
|
|
|
$this->dom->addChild( |
238
|
|
|
$exame, |
239
|
|
|
"procRealizado", |
240
|
|
|
$exa->procrealizado, |
241
|
|
|
true |
242
|
|
|
); |
243
|
|
|
$this->dom->addChild( |
244
|
|
|
$exame, |
245
|
|
|
"obsProc", |
246
|
|
|
!empty($exa->obsproc) ? $exa->obsproc : null, |
247
|
|
|
false |
248
|
|
|
); |
249
|
|
|
$this->dom->addChild( |
250
|
|
|
$exame, |
251
|
|
|
"ordExame", |
252
|
|
|
$exa->ordexame, |
253
|
|
|
true |
254
|
|
|
); |
255
|
|
|
$this->dom->addChild( |
256
|
|
|
$exame, |
257
|
|
|
"indResult", |
258
|
|
|
!empty($exa->indresult) ? $exa->indresult : null, |
259
|
|
|
false |
260
|
|
|
); |
261
|
|
|
$aso->appendChild($exame); |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
$stdmed = $this->std->exmedocup->aso->medico; |
265
|
|
|
$medico = $this->dom->createElement("medico"); |
266
|
|
|
$this->dom->addChild( |
267
|
|
|
$medico, |
268
|
|
|
"cpfMed", |
269
|
|
|
!empty($stdmed->cpfmed) ? $stdmed->cpfmed : null, |
270
|
|
|
false |
271
|
|
|
); |
272
|
|
|
$this->dom->addChild( |
273
|
|
|
$medico, |
274
|
|
|
"nisMed", |
275
|
|
|
!empty($stdmed->nismed) ? $stdmed->nismed : null, |
276
|
|
|
false |
277
|
|
|
); |
278
|
|
|
$this->dom->addChild( |
279
|
|
|
$medico, |
280
|
|
|
"nmMed", |
281
|
|
|
$stdmed->nmmed, |
282
|
|
|
true |
283
|
|
|
); |
284
|
|
|
$this->dom->addChild( |
285
|
|
|
$medico, |
286
|
|
|
"nrCRM", |
287
|
|
|
$stdmed->nrcrm, |
288
|
|
|
true |
289
|
|
|
); |
290
|
|
|
$this->dom->addChild( |
291
|
|
|
$medico, |
292
|
|
|
"ufCRM", |
293
|
|
|
$stdmed->ufcrm, |
294
|
|
|
true |
295
|
|
|
); |
296
|
|
|
$aso->appendChild($medico); |
297
|
|
|
$exMedOcup->appendChild($aso); |
298
|
|
|
|
299
|
|
|
$stdmon = $this->std->exmedocup->respmonit; |
300
|
|
|
$monit = $this->dom->createElement("respMonit"); |
301
|
|
|
$this->dom->addChild( |
302
|
|
|
$monit, |
303
|
|
|
"cpfResp", |
304
|
|
|
!empty($stdmon->cpfresp) ? $stdmon->cpfresp : null, |
305
|
|
|
false |
306
|
|
|
); |
307
|
|
|
$this->dom->addChild( |
308
|
|
|
$monit, |
309
|
|
|
"nmResp", |
310
|
|
|
$stdmon->nmresp, |
311
|
|
|
true |
312
|
|
|
); |
313
|
|
|
$this->dom->addChild( |
314
|
|
|
$monit, |
315
|
|
|
"nrCRM", |
316
|
|
|
$stdmon->nrcrm, |
317
|
|
|
true |
318
|
|
|
); |
319
|
|
|
$this->dom->addChild( |
320
|
|
|
$monit, |
321
|
|
|
"ufCRM", |
322
|
|
|
$stdmon->ufcrm, |
323
|
|
|
true |
324
|
|
|
); |
325
|
|
|
$exMedOcup->appendChild($monit); |
326
|
|
|
$this->node->appendChild($exMedOcup); |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* builder for version S.1.0.0 |
331
|
|
|
*/ |
332
|
|
|
protected function toNodeS100() |
333
|
|
|
{ |
334
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
335
|
|
|
//o idEvento pode variar de evento para evento |
336
|
|
|
//então cada factory individualmente terá de construir o seu |
337
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
338
|
|
|
$this->dom->addChild( |
339
|
|
|
$ideEvento, |
340
|
|
|
"indRetif", |
341
|
|
|
$this->std->indretif, |
342
|
|
|
true |
343
|
|
|
); |
344
|
|
|
$this->dom->addChild( |
345
|
|
|
$ideEvento, |
346
|
|
|
"tpAmb", |
347
|
|
|
$this->tpAmb, |
348
|
|
|
true |
349
|
|
|
); |
350
|
|
|
$this->dom->addChild( |
351
|
|
|
$ideEvento, |
352
|
|
|
"procEmi", |
353
|
|
|
$this->procEmi, |
354
|
|
|
true |
355
|
|
|
); |
356
|
|
|
$this->dom->addChild( |
357
|
|
|
$ideEvento, |
358
|
|
|
"verProc", |
359
|
|
|
$this->verProc, |
360
|
|
|
true |
361
|
|
|
); |
362
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
363
|
|
|
$ideVinculo = $this->dom->createElement("ideVinculo"); |
364
|
|
|
$this->dom->addChild( |
365
|
|
|
$ideVinculo, |
366
|
|
|
"cpfTrab", |
367
|
|
|
$this->std->idevinculo->cpftrab, |
368
|
|
|
true |
369
|
|
|
); |
370
|
|
|
$this->dom->addChild( |
371
|
|
|
$ideVinculo, |
372
|
|
|
"matricula", |
373
|
|
|
!empty($this->std->idevinculo->matricula) ? $this->std->idevinculo->matricula : null, |
374
|
|
|
false |
375
|
|
|
); |
376
|
|
|
$this->node->appendChild($ideVinculo); |
377
|
|
|
|
378
|
|
|
$exMedOcup = $this->dom->createElement("exMedOcup"); |
379
|
|
|
$this->dom->addChild( |
380
|
|
|
$exMedOcup, |
381
|
|
|
"tpExameOcup", |
382
|
|
|
$this->std->exmedocup->tpexameocup, |
383
|
|
|
true |
384
|
|
|
); |
385
|
|
|
$stdaso = $this->std->exmedocup->aso; |
386
|
|
|
$aso = $this->dom->createElement("aso"); |
387
|
|
|
$this->dom->addChild( |
388
|
|
|
$aso, |
389
|
|
|
"dtAso", |
390
|
|
|
$stdaso->dtaso, |
391
|
|
|
true |
392
|
|
|
); |
393
|
|
|
$this->dom->addChild( |
394
|
|
|
$aso, |
395
|
|
|
"resAso", |
396
|
|
|
$stdaso->resaso, |
397
|
|
|
true |
398
|
|
|
); |
399
|
|
|
|
400
|
|
|
foreach ($this->std->exmedocup->aso->exame as $exa) { |
401
|
|
|
$exame = $this->dom->createElement("exame"); |
402
|
|
|
$this->dom->addChild( |
403
|
|
|
$exame, |
404
|
|
|
"dtExm", |
405
|
|
|
$exa->dtexm, |
406
|
|
|
true |
407
|
|
|
); |
408
|
|
|
$this->dom->addChild( |
409
|
|
|
$exame, |
410
|
|
|
"procRealizado", |
411
|
|
|
$exa->procrealizado, |
412
|
|
|
true |
413
|
|
|
); |
414
|
|
|
$this->dom->addChild( |
415
|
|
|
$exame, |
416
|
|
|
"obsProc", |
417
|
|
|
!empty($exa->obsproc) ? $exa->obsproc : null, |
418
|
|
|
false |
419
|
|
|
); |
420
|
|
|
$this->dom->addChild( |
421
|
|
|
$exame, |
422
|
|
|
"ordExame", |
423
|
|
|
$exa->ordexame, |
424
|
|
|
true |
425
|
|
|
); |
426
|
|
|
$this->dom->addChild( |
427
|
|
|
$exame, |
428
|
|
|
"indResult", |
429
|
|
|
!empty($exa->indresult) ? $exa->indresult : null, |
430
|
|
|
false |
431
|
|
|
); |
432
|
|
|
$aso->appendChild($exame); |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
$stdmed = $this->std->exmedocup->aso->medico; |
436
|
|
|
$medico = $this->dom->createElement("medico"); |
437
|
|
|
$this->dom->addChild( |
438
|
|
|
$medico, |
439
|
|
|
"nmMed", |
440
|
|
|
$stdmed->nmmed, |
441
|
|
|
true |
442
|
|
|
); |
443
|
|
|
$this->dom->addChild( |
444
|
|
|
$medico, |
445
|
|
|
"nrCRM", |
446
|
|
|
$stdmed->nrcrm, |
447
|
|
|
true |
448
|
|
|
); |
449
|
|
|
$this->dom->addChild( |
450
|
|
|
$medico, |
451
|
|
|
"ufCRM", |
452
|
|
|
$stdmed->ufcrm, |
453
|
|
|
true |
454
|
|
|
); |
455
|
|
|
$aso->appendChild($medico); |
456
|
|
|
$exMedOcup->appendChild($aso); |
457
|
|
|
|
458
|
|
|
$stdmon = $this->std->exmedocup->respmonit; |
459
|
|
|
$monit = $this->dom->createElement("respMonit"); |
460
|
|
|
$this->dom->addChild( |
461
|
|
|
$monit, |
462
|
|
|
"cpfResp", |
463
|
|
|
!empty($stdmon->cpfresp) ? $stdmon->cpfresp : null, |
464
|
|
|
false |
465
|
|
|
); |
466
|
|
|
$this->dom->addChild( |
467
|
|
|
$monit, |
468
|
|
|
"nmResp", |
469
|
|
|
$stdmon->nmresp, |
470
|
|
|
true |
471
|
|
|
); |
472
|
|
|
$this->dom->addChild( |
473
|
|
|
$monit, |
474
|
|
|
"nrCRM", |
475
|
|
|
$stdmon->nrcrm, |
476
|
|
|
true |
477
|
|
|
); |
478
|
|
|
$this->dom->addChild( |
479
|
|
|
$monit, |
480
|
|
|
"ufCRM", |
481
|
|
|
$stdmon->ufcrm, |
482
|
|
|
true |
483
|
|
|
); |
484
|
|
|
$exMedOcup->appendChild($monit); |
485
|
|
|
$this->node->appendChild($exMedOcup); |
486
|
|
|
|
487
|
|
|
//finalização do xml |
488
|
|
|
$this->eSocial->appendChild($this->node); |
489
|
|
|
|
490
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
491
|
|
|
$this->sign(); |
|
|
|
|
492
|
|
|
} |
493
|
|
|
} |
494
|
|
|
|
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: