From e3208f224adbf64f531ea56607760de5a2a3e516 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Mon, 28 Dec 2020 14:12:17 +0800 Subject: [PATCH] * Finish task#8739. --- module/program/control.php | 40 +++++++++++++++++++++++++++++++---- module/program/lang/de.php | 1 + module/program/lang/en.php | 1 + module/program/lang/fr.php | 1 + module/program/lang/vi.php | 1 + module/program/lang/zh-cn.php | 1 + module/program/lang/zh-tw.php | 18 +++++++--------- module/program/model.php | 23 ++++++++++++++++++-- 8 files changed, 70 insertions(+), 16 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index f6d2b67087..9ece2e61df 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -221,9 +221,14 @@ class program extends control { $this->lang->navGroup->program = 'program'; $this->loadModel('action'); + $program = $this->program->getPGMByID($programID); if(!empty($_POST)) { + /* Only when all subprograms and subprojects are closed can the program be closed. */ + $hasUnfinished = $this->program->hasUnfinished($program); + if($hasUnfinished) die(js::error($this->lang->program->PGMCloseErrorMessage)); + $changes = $this->project->close($programID); if(dao::isError()) die(js::error(dao::getError())); @@ -232,12 +237,14 @@ class program extends control $actionID = $this->action->create('program', $programID, 'Closed', $this->post->comment); $this->action->logHistory($actionID, $changes); } + + $this->executeHooks($programID); die(js::reload('parent.parent')); } $this->view->title = $this->lang->program->PGMClose; $this->view->position[] = $this->lang->program->PGMClose; - $this->view->project = $this->program->getPGMByID($programID); + $this->view->project = $program; $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->actions = $this->action->getList('program', $programID); @@ -356,8 +363,8 @@ class program extends control /** * Delete a program. * - * @param int $projectID - * @param varchar $confirm + * @param int $projectID + * @param string $confirm yes|no * @access public * @return void */ @@ -1257,6 +1264,7 @@ class program extends control { $this->lang->navGroup->program = 'project'; $this->loadModel('action'); + $project = $this->program->getPRJByID($projectID); if(!empty($_POST)) { @@ -1268,13 +1276,37 @@ class program extends control $actionID = $this->action->create('project', $projectID, 'Started', $this->post->comment); $this->action->logHistory($actionID, $changes); } + + /* Start all superior programs. */ + if($project->parent) + { + $path = explode(',', $project->path); + $path = array_filter($path); + foreach($path as $programID) + { + if($programID == $projectID) continue; + $program = $this->program->getPGMByID($programID); + if($program->status == 'wait' || $program->status == 'suspended') + { + $changes = $this->project->start($programID); + if(dao::isError()) die(js::error(dao::getError())); + + if($this->post->comment != '' or !empty($changes)) + { + $actionID = $this->action->create('program', $programID, 'Started', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + } + } + } + $this->executeHooks($projectID); die(js::reload('parent.parent')); } $this->view->title = $this->lang->project->start; $this->view->position[] = $this->lang->project->start; - $this->view->project = $this->program->getPRJByID($projectID); + $this->view->project = $project; $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->actions = $this->action->getList('project', $projectID); $this->display(); diff --git a/module/program/lang/de.php b/module/program/lang/de.php index d846d84031..7afc677441 100644 --- a/module/program/lang/de.php +++ b/module/program/lang/de.php @@ -205,6 +205,7 @@ $lang->program->PGMBeginLetterParent = "Parent begin date: %s, begin date should $lang->program->PGMEndGreaterParent = "Parent end date: %s, end date should be <= parent end date."; $lang->program->PGMBeginGreateChild = "Child earliest begin: %s, parent begin date <= child earliest begin date."; $lang->program->PGMEndLetterChild = "Child latest end: %s, parent end date >= child latest end date."; +$lang->program->PGMCloseErrorMessage = 'There are subprograms or projects that are not closed'; $lang->program->stakeholderTypeList['inside'] = 'Inside'; $lang->program->stakeholderTypeList['outside'] = 'Outside'; diff --git a/module/program/lang/en.php b/module/program/lang/en.php index a690b4331f..fd8a597979 100644 --- a/module/program/lang/en.php +++ b/module/program/lang/en.php @@ -205,6 +205,7 @@ $lang->program->PGMBeginLetterParent = "Parent begin date: %s, begin date should $lang->program->PGMEndGreaterParent = "Parent end date: %s, end date should be <= parent end date."; $lang->program->PGMBeginGreateChild = "Child earliest begin: %s, parent begin date <= child earliest begin date."; $lang->program->PGMEndLetterChild = "Child latest end: %s, parent end date >= child latest end date."; +$lang->program->PGMCloseErrorMessage = 'There are subprograms or projects that are not closed'; $lang->program->stakeholderTypeList['inside'] = 'Inside'; $lang->program->stakeholderTypeList['outside'] = 'Outside'; diff --git a/module/program/lang/fr.php b/module/program/lang/fr.php index d846d84031..7afc677441 100644 --- a/module/program/lang/fr.php +++ b/module/program/lang/fr.php @@ -205,6 +205,7 @@ $lang->program->PGMBeginLetterParent = "Parent begin date: %s, begin date should $lang->program->PGMEndGreaterParent = "Parent end date: %s, end date should be <= parent end date."; $lang->program->PGMBeginGreateChild = "Child earliest begin: %s, parent begin date <= child earliest begin date."; $lang->program->PGMEndLetterChild = "Child latest end: %s, parent end date >= child latest end date."; +$lang->program->PGMCloseErrorMessage = 'There are subprograms or projects that are not closed'; $lang->program->stakeholderTypeList['inside'] = 'Inside'; $lang->program->stakeholderTypeList['outside'] = 'Outside'; diff --git a/module/program/lang/vi.php b/module/program/lang/vi.php index d846d84031..7afc677441 100644 --- a/module/program/lang/vi.php +++ b/module/program/lang/vi.php @@ -205,6 +205,7 @@ $lang->program->PGMBeginLetterParent = "Parent begin date: %s, begin date should $lang->program->PGMEndGreaterParent = "Parent end date: %s, end date should be <= parent end date."; $lang->program->PGMBeginGreateChild = "Child earliest begin: %s, parent begin date <= child earliest begin date."; $lang->program->PGMEndLetterChild = "Child latest end: %s, parent end date >= child latest end date."; +$lang->program->PGMCloseErrorMessage = 'There are subprograms or projects that are not closed'; $lang->program->stakeholderTypeList['inside'] = 'Inside'; $lang->program->stakeholderTypeList['outside'] = 'Outside'; diff --git a/module/program/lang/zh-cn.php b/module/program/lang/zh-cn.php index a0fa3fd641..da1aa24333 100644 --- a/module/program/lang/zh-cn.php +++ b/module/program/lang/zh-cn.php @@ -205,6 +205,7 @@ $lang->program->PGMBeginLetterParent = "父项目集的开始日期:%s,开 $lang->program->PGMEndGreaterParent = "父项目集的完成日期:%s,完成日期不能大于父项目集的完成日期"; $lang->program->PGMBeginGreateChild = "子项目集的最小开始日期:%s,父项目集的开始日期不能大于子项目集的最小开始日期"; $lang->program->PGMEndLetterChild = "子项目的最大完成日期:%s,父项目的完成日期不能小于子项目的最大完成日期"; +$lang->program->PGMCloseErrorMessage = '存在子项目集或项目为未关闭状态'; $lang->program->stakeholderTypeList['inside'] = '内部'; $lang->program->stakeholderTypeList['outside'] = '外部'; diff --git a/module/program/lang/zh-tw.php b/module/program/lang/zh-tw.php index f0a0471ac2..d12ede9ca6 100644 --- a/module/program/lang/zh-tw.php +++ b/module/program/lang/zh-tw.php @@ -22,6 +22,7 @@ $lang->program->PRJManageView = '項目維護視野'; $lang->program->PRJManagePriv = '項目維護權限'; $lang->program->PRJManageMembers = '項目團隊'; $lang->program->export = '導出'; +$lang->program->addProduct = '新建產品'; $lang->program->PRJManageGroupMember = '維護分組用戶'; $lang->program->PRJModuleSetting = '列表設置'; $lang->program->PRJModuleOpen = '顯示項目集名'; @@ -29,18 +30,15 @@ $lang->program->PRJUpdateOrder = '排序'; $lang->program->PRJSort = '項目排序'; $lang->program->PRJWhitelist = '項目白名單'; $lang->program->PRJAddWhitelist = '項目添加白名單'; +$lang->program->PRJStoryConcept = '需求概念組合'; $lang->program->unbindWhielist = '項目刪除白名單'; $lang->program->PRJManageProducts = '關聯產品'; $lang->program->view = '項目集詳情'; -$lang->program->copyTitle = '請選擇一個項目來複制'; +$lang->program->copyTitle = '請選擇要複製的項目'; $lang->program->errorSameProducts = '項目不能關聯多個相同的產品。'; $lang->program->errorNoProducts = '最少關聯一個產品'; $lang->program->copyNoProject = '沒有可用的項目來複制'; -$lang->program->PRJSource = '項目來源:'; -$lang->program->PRJStandalone = '沒有所屬項目集的項目'; -$lang->program->tips = '提示'; -$lang->program->setTeam = '設置團隊'; -$lang->program->goback = '返回項目列表'; +$lang->project->searchByName = '輸入項目名稱進行檢索'; /* Fields. */ $lang->program->common = '項目集'; @@ -148,7 +146,7 @@ $lang->program->scrum = 'Scrum'; $lang->program->waterfall = '瀑布'; $lang->program->waterfallTitle = '瀑布式項目管理'; $lang->program->cannotCreateChild = '該項目已經有實際的內容,無法直接添加子項目。您可以為當前項目創建一個父項目,然後在新的父項目下面添加子項目。'; -$lang->program->hasChildren = '該項目集有子項目集或子項目存在,不能刪除。'; +$lang->program->hasChildren = '該項目集有子項目集或項目存在,不能刪除。'; $lang->program->confirmDelete = "您確定要刪除嗎?"; $lang->program->emptyPM = '暫無'; $lang->program->cannotChangeToCat = "該項目已經有實際的內容,無法修改為父項目"; @@ -156,7 +154,6 @@ $lang->program->cannotCancelCat = "該項目下已經有子項目,無法取 $lang->program->parentBeginEnd = "父項目起止時間:%s ~ %s"; $lang->program->childLongTime = "子項目中有長期項目,父項目也應該是長期項目"; $lang->program->readjustTime = '重新調整項目起止時間'; -$lang->program->afterInfo = "項目添加成功,您現在可以進行以下操作:"; $lang->program->PRJProgramTitle['0'] = '不顯示'; $lang->program->PRJProgramTitle['base'] = '只顯示一級項目集'; @@ -208,8 +205,9 @@ $lang->program->PGMBeginLetterParent = "父項目集的開始日期:%s,開 $lang->program->PGMEndGreaterParent = "父項目集的完成日期:%s,完成日期不能大於父項目集的完成日期"; $lang->program->PGMBeginGreateChild = "子項目集的最小開始日期:%s,父項目集的開始日期不能大於子項目集的最小開始日期"; $lang->program->PGMEndLetterChild = "子項目的最大完成日期:%s,父項目的完成日期不能小於子項目的最大完成日期"; +$lang->program->PGMCloseErrorMessage = '存在子項目集或項目為未關閉狀態'; -$lang->program->stakeholderTypeList['inside'] = '内部'; +$lang->program->stakeholderTypeList['inside'] = '內部'; $lang->program->stakeholderTypeList['outside'] = '外部'; /* Fields. */ @@ -230,7 +228,7 @@ $lang->program->PGMLongTime = '長期項目'; $lang->program->noPGM = '暫時沒有項目集'; $lang->program->PGMShowClosed = '顯示已關閉'; -$lang->program->PGMTips = '修改父項目集,可關聯產品也會發生變化,並且變為必填,如果未選擇任何項目集,則系統會預設創建一個和該項目同名的產品並關聯到該項目。'; +$lang->program->PGMTips = '選擇了父項目集,則可關聯該父項目集下的產品。如果項目未選擇任何項目集,則系統會預設創建一個和該項目同名的產品並關聯該項目。'; $lang->program->PGMChangeTips = '修改父項目集後,項目已關聯的產品會被清空,並且項目下的需求、bug等數據也會受影響,是否修改?'; $lang->program->PGMAclList['private'] = "私有(項目集負責人和干係人可訪問,干係人可後續維護)"; diff --git a/module/program/model.php b/module/program/model.php index 1d3b02faad..de04dff541 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -445,13 +445,32 @@ class programModel extends model * * @param int $programID * @access public - * @return void + * @return int */ public function getChildren($programID = 0) { return $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('parent')->eq($programID)->fetch('count'); } + /** + * Judge whether there is an unclosed programs or projects. + * + * @param object $program + * @access public + * @return int + */ + public function hasUnfinished($program) + { + $unfinished = $this->dao->select("count(IF(id != {$program->id}, true, null)) as count")->from(TABLE_PROJECT) + ->where('type')->in('program,project') + ->andWhere('path')->like($program->path . '%') + ->andWhere('status')->ne('closed') + ->andWhere('deleted')->eq('0') + ->fetch('count'); + + return $unfinished; + } + /** * Get stakeholders by program id. * @@ -792,7 +811,7 @@ class programModel extends model $path = ''; if($programID) { - $program = $this->getPRJByID($programID); + $program = $this->getPGMByID($programID); $path = $program->path; }