Create documents in docx, xlsx (MS Office Word and Excel), odt, ods (LibreOffice and OpenOffice) and pdf format without MS Office or others plugins installed from any module and subpanel using templates.
#1539 - Sorting of line items
We are using SuiteCRM Version 7.8.10 with MailMergeReports 2.5.12 for creating documents in modules quotes and invoices in German language. In some cases, the sequence of line items is not the same as in SuiteCRM dialogue. It is very important for us that MMR uses the same sequence as it is in SuiteCRM.
This is the sequence in SuiteCRM dialogue:
This is the sequence in MMR document. The third item of Suite CRM is the first item of MMR. Fourth item SuiteCRM = Second item MMR. First item SuiteCRM = Third item MMR. Second item SuiteCMR = Fourth item MMR:
Please provide a correction so that the same sequence is used in SuiteCRM and MMR.
Regards, Wolf
6 years ago
Hi,
MMR does not control the order in which the data is presented, it is not a bug. There can be multiple circumstances to the order in which the data needs to be presented. To be able to sort the data you have to do it by code, extending the class DHA_DocumentTemplatesCalculatedFields.
You have two examples in custom/modules/Opportunities/DHA_DocumentTemplatesCalculatedFields.php (using calculated fields): - function OrderRows (event) - Order main module rows example - function BeforeMergeBlock (event) - Order rows example for submodule data
For this specific case, if you want to sort by line number, follow these steps: - Create a file called 'DHA_DocumentTemplatesCalculatedFields.php' in the '/custom/modules/AOS_Quotes' folder of SuiteCRM. - If necessary, assign the required permissions and owner to that file so that it does not fail when called from the server. - Copy the following code into the file and save:
Regards
6 years ago
Dear Izertis team,
Thank you! It works now, but is certainly not that easy to discover for a beginning user. I recommend adding this to some sort of FAQ.
I had to apply one minor adjustment: Your code sorted the report's product lines in the right sequence, but reversed order. Changing string "desc" in the SQL query line to "asc" changed that in the desired way.
Regards, Wolf
3 years ago
There is no need to hit the database again, very inefficient. what you really want to do is just sort the $data_array variable and add that back to the document generator instance