From b625c5e1f2a6cfd19b2337005de43b0d5867cad9 Mon Sep 17 00:00:00 2001 From: mayue Date: Fri, 22 Apr 2022 16:05:13 +0800 Subject: [PATCH] * Fix bug #21706. --- module/product/control.php | 8 +++++--- module/productplan/model.php | 14 ++++++++++---- module/productplan/view/view.html.php | 6 +++--- module/story/control.php | 2 +- module/story/view/header.html.php | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index b55c241d81..17e5520626 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -1009,10 +1009,12 @@ class product extends control public function ajaxGetPlans($productID, $branch = 0, $planID = 0, $fieldID = '', $needCreate = false, $expired = '', $param = '') { $param = strtolower($param); - $plans = $this->loadModel('productplan')->getPairs($productID, $branch, $expired, strpos($param, 'skipparent') !== false); + $plans = $this->loadModel('productplan')->getPairs($productID, $branch == 0 ? '' : $branch, $expired, strpos($param, 'skipparent') !== false); $field = $fieldID ? "plans[$fieldID]" : 'plan'; - $output = ''; - $output .= html::select($field, $plans, $planID, "class='form-control chosen'"); + $output = html::select($field, $plans, $planID, "class='form-control chosen'"); + + if($branch == 0 and strpos($param, 'edit')) $output = html::select($field, $plans, $planID, "class='form-control chosen' multiple"); + if(count($plans) == 1 and $needCreate and $needCreate !== 'false') { $output .= "
"; diff --git a/module/productplan/model.php b/module/productplan/model.php index 1be30ba3a1..b389bc6c81 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -238,7 +238,7 @@ class productplanModel extends model ->andWhere('deleted')->eq(0) ->beginIF(strpos($param, 'unexpired') !== false)->andWhere('end')->ge($date)->fi() ->beginIF(strpos($param, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() - ->beginIF($branch !== 'all' or $branch !== '')->andWhere("branch")->in($branch)->fi() + ->beginIF($branch !== 'all' and $branch !== '')->andWhere("branch")->in($branch)->fi() ->orderBy('begin desc') ->fetchAll('id'); @@ -375,7 +375,7 @@ class productplanModel extends model $plans = $this->dao->select('branch,id,title,begin,end')->from(TABLE_PRODUCTPLAN) ->where('product')->eq($productID) ->andWhere('deleted')->eq(0) - ->beginIF(!empty($branches))->andWhere('branch')->in($branches)->fi() + ->beginIF($branches != '')->andWhere('branch')->in($branches)->fi() ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi() ->fetchAll('id'); @@ -846,9 +846,15 @@ class productplanModel extends model } else { - $plansOfStory = $story->plan . ',' . $planID; + $branchPlanPairs = $this->dao->select('branch, id as plan')->from(TABLE_PRODUCTPLAN) + ->where('product')->eq($story->product) + ->andWhere('id')->in($story->plan) + ->fetchPairs(); + if(isset($branchPlanPairs[$plan->branch])) $branchPlanPairs[$plan->branch] = $planID; - $this->dao->update(TABLE_STORY)->set("plan")->eq($plansOfStory)->where('id')->eq((int)$storyID)->andWhere('branch')->eq('0')->exec(); + $plansOfStory = ',' . implode(',', $branchPlanPairs); + + $this->dao->update(TABLE_STORY)->set("plan")->eq($plansOfStory)->where('id')->eq((int)$storyID)->exec(); $this->story->updateStoryOrderOfPlan($storyID, $planID); } diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php index 8e710a3382..0ffd20a298 100644 --- a/module/productplan/view/view.html.php +++ b/module/productplan/view/view.html.php @@ -151,9 +151,9 @@ idAB);?> - priAB);?> - story->title);?> - statusAB);?> + priAB);?> + story->title);?> + statusAB);?> diff --git a/module/story/control.php b/module/story/control.php index b8072662be..0e6a275007 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -757,7 +757,7 @@ class story extends control $this->view->stories = $stories; $this->view->users = $users; $this->view->product = $product; - $this->view->plans = $this->loadModel('productplan')->getPairsForStory($story->product, $story->branch, 'skipParent'); + $this->view->plans = $this->loadModel('productplan')->getPairsForStory($story->product, $story->branch == 0 ? 'all' : $story->branch, 'skipParent'); $this->view->products = $products; $this->view->branchOption = $branchOption; $this->view->branchTagOption = $branchTagOption; diff --git a/module/story/view/header.html.php b/module/story/view/header.html.php index 237157fb63..550ad16e16 100644 --- a/module/story/view/header.html.php +++ b/module/story/view/header.html.php @@ -127,7 +127,7 @@ function loadProductPlans(productID, branch) if(typeof(branch) == 'undefined') branch = 0; if(!branch) branch = 0; var expired = config.currentMethod == 'create' ? 'unexpired' : ''; - planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=&needCreate=true&expired='+ expired +'¶m=skipParent'); + planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=&needCreate=true&expired='+ expired +'¶m=skipParent,' + config.currentMethod); var $planIdBox = $('#planIdBox'); $planIdBox.load(planLink, function() {