From de42397894c737ff4ca68857ccfd8170bb25af1e Mon Sep 17 00:00:00 2001 From: mayue Date: Wed, 23 Nov 2022 08:41:11 +0800 Subject: [PATCH] * Fix bug #29945. --- module/productplan/control.php | 23 +++++++++++----------- module/productplan/model.php | 3 +-- test/model/productplan/gettopplanpairs.php | 10 ++++------ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/module/productplan/control.php b/module/productplan/control.php index d0dd0b3263..ec00c46b97 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -100,10 +100,6 @@ class productplan extends control if($parent) $this->view->parentPlan = $this->productplan->getById($parent); $branchPairs = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($productID, 'active'); - /* Get parent plan pairs. */ - $parentPlanPairs = $this->productplan->getTopPlanPairs($productID, $branchID); - $this->view->parentPlanPairs = $parentPlanPairs; - /*Get default branch.*/ $branchList = $this->loadModel('branch')->getList($productID); foreach($branchList as $branch) @@ -115,12 +111,13 @@ class productplan extends control $this->view->position[] = $this->lang->productplan->common; $this->view->position[] = $this->lang->productplan->create; - $this->view->productID = $productID; - $this->view->lastPlan = $lastPlan; - $this->view->branch = $branchID; - $this->view->branches = $branchPairs; - $this->view->defaultBranch = $defaultBranch; - $this->view->parent = $parent; + $this->view->productID = $productID; + $this->view->lastPlan = $lastPlan; + $this->view->branch = $branchID; + $this->view->branches = $branchPairs; + $this->view->defaultBranch = $defaultBranch; + $this->view->parent = $parent; + $this->view->parentPlanPairs = $this->productplan->getTopPlanPairs($productID, $branchID, 'done,closed'); $this->display(); } @@ -153,13 +150,17 @@ class productplan extends control $plan = $this->productplan->getByID($planID); $oldBranch = array($planID => $plan->branch); + /* Get the parent plan pair exclusion itself. */ + $parentPlanPairs = $this->productplan->getTopPlanPairs($productID, $branchID); + unset($parentPlanPairs[$planID]); + $this->view->parentPlanPairs = $parentPlanPairs; + $this->commonAction($plan->product, $plan->branch); $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->edit; $this->view->position[] = $this->lang->productplan->edit; $this->view->productID = $plan->product; $this->view->oldBranch = $oldBranch; $this->view->plan = $plan; - $this->view->parentPlanPairs = $this->productplan->getTopPlanPairs($plan->product, $plan->branch, $planID); $this->display(); } diff --git a/module/productplan/model.php b/module/productplan/model.php index d9b9f0465d..72b5532ef6 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -221,11 +221,10 @@ class productplanModel extends model ->beginIF($branch !== '')->andWhere('branch')->eq($branch)->fi() ->andWhere('parent')->le(0) ->andWhere('deleted')->eq(0) + ->beginIF($exclude)->andWhere('status')->notin($exclude) ->orderBy('id_desc') ->fetchPairs(); - if($exclude) unset($planPairs[$exclude]); - return $planPairs; } diff --git a/test/model/productplan/gettopplanpairs.php b/test/model/productplan/gettopplanpairs.php index eab5b41fdf..46b60f4d38 100755 --- a/test/model/productplan/gettopplanpairs.php +++ b/test/model/productplan/gettopplanpairs.php @@ -7,12 +7,10 @@ $plan = new productPlan('admin'); $param = array(); $param[0] = array('productID' => 1, 'branch' => '', 'exclude' => ''); -$param[1] = array('productID' => 1, 'branch' => '', 'exclude' => 1); -$param[2] = array('productID' => 41, 'branch' => 1, 'exclude' => ''); -$param[3] = array('productID' => 41, 'branch' => 2, 'exclude' => ''); +$param[1] = array('productID' => 41, 'branch' => 1, 'exclude' => ''); +$param[2] = array('productID' => 41, 'branch' => 2, 'exclude' => ''); r($plan->getTopPlanPairsTest($param[0])) && p('1,2') && e('1.0,1.1'); //测试获取正常产品的顶级计划 -r($plan->getTopPlanPairsTest($param[1])) && p('1,2') && e(',1.1'); //测试获取排除1.0计划的正常产品的顶级计划 -r($plan->getTopPlanPairsTest($param[2])) && p('31') && e('1.0'); //测试获取分支1计划的正常产品的顶级计划 -r($plan->getTopPlanPairsTest($param[3])) && p('32') && e('1.1'); //测试获取分支2计划的正常产品的顶级计划 +r($plan->getTopPlanPairsTest($param[1])) && p('31') && e('1.0'); //测试获取分支1计划的正常产品的顶级计划 +r($plan->getTopPlanPairsTest($param[2])) && p('32') && e('1.1'); //测试获取分支2计划的正常产品的顶级计划 ?>