diff --git a/module/my/control.php b/module/my/control.php index f4eccf3ffa..fb55c88bc7 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -412,7 +412,7 @@ class my extends control $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->project; $this->view->position[] = $this->lang->my->project; $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->projects = $this->user->getProjects($this->app->user->account, 'project', $pager); + $this->view->projects = $this->user->getProjects($this->app->user->account, 'project', 'all', $pager); $this->view->pager = $pager; $this->view->status = $status; $this->display(); @@ -420,18 +420,28 @@ class my extends control /** * My executions. + * @param string $status undone|done + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * * @access public * @return void */ - public function execution() + public function execution($status = 'undone', $recTotal = 0, $recPerPage = 15, $pageID = 1) { $this->app->loadLang('project'); + /* Set the pager. */ + $this->app->loadClass('pager', $static = true); + $pager = new pager($recTotal, $recPerPage, $pageID); + $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->execution; $this->view->position[] = $this->lang->my->execution; $this->view->tabID = 'project'; - $this->view->executions = $this->user->getProjects($this->app->user->account, 'execution'); + $this->view->executions = $this->user->getProjects($this->app->user->account, 'execution', $status, $pager); + $this->view->status = $status; + $this->view->pager = $pager; $this->display(); } diff --git a/module/my/lang/en.php b/module/my/lang/en.php index c29e2f5924..b0da897126 100644 --- a/module/my/lang/en.php +++ b/module/my/lang/en.php @@ -32,6 +32,10 @@ $lang->my->name = 'Name'; $lang->my->code = 'Code'; $lang->my->projects = 'Project'; +$lang->my->executionMenu = new stdclass(); +$lang->my->executionMenu->undone = 'Undone'; +$lang->my->executionMenu->done = 'Done'; + $lang->my->taskMenu = new stdclass(); $lang->my->taskMenu->assignedToMe = 'AssignedToMe'; $lang->my->taskMenu->openedByMe = 'CreatedByMe'; diff --git a/module/my/lang/zh-cn.php b/module/my/lang/zh-cn.php index 62c4614aaf..242aeac851 100644 --- a/module/my/lang/zh-cn.php +++ b/module/my/lang/zh-cn.php @@ -32,6 +32,10 @@ $lang->my->name = '名称'; $lang->my->code = '代号'; $lang->my->projects = '项目'; +$lang->my->executionMenu = new stdclass(); +$lang->my->executionMenu->undone = '未结束'; +$lang->my->executionMenu->done = '已完成'; + $lang->my->taskMenu = new stdclass(); $lang->my->taskMenu->assignedToMe = '指派给我'; $lang->my->taskMenu->openedByMe = '由我创建'; diff --git a/module/my/view/execution.html.php b/module/my/view/execution.html.php index 6c8be874e9..b190c4de0c 100644 --- a/module/my/view/execution.html.php +++ b/module/my/view/execution.html.php @@ -13,7 +13,11 @@
@@ -26,11 +30,9 @@ - + - - @@ -38,16 +40,21 @@ + + createLink('project', 'browse', "id=$execution->id", '', '', $execution->project);?> - + - - - + @@ -62,10 +69,15 @@ + +
idAB;?> my->name;?>my->code;?>typeAB;?> my->projects;?> project->begin;?> project->end;?>team->role;?> team->join;?> team->hours;?>project->waitTasks;?>project->progress;?>
id);?>name);?>code;?>project->typeList, $execution->type);?> + + project->typeList, $execution->type);?> + + name);?> + createLink('project', 'browse', "id=$execution->project", '', '', $execution->project), $execution->projectName, '', "title='$execution->projectName'");?> begin;?> end;?>role;?> join;?> hours;?>waitTasks;?>progress}' data-border-color='#ddd' data-back-color='#f1f1f1'> {$execution->progress}%";?>
+
diff --git a/module/project/lang/en.php b/module/project/lang/en.php index c215ba8e06..add9106d84 100644 --- a/module/project/lang/en.php +++ b/module/project/lang/en.php @@ -76,6 +76,7 @@ $lang->project->relatedMember = 'Team'; $lang->project->watermark = 'Exported by ZenTao'; $lang->project->burnXUnit = '(Date)'; $lang->project->burnYUnit = '(Hours)'; +$lang->project->waitTasks = 'Waiting Tasks'; $lang->project->viewByUser = 'By User'; $lang->project->oneProduct = "Only one stage can be linked {$lang->productCommon}"; $lang->project->noLinkProduct = "Stage not linked {$lang->productCommon}"; diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php index d88d39fb88..8585d41a4e 100644 --- a/module/project/lang/zh-cn.php +++ b/module/project/lang/zh-cn.php @@ -76,6 +76,7 @@ $lang->project->relatedMember = '相关成员'; $lang->project->watermark = '由禅道导出'; $lang->project->burnXUnit = '(日期)'; $lang->project->burnYUnit = '(工时)'; +$lang->project->waitTasks = '待处理'; $lang->project->viewByUser = '按用户查看'; $lang->project->oneProduct = "阶段只能关联一个{$lang->productCommon}"; $lang->project->noLinkProduct = "阶段没有关联{$lang->productCommon}"; diff --git a/module/user/model.php b/module/user/model.php index c295bb31d7..1f88e55c8f 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -957,21 +957,67 @@ class userModel extends model * Get projects a user participated. * * @param string $account + * @param string $type + * @param string $status all|undone|done * @access public * @return array */ - public function getProjects($account, $type = 'project', $pager = null) + public function getProjects($account, $type = 'project', $status = 'all', $pager = null) { if($type == 'execution') $type = 'sprint,stage'; $myProjectsList = $this->dao->select('t1. *,t2. *')->from(TABLE_TEAM)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.root = t2.id') ->where('t1.type')->in($type) + ->beginIF($status == 'done')->andWhere('status')->in('done,closed')->fi() + ->beginIF($status == 'undone')->andWhere('status')->notin('done,closed')->fi() ->andWhere('t1.account')->eq($account) ->andWhere('t2.deleted')->eq(0) ->orderBy('t2.id_desc') ->page($pager) ->fetchGroup('project'); + $projectIdList = array(); + foreach($myProjectsList as $projects) + { + foreach($projects as $project) $projectIdList[] = $project->id; + } + + /* Get all tasks and compute totalConsumed, totalLeft, totalWait, progress according to them. */ + $hours = array(); + $emptyHour = array('totalConsumed' => 0, 'totalLeft' => 0, 'progress' => 0, 'waitTasks' => 0); + $searchField = $type == 'project' ? 'PRJ' : 'project'; + $tasks = $this->dao->select('id, PRJ, project, consumed, `left`, status') + ->from(TABLE_TASK) + ->where('parent')->lt(1) + ->andWhere($searchField)->in($projectIdList)->fi() + ->andWhere('deleted')->eq(0) + ->fetchGroup($searchField, 'id'); + + /* Compute totalEstimate, totalConsumed, totalLeft. */ + foreach($tasks as $projectID => $projectTasks) + { + $hour = (object)$emptyHour; + foreach($projectTasks as $task) + { + if($task->status == 'wait') + { + $hour->waitTasks += 1; + $hour->totalConsumed += $task->consumed; + } + if($task->status != 'cancel' and $task->status != 'closed') $hour->totalLeft += $task->left; + } + $hours[$projectID] = $hour; + } + + /* Compute totalReal and progress. */ + foreach($hours as $hour) + { + $hour->totalConsumed = round($hour->totalConsumed, 1); + $hour->totalLeft = round($hour->totalLeft, 1); + $hour->totalReal = $hour->totalConsumed + $hour->totalLeft; + $hour->progress = $hour->totalReal ? round($hour->totalConsumed / $hour->totalReal, 3) * 100 : 0; + } + $projectIdList = array_keys($myProjectsList); $projectList = $this->loadModel('program')->getPRJByIdList($projectIdList); @@ -987,6 +1033,10 @@ class userModel extends model if($delay > 0) $project->delay = $delay; } + /* Process the hours. */ + $project->progress = isset($hours[$project->id]) ? $hours[$project->id]->progress : 0; + $project->waitTasks = isset($hours[$project->id]) ? $hours[$project->id]->waitTasks : 0; + if($project->project) $project->projectName = $projectList[$project->project]->name; $myProjects[$project->id] = $project; }