in2code-de / powermail

This is the official repository of the TYPO3 extension powermail! Powermail is a well-known, editor-friendly, powerful and easy mailform extension for TYPO3
https://in2code.de
88 stars 174 forks source link

Easy fix for inconsistent CSV output? #574

Closed StiftungMitarbeit closed 3 months ago

StiftungMitarbeit commented 4 years ago

(Powermail 8.1.2) When exporting mails to CSV via module, some answer fields that weren't filled out by the senders wouldn't show as ""; in their respective lines, causing the following answer fields to shift columns. Thus, the resulting CSV file couldn't be processed further. I fixed the issue by overriding the Module/ExportCsv.html template with a modified template. Instead of having the apostrophes and the semicolon generated within the type related if clauses, I put them right after the "for each fieldUids" line; leading/trailing spaces are eliminated with :

<f:comment>
    Content line
</f:comment>
<f:for each="{mails}" as="mail" iteration="index">
    <f:for each="{fieldUids}" as="fieldUid">
        "<f:spaceless>
            ~~~
            Here goes the rest of the code, any previously rendered " and ; omitted
            ~~~
        </f:spaceless>";
    </f:for>
    <br/>
</f:for>            
einpraegsam commented 4 years ago

Can you please explain to me in a simple example what I should do to see the issue on my system? E.g. creating a small form with 3 fields, add values "foo" in frontend, submit, etc...

StiftungMitarbeit commented 4 years ago

Create a form with two separate checkbox fields. Fill out name and email, but only the second checkbox field and submit:

Name: __ Email: __ Newsletter: ☐ I want to receive your newsletter Additional Mailings: ☒ I want to receive additional notifications, e.g. |Submit|

Then use the Powermail Backend Export module to export a CSV file. Open that CSV file in Excel or Calc and you will find the "Additional Mailings" answer in the "Newsletter" column.

peerlight commented 3 years ago

Another example (powermail 8.4.0):

CustomerID Name (mandatory if CustomerID empty by powermail_cond condition) E-Mail (mandatory) Textfield

If CustomerID is given -> Name field not shown -> no value for Name

Export as XLS is correct

Export as CSV misses ""; for Name in value line "CustomerID";"Name";"E-Mail";"Textfield"; "123456789";"name@domain.org";"some Text";

peerlight commented 2 years ago

I can confirm that this change of Module/ExportCsv.html solved my above mentioned problem in powermail 8.4.1

This works because "<f:spaceless>...</f:spaceless>"; is wrapping every fieldUid of the FORM like <td>...</td> in Module/ExportXls.html and not just existing fieldUids of the ANSWER.

netcoop commented 1 year ago

I have the same issue with v10.7.2. It happens when a checkbox or radiobutton field is left empty, then the CSV export fails to insert the field divider (';') for the empty field. The solution mentioned above works, although the use of the SpacelessViewhelper is bit ugly since that is meant for HTML content. Rendering CSV from a FLUID-template also has it's quirks, but I'd prefer to use a simple trim (not the one from Powermail! Use the VHS TrimViewhelper, or add one to Powermail). I would prefer adding a viewhelper for adding both the field separator and the string delimiter, which will also replace the delimiter (quotes) in the content, and trim whitespace. That will replace the RemoveQuoteViewHelper.

I'll make a PR

mschwemer commented 3 months ago

Tested it with the current release

I cannot reproduce this issue. We worked on that code the last year.

Please re-open the issue, if you are still hit by it.