Report export to CSV dont export the Total.

Im trying to customise the report to make a Grand Total at the end of the report.

While trying to do this I’ve encounters a “bug” :

The total “Cumul Annuel Totalajout” (In the screen circle in green) is not exported in the CSV.

My main goal, at the end, is to sum every “Cumul Annuel Totalajout” to make a grand total. But for now I just want to know how I can add this to the CSV ?

Thanks In advance

There is some unfinished work you can find here:

A PR was made, but not merged; then a LOT of time passed and there were many changes to that part of the code, so that now the PR is quite out-dated.

If you can do that work of adapting the PR to the new code, that would be great.

Thanks PGR.

Whats a PR ? (quite new to github)

I’ve saw the hotfix that was made. Added it to my file but yeah , its not really working, its messing with the CSV.

Im trying my best to edit this and make it work but im a young dev and its a little bit hard for me.

A PR is a Pull Request, it’s when somebody proposes a change to the code in our repository, and then we have to decide if we “pull” it into the product or not, merging the proposed changes with existing code.

Are you using an IDE to develop? Do you have Xdebug set up? If not, I challenge you to try it, it will increase your quality and productivity tremendously. It is also great for learning, since you can track through the flow of SuiteCRM code and see where it’s going, inspect variables, etc.

Thanks for clarifying this.

Im trying really hard to fix this, so I’ve followed how the PDF is exported, I think we need to do the exact same process for CSV.

I need to change everything since the click of “export”

But this dont work (in AOR_Report.php) :

$action = $_REQUEST['action'];
                if ($action == 'Export') {}

Still trying to fix this !

Did you just try applying these changes?

Of course.

The problem is that the total is looping for all the data, without taking the GROUP_BY in consideration.

So it make like a grand total of everything.

For the PDF, it makes every group, one by one, by calling build_report_html() every time / group (so it make a total of the group, not a grand total.)

That’s why the PDF working great, I need to make the exact same thing for the CSV. By calling build_report_csv() every group, and make the total of the group.

For now with this code :

$totals[$name][] = $row[$name];
$csv .= $this->getTotalCSV($fields,$totals);

It take everything in the array and so, it make a grand total, not a total by group.

Sorry if it’s not really clear, my english may not be perfect.

I’d love to jump into this and write the function for you, it would actually count as a fun time for me (geek!) but I’m afraid I just don’t have the time.

It shouldn’t be too difficult, maybe try to get some help in a programming website if needed… it’s just a PHP routine to grab SQL results and dump them in text…

Okay, so I’ve finally done it. Will look how to push it on github.

Its ofc a newbie version not optimized at all, but the main code is done so someone with more skill can optimize it.

That’s cool B-), looking forward to seeing that!


Its done :

Sry in advance, its my first ever PR ahah


Do you have a solution to override AOR_Report.php ? I’ve created /SuiteCRM/custom/modules/AOR_Reports/ with all the file but it wont take my AOR_Report.php, it take the original file (wich I have to edit every update…)

Is there a way to override it like the views file for exemple, wich are working ! My /SuiteCRM/custom/modules/AOR_Reports/views/view.detail.php is correctly working ! but /SuiteCRM/custom/modules/AOR_Reports/AOR_Report.php not ahah

Yes, using the Extension Framework:

The one you want is “include”, so put a file in


In it, redefine this value:


$beanFiles['AOR_Report'] = 'custom/modules/AOR_Reports/AOR_Report.php';

Then run a QR&R and check it got included in this file:


Damn dont know about this sorry to ask.

I have created /SuiteCRM/custom/Extension/application/Ext/Include/AOR_Report_perso.php with this code :

$beanFiles['AOR_Report'] = 'custom/modules/AOR_Reports/AOR_Report.php';


But during the QR&R I’ve got this error :

Fatal error: Cannot declare class AOR_Report, because the name is already in use in …/htdocs/SuiteCRM/custom/modules/AOR_Reports/AOR_Report.php on line 1896

Quick Update :

Re done a QR&R and it work… without changing anything… Thanks for the help as always !

One last question : If during an update, the original file (/modules/AOR_Reports/AOR_Report.php) is changed, with new stuff/code, what is going to happen ?

I will not have this new code cause it take my custom php file ?

Correct. You will be alerted to this during the upgrade, and then you need to manually check the new changes and merge the two files.

1 Like


I’ve done a part of code that make a grand total of every fields that have been put as total by the user like this :

Everything is done in AOR_Report.php so I’ll be able to put the code in the PDF and the CSV too.

Do you want me to push it on github too ?

I guess you can push it there also, yes. I don’t use Reports a lot so I don’t know exactly what people need in that module, but hopefully others might comment on your contribution. Thanks

Done !

Hope this will help someone else. For me its a must-have feature for a report module.