@@ -29,17 +29,6 @@ public static function getFileContent(array $element, WebformSubmissionInterface
29
29
$ nemid_cpr = self ::getFirstValueByType ('os2forms_nemid_cpr ' , $ webform_submission );
30
30
$ nemid_com_cvr = self ::getFirstValueByType ('os2forms_nemid_company_cvr ' , $ webform_submission );
31
31
$ os2web_datalookup_plugins = \Drupal::service ('plugin.manager.os2web_datalookup ' );
32
- /** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterface $sp_cvr */
33
- $ sp_cvr = $ os2web_datalookup_plugins ->createInstance ('serviceplatformen_cvr ' );
34
- if (!empty ($ nemid_com_cvr ) && $ sp_cvr ->isReady ()) {
35
- $ company_info = $ sp_cvr ->getInfo ($ nemid_com_cvr );
36
- if ($ company_info ['status ' ]) {
37
- $ nemid_name = htmlspecialchars ($ company_info ['company_name ' ]);
38
- $ nemid_address = htmlspecialchars ($ company_info ['company_street ' ] . ' ' . $ company_info ['company_house_nr ' ] . ' ' . $ company_info ['company_ ' ]);
39
- $ nemid_city = htmlspecialchars ($ company_info ['company_city ' ]);
40
- $ nemid_zipcode = htmlspecialchars ($ company_info ['company_zipcode ' ]);
41
- }
42
- }
43
32
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterface $sp_cpr */
44
33
$ sp_cpr = $ os2web_datalookup_plugins ->createInstance ('serviceplatformen_cpr ' );
45
34
if (!empty ($ nemid_cpr ) && $ sp_cpr ->isReady ()) {
@@ -51,6 +40,17 @@ public static function getFileContent(array $element, WebformSubmissionInterface
51
40
$ nemid_zipcode = htmlspecialchars ($ person_address ['zipcode ' ]);
52
41
}
53
42
}
43
+ /** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterface $sp_cvr */
44
+ $ sp_cvr = $ os2web_datalookup_plugins ->createInstance ('serviceplatformen_cvr ' );
45
+ if (!empty ($ nemid_com_cvr ) && $ sp_cvr ->isReady ()) {
46
+ $ company_info = $ sp_cvr ->getInfo ($ nemid_com_cvr );
47
+ if ($ company_info ['status ' ]) {
48
+ $ nemid_name = htmlspecialchars ($ company_info ['company_name ' ]);
49
+ $ nemid_address = htmlspecialchars ($ company_info ['company_street ' ] . ' ' . $ company_info ['company_house_nr ' ] . ' ' . $ company_info ['company_ ' ]);
50
+ $ nemid_city = htmlspecialchars ($ company_info ['company_city ' ]);
51
+ $ nemid_zipcode = htmlspecialchars ($ company_info ['company_zipcode ' ]);
52
+ }
53
+ }
54
54
55
55
$ config = self ::getElementConfiguration ($ element );
56
56
$ os2formsId = self ::getConfigurationValue ('os2formsId ' , $ config , $ webform_submission );
@@ -83,6 +83,7 @@ public static function getFileContent(array $element, WebformSubmissionInterface
83
83
$ webform = $ webform_submission ->getWebform ();
84
84
$ webform_title = htmlspecialchars ($ webform ->label ());
85
85
$ fields = self ::getWebformElementsAsList ($ webform_submission );
86
+
86
87
if (isset ($ fields ['antal_rum_max ' ])) {
87
88
$ maxRoom = htmlspecialchars ($ fields ['antal_rum_max ' ]);
88
89
}
@@ -101,14 +102,14 @@ public static function getFileContent(array $element, WebformSubmissionInterface
101
102
$ xml_data = [
102
103
'OS2FormsId ' => $ os2formsId ,
103
104
'SBSYSJournalisering ' => [
104
- 'PrimaerPartCprNummer ' => (!empty ($ nemid_cpr )) ? $ nemid_cpr : '' ,
105
+ 'PrimaerPartCprNummer ' => (!empty ($ nemid_cpr ) && empty ( $ nemid_com_cvr ) ) ? $ nemid_cpr : '' ,
105
106
'PrimaerPartCvrNummer ' => (!empty ($ nemid_com_cvr )) ? $ nemid_com_cvr : '' ,
106
107
'KLe ' => $ kle ,
107
108
'SagSkabelonId ' => $ sagSkabelonId ,
108
109
],
109
110
'DigitalForsendelse ' => [
110
111
'Slutbruger ' => [
111
- 'CprNummer ' => (isset ($ nemid_cpr )) ? $ nemid_cpr : '' ,
112
+ 'CprNummer ' => (! empty ($ nemid_cpr) && empty ( $ nemid_com_cvr )) ? $ nemid_cpr : '' ,
112
113
'CvrNummer ' => (isset ($ nemid_com_cvr )) ? $ nemid_com_cvr : '' ,
113
114
'Navn ' => (isset ($ nemid_name )) ? $ nemid_name : '' ,
114
115
'Adresse ' => (isset ($ nemid_address )) ? $ nemid_address : '' ,
@@ -199,19 +200,28 @@ protected static function getFirstValueByType($type, WebformSubmissionInterface
199
200
* Webform elements as simple array.
200
201
*/
201
202
protected static function getWebformElementsAsList (WebformSubmissionInterface $ webform_submission ) {
203
+ $ nemid_cpr = self ::getFirstValueByType ('os2forms_nemid_cpr ' , $ webform_submission );
204
+ $ nemid_com_cvr = self ::getFirstValueByType ('os2forms_nemid_company_cvr ' , $ webform_submission );
202
205
$ webform = $ webform_submission ->getWebform ();
203
206
$ data = $ webform_submission ->getData ();
204
207
$ webform_elements = $ webform ->getElementsInitializedFlattenedAndHasValue ();
205
208
$ elements_list = [];
206
-
207
209
foreach ($ webform_elements as $ key => $ webform_element ) {
208
210
$ field_name = $ key ;
209
211
$ field_name = preg_replace ('/\W/ ' , '_ ' , $ field_name );
212
+ $ webform_element ['#type ' ];
210
213
if ($ webform_element ['#type ' ] == 'markup ' ) {
211
214
$ elements_list [$ field_name ] = $ webform_element ['value ' ];
212
215
}
213
216
elseif ($ data && isset ($ data [$ key ])) {
214
- $ elements_list [$ field_name ] = $ data [$ key ];
217
+ if ($ webform_element ['#type ' ] == 'os2forms_nemid_cpr ' ) {
218
+ if (!empty ($ nemid_cpr ) && empty ($ nemid_com_cvr )) {
219
+ $ elements_list [$ field_name ] = $ data [$ key ];
220
+ }
221
+ }
222
+ else {
223
+ $ elements_list [$ field_name ] = $ data [$ key ];
224
+ }
215
225
}
216
226
}
217
227
return $ elements_list ;
0 commit comments