1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class eSocial EvtTabEstab Event S-1005 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 EvtTabEstab extends Factory implements FactoryInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
public $sequencial; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $evtName = 'evtTabEstab'; |
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $evtAlias = 'S-1005'; |
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
|
|
|
$infoEstab = $this->dom->createElement("infoEstab"); |
|
|
|
|
90
|
|
|
|
91
|
|
|
//tag comum a todos os modos |
92
|
|
|
$ideEstab = $this->dom->createElement("ideEstab"); |
93
|
|
|
$this->dom->addChild( |
94
|
|
|
$ideEstab, |
95
|
|
|
"tpInsc", |
96
|
|
|
$this->std->tpinsc, |
97
|
|
|
true |
98
|
|
|
); |
99
|
|
|
$this->dom->addChild( |
100
|
|
|
$ideEstab, |
101
|
|
|
"nrInsc", |
102
|
|
|
$this->std->nrinsc, |
103
|
|
|
true |
104
|
|
|
); |
105
|
|
|
$this->dom->addChild( |
106
|
|
|
$ideEstab, |
107
|
|
|
"iniValid", |
108
|
|
|
$this->std->inivalid, |
109
|
|
|
true |
110
|
|
|
); |
111
|
|
|
$this->dom->addChild( |
112
|
|
|
$ideEstab, |
113
|
|
|
"fimValid", |
114
|
|
|
!empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
115
|
|
|
false |
116
|
|
|
); |
117
|
|
|
|
118
|
|
|
if ($this->std->modo == 'INC') { |
119
|
|
|
$node = $this->dom->createElement("inclusao"); |
120
|
|
|
} elseif ($this->std->modo == 'ALT') { |
121
|
|
|
$node = $this->dom->createElement("alteracao"); |
122
|
|
|
} else { |
123
|
|
|
$node = $this->dom->createElement("exclusao"); |
124
|
|
|
} |
125
|
|
|
$node->appendChild($ideEstab); |
126
|
|
|
|
127
|
|
|
if (!empty($this->std->dadosestab)) { |
128
|
|
|
$dadosEstab = $this->dom->createElement("dadosEstab"); |
129
|
|
|
$this->dom->addChild( |
130
|
|
|
$dadosEstab, |
131
|
|
|
"cnaePrep", |
132
|
|
|
$this->std->dadosestab->cnaeprep, |
133
|
|
|
true |
134
|
|
|
); |
135
|
|
|
$aliqGilrat = $this->dom->createElement("aliqGilrat"); |
136
|
|
|
$this->dom->addChild( |
137
|
|
|
$aliqGilrat, |
138
|
|
|
"aliqRat", |
139
|
|
|
$this->std->dadosestab->aliqgilrat->aliqrat, |
140
|
|
|
true |
141
|
|
|
); |
142
|
|
|
$fap = !empty($this->std->dadosestab->aliqgilrat->fap) ? $this->std->dadosestab->aliqgilrat->fap : null; |
143
|
|
|
if ($fap) { |
144
|
|
|
$fap = number_format($fap, 4, '.', ''); |
145
|
|
|
} |
146
|
|
|
$this->dom->addChild( |
147
|
|
|
$aliqGilrat, |
148
|
|
|
"fap", |
149
|
|
|
$fap, |
150
|
|
|
false |
151
|
|
|
); |
152
|
|
|
$aliqrata = !empty($this->std->dadosestab->aliqgilrat->aliqratajust) |
153
|
|
|
? $this->std->dadosestab->aliqgilrat->aliqratajust |
154
|
|
|
: null; |
155
|
|
|
if ($aliqrata) { |
156
|
|
|
$aliqrata = number_format($aliqrata, 4, '.', ''); |
157
|
|
|
} |
158
|
|
|
$this->dom->addChild( |
159
|
|
|
$aliqGilrat, |
160
|
|
|
"aliqRatAjust", |
161
|
|
|
$aliqrata, |
162
|
|
|
false |
163
|
|
|
); |
164
|
|
|
if (!empty($this->std->dadosestab->aliqgilrat->procadmjudrat)) { |
165
|
|
|
$procAdmJudRat = $this->dom->createElement("procAdmJudRat"); |
166
|
|
|
$this->dom->addChild( |
167
|
|
|
$procAdmJudRat, |
168
|
|
|
"tpProc", |
169
|
|
|
$this->std->dadosestab->aliqgilrat->procadmjudrat->tpproc, |
170
|
|
|
true |
171
|
|
|
); |
172
|
|
|
$this->dom->addChild( |
173
|
|
|
$procAdmJudRat, |
174
|
|
|
"nrProc", |
175
|
|
|
$this->std->dadosestab->aliqgilrat->procadmjudrat->nrproc, |
176
|
|
|
true |
177
|
|
|
); |
178
|
|
|
$this->dom->addChild( |
179
|
|
|
$procAdmJudRat, |
180
|
|
|
"codSusp", |
181
|
|
|
$this->std->dadosestab->aliqgilrat->procadmjudrat->codsusp, |
182
|
|
|
true |
183
|
|
|
); |
184
|
|
|
$aliqGilrat->appendChild($procAdmJudRat); |
185
|
|
|
} |
186
|
|
|
if (!empty($this->std->dadosestab->aliqgilrat->procadmjudfap)) { |
187
|
|
|
$procAdmJudFap = $this->dom->createElement("procAdmJudFap"); |
188
|
|
|
$this->dom->addChild( |
189
|
|
|
$procAdmJudFap, |
190
|
|
|
"tpProc", |
191
|
|
|
$this->std->dadosestab->aliqgilrat->procadmjudfap->tpproc, |
192
|
|
|
true |
193
|
|
|
); |
194
|
|
|
$this->dom->addChild( |
195
|
|
|
$procAdmJudFap, |
196
|
|
|
"nrProc", |
197
|
|
|
$this->std->dadosestab->aliqgilrat->procadmjudfap->nrproc, |
198
|
|
|
true |
199
|
|
|
); |
200
|
|
|
$this->dom->addChild( |
201
|
|
|
$procAdmJudFap, |
202
|
|
|
"codSusp", |
203
|
|
|
$this->std->dadosestab->aliqgilrat->procadmjudfap->codsusp, |
204
|
|
|
true |
205
|
|
|
); |
206
|
|
|
$aliqGilrat->appendChild($procAdmJudFap); |
207
|
|
|
} |
208
|
|
|
$dadosEstab->appendChild($aliqGilrat); |
209
|
|
|
|
210
|
|
|
if (!empty($this->std->dadosestab->infocaepf)) { |
211
|
|
|
$infoCaepf = $this->dom->createElement("infoCaepf"); |
212
|
|
|
$this->dom->addChild( |
213
|
|
|
$infoCaepf, |
214
|
|
|
"tpCaepf", |
215
|
|
|
$this->std->dadosestab->infocaepf->tpcaepf, |
216
|
|
|
true |
217
|
|
|
); |
218
|
|
|
$dadosEstab->appendChild($infoCaepf); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
if (!empty($this->std->dadosestab->infoobra)) { |
222
|
|
|
$infoObra = $this->dom->createElement("infoObra"); |
223
|
|
|
$this->dom->addChild( |
224
|
|
|
$infoObra, |
225
|
|
|
"indSubstPatrObra", |
226
|
|
|
$this->std->dadosestab->infoobra->indsubstpatrobra, |
227
|
|
|
true |
228
|
|
|
); |
229
|
|
|
$dadosEstab->appendChild($infoObra); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
$infoTrab = $this->dom->createElement("infoTrab"); |
233
|
|
|
$this->dom->addChild( |
234
|
|
|
$infoTrab, |
235
|
|
|
"regPt", |
236
|
|
|
$this->std->dadosestab->infotrab->regpt, |
237
|
|
|
true |
238
|
|
|
); |
239
|
|
|
|
240
|
|
|
$infoApr = $this->dom->createElement("infoApr"); |
241
|
|
|
$this->dom->addChild( |
242
|
|
|
$infoApr, |
243
|
|
|
"contApr", |
244
|
|
|
$this->std->dadosestab->infotrab->infoapr->contapr, |
245
|
|
|
true |
246
|
|
|
); |
247
|
|
|
$this->dom->addChild( |
248
|
|
|
$infoApr, |
249
|
|
|
"nrProcJud", |
250
|
|
|
!empty($this->std->dadosestab->infotrab->infoapr->nrprocjud) |
251
|
|
|
? $this->std->dadosestab->infotrab->infoapr->nrprocjud |
252
|
|
|
: null, |
253
|
|
|
false |
254
|
|
|
); |
255
|
|
|
$this->dom->addChild( |
256
|
|
|
$infoApr, |
257
|
|
|
"contEntEd", |
258
|
|
|
!empty($this->std->dadosestab->infotrab->infoapr->contented) |
259
|
|
|
? $this->std->dadosestab->infotrab->infoapr->contented |
260
|
|
|
: null, |
261
|
|
|
false |
262
|
|
|
); |
263
|
|
|
|
264
|
|
|
if (!empty($this->std->dadosestab->infotrab->infoapr->infoenteduc)) { |
265
|
|
|
foreach ($this->std->dadosestab->infotrab->infoapr->infoenteduc as $edu) { |
266
|
|
|
$infoEntEduc = $this->dom->createElement("infoEntEduc"); |
267
|
|
|
$this->dom->addChild( |
268
|
|
|
$infoEntEduc, |
269
|
|
|
"nrInsc", |
270
|
|
|
$edu->nrinsc, |
271
|
|
|
true |
272
|
|
|
); |
273
|
|
|
$infoApr->appendChild($infoEntEduc); |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
$infoTrab->appendChild($infoApr); |
278
|
|
|
if (!empty($this->std->dadosestab->infotrab->infopdc)) { |
279
|
|
|
$infoPCD = $this->dom->createElement("infoPCD"); |
280
|
|
|
$this->dom->addChild( |
281
|
|
|
$infoPCD, |
282
|
|
|
"contPCD", |
283
|
|
|
$this->std->dadosestab->infotrab->infopdc->contpdc, |
284
|
|
|
true |
285
|
|
|
); |
286
|
|
|
$this->dom->addChild( |
287
|
|
|
$infoPCD, |
288
|
|
|
"nrProcJud", |
289
|
|
|
!empty($this->std->dadosestab->infotrab->infopdc->nrprocjud) |
290
|
|
|
? $this->std->dadosestab->infotrab->infopdc->nrprocjud |
291
|
|
|
: null, |
292
|
|
|
false |
293
|
|
|
); |
294
|
|
|
$infoTrab->appendChild($infoPCD); |
295
|
|
|
} |
296
|
|
|
$dadosEstab->appendChild($infoTrab); |
297
|
|
|
$node->appendChild($dadosEstab); |
298
|
|
|
} |
299
|
|
|
$infoEstab = $this->dom->createElement("infoEstab"); |
300
|
|
|
$infoEstab->appendChild($node); |
301
|
|
|
//finalização do xml |
302
|
|
|
$this->node->appendChild($infoEstab); |
303
|
|
|
$this->eSocial->appendChild($this->node); |
304
|
|
|
$this->sign(); |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.