@@ -40,7 +40,6 @@ public static function getFileContent(array $element, WebformSubmissionInterface
40
40
$ nemid_zipcode = htmlspecialchars ($ person_address ['zipcode ' ]);
41
41
}
42
42
}
43
-
44
43
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterface $sp_cvr */
45
44
$ sp_cvr = $ os2web_datalookup_plugins ->createInstance ('serviceplatformen_cvr ' );
46
45
if (!empty ($ nemid_com_cvr ) && $ sp_cvr ->isReady ()) {
@@ -84,6 +83,7 @@ public static function getFileContent(array $element, WebformSubmissionInterface
84
83
$ webform = $ webform_submission ->getWebform ();
85
84
$ webform_title = htmlspecialchars ($ webform ->label ());
86
85
$ fields = self ::getWebformElementsAsList ($ webform_submission );
86
+
87
87
if (isset ($ fields ['antal_rum_max ' ])) {
88
88
$ maxRoom = htmlspecialchars ($ fields ['antal_rum_max ' ]);
89
89
}
@@ -102,14 +102,14 @@ public static function getFileContent(array $element, WebformSubmissionInterface
102
102
$ xml_data = [
103
103
'OS2FormsId ' => $ os2formsId ,
104
104
'SBSYSJournalisering ' => [
105
- 'PrimaerPartCprNummer ' => (!empty ($ nemid_cpr )) ? $ nemid_cpr : '' ,
105
+ 'PrimaerPartCprNummer ' => (!empty ($ nemid_cpr ) && empty ( $ nemid_com_cvr ) ) ? $ nemid_cpr : '' ,
106
106
'PrimaerPartCvrNummer ' => (!empty ($ nemid_com_cvr )) ? $ nemid_com_cvr : '' ,
107
107
'KLe ' => $ kle ,
108
108
'SagSkabelonId ' => $ sagSkabelonId ,
109
109
],
110
110
'DigitalForsendelse ' => [
111
111
'Slutbruger ' => [
112
- 'CprNummer ' => (isset ($ nemid_cpr )) ? $ nemid_cpr : '' ,
112
+ 'CprNummer ' => (! empty ($ nemid_cpr) && empty ( $ nemid_com_cvr )) ? $ nemid_cpr : '' ,
113
113
'CvrNummer ' => (isset ($ nemid_com_cvr )) ? $ nemid_com_cvr : '' ,
114
114
'Navn ' => (isset ($ nemid_name )) ? $ nemid_name : '' ,
115
115
'Adresse ' => (isset ($ nemid_address )) ? $ nemid_address : '' ,
@@ -200,19 +200,28 @@ protected static function getFirstValueByType($type, WebformSubmissionInterface
200
200
* Webform elements as simple array.
201
201
*/
202
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 );
203
205
$ webform = $ webform_submission ->getWebform ();
204
206
$ data = $ webform_submission ->getData ();
205
207
$ webform_elements = $ webform ->getElementsInitializedFlattenedAndHasValue ();
206
208
$ elements_list = [];
207
-
208
209
foreach ($ webform_elements as $ key => $ webform_element ) {
209
210
$ field_name = $ key ;
210
211
$ field_name = preg_replace ('/\W/ ' , '_ ' , $ field_name );
212
+ $ webform_element ['#type ' ];
211
213
if ($ webform_element ['#type ' ] == 'markup ' ) {
212
214
$ elements_list [$ field_name ] = $ webform_element ['value ' ];
213
215
}
214
216
elseif ($ data && isset ($ data [$ key ])) {
215
- $ 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
+ }
216
225
}
217
226
}
218
227
return $ elements_list ;
0 commit comments