Merge branch '20.x' of github.com:easysoft/zentaopms into 20.x

This commit is contained in:
z
2020-08-24 10:19:56 +08:00
24 changed files with 574 additions and 256 deletions
+94 -1
View File
@@ -43,7 +43,7 @@ class programModel extends model
public function getUserPrograms($status = 'all', $orderBy = 'id_desc', $limit = 15)
{
return $this->dao->select('*')->from(TABLE_PROJECT)
$programs = $this->dao->select('*')->from(TABLE_PROJECT)
->where('iscat')->eq(0)
->andWhere('template')->ne('')
->andWhere('program')->eq(0)
@@ -53,6 +53,99 @@ class programModel extends model
->orderBy($orderBy)
->limit($limit)
->fetchAll('id');
if(empty($programs)) return array();
$programIdList = array_keys($programs);
$consumes = $this->dao->select('program, sum(consumed) as consumed')->from(TABLE_TASK)
->where('program')->in($programIdList)
->andWhere('deleted')->eq(0)
->andWhere('parent')->lt(1)
->groupBy('program')
->fetchAll('program');
$teams = $this->dao->select('root, count(*) as count')->from(TABLE_TEAM)
->where('root')->in($programIdList)
->groupBy('root')
->fetchAll('root');
$leftTasks = $this->dao->select('program, count(*) as leftTasks')->from(TABLE_TASK)
->where('program')->in($programIdList)
->andWhere('deleted')->eq(0)
->andWhere('status')->in('wait,doing,pause')
->groupBy('program')
->fetchAll('program');
$leftStories = $this->dao->select('program, count(*) as leftStories')->from(TABLE_STORY)
->where('program')->in($programIdList)
->andWhere('deleted')->eq(0)
->andWhere('status')->eq('active')
->groupBy('program')
->fetchAll('program');
$leftBugs = $this->dao->select('program, count(*) as leftBugs')->from(TABLE_BUG)
->where('program')->in($programIdList)
->andWhere('deleted')->eq(0)
->andWhere('status')->eq('active')
->groupBy('program')
->fetchAll('program');
foreach($programs as $programID => $program)
{
$program->teamCount = isset($teams[$programID]) ? $teams[$programID]->count : 0;
$program->consumed = isset($consumes[$programID]) ? $consumes[$programID] : 0;
$program->leftTasks = isset($leftTasks[$programID]) ? $leftTasks[$programID] : 0;
$program->leftStories = isset($leftStories[$programID]) ? $leftStories[$programID] : 0;
$program->leftBugs = isset($leftBugs[$programID]) ? $leftBugs[$programID] : 0;
}
return $programs;
}
/**
* Get program stats.
*
* @param string $status
* @param int $itemCounts
* @param string $orderBy
* @param int $pager
* @access public
* @return void
*/
public function getProgramStats($status = 'undone', $itemCounts = 30, $orderBy = 'order_desc', $pager = null)
{
/* Init vars. */
$this->loadModel('project');
$programs = $this->getList($status, $orderBy, $pager);
if(empty($programs)) return array();
$programIdList = array_keys($programs);
$programs = $this->dao->select('*')->from(TABLE_PROJECT)
->where('id')->in($programIdList)
->orderBy($orderBy)
->limit($itemCounts)
->fetchAll('id');
$teams = $this->dao->select('root, count(*) as count')->from(TABLE_TEAM)
->where('root')->in($programIdList)
->groupBy('root')
->fetchAll('root');
$estimates = $this->dao->select('program, sum(estimate) as estimate')->from(TABLE_TASK)
->where('program')->in($programIdList)
->andWhere('deleted')->eq(0)
->andWhere('parent')->lt(1)
->groupBy('program')
->fetchAll('program');
foreach($programs as $programID => $program)
{
$program->projects = $this->project->getProjectStats($status, 0, 0, $itemCounts, 'id_desc', $pager, $programID);
$program->teamCount = isset($teams[$programID]) ? $teams[$programID]->count : 0;
$program->estimate = isset($estimates[$programID]) ? $estimates[$programID]->estimate : 0;
}
return $programs;
}
/**