onOffice-Web-Org / oo-wp-plugin

onOffice for WP-Websites
https://wp-plugin.onoffice.com
GNU General Public License v3.0
9 stars 9 forks source link

“Land” field in onOffice enterprise is a single select but it is output as input field in plugin and frontend #540

Open fredericalpers opened 1 year ago

fredericalpers commented 1 year ago

Discussed in https://github.com/onOffice-Web-Org/oo-wp-plugin/discussions/535

Originally posted by **fredericalpers** May 26, 2023 ### Current state The "Land" field is displayed as an input field in the plugin and in the frontend. However it is a single select in onOffice enterprise. This causes problems. Forms can not be submitted if a country name like "France" is entered. It is only possible to sent a form when typing the value from onOffice enterprise "10" for France. If the input is 10 then the form is sent and also an address will be created. If the fieldname "FRA" is entered, the form will be sent with "no data" to the e-mail but in onOffice enterprise the correct country will be added to the address. Edit: deleted the investigation part ### Desired state In the plugin and in the frontend, the field must also be a single select. All countries that the customers have activated in onOffice enterprise should be selectable here.
yeneastgate commented 1 year ago

@fredericalpers After checking this issue, we need more than a week to investigate closely and also work on it. Meanwhile, some issues in the cycle 25/05 such as "Default values for estate list" and other issues in this cycle also account for a considerable amount of time. Therefore, I'm not sure I'll be able to finish this issue in time this cycle. It would be great if we can push this issue to the next cycle so that we have enough time to work well on other issues. At that time, we can deal with a small change issue, please check and push if necessary. Thanks.

fredericalpers commented 1 year ago

@fredericalpers After checking this issue, we need more than a week to investigate closely and also work on it. Meanwhile, some issues in the cycle 25/05 such as "Default values for estate list" and other issues in this cycle also account for a considerable amount of time. Therefore, I'm not sure I'll be able to finish this issue in time this cycle. It would be great if we can push this issue to the next cycle so that we have enough time to work well on other issues. At that time, we can deal with a small change issue, please check and push if necessary. Thanks.

Thank you for investigating. I will lock this issue and push it to the next cycle. :)

dai-eastgate commented 1 year ago

Hi @fredericalpers, I have a few questions that need your clarification:

  1. Currently, I check the code and find there are 2 keys "land" and "Land", the one you are trying to change is "Land" right? image

  2. In the Investigate section, I understand your requirement but I don't really understand why you want to change the name from "Land" to "Country"

  3. Do you want the "Land" field to be a single select in both frontend and backend?

fredericalpers commented 1 year ago

@dai-eastgate

  1. we need to use both. "Land" is for address. "land" is for properties. for instance: in the applicantform in the part for contact details (address) the field "Land" has to be used. Further down in the part of the search criteria the "land" field has to be used.

    In search forms also the "land" field has to be used.

    1. We do not want to change the name to "country".

    2. yes, please change the field to a single select in both frontend and backend.

dai-eastgate commented 1 year ago

@dai-eastgate

  1. we need to use both. "Land" is for address. "land" is for properties. for instance: in the applicantform in the part for contact details (address) the field "Land" has to be used. Further down in the part of the search criteria the "land" field has to be used.

In search forms also the "land" field also the "land" field has to be used.

  1. We do not want to change the name to "country".
  2. yes, please change the field to a single select in both frontend and backend.

Yes, I will implement it. Thanks!

dai-eastgate commented 1 year ago

Apparently the "Land" field in the plugin is called "Country" everywhere. It is necessary to check whether a renaming in the plugin is necessary so that the function can be used as intended.

I have one question: If you don't want to change the name of "Land" to "Country", what do you mean, please explain to me.

fredericalpers commented 1 year ago

Apparently the "Land" field in the plugin is called "Country" everywhere. It is necessary to check whether a renaming in the plugin is necessary so that the function can be used as intended.

I have one question: If you don't want to change the name of "Land" to "Country", what do you mean, please explain to me.

@dai-eastgate you can ignore that part. I will edit it out of the original issue. :)

dai-eastgate commented 1 year ago

Hi @fredericalpers , I would like to confirm some points with you:

  1. When I checked first, the "Land" field displays in the address as a single-select and the value option of the single-select is a number. => It leads to this issue: "Forms can not be submitted if a country name like "France" is entered. It is only possible to send a form when typing the value from onOffice enterprise "10" for France. If the input is 10 then the form is sent and also an address will be created." Attached image image

  2. Currently, I check and see that the "Land" field displays in the address as single-select and the value option of single-select is "short name lower case" Attached image

image So, when we changed it to single-select, the address record is created correctly and the value of "Land" got the correct country submitted from the form.

  1. However, another problem, that is: in the content of the email sent, the "Land" field did not display the value of the submitted country from the form. Attached image

image

Reason: on your backend when generating email content, the "Land" field only accepts the value as "short name lowercase". Please check it with your IT Department and let me know your opinions about this. Thanks!

fredericalpers commented 1 year ago

@dai-eastgate If I'm not confusing it myself right now, the field that is not displayed is the different "land" field. As mentioned in the comment above there are two different fields.

Can you confirm this?

yeneastgate commented 1 year ago

@fredericalpers Sorry, You seem to be confusing "short name lowercase" in this comment "the 'Land' field only accepts the value as "short name lowercase".

"short name lowercase" is short name lowercase of ISO code not mean is the "land" field. short name lower case

We seem to find a solution for the "change the field 'Land' to a single select in both frontend and backend" issue work fine("Land" field display normal even in content email ) I need a day to research and implement it. I will reponse you later.

yeneastgate commented 1 year ago

@fredericalpers I need onOffice API documentation for "do" action_id with "contactaddress" resourceType. image

We don't find it in the API doc this link https://apidoc.onoffice.de/ Please provide me as soon as possible, thanks

fredericalpers commented 1 year ago

@fredericalpers I need onOffice API documentation for "do" action_id with "contactaddress" resourceType. image

We don't find it in the API doc this link https://apidoc.onoffice.de/ Please provide me as soon as possible, thanks

@yeneastgate I will get back to you as soon as possible, thank you. :)

fredericalpers commented 1 year ago

@yeneastgate please check the following links if any of this is helpful otherwise I will send a ticket to our IT-Department for clarification:

yeneastgate commented 1 year ago

I have researched, implemented and found the following problems:

When creating a contact address record According to the "API doc", the field "Land" required data type as "STRING” and the value is "country as ISO 3166-1 alpha-3 value format" image

But actually, if I submit the "Land" field as "ISO 3166-1 alpha-3 value", I can create a contact address record on the enterprise according to the name of the country we submitted, but the mail does not show that field.

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/104892108/ba24a340-6a8c-4838-a114-7cc592d5580a

If I send the “Land” field as "the German-translated country name", then I can create address in both contact and email

With the API doc you send me: ApiResponseDoContactaddress(https://github.com/onOffice-Web-Org/oo-wp-plugin/blob/7a436759c3b386a27744cc67924ed6d57a73eb0a/tests/resources/ApiResponseDoContactaddress.json) I can't find anything related to 'Land'.

So I guess, the current reason is that when generating email content, the "Land" field shows only "the German-translated country name". For the input field value "FRA", the form will be sent with "no data" to the e-mail but in onOffice enterprise, the correct country will be added to the address.

Please check with your IT about these problems and let us know about your opinion. Thanks.

fredericalpers commented 1 year ago

postponed for now, since I'm still waiting for more information.

fredericalpers commented 10 months ago

We would like to split this issue into two issues. Before we do that we would like to confirm if the following is possible:

Since there is a problem with using ISO 3166-1 alpha-3 for the mail transmission, we would like to skip this and instead just transmit the value (e.g. 10 for france) in the mail for now. Would this be possible?

@yeneastgate

yeneastgate commented 10 months ago

@fredericalpers Yes, let me try again and report back to you with the clearest results

yeneastgate commented 10 months ago

instead just transmit the value (e.g. 10 for france) in the mail for now.

@fredericalpers The result is:

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/104892108/5e7fb2fe-e36c-4873-8e15-fa1ada492878

fredericalpers commented 10 months ago

@yeneastgate As mentioned above, the values for the "Land" field apparently have changed from numbers to short name lowercase. See comment for reference.

After testing again I found that sending the "Land" field from the "Address module" is possible when entering the correct value "Deutschland" for Germany.

E.g.: Using the interest form I've added the country (Land) field to contact details in the form. This will be displayed as followed in the frontend:

<input type="text" name="Land" value>

Entering the correct value e.g. "Deutschland" will correctly transmit the data to onOffice enterprise and also will correctly display it as "Land: Deutschland" in the e-mail.

The values of the options always have to be in german. The option-text will automatically change to the respective language in enterprise depending on which language is set for the user.

The desired outcome for this issue: (1) Change the "Land" field into a single select field in the WordPress backend and frontend. See below attached screenshots as examples.

select-example-backend

select-example-frontend

yeneastgate commented 10 months ago

@fredericalpers Could you please provide API documentation for the "Land" field? I couldn't find it in the API doc link. Thanks!

fredericalpers commented 10 months ago

@yeneastgate marked as blocked for now... It seems like the API doc is not 100% correct.

fredericalpers commented 10 months ago

@yeneastgate

(1) What is the GET request to get all available countries for address records?

https://apidoc.onoffice.de/actions/datensatz-anlegen/adressen/

The following request can be used to display the values for the "Land" field:

{
        "actionid":"urn:onoffice-de-ns:smart:2.5:smartml:action:get",
        "resourceid":"fieldvalues",
        "identifier":"",
        "resourcetype":"confignewaddressfields",
        "parameters":
        {
          "fieldname": "Land"
        }
}

(2) How do we have to write a post request to create an address record with a country?

https://apidoc.onoffice.de/actions/datensatz-anlegen/adressen/

For country, simply enter the ISO 3166-1 alpha-3 value such as "DEU" for Deutschland or "AUT" for Austria.

{
    "actionid":"urn:onoffice-de-ns:smart:2.5:smartml:action:create",
    "resourcetype":"address",
    "resourceid":"",
    "identifier":"",
    "parameters": {
        "Land":"AUT",
        "Vorname":"Max",
        "Name":"Mustermann"
    }
}
yeneastgate commented 10 months ago

@yeneastgate Thanks, I will check and let you know asap.

yeneastgate commented 10 months ago

The following request can be used to display the values for the "Land" field:

{
        "actionid":"urn:onoffice-de-ns:smart:2.5:smartml:action:get",
        "resourceid":"fieldvalues",
        "identifier":"",
        "resourcetype":"confignewaddressfields",
        "parameters":
        {
          "fieldname": "Land"
        }
}

@fredericalpers yes, I can display the values for the "Land" field When calling this API

yeneastgate commented 10 months ago

https://apidoc.onoffice.de/actions/datensatz-anlegen/adressen/

For country, simply enter the ISO 3166-1 alpha-3 value such as "DEU" for Deutschland or "AUT" for Austria.

{
    "actionid":"urn:onoffice-de-ns:smart:2.5:smartml:action:create",
    "resourcetype":"address",
    "resourceid":"",
    "identifier":"",
    "parameters": {
        "Land":"AUT",
        "Vorname":"Max",
        "Name":"Mustermann"
    }
}

@fredericalpers I created an address record with a country When entering the ISO 3166-1 alpha-3 value such as "DEU" for Deutschland

yeneastgate commented 10 months ago

@fredericalpers However, when I enter the ISO 3166-1 alpha-3 value such as "DEU" for Deutschland, the "Land" Field do not show the value in the email content. not show country in email content The reason is that this API is not working properly api send email ex: You can check this API on "sendEmail" function in file "FormPostInterest.php" The API has parameters

ex: I enter the ISO 3166-1 alpha-3 value such as "DEU" for Deutschland $addressData for the "Land" field was submitted correctly is "DEU" image

Please check the above API operation with the IT department and let me know the results.

fredericalpers commented 10 months ago

@yeneastgate as mentioned in this comment when using the german names of the countries everything works fine.

For that reason we want to investigate further but could not find how the plugin is "building" the email content. would you please be so kind and let us know where we can find how the plugin is "building" the email?

form-mail

yeneastgate commented 10 months ago

@fredericalpers I will check and let you know asap.

yeneastgate commented 10 months ago

where we can find how the plugin is "building" the email? @fredericalpers You can check this API on "sendEmail" function in file "FormPostContact.php". https://github.com/onOffice-Web-Org/oo-wp-plugin/blob/54921f8fca26e7446002e54a41029991c6871675/plugin/FormPostContact.php#L170

fredericalpers commented 10 months ago

@yeneastgate

As mentioned in this comment from september 6, more specifically

Entering the correct value e.g. "Deutschland" will correctly transmit the data to onOffice enterprise and also will correctly display it as "Land: Deutschland" in the e-mail.

Please implement a singleselect for both backend and frontend that's displaying the german full name of the countries such as Deutschland, Frankreich, Spanien etc. that are available in onOffice enterprise.

Also use this full name to transfer the data into onOffice enterprise and via email.

yeneastgate commented 10 months ago

@fredericalpers Ok, I will check

yeneastgate commented 9 months ago

@fredericalpers I tried using a few libraries(e.g.: League..) to get "the German full name of the countries" from "ISO 3166-1 alpha-3 code" However, the name of the countries returned is not the same name displayed on the enterprise. image => So please update the API response "https://apidoc.onoffice.de/actions/datensatz-anlegen/adressen/" return "the German full name of the countries" information. ex: { "id": "VIR", "type": "", "elements": { "title": "American Virgin Islands" "name": "the German full name of the countries" } },

fredericalpers commented 8 months ago

@yeneastgate https://apidoc.onoffice.de/actions/informationen-abfragen/single-and-multiselect-values/

shouldn't it be possible to display the german full name using the "title" of the response? The value of "title" should also be the one being displayed in the e-mail. In the attached XML however it should still use the corresponding ISO 3166-1 alpha-3, so onOffice enterprise can correctly interpret the value.

yeneastgate commented 6 months ago

@fredericalpers After researching again I found that:

shouldn't it be possible to display the german full name using the "title" of the response? The value of "title" should also be the one being displayed in the e-mail.

=> Yes, it is impossible to display the German full name using the "title" of the response When using the "contactaddress" API to send the email.

I also tried implementing testing on branch "35108-implement-change-land-field-input-to-single-select"

Step 1: Generate the "email body content" on the "onoffice wordpress plugin" side with the "sendmail" old API. Step 2: Processed the "addressData" with the "createStringFromInputData" method before passing it to $requestParams($body) => It is possible to display the German full name using the "title" of the response. image

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/104892108/bbb59185-822f-4df5-9e86-ef4a47abfd13

So I think: We missed process the "addressData" when generating the "content body of email" using the "contactaddress" API of the Onoffice Enterprise system. =>If we process the "addressData" => Possibly display the full German name using the "title" field when sending an email using the "contactaddress" API. => Please check with the IT department again.

In the attached XML however it should still use the corresponding ISO 3166-1 alpha-3, so onOffice enterprise can correctly interpret the value.

I checked again and I did not find <land></land> XML tags related to data processing for the "Land" field (even though I entered a value for the "Land" field when submitting the form).

=> Please check with the IT department generated miss <land></land> XML tags When using the "contactaddress" API to send emails has attachment XML.

fredericalpers commented 6 months ago

@yeneastgate

Step 1: Generate the "email body content" on the "onoffice wordpress plugin" side with the "sendmail" old API. Step 2: Processed the "addressData" with the "createStringFromInputData" method before passing it to $requestParams($body) => It is possible to display the German full name using the "title" of the response.

When using this, the transmission in the mail works as intended, correct?

The XML-Tag seems not to be necessary. It's currently not in the feedback.xml file which is attached to the email but the countries are transmitted to onOffice enterprise correctly.

nglelinh commented 6 months ago

@fredericalpers your last response is a little bit confusing for us. Let me try to summarize our understanding, please help to confirm

  1. the issue is missing a "Land" field in the email sending to the user
  2. current implementation uses the API endpoint - "contactaddress", which generates the email, but the logic on enterprise side misses "Land" field, and we can not control that to add the "Land field
  3. using the another API - "sendemail", we can generate the email content on the plugin side and add the missing "Land" field, but the plugin can not generate the .xml file

Question:

  1. what should we investigate more ?

If needed we can schedule a call to take about