Total Sum is defaulting to type hidden due to missing break in swtich case. #5053

Open
opened 2026-02-20 16:28:49 -05:00 by deekerman · 0 comments
Owner

Originally created by @JamesBrickell on GitHub (Aug 16, 2023).

Issue

The switch case on line 966 of AOR_Report.php is not logically sound for case of type SUM causing the value to be of type=hidden in the html.
https://github.com/salesagility/SuiteCRM/blob/hotfix/modules/AOR_Reports/AOR_Report.php#L966

If a case is not defined it defaults to the next defined case in this case is the case for AVG which calls the getModuleField function, please see: https://www.php.net/manual/en/control-structures.switch.php#:~:text=The%20statement%20list%20for%20a%20case%20can%20also%20be%20empty%2C%20which%20simply%20passes%20control%20into%20the%20statement%20list%20for%20the%20next%20case.

Expected Behavior

The expected behavior is to break on this case since total is defined by line 964.
https://github.com/salesagility/SuiteCRM/blob/hotfix/modules/AOR_Reports/AOR_Report.php#L964

Actual Behavior

Instead the code passes through the SUM case into the next defined AVG case.

Possible Fix

            if ($field['total'] && isset($totals[$label])) {
                $type = $field['total'];
                $total = $this->calculateTotal($type, $totals[$label]);
                $params = isset($field['params']) ? $field['params'] : [];
                switch ($type) {
                    case 'SUM':
//FIX                 break;
                    case 'AVG':
                        $total = getModuleField(
                            $field['module'],
                            $field['field'],
                            $field['field'],
                            'DetailView',
                            $total,
                            '',
                            $currency->id,
                            $params
                        );
                        break;
                    case 'COUNT':
                    default:
                        break;
                }
                $html .= '<td>' . $total . '</td>';

Steps to Reproduce

  1. Create a report using AOR_Report.
  2. For one of the fields select sum total.

Context

Missing sum total from reports.

Your Environment

  • SuiteCRM Version used: 7.7.11.23
  • PHP5.6
Originally created by @JamesBrickell on GitHub (Aug 16, 2023). #### Issue <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> The switch case on line 966 of AOR_Report.php is not logically sound for case of type SUM causing the value to be of type=hidden in the html. https://github.com/salesagility/SuiteCRM/blob/hotfix/modules/AOR_Reports/AOR_Report.php#L966 If a case is not defined it defaults to the next defined case in this case is the case for AVG which calls the getModuleField function, please see: https://www.php.net/manual/en/control-structures.switch.php#:~:text=The%20statement%20list%20for%20a%20case%20can%20also%20be%20empty%2C%20which%20simply%20passes%20control%20into%20the%20statement%20list%20for%20the%20next%20case. #### Expected Behavior The expected behavior is to break on this case since total is defined by line 964. https://github.com/salesagility/SuiteCRM/blob/hotfix/modules/AOR_Reports/AOR_Report.php#L964 #### Actual Behavior Instead the code passes through the SUM case into the next defined AVG case. #### Possible Fix ``` if ($field['total'] && isset($totals[$label])) { $type = $field['total']; $total = $this->calculateTotal($type, $totals[$label]); $params = isset($field['params']) ? $field['params'] : []; switch ($type) { case 'SUM': //FIX break; case 'AVG': $total = getModuleField( $field['module'], $field['field'], $field['field'], 'DetailView', $total, '', $currency->id, $params ); break; case 'COUNT': default: break; } $html .= '<td>' . $total . '</td>'; ``` #### Steps to Reproduce 1. Create a report using AOR_Report. 2. For one of the fields select sum total. #### Context Missing sum total from reports. #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.7.11.23 * PHP5.6
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#5053
No description provided.