1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
4
|
|
|
|
5
|
|
|
trait TraitS2240 |
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
|
|
|
"nrRecibo", |
25
|
|
|
!empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
26
|
|
|
false |
27
|
|
|
); |
28
|
|
|
$this->dom->addChild( |
29
|
|
|
$ideEvento, |
30
|
|
|
"tpAmb", |
31
|
|
|
$this->tpAmb, |
|
|
|
|
32
|
|
|
true |
33
|
|
|
); |
34
|
|
|
$this->dom->addChild( |
35
|
|
|
$ideEvento, |
36
|
|
|
"procEmi", |
37
|
|
|
$this->procEmi, |
|
|
|
|
38
|
|
|
true |
39
|
|
|
); |
40
|
|
|
$this->dom->addChild( |
41
|
|
|
$ideEvento, |
42
|
|
|
"verProc", |
43
|
|
|
$this->verProc, |
|
|
|
|
44
|
|
|
true |
45
|
|
|
); |
46
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
47
|
|
|
$ide = $this->dom->createElement("ideVinculo"); |
48
|
|
|
$this->dom->addChild( |
49
|
|
|
$ide, |
50
|
|
|
"cpfTrab", |
51
|
|
|
$this->std->cpftrab, |
52
|
|
|
true |
53
|
|
|
); |
54
|
|
|
$this->dom->addChild( |
55
|
|
|
$ide, |
56
|
|
|
"nisTrab", |
57
|
|
|
!empty($this->std->nistrab) ? $this->std->nistrab : null, |
58
|
|
|
false |
59
|
|
|
); |
60
|
|
|
$this->dom->addChild( |
61
|
|
|
$ide, |
62
|
|
|
"matricula", |
63
|
|
|
!empty($this->std->matricula) ? $this->std->matricula : null, |
64
|
|
|
false |
65
|
|
|
); |
66
|
|
|
$this->dom->addChild( |
67
|
|
|
$ide, |
68
|
|
|
"codCateg", |
69
|
|
|
!empty($this->std->codcateg) ? $this->std->codcateg : null, |
70
|
|
|
false |
71
|
|
|
); |
72
|
|
|
$this->node->appendChild($ide); |
73
|
|
|
$info = $this->dom->createElement("infoExpRisco"); |
74
|
|
|
$this->dom->addChild( |
75
|
|
|
$info, |
76
|
|
|
"dtIniCondicao", |
77
|
|
|
$this->std->dtcondicao, |
78
|
|
|
true |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
foreach ($this->std->infoamb as $amb) { |
82
|
|
|
$infoamb = $this->dom->createElement("infoAmb"); |
83
|
|
|
$this->dom->addChild( |
84
|
|
|
$infoamb, |
85
|
|
|
"codAmb", |
86
|
|
|
$amb->codamb, |
87
|
|
|
true |
88
|
|
|
); |
89
|
|
|
$info->appendChild($infoamb); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$infoAtiv = $this->dom->createElement("infoAtiv"); |
93
|
|
|
$this->dom->addChild( |
94
|
|
|
$infoAtiv, |
95
|
|
|
"dscAtivDes", |
96
|
|
|
$this->std->infoativ->dscativdes, |
97
|
|
|
true |
98
|
|
|
); |
99
|
|
|
foreach ($this->std->infoativ->ativpericinsal as $p) { |
100
|
|
|
$ativPericInsal = $this->dom->createElement("ativPericInsal"); |
101
|
|
|
$this->dom->addChild( |
102
|
|
|
$ativPericInsal, |
103
|
|
|
"codAtiv", |
104
|
|
|
$p->codativ, |
105
|
|
|
true |
106
|
|
|
); |
107
|
|
|
$infoAtiv->appendChild($ativPericInsal); |
108
|
|
|
} |
109
|
|
|
$info->appendChild($infoAtiv); |
110
|
|
|
|
111
|
|
|
foreach ($this->std->fatrisco as $f) { |
112
|
|
|
$fatRisco = $this->dom->createElement("fatRisco"); |
113
|
|
|
$this->dom->addChild( |
114
|
|
|
$fatRisco, |
115
|
|
|
"codFatRis", |
116
|
|
|
$f->codfatris, |
117
|
|
|
true |
118
|
|
|
); |
119
|
|
|
$this->dom->addChild( |
120
|
|
|
$fatRisco, |
121
|
|
|
"dscFatRisc", |
122
|
|
|
isset($f->dscfatrisc) ? $f->dscfatrisc : null, |
123
|
|
|
false |
124
|
|
|
); |
125
|
|
|
$this->dom->addChild( |
126
|
|
|
$fatRisco, |
127
|
|
|
"tpAval", |
128
|
|
|
$f->tpaval, |
129
|
|
|
true |
130
|
|
|
); |
131
|
|
|
$this->dom->addChild( |
132
|
|
|
$fatRisco, |
133
|
|
|
"intConc", |
134
|
|
|
isset($f->intconc) ? $f->intconc : null, |
135
|
|
|
false |
136
|
|
|
); |
137
|
|
|
$this->dom->addChild( |
138
|
|
|
$fatRisco, |
139
|
|
|
"limTol", |
140
|
|
|
isset($f->limtol) ? $f->limtol : null, |
141
|
|
|
false |
142
|
|
|
); |
143
|
|
|
$this->dom->addChild( |
144
|
|
|
$fatRisco, |
145
|
|
|
"unMed", |
146
|
|
|
isset($f->unmed) ? $f->unmed : null, |
147
|
|
|
false |
148
|
|
|
); |
149
|
|
|
$this->dom->addChild( |
150
|
|
|
$fatRisco, |
151
|
|
|
"tecMedicao", |
152
|
|
|
isset($f->tecmedicao) ? $f->tecmedicao : null, |
153
|
|
|
false |
154
|
|
|
); |
155
|
|
|
$this->dom->addChild( |
156
|
|
|
$fatRisco, |
157
|
|
|
"insalubridade", |
158
|
|
|
isset($f->insalubridade) ? $f->insalubridade : null, |
159
|
|
|
false |
160
|
|
|
); |
161
|
|
|
$this->dom->addChild( |
162
|
|
|
$fatRisco, |
163
|
|
|
"periculosidade", |
164
|
|
|
isset($f->periculosidade) ? $f->periculosidade : null, |
165
|
|
|
false |
166
|
|
|
); |
167
|
|
|
$this->dom->addChild( |
168
|
|
|
$fatRisco, |
169
|
|
|
"aposentEsp", |
170
|
|
|
isset($f->aposentesp) ? $f->aposentesp : null, |
171
|
|
|
false |
172
|
|
|
); |
173
|
|
|
|
174
|
|
|
$epcEpi = $this->dom->createElement("epcEpi"); |
175
|
|
|
$this->dom->addChild( |
176
|
|
|
$epcEpi, |
177
|
|
|
"utilizEPC", |
178
|
|
|
$f->epcepi->utilizepc, |
179
|
|
|
true |
180
|
|
|
); |
181
|
|
|
$this->dom->addChild( |
182
|
|
|
$epcEpi, |
183
|
|
|
"eficEpc", |
184
|
|
|
isset($f->epcepi->eficepc) ? $f->epcepi->eficepc : null, |
185
|
|
|
false |
186
|
|
|
); |
187
|
|
|
$this->dom->addChild( |
188
|
|
|
$epcEpi, |
189
|
|
|
"utilizEPI", |
190
|
|
|
$f->epcepi->utilizepi, |
191
|
|
|
true |
192
|
|
|
); |
193
|
|
|
|
194
|
|
|
if (!empty($f->epcepi->epi)) { |
195
|
|
|
foreach ($f->epcepi->epi as $e) { |
196
|
|
|
$epi = $this->dom->createElement("epi"); |
197
|
|
|
$this->dom->addChild( |
198
|
|
|
$epi, |
199
|
|
|
"caEPI", |
200
|
|
|
isset($e->caepi) ? $e->caepi : null, |
201
|
|
|
false |
202
|
|
|
); |
203
|
|
|
$this->dom->addChild( |
204
|
|
|
$epi, |
205
|
|
|
"dscEPI", |
206
|
|
|
isset($e->dscepi) ? $e->dscepi : null, |
207
|
|
|
false |
208
|
|
|
); |
209
|
|
|
$this->dom->addChild( |
210
|
|
|
$epi, |
211
|
|
|
"eficEpi", |
212
|
|
|
$e->eficepi, |
213
|
|
|
true |
214
|
|
|
); |
215
|
|
|
$this->dom->addChild( |
216
|
|
|
$epi, |
217
|
|
|
"medProtecao", |
218
|
|
|
$e->medprotecao, |
219
|
|
|
true |
220
|
|
|
); |
221
|
|
|
$this->dom->addChild( |
222
|
|
|
$epi, |
223
|
|
|
"condFuncto", |
224
|
|
|
$e->condfuncto, |
225
|
|
|
true |
226
|
|
|
); |
227
|
|
|
$this->dom->addChild( |
228
|
|
|
$epi, |
229
|
|
|
"usoInint", |
230
|
|
|
$e->usoinint, |
231
|
|
|
true |
232
|
|
|
); |
233
|
|
|
$this->dom->addChild( |
234
|
|
|
$epi, |
235
|
|
|
"przValid", |
236
|
|
|
$e->przvalid, |
237
|
|
|
true |
238
|
|
|
); |
239
|
|
|
$this->dom->addChild( |
240
|
|
|
$epi, |
241
|
|
|
"periodicTroca", |
242
|
|
|
$e->periodictroca, |
243
|
|
|
true |
244
|
|
|
); |
245
|
|
|
$this->dom->addChild( |
246
|
|
|
$epi, |
247
|
|
|
"higienizacao", |
248
|
|
|
$e->higienizacao, |
249
|
|
|
true |
250
|
|
|
); |
251
|
|
|
$epcEpi->appendChild($epi); |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
$fatRisco->appendChild($epcEpi); |
255
|
|
|
$info->appendChild($fatRisco); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
foreach ($this->std->respreg as $r) { |
259
|
|
|
$respReg = $this->dom->createElement("respReg"); |
260
|
|
|
$this->dom->addChild( |
261
|
|
|
$respReg, |
262
|
|
|
"cpfResp", |
263
|
|
|
$r->cpfresp, |
264
|
|
|
true |
265
|
|
|
); |
266
|
|
|
$this->dom->addChild( |
267
|
|
|
$respReg, |
268
|
|
|
"nisResp", |
269
|
|
|
$r->nisresp, |
270
|
|
|
true |
271
|
|
|
); |
272
|
|
|
$this->dom->addChild( |
273
|
|
|
$respReg, |
274
|
|
|
"nmResp", |
275
|
|
|
$r->nmresp, |
276
|
|
|
true |
277
|
|
|
); |
278
|
|
|
$this->dom->addChild( |
279
|
|
|
$respReg, |
280
|
|
|
"ideOC", |
281
|
|
|
$r->ideoc, |
282
|
|
|
true |
283
|
|
|
); |
284
|
|
|
$this->dom->addChild( |
285
|
|
|
$respReg, |
286
|
|
|
"dscOC", |
287
|
|
|
!empty($r->dscoc) ? $r->dscoc : null, |
288
|
|
|
false |
289
|
|
|
); |
290
|
|
|
$this->dom->addChild( |
291
|
|
|
$respReg, |
292
|
|
|
"nrOC", |
293
|
|
|
$r->nroc, |
294
|
|
|
true |
295
|
|
|
); |
296
|
|
|
$this->dom->addChild( |
297
|
|
|
$respReg, |
298
|
|
|
"ufOC", |
299
|
|
|
$r->ufoc, |
300
|
|
|
true |
301
|
|
|
); |
302
|
|
|
$info->appendChild($respReg); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
if (!empty($this->std->obs)) { |
306
|
|
|
$o = $this->std->obs; |
307
|
|
|
$obs = $this->dom->createElement("obs"); |
308
|
|
|
$this->dom->addChild( |
309
|
|
|
$obs, |
310
|
|
|
"metErg", |
311
|
|
|
!empty($o->meterg) ? $o->meterg : null, |
312
|
|
|
false |
313
|
|
|
); |
314
|
|
|
$this->dom->addChild( |
315
|
|
|
$obs, |
316
|
|
|
"obsCompl", |
317
|
|
|
!empty($o->obscompl) ? $o->obscompl : null, |
318
|
|
|
false |
319
|
|
|
); |
320
|
|
|
$info->appendChild($obs); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
$this->node->appendChild($info); |
324
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
325
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
326
|
|
|
$this->sign(); |
|
|
|
|
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
|
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* builder for version S.1.0.0 |
333
|
|
|
*/ |
334
|
|
|
protected function toNodeS100() |
335
|
|
|
{ |
336
|
|
|
throw new \Exception("TODO !!"); |
337
|
|
|
} |
338
|
|
|
} |
339
|
|
|
|
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: