From 3fe0ecf662dbb8403d2d4e19f8260ceee9171976 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Thu, 17 Jan 2013 15:55:08 +0000 Subject: [PATCH] * Infolog: fix problem regarding the display of wrong sums on timesheets when applying a search AND have multiple customfields set for timesheets --- timesheet/inc/class.timesheet_bo.inc.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index 460d8bad04..31a4849a21 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -506,6 +506,21 @@ class timesheet_bo extends so_sql_cf $this->summary = array(); return array(); } + if ($only_summary==false && $criteria && $this->show_sums) + { + // if we have a criteria AND intend to show the sums we first query the affected ids, + // then we throw away criteria and filter, and replace the filter with the list of ids + $ids = parent::search($criteria,'egw_timesheet.ts_id as id','','',$wildcard,$empty,$op,false,$filter,$join); + //_debug_array($ids); + if (empty($ids)) + { + $this->summary = array('duration'=>0,'price'=>null,'quantity'=>0); + return array(); + } + unset($criteria); + foreach ($ids as $r =>$v) $id_filter[] = $v['id']; + $filter = array('ts_id'=>$id_filter); + } // 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