diff --git a/module/project/model.php b/module/project/model.php index 7dc7d73661..b038877e23 100755 --- a/module/project/model.php +++ b/module/project/model.php @@ -256,7 +256,7 @@ class projectModel extends model /* Get team members and estimates under the project. */ $projectIdList = array_keys($projects); $teamCount = $this->projectTao->fetchMemberCountByIdList($projectIdList); - $estimates = $this->projectTao->fetchTaskEstimateByIdList($projectIdList); + $estimates = $this->projectTao->fetchTaskEstimateByIdList($projectIdList, 'estimate'); /* Set project attribute. */ $this->app->loadClass('pager', true); @@ -294,8 +294,7 @@ class projectModel extends model $teamCount = $this->projectTao->fetchMemberCountByIdList($projectIdList); /* Get all consumed and all estimate under the project. */ - $fields = 't2.project, ROUND(SUM(t1.consumed), 1) AS consumed, ROUND(SUM(t1.estimate), 1) AS estimate'; - $hours = $this->projectTao->fetchTaskEstimateByIdList($projectIdList, $fields); + $hours = $this->projectTao->fetchTaskEstimateByIdList($projectIdList, 'consumed,estimate'); /* Get bug, task and story summary under the project. */ $bugSummary = $this->projectTao->getTotalBugByProject($projectIdList); diff --git a/module/project/tao.php b/module/project/tao.php index d8c2469768..c0329dc3bf 100755 --- a/module/project/tao.php +++ b/module/project/tao.php @@ -737,9 +737,13 @@ class projectTao extends projectModel * @access protected * @return array */ - protected function fetchTaskEstimateByIdList(array $projectIdList, string $fields = 't2.project as project, sum(estimate) as estimate'): array + protected function fetchTaskEstimateByIdList(array $projectIdList, string $fields = 'estimate'): array { - return $this->dao->select($fields)->from(TABLE_TASK)->alias('t1') + $fields = explode(',', $fields); + $selectFields = 't2.project'; + foreach($fields as $field) $selectFields .= ", ROUND(SUM(t1.{$field}), 1) AS {$field}"; + + return $this->dao->select($selectFields)->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id') ->where('t1.parent')->lt(1) ->andWhere('t2.project')->in($projectIdList)