1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories\Traits; |
4
|
|
|
|
5
|
|
|
trait TraitS2416 |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* builder for version 2.5.0 |
9
|
|
|
*/ |
10
|
|
|
protected function toNode250() |
11
|
|
|
{ |
12
|
|
|
throw new \Exception("NÃO EXISTE EVENTO {$this->evtAlias} na versão 2.5.0 !!"); |
|
|
|
|
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* builder for version S.1.0.0 |
17
|
|
|
*/ |
18
|
|
|
protected function toNodeS100() |
19
|
|
|
{ |
20
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
|
|
|
|
21
|
|
|
//o idEvento pode variar de evento para evento |
22
|
|
|
//então cada factory individualmente terá de construir o seu |
23
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
|
|
|
|
24
|
|
|
$this->dom->addChild( |
25
|
|
|
$ideEvento, |
26
|
|
|
"indRetif", |
27
|
|
|
$this->std->indretif, |
|
|
|
|
28
|
|
|
true |
29
|
|
|
); |
30
|
|
|
if ($this->std->indretif == 2) { |
31
|
|
|
$this->dom->addChild( |
32
|
|
|
$ideEvento, |
33
|
|
|
"nrRecibo", |
34
|
|
|
$this->std->nrrecibo, |
35
|
|
|
true |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
$this->dom->addChild( |
39
|
|
|
$ideEvento, |
40
|
|
|
"tpAmb", |
41
|
|
|
$this->tpAmb, |
|
|
|
|
42
|
|
|
true |
43
|
|
|
); |
44
|
|
|
$this->dom->addChild( |
45
|
|
|
$ideEvento, |
46
|
|
|
"procEmi", |
47
|
|
|
$this->procEmi, |
|
|
|
|
48
|
|
|
true |
49
|
|
|
); |
50
|
|
|
$this->dom->addChild( |
51
|
|
|
$ideEvento, |
52
|
|
|
"verProc", |
53
|
|
|
$this->verProc, |
|
|
|
|
54
|
|
|
true |
55
|
|
|
); |
56
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
57
|
|
|
|
58
|
|
|
$ideBeneficio = $this->dom->createElement("ideBeneficio"); |
59
|
|
|
$this->dom->addChild( |
60
|
|
|
$ideBeneficio, |
61
|
|
|
"cpfBenef", |
62
|
|
|
$this->std->cpfbenef, |
63
|
|
|
true |
64
|
|
|
); |
65
|
|
|
$this->dom->addChild( |
66
|
|
|
$ideBeneficio, |
67
|
|
|
"nrBeneficio", |
68
|
|
|
$this->std->nrbeneficio, |
69
|
|
|
true |
70
|
|
|
); |
71
|
|
|
$this->node->appendChild($ideBeneficio); |
72
|
|
|
|
73
|
|
|
$infoBenAlteracao = $this->dom->createElement("infoBenAlteracao"); |
74
|
|
|
$this->dom->addChild( |
75
|
|
|
$infoBenAlteracao, |
76
|
|
|
"dtAltBeneficio", |
77
|
|
|
$this->std->dtaltbeneficio, |
78
|
|
|
true |
79
|
|
|
); |
80
|
|
|
$dadosBeneficio = $this->dom->createElement("dadosBeneficio"); |
81
|
|
|
$this->dom->addChild( |
82
|
|
|
$dadosBeneficio, |
83
|
|
|
"tpBeneficio", |
84
|
|
|
$this->std->tpbeneficio, |
85
|
|
|
true |
86
|
|
|
); |
87
|
|
|
$this->dom->addChild( |
88
|
|
|
$dadosBeneficio, |
89
|
|
|
"tpPlanRP", |
90
|
|
|
$this->std->tpplanrp, |
91
|
|
|
true |
92
|
|
|
); |
93
|
|
|
$this->dom->addChild( |
94
|
|
|
$dadosBeneficio, |
95
|
|
|
"dsc", |
96
|
|
|
!empty($this->std->dsc) ? $this->std->dsc : null, |
97
|
|
|
false |
98
|
|
|
); |
99
|
|
|
$this->dom->addChild( |
100
|
|
|
$dadosBeneficio, |
101
|
|
|
"indSuspensao", |
102
|
|
|
$this->std->indsuspensao, |
103
|
|
|
true |
104
|
|
|
); |
105
|
|
|
if (!empty($this->std->infopenmorte)) { |
106
|
|
|
$infoPenMorte = $this->dom->createElement("infoPenMorte"); |
107
|
|
|
$this->dom->addChild( |
108
|
|
|
$infoPenMorte, |
109
|
|
|
"tpPenMorte", |
110
|
|
|
$this->std->infopenmorte->tppenmorte, |
111
|
|
|
true |
112
|
|
|
); |
113
|
|
|
$dadosBeneficio->appendChild($infoPenMorte); |
114
|
|
|
} |
115
|
|
|
if (!empty($this->std->suspensao)) { |
116
|
|
|
$suspensao = $this->dom->createElement("suspensao"); |
117
|
|
|
$this->dom->addChild( |
118
|
|
|
$suspensao, |
119
|
|
|
"mtvSuspensao", |
120
|
|
|
$this->std->suspensao->mtvsuspensao, |
121
|
|
|
true |
122
|
|
|
); |
123
|
|
|
$this->dom->addChild( |
124
|
|
|
$suspensao, |
125
|
|
|
"dscSuspensao", |
126
|
|
|
!empty($this->std->suspensao->dscssuspensao) |
127
|
|
|
? $this->std->suspensao->dscssuspensao |
128
|
|
|
: null, |
129
|
|
|
false |
130
|
|
|
); |
131
|
|
|
$dadosBeneficio->appendChild($suspensao); |
132
|
|
|
} |
133
|
|
|
$infoBenAlteracao->appendChild($dadosBeneficio); |
134
|
|
|
$this->node->appendChild($infoBenAlteracao); |
135
|
|
|
//finalização do xml |
136
|
|
|
$this->eSocial->appendChild($this->node); |
|
|
|
|
137
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
138
|
|
|
$this->sign(); |
|
|
|
|
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
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: