|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
|
4
|
|
|
|
|
5
|
|
|
trait TraitS5001 |
|
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
|
|
|
"indApuracao", |
|
25
|
|
|
$this->std->indapuracao, |
|
26
|
|
|
true |
|
27
|
|
|
); |
|
28
|
|
|
$this->dom->addChild( |
|
29
|
|
|
$ideEvento, |
|
30
|
|
|
"perApur", |
|
31
|
|
|
$this->std->perapur, |
|
32
|
|
|
true |
|
33
|
|
|
); |
|
34
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
|
35
|
|
|
|
|
36
|
|
|
$ideTrabalhador = $this->dom->createElement("ideTrabalhador"); |
|
37
|
|
|
$this->dom->addChild( |
|
38
|
|
|
$ideTrabalhador, |
|
39
|
|
|
"cpfTrab", |
|
40
|
|
|
$this->std->cpftrab, |
|
41
|
|
|
true |
|
42
|
|
|
); |
|
43
|
|
|
if (isset($this->std->procjudtrab)) { |
|
44
|
|
|
foreach ($this->std->procjudtrab as $proc) { |
|
45
|
|
|
$procJudTrab = $this->dom->createElement("procJudTrab"); |
|
46
|
|
|
$this->dom->addChild( |
|
47
|
|
|
$procJudTrab, |
|
48
|
|
|
"nrProcJud", |
|
49
|
|
|
$proc->nrprocjud, |
|
50
|
|
|
true |
|
51
|
|
|
); |
|
52
|
|
|
$this->dom->addChild( |
|
53
|
|
|
$procJudTrab, |
|
54
|
|
|
"codSusp", |
|
55
|
|
|
$proc->codsusp, |
|
56
|
|
|
true |
|
57
|
|
|
); |
|
58
|
|
|
$ideTrabalhador->appendChild($procJudTrab); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
$this->node->appendChild($ideTrabalhador); |
|
62
|
|
|
|
|
63
|
|
|
if (isset($this->std->infocpcalc)) { |
|
64
|
|
|
foreach ($this->std->infocpcalc as $info) { |
|
65
|
|
|
$infoCpCalc = $this->dom->createElement("infoCpCalc"); |
|
66
|
|
|
$this->dom->addChild( |
|
67
|
|
|
$infoCpCalc, |
|
68
|
|
|
"tpCR", |
|
69
|
|
|
$info->tpcr, |
|
70
|
|
|
true |
|
71
|
|
|
); |
|
72
|
|
|
$this->dom->addChild( |
|
73
|
|
|
$infoCpCalc, |
|
74
|
|
|
"vrCpSeg", |
|
75
|
|
|
$info->vrcpseg, |
|
76
|
|
|
true |
|
77
|
|
|
); |
|
78
|
|
|
$this->dom->addChild( |
|
79
|
|
|
$infoCpCalc, |
|
80
|
|
|
"vrDescSeg", |
|
81
|
|
|
$info->vrdescseg, |
|
82
|
|
|
true |
|
83
|
|
|
); |
|
84
|
|
|
$this->node->appendChild($infoCpCalc); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$infoCp = $this->dom->createElement("infoCp"); |
|
89
|
|
|
foreach ($this->std->ideestablot as $ideest) { |
|
90
|
|
|
$ideEstabLot = $this->dom->createElement("ideEstabLot"); |
|
91
|
|
|
$this->dom->addChild( |
|
92
|
|
|
$ideEstabLot, |
|
93
|
|
|
"tpInsc", |
|
94
|
|
|
$ideest->tpinsc, |
|
95
|
|
|
true |
|
96
|
|
|
); |
|
97
|
|
|
$this->dom->addChild( |
|
98
|
|
|
$ideEstabLot, |
|
99
|
|
|
"nrInsc", |
|
100
|
|
|
$ideest->nrinsc, |
|
101
|
|
|
true |
|
102
|
|
|
); |
|
103
|
|
|
$this->dom->addChild( |
|
104
|
|
|
$ideEstabLot, |
|
105
|
|
|
"codLotacao", |
|
106
|
|
|
$ideest->codlotacao, |
|
107
|
|
|
true |
|
108
|
|
|
); |
|
109
|
|
|
foreach ($ideest->infocategincid as $infocat) { |
|
110
|
|
|
$infoCategIncid = $this->dom->createElement("infoCategIncid"); |
|
111
|
|
|
$this->dom->addChild( |
|
112
|
|
|
$infoCategIncid, |
|
113
|
|
|
"matricula", |
|
114
|
|
|
! empty($infocat->matricula) ? $infocat->matricula : null, |
|
115
|
|
|
false |
|
116
|
|
|
); |
|
117
|
|
|
$this->dom->addChild( |
|
118
|
|
|
$infoCategIncid, |
|
119
|
|
|
"codCateg", |
|
120
|
|
|
$infocat->codcateg, |
|
121
|
|
|
true |
|
122
|
|
|
); |
|
123
|
|
|
$this->dom->addChild( |
|
124
|
|
|
$infoCategIncid, |
|
125
|
|
|
"indSimples", |
|
126
|
|
|
! empty($infocat->indsimples) ? $infocat->indsimples : null, |
|
127
|
|
|
false |
|
128
|
|
|
); |
|
129
|
|
|
foreach ($infocat->infobasecs as $infobase) { |
|
130
|
|
|
$infoBaseCS = $this->dom->createElement("infoBaseCS"); |
|
131
|
|
|
$this->dom->addChild( |
|
132
|
|
|
$infoBaseCS, |
|
133
|
|
|
"ind13", |
|
134
|
|
|
$infobase->ind13, |
|
135
|
|
|
true |
|
136
|
|
|
); |
|
137
|
|
|
$this->dom->addChild( |
|
138
|
|
|
$infoBaseCS, |
|
139
|
|
|
"tpValor", |
|
140
|
|
|
$infobase->tpvalor, |
|
141
|
|
|
true |
|
142
|
|
|
); |
|
143
|
|
|
$this->dom->addChild( |
|
144
|
|
|
$infoBaseCS, |
|
145
|
|
|
"valor", |
|
146
|
|
|
$infobase->valor, |
|
147
|
|
|
true |
|
148
|
|
|
); |
|
149
|
|
|
$infoCategIncid->appendChild($infoBaseCS); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
if (isset($infocat->calcterc)) { |
|
153
|
|
|
foreach ($infocat->calcterc as $cT) { |
|
154
|
|
|
$calcTerc = $this->dom->createElement("calcTerc"); |
|
155
|
|
|
$this->dom->addChild( |
|
156
|
|
|
$calcTerc, |
|
157
|
|
|
"tpCR", |
|
158
|
|
|
$cT->tpcr, |
|
159
|
|
|
true |
|
160
|
|
|
); |
|
161
|
|
|
$this->dom->addChild( |
|
162
|
|
|
$calcTerc, |
|
163
|
|
|
"vrCsSegTerc", |
|
164
|
|
|
$cT->vrcssegterc, |
|
165
|
|
|
true |
|
166
|
|
|
); |
|
167
|
|
|
$this->dom->addChild( |
|
168
|
|
|
$calcTerc, |
|
169
|
|
|
"vrDescTerc", |
|
170
|
|
|
$cT->vrdescterc, |
|
171
|
|
|
true |
|
172
|
|
|
); |
|
173
|
|
|
$infoCategIncid->appendChild($calcTerc); |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
if (isset($infocat->infoperref)) { |
|
177
|
|
|
foreach ($infocat->infoperref as $iref) { |
|
178
|
|
|
$inforef = $this->dom->createElement("infoPerRef"); |
|
179
|
|
|
$this->dom->addChild( |
|
180
|
|
|
$inforef, |
|
181
|
|
|
"perRef", |
|
182
|
|
|
$iref->perRef, |
|
183
|
|
|
true |
|
184
|
|
|
); |
|
185
|
|
|
foreach ($iref->detinfoperref as $dref) { |
|
186
|
|
|
$detref = $this->dom->createElement("detInfoPerRef"); |
|
187
|
|
|
$this->dom->addChild( |
|
188
|
|
|
$detref, |
|
189
|
|
|
"ind13", |
|
190
|
|
|
$dref->ind13, |
|
191
|
|
|
true |
|
192
|
|
|
); |
|
193
|
|
|
$this->dom->addChild( |
|
194
|
|
|
$detref, |
|
195
|
|
|
"tpValor", |
|
196
|
|
|
$dref->tpvalor, |
|
197
|
|
|
true |
|
198
|
|
|
); |
|
199
|
|
|
$this->dom->addChild( |
|
200
|
|
|
$detref, |
|
201
|
|
|
"vrPerRef", |
|
202
|
|
|
$dref->vrperref, |
|
203
|
|
|
true |
|
204
|
|
|
); |
|
205
|
|
|
$inforef->appendChild($detref); |
|
206
|
|
|
} |
|
207
|
|
|
$infoCategIncid->appendChild($inforef); |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
$ideEstabLot->appendChild($infoCategIncid); |
|
211
|
|
|
} |
|
212
|
|
|
$infoCp->appendChild($ideEstabLot); |
|
213
|
|
|
} |
|
214
|
|
|
$this->node->appendChild($infoCp); |
|
215
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
|
|
216
|
|
|
//$this->xml = $this->dom->saveXML($this->node); |
|
217
|
|
|
$this->sign(); |
|
|
|
|
|
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* builder for version S.1.0.0 |
|
222
|
|
|
*/ |
|
223
|
|
|
protected function toNodeS100() |
|
224
|
|
|
{ |
|
225
|
|
|
throw new \Exception("TODO !!"); |
|
226
|
|
|
} |
|
227
|
|
|
} |
|
228
|
|
|
|
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: