1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
4
|
|
|
|
5
|
|
|
trait TraitS5003 |
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
|
|
|
"nrRecArqBase", |
19
|
|
|
!empty($this->std->nrrecarqbase) ? $this->std->nrrecarqbase : null, |
|
|
|
|
20
|
|
|
false |
21
|
|
|
); |
22
|
|
|
$this->dom->addChild( |
23
|
|
|
$ideEvento, |
24
|
|
|
"perApur", |
25
|
|
|
$this->std->perapur, |
26
|
|
|
true |
27
|
|
|
); |
28
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
29
|
|
|
|
30
|
|
|
$ide = $this->dom->createElement("ideTrabalhador"); |
31
|
|
|
$this->dom->addChild( |
32
|
|
|
$ide, |
33
|
|
|
"cpfTrab", |
34
|
|
|
$this->std->cpftrab, |
35
|
|
|
true |
36
|
|
|
); |
37
|
|
|
$this->dom->addChild( |
38
|
|
|
$ide, |
39
|
|
|
"nisTrab", |
40
|
|
|
!empty($this->std->nistrab) ? $this->std->nistrab : null, |
41
|
|
|
false |
42
|
|
|
); |
43
|
|
|
$this->node->appendChild($ide); |
44
|
|
|
|
45
|
|
|
if (!empty($this->std->infofgts)) { |
46
|
|
|
$info = $this->std->infofgts; |
47
|
|
|
$infoFGTS = $this->dom->createElement("infoFGTS"); |
48
|
|
|
$this->dom->addChild( |
49
|
|
|
$infoFGTS, |
50
|
|
|
"dtVenc", |
51
|
|
|
!empty($info->dtvenc) ? $info->dtvenc : null, |
52
|
|
|
false |
53
|
|
|
); |
54
|
|
|
foreach ($info->ideestablot as $isl) { |
55
|
|
|
$ideEstabLot = $this->dom->createElement("ideEstabLot"); |
56
|
|
|
$this->dom->addChild( |
57
|
|
|
$ideEstabLot, |
58
|
|
|
"tpInsc", |
59
|
|
|
$isl->tpinsc, |
60
|
|
|
true |
61
|
|
|
); |
62
|
|
|
$this->dom->addChild( |
63
|
|
|
$ideEstabLot, |
64
|
|
|
"nrInsc", |
65
|
|
|
$isl->nrinsc, |
66
|
|
|
true |
67
|
|
|
); |
68
|
|
|
$this->dom->addChild( |
69
|
|
|
$ideEstabLot, |
70
|
|
|
"codLotacao", |
71
|
|
|
$isl->codlotacao, |
72
|
|
|
true |
73
|
|
|
); |
74
|
|
|
foreach ($isl->infotrabfgts as $itf) { |
75
|
|
|
$infoTrabFGTS = $this->dom->createElement("infoTrabFGTS"); |
76
|
|
|
$this->dom->addChild( |
77
|
|
|
$infoTrabFGTS, |
78
|
|
|
"matricula", |
79
|
|
|
!empty($itf->matricula) ? $itf->matricula : null, |
80
|
|
|
false |
81
|
|
|
); |
82
|
|
|
$this->dom->addChild( |
83
|
|
|
$infoTrabFGTS, |
84
|
|
|
"codCateg", |
85
|
|
|
$itf->codcateg, |
86
|
|
|
true |
87
|
|
|
); |
88
|
|
|
$this->dom->addChild( |
89
|
|
|
$infoTrabFGTS, |
90
|
|
|
"dtAdm", |
91
|
|
|
!empty($itf->dtadm) ? $itf->dtadm : null, |
92
|
|
|
false |
93
|
|
|
); |
94
|
|
|
$this->dom->addChild( |
95
|
|
|
$infoTrabFGTS, |
96
|
|
|
"dtDeslig", |
97
|
|
|
!empty($itf->dtdeslig) ? $itf->dtdeslig : null, |
98
|
|
|
false |
99
|
|
|
); |
100
|
|
|
$this->dom->addChild( |
101
|
|
|
$infoTrabFGTS, |
102
|
|
|
"dtInicio", |
103
|
|
|
!empty($itf->dtinicio) ? $itf->dtinicio : null, |
104
|
|
|
false |
105
|
|
|
); |
106
|
|
|
$this->dom->addChild( |
107
|
|
|
$infoTrabFGTS, |
108
|
|
|
"mtvDeslig", |
109
|
|
|
!empty($itf->mtvdeslig) ? $itf->mtvdeslig : null, |
110
|
|
|
false |
111
|
|
|
); |
112
|
|
|
$this->dom->addChild( |
113
|
|
|
$infoTrabFGTS, |
114
|
|
|
"dtTerm", |
115
|
|
|
!empty($itf->dtterm) ? $itf->dtterm : null, |
116
|
|
|
false |
117
|
|
|
); |
118
|
|
|
$this->dom->addChild( |
119
|
|
|
$infoTrabFGTS, |
120
|
|
|
"mtvDesligTSV", |
121
|
|
|
!empty($itf->mtvdesligtsv) ? $itf->mtvdesligtsv : null, |
122
|
|
|
false |
123
|
|
|
); |
124
|
|
|
|
125
|
|
|
if (!empty($itf->infobasefgts)) { |
126
|
|
|
$ibf = $itf->infobasefgts; |
127
|
|
|
$infoBaseFGTS = $this->dom->createElement("infoBaseFGTS"); |
128
|
|
|
if ($ibf->baseperapur) { |
129
|
|
|
foreach ($ibf->baseperapur as $bpa) { |
130
|
|
|
$basePerApur = $this->dom->createElement("basePerApur"); |
131
|
|
|
$this->dom->addChild( |
132
|
|
|
$basePerApur, |
133
|
|
|
"tpValor", |
134
|
|
|
$bpa->tpvalor, |
135
|
|
|
true |
136
|
|
|
); |
137
|
|
|
$this->dom->addChild( |
138
|
|
|
$basePerApur, |
139
|
|
|
"remFGTS", |
140
|
|
|
number_format($bpa->remfgts, 2, ".", ""), |
141
|
|
|
true |
142
|
|
|
); |
143
|
|
|
$infoBaseFGTS->appendChild($basePerApur); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
if ($ibf->infobaseperante) { |
148
|
|
|
foreach ($ibf->infobaseperante as $ibpae) { |
149
|
|
|
$infoBasePerAntE = $this->dom->createElement("infoBasePerAntE"); |
150
|
|
|
$this->dom->addChild( |
151
|
|
|
$infoBasePerAntE, |
152
|
|
|
"perRef", |
153
|
|
|
$ibpae->perref, |
154
|
|
|
true |
155
|
|
|
); |
156
|
|
|
foreach ($ibpae->baseperante as $bpae) { |
157
|
|
|
$basePerAntE = $this->dom->createElement("basePerAntE"); |
158
|
|
|
$this->dom->addChild( |
159
|
|
|
$basePerAntE, |
160
|
|
|
"tpValorE", |
161
|
|
|
$bpae->tpvalore, |
162
|
|
|
true |
163
|
|
|
); |
164
|
|
|
$this->dom->addChild( |
165
|
|
|
$basePerAntE, |
166
|
|
|
"remFGTSE", |
167
|
|
|
number_format($bpae->remfgtse, 2, ".", ""), |
168
|
|
|
true |
169
|
|
|
); |
170
|
|
|
$infoBasePerAntE->appendChild($basePerAntE); |
171
|
|
|
} |
172
|
|
|
$infoBaseFGTS->appendChild($infoBasePerAntE); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
$infoTrabFGTS->appendChild($infoBaseFGTS); |
176
|
|
|
} |
177
|
|
|
$ideEstabLot->appendChild($infoTrabFGTS); |
178
|
|
|
} |
179
|
|
|
$infoFGTS->appendChild($ideEstabLot); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
if (!empty($info->infodpsfgts)) { |
183
|
|
|
$idps = $info->infodpsfgts; |
184
|
|
|
$infoDpsFGTS = $this->dom->createElement("infoDpsFGTS"); |
185
|
|
|
foreach ($idps->infotrabdps as $itdps) { |
186
|
|
|
$infoTrabDps = $this->dom->createElement("infoTrabDps"); |
187
|
|
|
$this->dom->addChild( |
188
|
|
|
$infoTrabDps, |
189
|
|
|
"matricula", |
190
|
|
|
!empty($itdps->matricula) ? $itdps->matricula : null, |
191
|
|
|
false |
192
|
|
|
); |
193
|
|
|
$this->dom->addChild( |
194
|
|
|
$infoTrabDps, |
195
|
|
|
"codCateg", |
196
|
|
|
$itdps->codcateg, |
197
|
|
|
true |
198
|
|
|
); |
199
|
|
|
|
200
|
|
|
if (!empty($itdps->dpsperapur)) { |
201
|
|
|
foreach ($itdps->dpsperapur as $dpsapp) { |
202
|
|
|
$dpsPerApur = $this->dom->createElement("dpsPerApur"); |
203
|
|
|
$this->dom->addChild( |
204
|
|
|
$dpsPerApur, |
205
|
|
|
"tpDps", |
206
|
|
|
$dpsapp->tpdps, |
207
|
|
|
true |
208
|
|
|
); |
209
|
|
|
$this->dom->addChild( |
210
|
|
|
$dpsPerApur, |
211
|
|
|
"dpsFGTS", |
212
|
|
|
number_format($dpsapp->dpsfgts, 2, ".", ""), |
213
|
|
|
true |
214
|
|
|
); |
215
|
|
|
$infoTrabDps->appendChild($dpsPerApur); |
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
if (!empty($itdps->infodpsperante)) { |
220
|
|
|
foreach ($itdps->infodpsperante as $ipae) { |
221
|
|
|
$infoDpsPerAntE = $this->dom->createElement("infoDpsPerAntE"); |
222
|
|
|
$this->dom->addChild( |
223
|
|
|
$infoDpsPerAntE, |
224
|
|
|
"perRef", |
225
|
|
|
$ipae->perref, |
226
|
|
|
true |
227
|
|
|
); |
228
|
|
|
foreach ($ipae->dpsperante as $dpspae) { |
229
|
|
|
$dpsPerAntE = $this->dom->createElement("dpsPerAntE"); |
230
|
|
|
$this->dom->addChild( |
231
|
|
|
$dpsPerAntE, |
232
|
|
|
"tpDpsE", |
233
|
|
|
$dpspae->tpdpse, |
234
|
|
|
true |
235
|
|
|
); |
236
|
|
|
$this->dom->addChild( |
237
|
|
|
$dpsPerAntE, |
238
|
|
|
"dpsFGTSE", |
239
|
|
|
number_format($dpspae->dpsfgtse, 2, ".", ""), |
240
|
|
|
true |
241
|
|
|
); |
242
|
|
|
$infoDpsPerAntE->appendChild($dpsPerAntE); |
243
|
|
|
} |
244
|
|
|
$infoTrabDps->appendChild($infoDpsPerAntE); |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
$infoDpsFGTS->appendChild($infoTrabDps); |
248
|
|
|
} |
249
|
|
|
$infoFGTS->appendChild($infoDpsFGTS); |
250
|
|
|
} |
251
|
|
|
$this->node->appendChild($infoFGTS); |
252
|
|
|
} |
253
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
254
|
|
|
//$this->xml = $this->dom->saveXML($this->node); |
255
|
|
|
$this->sign(); |
|
|
|
|
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* builder for version S.1.0.0 |
260
|
|
|
*/ |
261
|
|
|
protected function toNodeS100() |
262
|
|
|
{ |
263
|
|
|
throw new \Exception("TODO !!"); |
264
|
|
|
} |
265
|
|
|
} |
266
|
|
|
|
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: