1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class eSocial EvtAfastTemp Event S-2230 constructor |
7
|
|
|
* |
8
|
|
|
* @category NFePHP |
9
|
|
|
* @package NFePHPSocial |
10
|
|
|
* @copyright NFePHP Copyright (c) 2017 |
11
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPLv3+ |
12
|
|
|
* @license https://opensource.org/licenses/MIT MIT |
13
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+ |
14
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
15
|
|
|
* @link http://github.com/nfephp-org/sped-esocial for the canonical source repository |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
use NFePHP\eSocial\Common\Factory; |
19
|
|
|
use NFePHP\eSocial\Common\FactoryInterface; |
20
|
|
|
use NFePHP\eSocial\Common\FactoryId; |
21
|
|
|
use NFePHP\Common\Certificate; |
22
|
|
|
use stdClass; |
23
|
|
|
|
24
|
|
|
class EvtAfastTemp extends Factory implements FactoryInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
public $sequencial; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $evtName = 'evtAfastTemp'; |
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $evtAlias = 'S-2230'; |
39
|
|
|
/** |
40
|
|
|
* Parameters patterns |
41
|
|
|
* |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $parameters = []; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Constructor |
48
|
|
|
* |
49
|
|
|
* @param string $config |
50
|
|
|
* @param stdClass $std |
51
|
|
|
* @param Certificate $certificate |
52
|
|
|
*/ |
53
|
|
|
public function __construct( |
54
|
|
|
$config, |
55
|
|
|
stdClass $std, |
56
|
|
|
Certificate $certificate |
57
|
|
|
) { |
58
|
|
|
parent::__construct($config, $std, $certificate); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Node constructor |
63
|
|
|
*/ |
64
|
|
|
protected function toNode() |
65
|
|
|
{ |
66
|
|
|
$evtid = FactoryId::build( |
67
|
|
|
$this->tpInsc, |
68
|
|
|
$this->nrInsc, |
69
|
|
|
$this->date, |
70
|
|
|
$this->sequencial |
71
|
|
|
); |
72
|
|
|
|
73
|
|
|
$evtAfastTemp = $this->dom->createElement("evtAfastTemp"); |
74
|
|
|
|
75
|
|
|
$att = $this->dom->createAttribute('Id'); |
76
|
|
|
|
77
|
|
|
$att->value = $evtid; |
78
|
|
|
|
79
|
|
|
$evtAfastTemp->appendChild($att); |
80
|
|
|
|
81
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
82
|
|
|
|
83
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
84
|
|
|
$this->dom->addChild( |
85
|
|
|
$ideEvento, |
86
|
|
|
"indRetif", |
87
|
|
|
$this->std->indretif, |
88
|
|
|
true |
89
|
|
|
); |
90
|
|
|
$this->dom->addChild( |
91
|
|
|
$ideEvento, |
92
|
|
|
"tpAmb", |
93
|
|
|
$this->tpAmb, |
94
|
|
|
true |
95
|
|
|
); |
96
|
|
|
$this->dom->addChild( |
97
|
|
|
$ideEvento, |
98
|
|
|
"procEmi", |
99
|
|
|
$this->procEmi, |
100
|
|
|
true |
101
|
|
|
); |
102
|
|
|
$this->dom->addChild( |
103
|
|
|
$ideEvento, |
104
|
|
|
"verProc", |
105
|
|
|
$this->verProc, |
106
|
|
|
true |
107
|
|
|
); |
108
|
|
|
$evtAfastTemp->appendChild($ideEvento); |
109
|
|
|
|
110
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
111
|
|
|
|
112
|
|
|
$ideVinculo = $this->dom->createElement("ideVinculo"); |
113
|
|
|
|
114
|
|
|
$this->dom->addChild( |
115
|
|
|
$ideVinculo, |
116
|
|
|
"cpfTrab", |
117
|
|
|
$this->std->idevinculo->cpftrab, |
118
|
|
|
true |
119
|
|
|
); |
120
|
|
|
$this->dom->addChild( |
121
|
|
|
$ideVinculo, |
122
|
|
|
"nisTrab", |
123
|
|
|
$this->std->idevinculo->nistrab, |
124
|
|
|
true |
125
|
|
|
); |
126
|
|
|
$this->dom->addChild( |
127
|
|
|
$ideVinculo, |
128
|
|
|
"matricula", |
129
|
|
|
$this->std->idevinculo->matricula, |
130
|
|
|
true |
131
|
|
|
); |
132
|
|
|
$this->dom->addChild( |
133
|
|
|
$ideVinculo, |
134
|
|
|
"codCateg", |
135
|
|
|
!empty($this->std->idevinculo->codcateg) ? $this->std->idevinculo->codcateg : null, |
136
|
|
|
false |
137
|
|
|
); |
138
|
|
|
$this->node->appendChild($ideVinculo); |
139
|
|
|
|
140
|
|
|
$infoAfastamento = $this->dom->createElement("infoAfastamento"); |
141
|
|
|
|
142
|
|
|
$iniAfastamento = $this->dom->createElement("iniAfastamento"); |
143
|
|
|
|
144
|
|
|
$this->dom->addChild( |
145
|
|
|
$iniAfastamento, |
146
|
|
|
"dtIniAfast", |
147
|
|
|
$this->std->iniafastamento->dtiniafast, |
148
|
|
|
true |
149
|
|
|
); |
150
|
|
|
|
151
|
|
|
$this->dom->addChild( |
152
|
|
|
$iniAfastamento, |
153
|
|
|
"codMotAfast", |
154
|
|
|
$this->std->iniafastamento->codmotafast, |
155
|
|
|
true |
156
|
|
|
); |
157
|
|
|
|
158
|
|
|
$this->dom->addChild( |
159
|
|
|
$iniAfastamento, |
160
|
|
|
"infoMesmoMtv", |
161
|
|
|
!empty($this->std->iniafastamento->infomesmomtv) ? $this->std->iniafastamento->infomesmomtv : null, |
162
|
|
|
false |
163
|
|
|
); |
164
|
|
|
|
165
|
|
|
$this->dom->addChild( |
166
|
|
|
$iniAfastamento, |
167
|
|
|
"tpAcidTransito", |
168
|
|
|
!empty($this->std->iniafastamento->tpacidtransito) ? $this->std->iniafastamento->tpacidtransito : null, |
169
|
|
|
false |
170
|
|
|
); |
171
|
|
|
|
172
|
|
|
$this->dom->addChild( |
173
|
|
|
$iniAfastamento, |
174
|
|
|
"observacao", |
175
|
|
|
!empty($this->std->iniafastamento->observacao) ? $this->std->iniafastamento->observacao : null, |
176
|
|
|
false |
177
|
|
|
); |
178
|
|
|
|
179
|
|
|
if (isset($this->std->iniafastamento->infoatestado)) { |
180
|
|
|
foreach ($this->std->iniafastamento->infoatestado as $info) { |
181
|
|
|
$infoAtestado = $this->dom->createElement("infoAtestado"); |
182
|
|
|
|
183
|
|
|
$this->dom->addChild( |
184
|
|
|
$infoAtestado, |
185
|
|
|
"codCID", |
186
|
|
|
!empty($info->codcid) ? $info->codcid : null, |
187
|
|
|
false |
188
|
|
|
); |
189
|
|
|
|
190
|
|
|
$this->dom->addChild( |
191
|
|
|
$infoAtestado, |
192
|
|
|
"qtdDiasAfast", |
193
|
|
|
$info->qtddiasafast, |
194
|
|
|
true |
195
|
|
|
); |
196
|
|
|
|
197
|
|
|
if (isset($info->emitente)) { |
198
|
|
|
|
199
|
|
|
$emitente = $this->dom->createElement("emitente"); |
200
|
|
|
|
201
|
|
|
$this->dom->addChild( |
202
|
|
|
$emitente, |
203
|
|
|
"nmEmit", |
204
|
|
|
$info->emitente->nmemit, |
205
|
|
|
true |
206
|
|
|
); |
207
|
|
|
|
208
|
|
|
$this->dom->addChild( |
209
|
|
|
$emitente, |
210
|
|
|
"ideOC", |
211
|
|
|
$info->emitente->ideoc, |
212
|
|
|
true |
213
|
|
|
); |
214
|
|
|
|
215
|
|
|
$this->dom->addChild( |
216
|
|
|
$emitente, |
217
|
|
|
"nrOc", |
218
|
|
|
$info->emitente->nroc, |
219
|
|
|
true |
220
|
|
|
); |
221
|
|
|
|
222
|
|
|
$this->dom->addChild( |
223
|
|
|
$emitente, |
224
|
|
|
"ufOC", |
225
|
|
|
!empty($info->emitente->ufoc) ? $info->emitente->ufoc : null, |
226
|
|
|
false |
227
|
|
|
); |
228
|
|
|
|
229
|
|
|
$infoAtestado->appendChild($emitente); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
$iniAfastamento->appendChild($infoAtestado); |
233
|
|
|
} |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
if (!empty($this->std->infocessao)) { |
237
|
|
|
$infoCessao = $this->dom->createElement("infoCessao"); |
238
|
|
|
|
239
|
|
|
$this->dom->addChild( |
240
|
|
|
$infoCessao, |
241
|
|
|
"cnpjCess", |
242
|
|
|
$this->std->infocessao->cnpjcess, |
243
|
|
|
true |
244
|
|
|
); |
245
|
|
|
|
246
|
|
|
$this->dom->addChild( |
247
|
|
|
$infoCessao, |
248
|
|
|
"infOnus", |
249
|
|
|
$this->std->infocessao->infonus, |
250
|
|
|
true |
251
|
|
|
); |
252
|
|
|
|
253
|
|
|
$iniAfastamento->appendChild($infoCessao); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
if (!empty($this->std->infomandsind)) { |
257
|
|
|
$infoMandSind = $this->dom->createElement("infoMandSind"); |
258
|
|
|
|
259
|
|
|
$this->dom->addChild( |
260
|
|
|
$infoMandSind, |
261
|
|
|
"cnpjSind", |
262
|
|
|
$this->std->infomandsind->cnpjsind, |
263
|
|
|
true |
264
|
|
|
); |
265
|
|
|
|
266
|
|
|
$this->dom->addChild( |
267
|
|
|
$infoMandSind, |
268
|
|
|
"infOnusRemun", |
269
|
|
|
$this->std->infomandsind->infonusremun, |
270
|
|
|
true |
271
|
|
|
); |
272
|
|
|
|
273
|
|
|
$iniAfastamento->appendChild($infoMandSind); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
$infoAfastamento->appendChild($iniAfastamento); |
277
|
|
|
|
278
|
|
|
if (!empty($this->std->inforetif)) { |
279
|
|
|
$infoRetif = $this->dom->createElement("infoRetif"); |
280
|
|
|
|
281
|
|
|
$this->dom->addChild( |
282
|
|
|
$infoRetif, |
283
|
|
|
"origRetif", |
284
|
|
|
$this->std->inforetif->origretif, |
285
|
|
|
true |
286
|
|
|
); |
287
|
|
|
|
288
|
|
|
$this->dom->addChild( |
289
|
|
|
$infoRetif, |
290
|
|
|
"tpProc", |
291
|
|
|
$this->std->inforetif->tpproc, |
292
|
|
|
true |
293
|
|
|
); |
294
|
|
|
|
295
|
|
|
$this->dom->addChild( |
296
|
|
|
$infoRetif, |
297
|
|
|
"nrProc", |
298
|
|
|
!empty($this->std->inforetif->nrproc) ? $this->std->inforetif->nrproc : null, |
299
|
|
|
false |
300
|
|
|
); |
301
|
|
|
|
302
|
|
|
$infoAfastamento->appendChild($infoRetif); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
if (!empty($this->std->fimafastamento)) { |
306
|
|
|
$fimAfastamento = $this->dom->createElement("fimAfastamento"); |
307
|
|
|
|
308
|
|
|
$this->dom->addChild( |
309
|
|
|
$fimAfastamento, |
310
|
|
|
"dtTermAfast", |
311
|
|
|
$this->std->fimafastamento->dttermafast, |
312
|
|
|
true |
313
|
|
|
); |
314
|
|
|
|
315
|
|
|
$this->dom->addChild( |
316
|
|
|
$fimAfastamento, |
317
|
|
|
"codMotAfast", |
318
|
|
|
$this->std->fimafastamento->codmotafast, |
319
|
|
|
true |
320
|
|
|
); |
321
|
|
|
|
322
|
|
|
|
323
|
|
|
$infoAfastamento->appendChild($fimAfastamento); |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
$this->node->appendChild($infoAfastamento); |
327
|
|
|
|
328
|
|
|
$this->eSocial->appendChild($this->node); |
329
|
|
|
$this->sign(); |
330
|
|
|
} |
331
|
|
|
} |
332
|
|
|
|