1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class eSocial EvtToxic Event S-2221 constructor |
7
|
|
|
* Read for 2.5.0 layout |
8
|
|
|
* |
9
|
|
|
* @category library |
10
|
|
|
* @package NFePHP\eSocial |
11
|
|
|
* @copyright NFePHP Copyright (c) 2017-2019 |
12
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPLv3+ |
13
|
|
|
* @license https://opensource.org/licenses/MIT MIT |
14
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+ |
15
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
16
|
|
|
* @link http://github.com/nfephp-org/sped-esocial for the canonical source repository |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use NFePHP\Common\Certificate; |
20
|
|
|
use NFePHP\eSocial\Common\Factory; |
21
|
|
|
use NFePHP\eSocial\Common\FactoryInterface; |
22
|
|
|
use stdClass; |
23
|
|
|
|
24
|
|
|
class EvtToxic extends Factory implements FactoryInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $evtName = 'evtToxic'; |
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $evtAlias = 'S-2221'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Constructor |
37
|
|
|
* |
38
|
|
|
* @param string $config |
39
|
|
|
* @param stdClass $std |
40
|
|
|
* @param Certificate $certificate | null |
41
|
|
|
* @param string $date |
42
|
|
|
*/ |
43
|
|
|
public function __construct( |
44
|
|
|
$config, |
45
|
|
|
stdClass $std, |
46
|
|
|
Certificate $certificate = null, |
47
|
|
|
$date = '' |
48
|
|
|
) { |
49
|
|
|
parent::__construct($config, $std, $certificate, $date); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Node constructor |
54
|
|
|
*/ |
55
|
|
|
protected function toNode() |
56
|
|
|
{ |
57
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
58
|
|
|
//o idEvento pode variar de evento para evento |
59
|
|
|
//então cada factory individualmente terá de construir o seu |
60
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
61
|
|
|
$this->dom->addChild( |
62
|
|
|
$ideEvento, |
63
|
|
|
"indRetif", |
64
|
|
|
$this->std->indretif, |
65
|
|
|
true |
66
|
|
|
); |
67
|
|
|
$this->dom->addChild( |
68
|
|
|
$ideEvento, |
69
|
|
|
"nrRecibo", |
70
|
|
|
!empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
71
|
|
|
false |
72
|
|
|
); |
73
|
|
|
$this->dom->addChild( |
74
|
|
|
$ideEvento, |
75
|
|
|
"tpAmb", |
76
|
|
|
$this->tpAmb, |
77
|
|
|
true |
78
|
|
|
); |
79
|
|
|
$this->dom->addChild( |
80
|
|
|
$ideEvento, |
81
|
|
|
"procEmi", |
82
|
|
|
$this->procEmi, |
83
|
|
|
true |
84
|
|
|
); |
85
|
|
|
$this->dom->addChild( |
86
|
|
|
$ideEvento, |
87
|
|
|
"verProc", |
88
|
|
|
$this->verProc, |
89
|
|
|
true |
90
|
|
|
); |
91
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
92
|
|
|
|
93
|
|
|
$ideVinculo = $this->dom->createElement("ideVinculo"); |
94
|
|
|
$ide = $this->std->idevinculo; |
95
|
|
|
$this->dom->addChild( |
96
|
|
|
$ideVinculo, |
97
|
|
|
"cpfTrab", |
98
|
|
|
$ide->cpftrab, |
99
|
|
|
true |
100
|
|
|
); |
101
|
|
|
$this->dom->addChild( |
102
|
|
|
$ideVinculo, |
103
|
|
|
"nisTrab", |
104
|
|
|
!empty($ide->nistrab) ? $ide->nistrab : null, |
105
|
|
|
false |
106
|
|
|
); |
107
|
|
|
$this->dom->addChild( |
108
|
|
|
$ideVinculo, |
109
|
|
|
"matricula", |
110
|
|
|
!empty($ide->matricula) ? $ide->matricula : null, |
111
|
|
|
false |
112
|
|
|
); |
113
|
|
|
$this->dom->addChild( |
114
|
|
|
$ideVinculo, |
115
|
|
|
"codCateg", |
116
|
|
|
!empty($ide->codcateg) ? $ide->codcateg : null, |
117
|
|
|
false |
118
|
|
|
); |
119
|
|
|
$this->node->appendChild($ideVinculo); |
120
|
|
|
|
121
|
|
|
$toxic = $this->dom->createElement("toxicologico"); |
122
|
|
|
$tox = $this->std->toxicologico; |
123
|
|
|
$this->dom->addChild( |
124
|
|
|
$toxic, |
125
|
|
|
"dtExame", |
126
|
|
|
$tox->dtexame, |
127
|
|
|
true |
128
|
|
|
); |
129
|
|
|
$this->dom->addChild( |
130
|
|
|
$toxic, |
131
|
|
|
"cnpjLab", |
132
|
|
|
!empty($tox->cnpjlab) ? $tox->cnpjlab : null, |
133
|
|
|
false |
134
|
|
|
); |
135
|
|
|
$this->dom->addChild( |
136
|
|
|
$toxic, |
137
|
|
|
"codSeqExame", |
138
|
|
|
!empty($tox->codseqexame) ? $tox->codseqexame : null, |
139
|
|
|
false |
140
|
|
|
); |
141
|
|
|
$this->dom->addChild( |
142
|
|
|
$toxic, |
143
|
|
|
"nmMed", |
144
|
|
|
!empty($tox->nmmed) ? $tox->nmmed : null, |
145
|
|
|
false |
146
|
|
|
); |
147
|
|
|
$this->dom->addChild( |
148
|
|
|
$toxic, |
149
|
|
|
"nrCRM", |
150
|
|
|
!empty($tox->nrcrm) ? $tox->nrcrm : null, |
151
|
|
|
false |
152
|
|
|
); |
153
|
|
|
$this->dom->addChild( |
154
|
|
|
$toxic, |
155
|
|
|
"ufCRM", |
156
|
|
|
!empty($tox->ufcrm) ? $tox->ufcrm : null, |
157
|
|
|
false |
158
|
|
|
); |
159
|
|
|
$this->dom->addChild( |
160
|
|
|
$toxic, |
161
|
|
|
"indRecusa", |
162
|
|
|
$tox->indrecusa, |
163
|
|
|
true |
164
|
|
|
); |
165
|
|
|
$this->node->appendChild($toxic); |
166
|
|
|
//finalização do xml |
167
|
|
|
$this->eSocial->appendChild($this->node); |
168
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
|
|
|
|
169
|
|
|
$this->sign(); |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.