Problem in the Report module with columns width in the Total row of a report table.

Hi team,

Problem in the Report module with columns width in the Total row of a report table.

I worked with reports in 7.10.4 version good enough.
After upgrade to 7.10.15 I have the problem.

I tested this problem with up to 10 reports worked well in 7.10.4 version right before upgrade.
All reports have the same problem.

Screenshot attached to the post.

RedHat. Linux Version 7.10.15 ( Sugar Version 6.5.25 (Build 344) )

Thanks, Alex

I found where is the problem could be.

In 7.10.4 template its OK. And a report shows me the structure of bottom row with totals correctly:

But in 7.10.15 after upgrade I see the problem with column width.
I think it happens because in the new template last raw starts wit TABLE tag.
But should starts just as new only.

Hope you fix it soon :slight_smile:
Thanks, Alex.

Yep. Just moving all content without

tags from the 2nd table “Total” with total raw to main table before the last
tag, then we get right template solution as before.

Code:

<table id="report_table_95693c2d-cce3-a58f-86b2-5cbef5d7be35" class="list view table-responsive aor_reports".......
<tbody>
....
</tbody>

<!-- second table moved here -->
<thead class="fc-head"><tr><th>Count Sum</th><th>Name Count</th><th></th><th></th><th></th><th></th></tr></thead><tbody><tr class="oddListRowS1"><td>36</td><td>19</td><td></td><td></td><td></td><td></td></tr></tbody>

</table>

Alex

Do you know which template file is this in? I mean, the original source file on the server.

Sorry I miss it.
No. I test it in the browser inspector (FireFox).

Version 7.10.15 Sugar Version 6.5.25 (Build 344)
Template is origin Suitecrm.
Admin > Profile > Themes = SuiteP

Alex

Alex

Hi. Found it here /modules/AOR_Reports//AOR_Report.php

reason - splitting to different tables cause columns width losses

Line 857 or near depends on code revision
original = $html .= $this->getTotalHTML($fields, $totals);

test code

$html .= htmlspecialchars( $this->getTotalHTML($fields, $totals) );

output:

ID Sum Area of help Count
230 36

1st problem is line 855 $html .= “”;
tag TABLE is closed

2nd problem is line 857 - the function getTotalHTML() returns raw but wrapped in tags TABLE

Where your team prepare total html code I dont know. I’m just newby in Suitecrm :slight_smile:

Alex

Hi. Temporaral solution is:
a) cut the table tag after main tbody
b) cut

tag for total raws in result of function $this->getTotalHTML($fields, $totals),

line 855

//        $html .= "</tbody></table>";
<------>$html .= "</tbody>"; // avoid closing current table to save column width in total raws

//        $html .= $this->getTotalHTML($fields, $totals);
<------>$html .= substr( $this->getTotalHTML($fields, $totals), 7); // trim starting 7 chars of tag  <table> tag to avoid une
        $html .= '</div>';

result:

Alex

If you check this view

https://github.com/salesagility/SuiteCRM/blame/master/modules/AOR_Reports/AOR_Report.php

it tells you the latest commits that affected each part of the code. This way we can try to find when this was broken. I suspect it was here

https://github.com/salesagility/SuiteCRM/commit/85f6d6d71029888240f371187d0b95633a063616

so I left a comment to the author here: https://github.com/salesagility/SuiteCRM/issues/5856#issuecomment-485795985

Let’s see if he answers…

Hi, thanks for posting the issue.
I opened my prod server with 7.10.4 and here is code withoud this issue and with the same logic as my fix.

AOR_Report.php

822 $html .= “”;
823
824 $html .= $this->getTotalHTML($fields, $totals);
825
826 $html .= ‘’;

Alex

How to delete an old message?

Hi, PGR :slight_smile:
I found your blog about my new question.
Here is the link to your article about it https://pgorod.github.io/Custom-folder/

I wanna to fix the bug we discussed before with custom module to be upgrade safe in the future.

  1. I creaded the /suitecrm/custom/modules/AOR_Reports/ folder (directory).
  2. Copy and made changes in AOR_Report.php
    Nothing changed.
    In the article you wrote that changes in php file works right after reload.

Any changes in the file /suitecrm/modules/AOR_Reports/AOR_Report.php work immediately and correctly.

a. Delete cache directory
= nothing chenged, same bug

b. Add some directories as I saw in other custom modules:
./language
./metadata
= nothing chenged, same bug

c. Rename original AOR_Report.php in ./modules/AOR_Reports/ to force CRM to use custom code
= error with module - it was expected

So it looks I did all right to add custom module php file.
But CRM doesn’t use it. Always use php file from original ./modules/

How to solve it ?
Red Hat, Apache
PS: Version 7.10.15 Sugar Version 6.5.25 (Build 344)

Thanks in advance, Alex

If this is a bug, it should be fixed by contributing to the core code on Github…

Not all files are customizable with that “custom folder” mechanism. It depends on how they are loaded.

In this case I believe you should use the Extension mechanism instead:

https://docs.suitecrm.com/developer/extension-framework/#_standard_extensions

That part about modules.ext.php will let you override this:

https://github.com/salesagility/SuiteCRM/blob/master/include/modules.php#L412

The version 7.10.16 has the same Total raw problem.

The reason is splitting to different tables as descibed above.
The same way to solve it.

Alex

Thanks @alex

7.11.5 this issue has not been fixed

I used your code to solve it.

Hi duongnk. For nothing :slight_smile: Have a nice time and CRM :slight_smile:
Alex

Hello, I am testing your solution, but I want to notice that the patch causes problems in PDF export.
After edit, I am experiencing empty pages in multipage pdf report export.
I will update you if I find a fix.

S

Hi guys !
Back to you with a little hack in getTotalHTML function to make everything work.
The PDF export problem was created by thead html tag.
Maybe somebody better than me can find a way to keep the style without breaking CSS.

        $html .= "</tbody>"; //removed </table>

        $html .= $this->getTotalHTML($fields, $totals);

        $html .= '</table></div>'; //moved </table

and rewrite fix the getTotalHTML function like that:

   public function getTotalHTML($fields, $totals)
    {
        global $app_list_strings;

        $currency = new Currency();
        $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));

        $showTotal = false;
        $html .= "<tbody><tr>"; //hack to fix PDF export

        foreach ($fields as $label => $field) {
            if (!$field['display']) {
                continue;
            }

            $fieldTotal = null;
            if (!isset($field['total'])) {
                LoggerManager::getLogger()->warn('AOR_Report problem: field[total] is not set for getTotalHTML()');
            } else {
                $fieldTotal = $field['total'];
            }

            $appListStringsAorTotalOptionsFieldTotal = null;
            if (!isset($app_list_strings['aor_total_options'][$fieldTotal])) {
                LoggerManager::getLogger()->warn('AOR_Report problem: app_list_strings[aor_total_options][fieldTotal] is not set for getTotalHTML()');
            } else {
                $appListStringsAorTotalOptionsFieldTotal = $app_list_strings['aor_total_options'][$fieldTotal];
            }


            if ($fieldTotal) {
                $showTotal = true;
                $totalLabel = $field['label'] . ' ' . $appListStringsAorTotalOptionsFieldTotal;
                $html .= "<th style='color:black'>{$totalLabel}</th>"; //added font color
            } else {
                $html .= '<th></th>';
            }
        }
        $html .= '<tbody></tr>';

        if (!$showTotal) {
            return '';
        }

SM

Note that this was already opened as an issue on Github

https://github.com/salesagility/SuiteCRM/issues/7979

and it has a fix

https://github.com/salesagility/SuiteCRM/pull/7984

which was merged 25 days ago.