1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class eSocial EvtTabRubrica Event S-1010 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 EvtTabRubrica extends Factory implements FactoryInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
public $sequencial; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $evtName = 'evtTabRubrica'; |
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $evtAlias = 'S-1010'; |
39
|
|
|
/** |
40
|
|
|
* Parameters patterns |
41
|
|
|
* @var array |
42
|
|
|
*/ |
43
|
|
|
protected $parameters = []; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Constructor |
47
|
|
|
* @param string $config |
48
|
|
|
* @param stdClass $std |
49
|
|
|
* @param Certificate $certificate |
50
|
|
|
*/ |
51
|
|
|
public function __construct( |
52
|
|
|
$config, |
53
|
|
|
stdClass $std, |
54
|
|
|
Certificate $certificate |
55
|
|
|
) { |
56
|
|
|
parent::__construct($config, $std, $certificate); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Node constructor |
61
|
|
|
*/ |
62
|
|
|
protected function toNode() |
63
|
|
|
{ |
64
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
65
|
|
|
//o idEvento pode variar de evento para evento |
66
|
|
|
//então cada factory individualmente terá de construir o seu |
67
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
68
|
|
|
$this->dom->addChild( |
69
|
|
|
$ideEvento, |
70
|
|
|
"tpAmb", |
71
|
|
|
$this->tpAmb, |
72
|
|
|
true |
73
|
|
|
); |
74
|
|
|
$this->dom->addChild( |
75
|
|
|
$ideEvento, |
76
|
|
|
"procEmi", |
77
|
|
|
$this->procEmi, |
78
|
|
|
true |
79
|
|
|
); |
80
|
|
|
$this->dom->addChild( |
81
|
|
|
$ideEvento, |
82
|
|
|
"verProc", |
83
|
|
|
$this->verProc, |
84
|
|
|
true |
85
|
|
|
); |
86
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
87
|
|
|
|
88
|
|
|
//tag deste evento em particular |
89
|
|
|
$infoRubrica = $this->dom->createElement("infoRubrica"); |
90
|
|
|
//tag comum a todos os modos |
91
|
|
|
$ideRubrica = $this->dom->createElement("ideRubrica"); |
92
|
|
|
$this->dom->addChild( |
93
|
|
|
$ideRubrica, |
94
|
|
|
"codRubr", |
95
|
|
|
$this->std->codrubr, |
96
|
|
|
true |
97
|
|
|
); |
98
|
|
|
$this->dom->addChild( |
99
|
|
|
$ideRubrica, |
100
|
|
|
"ideTabRubr", |
101
|
|
|
$this->std->idetabrubr, |
102
|
|
|
true |
103
|
|
|
); |
104
|
|
|
$this->dom->addChild( |
105
|
|
|
$ideRubrica, |
106
|
|
|
"iniValid", |
107
|
|
|
$this->std->inivalid, |
108
|
|
|
true |
109
|
|
|
); |
110
|
|
|
$this->dom->addChild( |
111
|
|
|
$ideRubrica, |
112
|
|
|
"fimValid", |
113
|
|
|
!empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
114
|
|
|
false |
115
|
|
|
); |
116
|
|
|
//seleção do modo |
117
|
|
|
if ($this->std->modo == 'INC') { |
118
|
|
|
$node = $this->dom->createElement("inclusao"); |
119
|
|
|
} elseif ($this->std->modo == 'ALT') { |
120
|
|
|
$node = $this->dom->createElement("alteracao"); |
121
|
|
|
} else { |
122
|
|
|
$node = $this->dom->createElement("exclusao"); |
123
|
|
|
} |
124
|
|
|
$node->appendChild($ideRubrica); |
125
|
|
|
|
126
|
|
|
if (!empty($this->std->dadosrubrica)) { |
127
|
|
|
$dadosRubrica = $this->dom->createElement("dadosRubrica"); |
128
|
|
|
$this->dom->addChild( |
129
|
|
|
$dadosRubrica, |
130
|
|
|
"dscRubr", |
131
|
|
|
$this->std->dadosrubrica->dscrubr, |
132
|
|
|
true |
133
|
|
|
); |
134
|
|
|
$this->dom->addChild( |
135
|
|
|
$dadosRubrica, |
136
|
|
|
"natRubr", |
137
|
|
|
$this->std->dadosrubrica->natrubr, |
138
|
|
|
true |
139
|
|
|
); |
140
|
|
|
$this->dom->addChild( |
141
|
|
|
$dadosRubrica, |
142
|
|
|
"tpRubr", |
143
|
|
|
$this->std->dadosrubrica->tprubr, |
144
|
|
|
true |
145
|
|
|
); |
146
|
|
|
$this->dom->addChild( |
147
|
|
|
$dadosRubrica, |
148
|
|
|
"codIncCP", |
149
|
|
|
$this->std->dadosrubrica->codinccp, |
150
|
|
|
true |
151
|
|
|
); |
152
|
|
|
$this->dom->addChild( |
153
|
|
|
$dadosRubrica, |
154
|
|
|
"codIncIRRF", |
155
|
|
|
$this->std->dadosrubrica->codincirrf, |
156
|
|
|
true |
157
|
|
|
); |
158
|
|
|
$this->dom->addChild( |
159
|
|
|
$dadosRubrica, |
160
|
|
|
"codIncFGTS", |
161
|
|
|
$this->std->dadosrubrica->codincfgts, |
162
|
|
|
true |
163
|
|
|
); |
164
|
|
|
$this->dom->addChild( |
165
|
|
|
$dadosRubrica, |
166
|
|
|
"codIncSIND", |
167
|
|
|
$this->std->dadosrubrica->codincsind, |
168
|
|
|
true |
169
|
|
|
); |
170
|
|
|
$this->dom->addChild( |
171
|
|
|
$dadosRubrica, |
172
|
|
|
"repDSR", |
173
|
|
|
$this->std->dadosrubrica->repdsr, |
174
|
|
|
true |
175
|
|
|
); |
176
|
|
|
$this->dom->addChild( |
177
|
|
|
$dadosRubrica, |
178
|
|
|
"rep13", |
179
|
|
|
$this->std->dadosrubrica->rep13, |
180
|
|
|
true |
181
|
|
|
); |
182
|
|
|
$this->dom->addChild( |
183
|
|
|
$dadosRubrica, |
184
|
|
|
"repFerias", |
185
|
|
|
$this->std->dadosrubrica->repferias, |
186
|
|
|
true |
187
|
|
|
); |
188
|
|
|
$this->dom->addChild( |
189
|
|
|
$dadosRubrica, |
190
|
|
|
"repAviso", |
191
|
|
|
$this->std->dadosrubrica->repaviso, |
192
|
|
|
true |
193
|
|
|
); |
194
|
|
|
$this->dom->addChild( |
195
|
|
|
$dadosRubrica, |
196
|
|
|
"observacao", |
197
|
|
|
!empty($this->std->dadosrubrica->observacao) |
198
|
|
|
? $this->std->dadosrubrica->observacao |
199
|
|
|
: null, |
200
|
|
|
false |
201
|
|
|
); |
202
|
|
|
|
203
|
|
|
if (!empty($this->std->dadosrubrica->ideprocessocp)) { |
204
|
|
|
foreach ($this->std->dadosrubrica->ideprocessocp as $cp) { |
205
|
|
|
$ideProcessoCP = $this->dom->createElement("ideProcessoCP"); |
206
|
|
|
$this->dom->addChild( |
207
|
|
|
$ideProcessoCP, |
208
|
|
|
"tpProc", |
209
|
|
|
$cp->tpproc, |
210
|
|
|
true |
211
|
|
|
); |
212
|
|
|
$this->dom->addChild( |
213
|
|
|
$ideProcessoCP, |
214
|
|
|
"nrProc", |
215
|
|
|
$cp->nrproc, |
216
|
|
|
true |
217
|
|
|
); |
218
|
|
|
$this->dom->addChild( |
219
|
|
|
$ideProcessoCP, |
220
|
|
|
"extDecisao", |
221
|
|
|
$cp->extdecisao, |
222
|
|
|
true |
223
|
|
|
); |
224
|
|
|
$this->dom->addChild( |
225
|
|
|
$ideProcessoCP, |
226
|
|
|
"codSusp", |
227
|
|
|
$cp->codsusp, |
228
|
|
|
true |
229
|
|
|
); |
230
|
|
|
$dadosRubrica->appendChild($ideProcessoCP); |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
if (!empty($this->std->dadosrubrica->ideprocessoirrf)) { |
235
|
|
|
foreach ($this->std->dadosrubrica->ideprocessoirrf as $irrf) { |
236
|
|
|
$ideProcessoIRRF = $this->dom->createElement("ideProcessoIRRF"); |
237
|
|
|
$this->dom->addChild( |
238
|
|
|
$ideProcessoIRRF, |
239
|
|
|
"nrProc", |
240
|
|
|
$irrf->nrproc, |
241
|
|
|
true |
242
|
|
|
); |
243
|
|
|
$this->dom->addChild( |
244
|
|
|
$ideProcessoIRRF, |
245
|
|
|
"codSusp", |
246
|
|
|
$irrf->codsusp, |
247
|
|
|
true |
248
|
|
|
); |
249
|
|
|
$dadosRubrica->appendChild($ideProcessoIRRF); |
250
|
|
|
} |
251
|
|
|
} |
252
|
|
|
if (!empty($this->std->dadosrubrica->ideprocessofgts)) { |
253
|
|
|
foreach ($this->std->dadosrubrica->ideprocessofgts as $fgts) { |
254
|
|
|
$ideProcessoFGTS = $this->dom->createElement("ideProcessoFGTS"); |
255
|
|
|
$this->dom->addChild( |
256
|
|
|
$ideProcessoFGTS, |
257
|
|
|
"nrProc", |
258
|
|
|
$fgts->nrproc, |
259
|
|
|
true |
260
|
|
|
); |
261
|
|
|
$this->dom->addChild( |
262
|
|
|
$ideProcessoFGTS, |
263
|
|
|
"codSusp", |
264
|
|
|
$fgts->codsusp, |
265
|
|
|
true |
266
|
|
|
); |
267
|
|
|
$dadosRubrica->appendChild($ideProcessoFGTS); |
268
|
|
|
} |
269
|
|
|
} |
270
|
|
|
if (!empty($this->std->dadosrubrica->ideprocessosind)) { |
271
|
|
|
foreach ($this->std->dadosrubrica->ideprocessosind as $sind) { |
272
|
|
|
$ideProcessoSIND = $this->dom->createElement("ideProcessoSIND"); |
273
|
|
|
$this->dom->addChild( |
274
|
|
|
$ideProcessoSIND, |
275
|
|
|
"nrProc", |
276
|
|
|
$sind->nrproc, |
277
|
|
|
true |
278
|
|
|
); |
279
|
|
|
$this->dom->addChild( |
280
|
|
|
$ideProcessoSIND, |
281
|
|
|
"codSusp", |
282
|
|
|
$sind->codsusp, |
283
|
|
|
true |
284
|
|
|
); |
285
|
|
|
$dadosRubrica->appendChild($ideProcessoSIND); |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
$node->appendChild($dadosRubrica); |
289
|
|
|
} |
290
|
|
|
if (!empty($this->std->novavalidade) && $this->std->modo == 'ALT') { |
291
|
|
|
$newVal = $this->std->novavalidade; |
292
|
|
|
$novaValidade = $this->dom->createElement("novaValidade"); |
293
|
|
|
$this->dom->addChild( |
294
|
|
|
$ideRubrica, |
295
|
|
|
"iniValid", |
296
|
|
|
$newVal->inivalid, |
297
|
|
|
true |
298
|
|
|
); |
299
|
|
|
$this->dom->addChild( |
300
|
|
|
$ideRubrica, |
301
|
|
|
"fimValid", |
302
|
|
|
!empty($newVal->fimvalid) ? $newVal->fimvalid : null, |
303
|
|
|
false |
304
|
|
|
); |
305
|
|
|
$node->appendChild($novaValidade); |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
//finalização do xml |
309
|
|
|
$infoRubrica->appendChild($node); |
310
|
|
|
$this->node->appendChild($infoRubrica); |
311
|
|
|
$this->eSocial->appendChild($this->node); |
312
|
|
|
$this->sign(); |
313
|
|
|
} |
314
|
|
|
} |
315
|
|
|
|