From 0328182a4719c277eb5356fffa4cda6289ea1400 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 5 Nov 2021 17:19:41 +0800 Subject: [PATCH] * Modify the logic of the acquisition plan. --- module/productplan/model.php | 23 ++++++++++++++++++++++- module/story/control.php | 13 ++++++------- module/story/lang/en.php | 2 +- module/story/lang/zh-cn.php | 2 +- module/story/model.php | 4 ++-- module/story/view/batchedit.html.php | 16 +++++++++++++++- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/module/productplan/model.php b/module/productplan/model.php index d5fae673f5..8fcbd05056 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -332,10 +332,31 @@ class productplanModel extends model ->leftJoin(TABLE_PLANSTORY)->alias('t2')->on('t1.id=t2.story') ->leftJoin(TABLE_PRODUCTPLAN)->alias('t3')->on('t2.plan=t3.id') ->where('t1.id')->in($storyIdList) - ->andWhere('t3.deleted')->eq(0) ->fetchGroup('storyID', 'id'); } + /** + * Get branch plan pairs. + * + * @param int $productID + * @access public + * @return array + */ + public function getBranchPlanPairs($productID) + { + $plans = $this->dao->select('branch,id,title,begin,end')->from(TABLE_PRODUCTPLAN) + ->where('deleted')->eq(0) + ->andWhere('product')->eq($productID) + ->fetchAll('id'); + + $planPairs = array(); + foreach($plans as $planID => $plan) + { + $planPairs[$plan->branch][$planID] = $plan->title . ' [' . $plan->begin . '~' . $plan->end . ']'; + } + return $planPairs; + } + /** * Create a plan. * diff --git a/module/story/control.php b/module/story/control.php index 481e2fc666..375395a82e 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -706,15 +706,12 @@ class story extends control $product = $this->product->getByID($productID); $branchProduct = $product->type == 'normal' ? false : true; - /* Set modules and productPlans. */ - $modules = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch); - $modules = array('ditto' => $this->lang->story->ditto) + $modules; - $productPlans = $this->productplan->getPairs($productID, $branch, '', true); - $productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans; + /* Set modules. */ + $modules = array('ditto' => $this->lang->story->ditto) + $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch); $this->view->modules = $modules; $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($product->id); - $this->view->productPlans = $productPlans; + $this->view->plans = $this->productplan->getBranchPlanPairs($productID); $this->view->position[] = html::a($this->createLink('product', 'browse', "product=$product->id&branch=$branch"), $product->name); $this->view->title = $product->name . $this->lang->colon . $this->lang->story->batchEdit; } @@ -1393,6 +1390,7 @@ class story extends control $normalStotyIdList = ''; $conflictStoryIdList = ''; $conflictStoryArray = array(); + /* Determine whether there is a conflict between the branch of the story and the linked plan. */ foreach($storyIdList as $storyID) { @@ -1400,10 +1398,11 @@ class story extends control { foreach($plans[$storyID] as $plan) { - if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID and strpos($conflictStoryIdList, '[' . $storyID . ']') === false) + if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID) { $conflictStoryIdList .= '[' . $storyID . ']'; $conflictStoryArray[] = $storyID; + break; } } } diff --git a/module/story/lang/en.php b/module/story/lang/en.php index e8993a551f..75cfdb335c 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -277,7 +277,7 @@ $lang->story->moveChildrenTips = "Its Child {$lang->SRCommon} will be moved $lang->story->changeTips = 'The story associated with the requirements to change, click "Cancel" ignore this change, click "Confirm" to change the story.'; $lang->story->estimateMustBeNumber = 'Estimate value must be number.'; $lang->story->estimateMustBePlus = 'Estimated value cannot be negative'; -$lang->story->confirmChangeBranch = $lang->SRCommon . '%s is linked to the plan of its linked branch. If the branch is edited, ' . $lang->SRCommon . ' will be removed from the plan of its linked branch. Do you want to continue edit ' . $lang->SRCommon . '?'; +$lang->story->confirmChangeBranch = $lang->SRCommon . ' %s is linked to the plan of its linked branch. If the branch is edited, ' . $lang->SRCommon . ' will be removed from the plan of its linked branch. Do you want to continue edit ' . $lang->SRCommon . '?'; $lang->story->form = new stdclass(); $lang->story->form->area = 'Scope'; diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index 9c2de764dd..6c485b6e94 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -277,7 +277,7 @@ $lang->story->moveChildrenTips = "修改父{$lang->SRCommon}的所属产品 $lang->story->changeTips = '该软件需求关联的用户需求有变更,点击“不变更”忽略此条变更,点击“变更”来进行该软件需求的变更。'; $lang->story->estimateMustBeNumber = '估算值必须是数字'; $lang->story->estimateMustBePlus = '估算值不能是负数'; -$lang->story->confirmChangeBranch = $lang->SRCommon . '%s已关联在之前所属分支的计划中,调整分支后,' . $lang->SRCommon . '将从之前所属分支的计划中移除,请确认是否继续修改上述' . $lang->SRCommon . ' 的分支。'; +$lang->story->confirmChangeBranch = $lang->SRCommon . '%s已关联在之前所属分支的计划中,调整分支后,' . $lang->SRCommon . '将从之前所属分支的计划中移除,请确认是否继续修改上述' . $lang->SRCommon . '的分支。'; $lang->story->form = new stdclass(); $lang->story->form->area = "该{$lang->SRCommon}所属范围"; diff --git a/module/story/model.php b/module/story/model.php index 259dac2f26..e2e03ccf98 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1678,7 +1678,7 @@ class storyModel extends model * @param string $confirm * @param array $plans * @access public - * @return void + * @return array */ public function batchChangeBranch($storyIdList, $branchID, $confirm = '', $plans = array()) { @@ -1716,7 +1716,7 @@ class storyModel extends model } } - /* If there is a conflict in the linked plan when the branch story to be modified, the linked with the conflicting plan will be removed. */ + /* If there is a conflict in the linked plan when the branch story to be modified, the linked with the conflicting plan will be removed. */ if($conflictPlanIdList) { $story->plan = $planIdList; diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index c6206af93f..2bc81e2e13 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -100,7 +100,21 @@ foreach(explode(',', $showFields) as $field) module, "class='form-control chosen'");?> '> - session->currentProductType != 'normal') $productPlans = $this->productplan->getPairs($productID, $story->branch, '', true);?> + branch != BRANCH_MAIN) + { + $productPlans = zget($plans, $story->branch) + zget($plans, 0); + } + else + { + foreach($plans as $branchPlan) + { + $productPlans += $branchPlan; + } + } + ?> + session->currentProductType == 'normal') $productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans;?> plan, "class='form-control chosen'");?>