1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
4
|
|
|
|
5
|
|
|
trait TraitS2245 |
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
|
|
|
"indRetif", |
19
|
|
|
$this->std->indretif, |
|
|
|
|
20
|
|
|
true |
21
|
|
|
); |
22
|
|
|
$this->dom->addChild( |
23
|
|
|
$ideEvento, |
24
|
|
|
"nrRecibo", |
25
|
|
|
isset($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
26
|
|
|
false |
27
|
|
|
); |
28
|
|
|
$this->dom->addChild( |
29
|
|
|
$ideEvento, |
30
|
|
|
"tpAmb", |
31
|
|
|
$this->tpAmb, |
|
|
|
|
32
|
|
|
true |
33
|
|
|
); |
34
|
|
|
$this->dom->addChild( |
35
|
|
|
$ideEvento, |
36
|
|
|
"procEmi", |
37
|
|
|
$this->procEmi, |
|
|
|
|
38
|
|
|
true |
39
|
|
|
); |
40
|
|
|
$this->dom->addChild( |
41
|
|
|
$ideEvento, |
42
|
|
|
"verProc", |
43
|
|
|
$this->verProc, |
|
|
|
|
44
|
|
|
true |
45
|
|
|
); |
46
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
47
|
|
|
$ideVinculo = $this->dom->createElement("ideVinculo"); |
48
|
|
|
$this->dom->addChild( |
49
|
|
|
$ideVinculo, |
50
|
|
|
"cpfTrab", |
51
|
|
|
$this->std->idevinculo->cpftrab, |
52
|
|
|
true |
53
|
|
|
); |
54
|
|
|
$this->dom->addChild( |
55
|
|
|
$ideVinculo, |
56
|
|
|
"nisTrab", |
57
|
|
|
!empty($this->std->idevinculo->nistrab) ? $this->std->idevinculo->nistrab : null, |
58
|
|
|
false |
59
|
|
|
); |
60
|
|
|
$this->dom->addChild( |
61
|
|
|
$ideVinculo, |
62
|
|
|
"matricula", |
63
|
|
|
!empty($this->std->idevinculo->matricula) ? $this->std->idevinculo->matricula : null, |
64
|
|
|
false |
65
|
|
|
); |
66
|
|
|
$this->dom->addChild( |
67
|
|
|
$ideVinculo, |
68
|
|
|
"codCateg", |
69
|
|
|
!empty($this->std->idevinculo->codcateg) ? $this->std->idevinculo->codcateg : null, |
70
|
|
|
false |
71
|
|
|
); |
72
|
|
|
$this->node->appendChild($ideVinculo); |
73
|
|
|
|
74
|
|
|
$t = $this->std->treicap; |
75
|
|
|
$treiCap = $this->dom->createElement("treiCap"); |
76
|
|
|
$this->dom->addChild( |
77
|
|
|
$treiCap, |
78
|
|
|
"codTreiCap", |
79
|
|
|
$t->codtreicap, |
80
|
|
|
true |
81
|
|
|
); |
82
|
|
|
$this->dom->addChild( |
83
|
|
|
$treiCap, |
84
|
|
|
"obsTreiCap", |
85
|
|
|
!empty($t->obstreicap) ? $t->obstreicap : null, |
86
|
|
|
false |
87
|
|
|
); |
88
|
|
|
if (!empty($t->infocomplem)) { |
89
|
|
|
$i = $t->infocomplem; |
90
|
|
|
$infoComplem = $this->dom->createElement("infoComplem"); |
91
|
|
|
$this->dom->addChild( |
92
|
|
|
$infoComplem, |
93
|
|
|
"dtTreiCap", |
94
|
|
|
$i->dttreicap, |
95
|
|
|
true |
96
|
|
|
); |
97
|
|
|
$this->dom->addChild( |
98
|
|
|
$infoComplem, |
99
|
|
|
"durTreiCap", |
100
|
|
|
$i->durtreicap, |
101
|
|
|
true |
102
|
|
|
); |
103
|
|
|
$this->dom->addChild( |
104
|
|
|
$infoComplem, |
105
|
|
|
"modTreiCap", |
106
|
|
|
$i->modtreicap, |
107
|
|
|
true |
108
|
|
|
); |
109
|
|
|
$this->dom->addChild( |
110
|
|
|
$infoComplem, |
111
|
|
|
"tpTreiCap", |
112
|
|
|
$i->tptreicap, |
113
|
|
|
true |
114
|
|
|
); |
115
|
|
|
$this->dom->addChild( |
116
|
|
|
$infoComplem, |
117
|
|
|
"indTreinAnt", |
118
|
|
|
$i->indtreinant, |
119
|
|
|
true |
120
|
|
|
); |
121
|
|
|
|
122
|
|
|
foreach ($i->ideprofresp as $p) { |
123
|
|
|
$ideProfResp = $this->dom->createElement("ideProfResp"); |
124
|
|
|
$this->dom->addChild( |
125
|
|
|
$ideProfResp, |
126
|
|
|
"cpfProf", |
127
|
|
|
!empty($p->cpfprof) ? $p->cpfprof : null, |
128
|
|
|
false |
129
|
|
|
); |
130
|
|
|
$this->dom->addChild( |
131
|
|
|
$ideProfResp, |
132
|
|
|
"nmProf", |
133
|
|
|
$p->nmprof, |
134
|
|
|
true |
135
|
|
|
); |
136
|
|
|
$this->dom->addChild( |
137
|
|
|
$ideProfResp, |
138
|
|
|
"tpProf", |
139
|
|
|
$p->tpprof, |
140
|
|
|
true |
141
|
|
|
); |
142
|
|
|
$this->dom->addChild( |
143
|
|
|
$ideProfResp, |
144
|
|
|
"formProf", |
145
|
|
|
$p->formprof, |
146
|
|
|
true |
147
|
|
|
); |
148
|
|
|
$this->dom->addChild( |
149
|
|
|
$ideProfResp, |
150
|
|
|
"codCBO", |
151
|
|
|
$p->codcbo, |
152
|
|
|
true |
153
|
|
|
); |
154
|
|
|
$this->dom->addChild( |
155
|
|
|
$ideProfResp, |
156
|
|
|
"nacProf", |
157
|
|
|
$p->nacprof, |
158
|
|
|
true |
159
|
|
|
); |
160
|
|
|
$infoComplem->appendChild($ideProfResp); |
161
|
|
|
} |
162
|
|
|
$treiCap->appendChild($infoComplem); |
163
|
|
|
} |
164
|
|
|
$this->node->appendChild($treiCap); |
165
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
166
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
167
|
|
|
$this->sign(); |
|
|
|
|
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* builder for version S.1.0.0 |
172
|
|
|
*/ |
173
|
|
|
protected function toNodeS100() |
174
|
|
|
{ |
175
|
|
|
throw new \Exception("NÃO EXISTE EVENTO {$this->evtAlias} na versão S_1.0 !!"); |
|
|
|
|
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|
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: