From a6a30e80b5211e67a14dafb8632210770c800cab Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 11 Apr 2023 17:32:55 -0600 Subject: [PATCH] Timesheet: Fix broken total in header Passing columns as string caused them to get split by comma, but $total_sql had round(...,2) in it. Changed to use array. --- timesheet/inc/class.timesheet_bo.inc.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index fced160675..6bc0814fb0 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -510,12 +510,20 @@ class timesheet_bo extends Api\Storage // if we only want to return the summary (sum of duration and sum of price) we have to take care that the customfield table // is not joined, as the join causes a multiplication of the sum per customfield found // joining of the cutomfield table is triggered by criteria being set with either a string or an array - $this->summary = parent::search($only_summary ? null : $criteria, - "SUM(ts_duration) AS duration,SUM($total_sql) AS price,MAX(ts_modified) AS max_modified". - ($this->quantity_sum ? ",SUM(ts_quantity) AS quantity" : ''), + $cols = ['SUM(ts_duration) AS duration', + "SUM($total_sql) AS price", + 'MAX(ts_modified) AS max_modified']; + if($this->quantity_sum) + { + $cols[] = 'SUM(ts_quantity) AS quantity'; + } + $this->summary = parent::search( + $only_summary ? null : $criteria, + $cols, '', '', $wildcard, $empty, $op, false, $only_summary && is_array($criteria) ? ($filter ? array_merge($criteria, (array)$filter) : $criteria) : $filter, - $only_summary ? '' : $join); + $only_summary ? '' : $join + ); $this->summary = $this->summary[0]; $this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']);