Merge branch 'master' of https://gitlab.zcorp.cc/easycorp/zentaopms
This commit is contained in:
@@ -153,10 +153,11 @@ class programModel extends model
|
||||
* @param object $pager
|
||||
* @param int $programTitle
|
||||
* @param int $involved
|
||||
* @param bool $queryAll
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getProjectList($programID = 0, $browseType = 'all', $queryID = 0, $orderBy = 'id_desc', $pager = null, $programTitle = 0, $involved = 0)
|
||||
public function getProjectList($programID = 0, $browseType = 'all', $queryID = 0, $orderBy = 'id_desc', $pager = null, $programTitle = 0, $involved = 0, $queryAll = false)
|
||||
{
|
||||
$path = '';
|
||||
if($programID)
|
||||
@@ -170,8 +171,8 @@ class programModel extends model
|
||||
->beginIF($this->config->systemMode == 'new')->andWhere('type')->eq('project')->fi()
|
||||
->beginIF($browseType != 'all')->andWhere('status')->eq($browseType)->fi()
|
||||
->beginIF($path)->andWhere('path')->like($path . '%')->fi()
|
||||
->beginIF(!$this->app->user->admin and $this->config->systemMode == 'new')->andWhere('id')->in($this->app->user->view->projects)->fi()
|
||||
->beginIF(!$this->app->user->admin and $this->config->systemMode == 'classic')->andWhere('id')->in($this->app->user->view->sprints)->fi()
|
||||
->beginIF(!$queryAll and !$this->app->user->admin and $this->config->systemMode == 'new')->andWhere('id')->in($this->app->user->view->projects)->fi()
|
||||
->beginIF(!$queryAll and !$this->app->user->admin and $this->config->systemMode == 'classic')->andWhere('id')->in($this->app->user->view->sprints)->fi()
|
||||
->beginIF($this->cookie->involved or $involved)
|
||||
->andWhere('openedBy', true)->eq($this->app->user->account)
|
||||
->orWhere('PM')->eq($this->app->user->account)
|
||||
@@ -236,6 +237,44 @@ class programModel extends model
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get program and project progress list.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProgressList()
|
||||
{
|
||||
$TotalProgress = array();
|
||||
$projectCount = array();
|
||||
$progressList = array();
|
||||
$programPairs = $this->getPairs();
|
||||
$projectStats = $this->getProjectStats(0, 'all', 0, 'id_desc', null, 0, 0, true);
|
||||
|
||||
/* Add program progress. */
|
||||
foreach(array_keys($programPairs) as $programID)
|
||||
{
|
||||
$TotalProgress[$programID] = 0;
|
||||
$projectCount[$programID] = 0;
|
||||
$progressList[$programID] = 0;
|
||||
|
||||
foreach($projectStats as $project)
|
||||
{
|
||||
if(strpos($project->path, ',' . $programID . ',') === false) continue;
|
||||
$TotalProgress[$programID] += $project->hours->progress;
|
||||
$projectCount[$programID]++;
|
||||
}
|
||||
|
||||
if(empty($projectCount[$programID])) continue;
|
||||
$progressList[$programID] = round($TotalProgress[$programID] / $projectCount[$programID]);
|
||||
}
|
||||
|
||||
/* Add project progress. */
|
||||
foreach($projectStats as $project) $progressList[$project->id] = $project->hours->progress;
|
||||
|
||||
return $progressList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a program.
|
||||
*
|
||||
@@ -823,13 +862,14 @@ class programModel extends model
|
||||
* @param object $pager
|
||||
* @param string $programTitle
|
||||
* @param int $involved
|
||||
* @param bool $queryAll
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectStats($programID = 0, $browseType = 'undone', $queryID = 0, $orderBy = 'id_desc', $pager = null, $programTitle = 0, $involved = 0)
|
||||
public function getProjectStats($programID = 0, $browseType = 'undone', $queryID = 0, $orderBy = 'id_desc', $pager = null, $programTitle = 0, $involved = 0, $queryAll = false)
|
||||
{
|
||||
/* Init vars. */
|
||||
$projects = $this->getProjectList($programID, $browseType, $queryID, $orderBy, $pager, $programTitle, $involved);
|
||||
$projects = $this->getProjectList($programID, $browseType, $queryID, $orderBy, $pager, $programTitle, $involved, $queryAll);
|
||||
if(empty($projects)) return array();
|
||||
|
||||
$projectKeys = array_keys($projects);
|
||||
|
||||
Reference in New Issue
Block a user