* fix for statistical data.
This commit is contained in:
+28
-20
@@ -284,9 +284,10 @@ class projectModel extends model
|
||||
->andWhere('type')->eq('project')
|
||||
->groupBy('root')->fetchPairs();
|
||||
|
||||
$hours = $this->dao->select('t2.parent as project, sum(t1.consumed) as consumed, sum(t1.estimate) as estimate')->from(TABLE_TASK)->alias('t1')
|
||||
$hours = $this->dao->select('t2.parent as project, ROUND(SUM(t1.consumed), 1) AS consumed, ROUND(SUM(t1.estimate), 1) AS estimate')->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id')
|
||||
->where('t2.project')->in($projectIdList)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t1.parent')->lt(1)
|
||||
->groupBy('t2.project')
|
||||
@@ -295,6 +296,7 @@ class projectModel extends model
|
||||
$leftTasks = $this->dao->select('t2.parent as project, count(*) as tasks')->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id')
|
||||
->where('t2.project')->in($projectIdList)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t1.status')->in('wait,doing,pause')
|
||||
->groupBy('t2.project')
|
||||
@@ -367,32 +369,38 @@ class projectModel extends model
|
||||
*/
|
||||
public function getWorkhour($projectID)
|
||||
{
|
||||
$executions = $this->loadModel('execution')->getPairs($projectID);
|
||||
|
||||
$total = $this->dao->select('
|
||||
ROUND(SUM(estimate), 1) AS totalEstimate,
|
||||
ROUND(SUM(`left`), 2) AS totalLeft')
|
||||
->from(TABLE_TASK)
|
||||
->where('execution')->in(array_keys($executions))
|
||||
->andWhere('deleted')->eq(0)
|
||||
->andWhere('parent')->lt(1)
|
||||
$total = $this->dao->select('ROUND(SUM(estimate), 1) AS totalEstimate, ROUND(SUM(`left`), 2) AS totalLeft')->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id')
|
||||
->where('t2.project')->in($projectID)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t1.parent')->lt(1)
|
||||
->fetch();
|
||||
|
||||
$totalConsumed = $this->dao->select('ROUND(SUM(consumed), 1) AS totalConsumed')->from(TABLE_TASK)
|
||||
->where('execution')->in(array_keys($executions))
|
||||
->andWhere('deleted')->eq(0)
|
||||
->andWhere('parent')->lt(1)
|
||||
$totalConsumed = $this->dao->select('ROUND(SUM(consumed), 1) AS totalConsumed')->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id')
|
||||
->where('t2.project')->in($projectID)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t1.parent')->lt(1)
|
||||
->fetch('totalConsumed');
|
||||
|
||||
$closedTotalLeft = $this->dao->select('ROUND(SUM(`left`), 2) AS totalLeft')->from(TABLE_TASK)
|
||||
->where('execution')->in(array_keys($executions))
|
||||
->andWhere('deleted')->eq(0)
|
||||
->andWhere('parent')->lt(1)
|
||||
->andWhere('status')->in('closed,cancel')
|
||||
$closedTotalLeft = $this->dao->select('ROUND(SUM(`left`), 2) AS totalLeft')->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id')
|
||||
->where('t2.project')->in($projectID)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t1.parent')->lt(1)
|
||||
->andWhere('t1.status')->in('closed,cancel')
|
||||
->fetch('totalLeft');
|
||||
|
||||
$workhour = new stdclass();
|
||||
$workhour->totalHours = $this->dao->select('sum(days * hours) AS totalHours')->from(TABLE_TEAM)->where('root')->in(array_keys($executions))->andWhere('type')->eq('project')->fetch('totalHours');
|
||||
$workhour->totalHours = $this->dao->select('sum(t1.days * t1.hours) AS totalHours')->from(TABLE_TEAM)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.root=t2.id')
|
||||
->where('t2.project')->in($projectID)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t1.type')->eq('project')
|
||||
->fetch('totalHours');
|
||||
$workhour->totalEstimate = $total->totalEstimate;
|
||||
$workhour->totalConsumed = $totalConsumed;
|
||||
$workhour->totalLeft = round($total->totalLeft - $closedTotalLeft, 1);
|
||||
|
||||
Reference in New Issue
Block a user