1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
4
|
|
|
|
5
|
|
|
trait TraitS5002 |
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
|
|
|
$ideTrabalhador = $this->dom->createElement("ideTrabalhador"); |
30
|
|
|
$this->dom->addChild( |
31
|
|
|
$ideTrabalhador, |
32
|
|
|
"cpfTrab", |
33
|
|
|
$this->std->cpftrab, |
34
|
|
|
true |
35
|
|
|
); |
36
|
|
|
$this->node->appendChild($ideTrabalhador); |
37
|
|
|
if (! empty($this->std->vrdeddep)) { |
38
|
|
|
$infoDep = $this->dom->createElement("infoDep"); |
39
|
|
|
$this->dom->addChild( |
40
|
|
|
$infoDep, |
41
|
|
|
"vrDedDep", |
42
|
|
|
$this->std->vrdeddep, |
43
|
|
|
true |
44
|
|
|
); |
45
|
|
|
$this->node->appendChild($infoDep); |
46
|
|
|
} |
47
|
|
|
foreach ($this->std->infoirrf as $nIrrf) { |
48
|
|
|
$infoIrrf = $this->dom->createElement("infoIrrf"); |
49
|
|
|
$this->dom->addChild( |
50
|
|
|
$infoIrrf, |
51
|
|
|
"codCateg", |
52
|
|
|
! empty($nIrrf->codcateg) ? $nIrrf->codcateg : null, |
53
|
|
|
false |
54
|
|
|
); |
55
|
|
|
$this->dom->addChild( |
56
|
|
|
$infoIrrf, |
57
|
|
|
"indResBr", |
58
|
|
|
$nIrrf->indresbr, |
59
|
|
|
true |
60
|
|
|
); |
61
|
|
|
foreach ($nIrrf->basesirrf as $base) { |
62
|
|
|
$basesIrrf = $this->dom->createElement("basesIrrf"); |
63
|
|
|
$this->dom->addChild( |
64
|
|
|
$basesIrrf, |
65
|
|
|
"tpValor", |
66
|
|
|
$base->tpvalor, |
67
|
|
|
true |
68
|
|
|
); |
69
|
|
|
$this->dom->addChild( |
70
|
|
|
$basesIrrf, |
71
|
|
|
"valor", |
72
|
|
|
$base->valor, |
73
|
|
|
true |
74
|
|
|
); |
75
|
|
|
$infoIrrf->appendChild($basesIrrf); |
76
|
|
|
} |
77
|
|
|
foreach ($nIrrf->irrf as $base) { |
78
|
|
|
$irrf = $this->dom->createElement("irrf"); |
79
|
|
|
$this->dom->addChild( |
80
|
|
|
$irrf, |
81
|
|
|
"tpCR", |
82
|
|
|
$base->tpcr, |
83
|
|
|
true |
84
|
|
|
); |
85
|
|
|
$this->dom->addChild( |
86
|
|
|
$irrf, |
87
|
|
|
"vrIrrfDesc", |
88
|
|
|
$base->vrirrfdesc, |
89
|
|
|
true |
90
|
|
|
); |
91
|
|
|
$infoIrrf->appendChild($irrf); |
92
|
|
|
} |
93
|
|
|
if (isset($nIrrf->idepgtoext)) { |
94
|
|
|
$idePgtoExt = $this->dom->createElement("idePgtoExt"); |
95
|
|
|
$idePais = $this->dom->createElement("idePais"); |
96
|
|
|
$this->dom->addChild( |
97
|
|
|
$idePais, |
98
|
|
|
"codPais", |
99
|
|
|
$nIrrf->idepgtoext->codpais, |
100
|
|
|
true |
101
|
|
|
); |
102
|
|
|
$this->dom->addChild( |
103
|
|
|
$idePais, |
104
|
|
|
"indNIF", |
105
|
|
|
$nIrrf->idepgtoext->indnif, |
106
|
|
|
true |
107
|
|
|
); |
108
|
|
|
$this->dom->addChild( |
109
|
|
|
$idePais, |
110
|
|
|
"nifBenef", |
111
|
|
|
! empty($nIrrf->idepgtoext->nifbenef) ? $nIrrf->idepgtoext->nifbenef : null, |
112
|
|
|
false |
113
|
|
|
); |
114
|
|
|
$idePgtoExt->appendChild($idePais); |
115
|
|
|
|
116
|
|
|
$endExt = $this->dom->createElement("endExt"); |
117
|
|
|
$this->dom->addChild( |
118
|
|
|
$endExt, |
119
|
|
|
"dscLograd", |
120
|
|
|
$nIrrf->idepgtoext->dsclograd, |
121
|
|
|
true |
122
|
|
|
); |
123
|
|
|
$this->dom->addChild( |
124
|
|
|
$endExt, |
125
|
|
|
"nrLograd", |
126
|
|
|
! empty($nIrrf->idepgtoext->nrlograd) ? $nIrrf->idepgtoext->nrlograd : null, |
127
|
|
|
false |
128
|
|
|
); |
129
|
|
|
$this->dom->addChild( |
130
|
|
|
$endExt, |
131
|
|
|
"complem", |
132
|
|
|
! empty($nIrrf->idepgtoext->complem) ? $nIrrf->idepgtoext->complem : null, |
133
|
|
|
false |
134
|
|
|
); |
135
|
|
|
$this->dom->addChild( |
136
|
|
|
$endExt, |
137
|
|
|
"bairro", |
138
|
|
|
! empty($nIrrf->idepgtoext->bairro) ? $nIrrf->idepgtoext->bairro : null, |
139
|
|
|
false |
140
|
|
|
); |
141
|
|
|
$this->dom->addChild( |
142
|
|
|
$endExt, |
143
|
|
|
"nmCid", |
144
|
|
|
$nIrrf->idepgtoext->nmcid, |
145
|
|
|
true |
146
|
|
|
); |
147
|
|
|
$this->dom->addChild( |
148
|
|
|
$endExt, |
149
|
|
|
"codPostal", |
150
|
|
|
! empty($nIrrf->idepgtoext->codpostal) ? $nIrrf->idepgtoext->codpostal : null, |
151
|
|
|
false |
152
|
|
|
); |
153
|
|
|
$idePgtoExt->appendChild($endExt); |
154
|
|
|
$infoIrrf->appendChild($idePgtoExt); |
155
|
|
|
$this->node->appendChild($infoIrrf); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
159
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
160
|
|
|
$this->sign(); |
|
|
|
|
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* builder for version S.1.0.0 |
165
|
|
|
*/ |
166
|
|
|
protected function toNodeS100() |
167
|
|
|
{ |
168
|
|
|
throw new \Exception("TODO !!"); |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|
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: