Merge branch '12.x'

This commit is contained in:
wangyidong
2021-02-19 13:17:23 +08:00
109 changed files with 5297 additions and 1570 deletions
+64 -91
View File
@@ -254,14 +254,21 @@ class report extends control
}
/**
* Show personal annual data
* Show annual data
*
* @param string $year
* @param string $dept
* @param string $userID
* @access public
* @return void
*/
public function annualData($year = '')
{
$account = $this->app->user->account;
public function annualData($year = '', $dept = '', $userID = '')
{
$this->app->loadLang('story');
$this->app->loadLang('task');
$this->app->loadLang('bug');
$this->app->loadLang('testcase');
$firstAction = $this->dao->select('*')->from(TABLE_ACTION)->orderBy('id')->limit(1)->fetch();
$currentYear = date('Y');
$firstYear = empty($firstAction) ? $currentYear : substr($firstAction->date, 0, 4);
@@ -282,101 +289,67 @@ class report extends control
}
}
/* Get common annual data. */
/* Get users and depts. */
$users = $this->loadModel('user')->getPairs('noletter|useid|noclosed');
$users[''] = $this->lang->report->annualData->allUser;
$depts = $this->loadModel('dept')->getOptionMenu();
$depts = array('' => $this->lang->report->annualData->allDept) + $depts;
if(empty($userID)) unset($depts[0]);
$accounts = array();
if($dept)
{
$accounts = $this->loadModel('dept')->getDeptUserPairs($dept);
}
if($userID)
{
$user = $this->loadModel('user')->getById($userID, 'id');
$dept = $user->dept;
$accounts = array($user->account => ($user->realname ? $user->realname : $user->account));
}
if($accounts) $accounts = array_keys($accounts);
if($dept)
{
$users = $this->loadModel('dept')->getDeptUserPairs($dept, 'useid');
$users = array('' => $this->lang->report->annualData->allUser) + $users;
}
/* Get annual data. */
$data = array();
$data['logins'] = $this->report->getUserYearLogins($account, $year);
/* Set role. */
$role = 'po';
if($this->app->user->role == 'dev' or $this->app->user->role == 'td' or $this->app->user->role == 'pm') $role = 'dev';
if($this->app->user->role == 'qd' or $this->app->user->role == 'qa') $role = 'qa';
/* Get annual data by role. */
if($role == 'po')
if(!$userID)
{
$products = $this->report->getUserYearProducts($account, $year);
$data['involvedProducts'] = count($products);
$planGroups = $this->report->getPlansByProducts($products, $account, $year);
$planCount = 0;
foreach($planGroups as $plans) $planCount += $plans;
$data['createdPlans'] = $planCount;
$data['productStat'] = $this->report->getStatByProducts($products, $account, $year);
$storyInfo = $this->report->getUserYearStory($products, $account, $year);
$data['createdStories'] = $storyInfo['count'];
$data['storyPri'] = $storyInfo['pri'];
$data['storyStage'] = $storyInfo['stage'];
$data['storyMonth'] = $storyInfo['month'];
$storyGroups = $this->report->getStoriesByProducts($products, $account, $year);
foreach($products as $productID => $product)
{
$product->plans = zget($planGroups, $productID, 0);
$product->stories = zget($storyGroups, $productID, 0);
}
$data['products'] = $products;
$data['users'] = $dept ? count($accounts) : (count($users) - 1);
}
elseif($role == 'dev')
else
{
$data['actions'] = $this->report->getUserYearActions($account, $year);
$efforts = $this->report->getUserYearEfforts($account, $year);
$data['efforts'] = $efforts->count;
$data['consumed'] = round($efforts->consumed, 2);
$projects = $this->report->getUserYearProjects($account, $year);
$projectStat = $this->report->getStatByProjects($projects);
$tasks = $this->report->getUserYearFinishedTasks($account, $year);
$bugs = $this->report->getUserYearResolvedBugs($account, $year);
$data['finishedTaskPri'] = $tasks['pri'];
$data['resolvedBugPri'] = $bugs['pri'];
$data['taskMonth'] = $tasks['month'];
$data['bugMonth'] = $bugs['month'];
$data['effortMonth'] = $this->report->getEffort4Month($account, $year);;
$stories = $this->report->getFinishedStoryByProjects($projects, $account, $year);
$tasks = $this->report->getFinishedTaskByProjects($projects, $account, $year);
$bugs = $this->report->getResolvedBugByProjects($projects, $account, $year);
foreach($projects as $projectID => $project)
{
$project->stories = zget($stories, $projectID, 0);
$project->tasks = zget($tasks, $projectID, 0);
$project->bugs = zget($bugs, $projectID, 0);
}
$data['projects'] = $projects;
$data['projectStat'] = $projectStat;
$data['logins'] = $this->report->getUserYearLogins($accounts, $year);
}
elseif($role == 'qa')
{
$data['actions'] = $this->report->getUserYearActions($account, $year);
$bugInfo = $this->report->getUserYearCreatedBugs($account, $year);
$data['foundBugs'] = $bugInfo['count'];
$data['bugPri'] = $bugInfo['pri'];
$data['bugMonth'] = $bugInfo['month'];
$data['actions'] = $this->report->getUserYearActions($accounts, $year);
$data['todos'] = $this->report->getUserYearTodos($accounts, $year);
$data['contributions'] = $this->report->getUserYearContributions($accounts, $year);
$data['projectStat'] = $this->report->getUserYearProjects($accounts, $year);
$data['productStat'] = $this->report->getUserYearProducts($accounts, $year);
$data['storyStat'] = $this->report->getYearObjectStat($accounts, $year, 'story');
$data['taskStat'] = $this->report->getYearObjectStat($accounts, $year, 'task');
$data['bugStat'] = $this->report->getYearObjectStat($accounts, $year, 'bug');
$data['caseStat'] = $this->report->getYearCaseStat($accounts, $year);
$caseInfo = $this->report->getUserYearCreatedCases($account, $year);
$data['createdCases'] = $caseInfo['count'];
$data['casePri'] = $caseInfo['pri'];
$data['caseMonth'] = $caseInfo['month'];
$yearEfforts = $this->report->getUserYearEfforts($accounts, $year);
$data['consumed'] = $yearEfforts->consumed;
$products = $this->report->getUserYearProducts4QA($account, $year);
$productStat = $this->report->getBugStatByProducts($products, $account, $year);
if(empty($dept) and empty($userID)) $data['statusStat'] = $this->report->getAllTimeStatusStat();
$bugs = $this->report->getCreatedBugByProducts($products, $account, $year);
foreach($products as $productID => $product) $product->bugs = zget($bugs, $productID, 0);
$data['products'] = $products;
$data['productStat'] = $productStat;
}
$this->view->title = sprintf($this->lang->report->annualData->title, $year, $this->app->user->realname);
$this->view->data = $data;
$this->view->role = $role;
$this->view->year = $year;
$this->view->years = $years;
$this->view->title = sprintf($this->lang->report->annualData->title, ($userID ? $users[$userID] : ($dept ? substr($depts[$dept], strrpos($depts[$dept], '/') + 1) : $depts[''])), $year);
$this->view->data = $data;
$this->view->year = $year;
$this->view->users = $users;
$this->view->depts = $depts;
$this->view->years = $years;
$this->view->dept = $dept;
$this->view->userID = $userID;
$this->view->months = $this->report->getYearMonths($year);
die($this->display());
}
}