diff --git a/module/execution/control.php b/module/execution/control.php index e89d613e03..477a68ad5d 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1496,7 +1496,7 @@ class execution extends control $this->view->name = $name; $this->view->code = $code; $this->view->team = $team; - $this->view->teams = array(0 => '', $projectID => (isset($project->name) ? $project->name : '')) + $this->execution->getCanCopyObjects((int)$projectID); + $this->view->teams = array(0 => '') + $this->execution->getCanCopyObjects((int)$projectID); $this->view->allProjects = array(0 => '') + $this->project->getPairsByModel('all', 0, 'noclosed'); $this->view->executionID = $executionID; $this->view->productID = $productID; @@ -2730,7 +2730,7 @@ class execution extends control $currentMembers = $this->execution->getTeamMembers($executionID); $members2Import = $this->execution->getMembers2Import($team2Import, array_keys($currentMembers)); - $teams2Import = $this->loadModel('personnel')->getCopiedObjects($executionID, 'sprint'); + $teams2Import = $this->loadModel('personnel')->getCopiedObjects($executionID, 'sprint', true); $teams2Import = array('' => '') + $teams2Import; /* Append users for get users. */ diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php index e7f31a3056..e212fcdba8 100644 --- a/module/execution/lang/en.php +++ b/module/execution/lang/en.php @@ -396,6 +396,7 @@ $lang->execution->projectNotEmpty = 'Project cannot be empty.'; $lang->execution->confirmStoryToTask = $lang->SRCommon . '%s are converted to tasks in the current. Do you want to convert them anyways?'; $lang->execution->ge = "『%s』should be >= actual begin『%s』."; $lang->execution->storyDragError = "The {$lang->SRCommon} is still a draft or has been changed, please drag it after the review"; +$lang->execution->countTip = ' (%s member)'; /* Statistics. */ $lang->execution->charts = new stdclass(); diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index 7722eb13d6..6edf842aef 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -396,6 +396,7 @@ $lang->execution->projectNotEmpty = '所属项目不能为空。'; $lang->execution->confirmStoryToTask = '%s' . $lang->SRCommon . '已经在当前' . $lang->execution->common . '中转了任务,请确认是否重复转任务。'; $lang->execution->ge = "『%s』应当不小于实际开始时间『%s』。"; $lang->execution->storyDragError = "该{$lang->SRCommon}还是草稿或已变更状态,请评审通过后再拖动"; +$lang->execution->countTip = '(%s人)'; /* 统计。*/ $lang->execution->charts = new stdclass(); diff --git a/module/execution/model.php b/module/execution/model.php index 1cc5b1f52d..c09d465202 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2743,14 +2743,31 @@ class executionModel extends model $objectPairs = $this->dao->select('id,name')->from(TABLE_PROJECT) ->where('deleted')->eq(0) + ->andWhere('project', true)->eq($projectID) ->andWhere('type')->ne('project') - ->andWhere('(project')->eq($projectID) - ->orWhere('id')->eq($projectID) ->markRight(1) + ->orWhere('id')->eq($projectID) ->orderBy('type_asc,openedDate_desc') ->limit('9') ->fetchPairs(); + $countPairs = $this->dao->select('root, COUNT(*) as count')->from(TABLE_TEAM) + ->where('( type')->eq('project') + ->andWhere('root')->eq($projectID) + ->markRight(1) + ->orWhere('( type')->eq('execution') + ->andWhere('root')->in(array_keys($objectPairs)) + ->markRight(1) + ->groupBy('root') + ->fetchPairs('root'); + + foreach($objectPairs as $objectID => $objectName) + { + $memberCount = zget($countPairs, $objectID, 0); + $countTip = $memberCount > 1 ? str_replace('member', 'members', $this->lang->execution->countTip) : $this->lang->execution->countTip; + $objectPairs[$objectID] = $objectName . sprintf($countTip, $memberCount); + } + return $objectPairs; } diff --git a/module/personnel/lang/de.php b/module/personnel/lang/de.php index fab6b23d11..1ccd82d13d 100644 --- a/module/personnel/lang/de.php +++ b/module/personnel/lang/de.php @@ -38,3 +38,4 @@ $lang->personnel->copy = 'Copy Whitelist'; $lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.'; $lang->personnel->selectObjectTips = 'Select %s to copy its whitelist'; +$lang->personnel->countTip = ' (%s member)'; diff --git a/module/personnel/lang/en.php b/module/personnel/lang/en.php index 3f78c567f9..fc2b640f72 100644 --- a/module/personnel/lang/en.php +++ b/module/personnel/lang/en.php @@ -38,3 +38,4 @@ $lang->personnel->copy = 'Copy Whitelist'; $lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.'; $lang->personnel->selectObjectTips = 'Select %s to copy its whitelist'; +$lang->personnel->countTip = ' (%s member)'; diff --git a/module/personnel/lang/fr.php b/module/personnel/lang/fr.php index fab6b23d11..1ccd82d13d 100644 --- a/module/personnel/lang/fr.php +++ b/module/personnel/lang/fr.php @@ -38,3 +38,4 @@ $lang->personnel->copy = 'Copy Whitelist'; $lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.'; $lang->personnel->selectObjectTips = 'Select %s to copy its whitelist'; +$lang->personnel->countTip = ' (%s member)'; diff --git a/module/personnel/lang/vi.php b/module/personnel/lang/vi.php index fab6b23d11..1ccd82d13d 100644 --- a/module/personnel/lang/vi.php +++ b/module/personnel/lang/vi.php @@ -38,3 +38,4 @@ $lang->personnel->copy = 'Copy Whitelist'; $lang->personnel->openedPGMTip = 'The program is public and can be accessed by users with Program privileges.'; $lang->personnel->selectObjectTips = 'Select %s to copy its whitelist'; +$lang->personnel->countTip = ' (%s member)'; diff --git a/module/personnel/lang/zh-cn.php b/module/personnel/lang/zh-cn.php index d5b345f623..7ff83f85d5 100644 --- a/module/personnel/lang/zh-cn.php +++ b/module/personnel/lang/zh-cn.php @@ -38,3 +38,4 @@ $lang->personnel->copy = '复制白名单'; $lang->personnel->openedPGMTip = '该项目集是公开状态,有项目集视图权限的人员即可访问。'; $lang->personnel->selectObjectTips = '请选择一个%s白名单来复制'; +$lang->personnel->countTip = '(%s人)'; diff --git a/module/personnel/lang/zh-tw.php b/module/personnel/lang/zh-tw.php index cf13e67ab1..9a23a0db5d 100644 --- a/module/personnel/lang/zh-tw.php +++ b/module/personnel/lang/zh-tw.php @@ -38,3 +38,4 @@ $lang->personnel->copy = '複製白名單'; $lang->personnel->openedPGMTip = '該項目集是公開狀態,有項目集視圖權限的人員即可訪問。'; $lang->personnel->selectObjectTips = '請選擇一個%s白名單來複制'; +$lang->personnel->countTip = '(%s人)'; diff --git a/module/personnel/model.php b/module/personnel/model.php index e566e6d0b1..d4833d2afb 100644 --- a/module/personnel/model.php +++ b/module/personnel/model.php @@ -466,10 +466,11 @@ class personnelModel extends model * * @param int $objectID * @param int $objectType + * @param bool $addCount * @access public * @return array */ - public function getCopiedObjects($objectID, $objectType) + public function getCopiedObjects($objectID, $objectType, $addCount = false) { $objects = array(); @@ -512,6 +513,28 @@ class personnelModel extends model } unset($objects[$objectID]); + + if($addCount) + { + $objectType = $objectType == 'sprint' ? 'execution' : $objectType; + $countPairs = $this->dao->select('root, COUNT(*) as count')->from(TABLE_TEAM) + ->where('type')->eq($objectType) + ->andWhere('root')->in(array_keys($objects)) + ->beginIF($objectType == 'execution') + ->orWhere('( type')->eq('project') + ->andWhere('root')->eq($parentID)->markRight(1) + ->fi() + ->groupBy('root') + ->fetchPairs('root'); + + foreach($objects as $objectID => $objectName) + { + $memberCount = zget($countPairs, $objectID, 0); + $countTip = $memberCount > 1 ? str_replace('member', 'members', $this->lang->personnel->countTip) : $this->lang->personnel->countTip; + $objects[$objectID] = $objectName . sprintf($countTip, $memberCount); + } + } + return $objects; } diff --git a/module/project/control.php b/module/project/control.php index 5bfc6e474e..69dabdd709 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1455,7 +1455,7 @@ class project extends control $this->view->depts = array('' => '') + $this->dept->getOptionMenu(); $this->view->currentMembers = $currentMembers; $this->view->members2Import = $members2Import; - $this->view->teams2Import = array('' => '') + $this->loadModel('personnel')->getCopiedObjects($projectID, 'project'); + $this->view->teams2Import = array('' => '') + $this->loadModel('personnel')->getCopiedObjects($projectID, 'project', true); $this->view->copyProjectID = $copyProjectID; $this->display(); }