From 44bfbb7cdc245490d2ba5b9fbfd11a6094eef809 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 12 Nov 2021 13:10:52 +0800 Subject: [PATCH] * Fix bug #16190. --- module/productplan/control.php | 18 +++++++++++++++--- module/productplan/model.php | 4 ++-- module/story/control.php | 12 +++++++++++- module/story/js/batchcreate.js | 2 +- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/module/productplan/control.php b/module/productplan/control.php index 472f7c8229..4b4f947742 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -329,13 +329,25 @@ class productplan extends control * @param int $productID * @param int $branch * @param string $number - * + * @param string $from * @access public * @return void */ - public function ajaxGetProductplans($productID, $branch = 0, $number = '') + public function ajaxGetProductplans($productID, $branch = 0, $number = '', $from = '') { - $plans = $this->productplan->getPairs($productID, $branch); + if($from == 'story' and $branch == BRANCH_MAIN) + { + $plans = $this->productplan->getPairs($productID); + } + elseif($from == 'story' and $branch) + { + $plans = $this->productplan->getPairs($productID, 0); + $plans += $this->productplan->getPairs($productID, $branch); + } + else + { + $plans = $this->productplan->getPairs($productID, $branch, $expired); + } $planName = $number === '' ? 'plan' : "plan[$number]"; $plans = empty($plans) ? array('' => '') : $plans; diff --git a/module/productplan/model.php b/module/productplan/model.php index 893a17f060..70192febcb 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -226,13 +226,13 @@ class productplanModel extends model * @access public * @return array */ - public function getPairsForStory($product = 0, $branch = 0, $skipParent = false) + public function getPairsForStory($product = 0, $branch = '', $skipParent = false) { $date = date('Y-m-d'); $plans = $this->dao->select('id,title,parent,begin,end')->from(TABLE_PRODUCTPLAN) ->where('product')->in($product) ->andWhere('deleted')->eq(0) - ->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi() + ->beginIF($branch !== '')->andWhere("branch")->eq($branch)->fi() ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi() ->orderBy('begin desc') ->fetchAll('id'); diff --git a/module/story/control.php b/module/story/control.php index 46d3a21642..c646a3df74 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -456,8 +456,18 @@ class story extends control $this->view->titles = $titles; } + $this->loadModel('productplan'); + if($branch == BRANCH_MAIN) + { + $plans = $this->productplan->getPairsForStory($productID, '', true); + } + else + { + $plans = $this->productplan->getPairsForStory($productID, 0, true); + $plans += $this->productplan->getPairsForStory($productID, $branch, true); + } + $moduleOptionMenu['ditto'] = $this->lang->story->ditto; - $plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch, true); $plans['ditto'] = $this->lang->story->ditto; $priList = (array)$this->lang->story->priList; $priList['ditto'] = $this->lang->story->ditto; diff --git a/module/story/js/batchcreate.js b/module/story/js/batchcreate.js index 1bee68b060..412811809f 100644 --- a/module/story/js/batchcreate.js +++ b/module/story/js/batchcreate.js @@ -58,7 +58,7 @@ function setModuleAndPlan(branchID, productID, num) $("#module" + num).chosen(); }); - planLink = createLink('productPlan', 'ajaxGetProductPlans', 'productID=' + productID + '&branch=' + branchID + '&num=' + num); + planLink = createLink('productPlan', 'ajaxGetProductPlans', 'productID=' + productID + '&branch=' + branchID + '&num=' + num + "&from=story"); $.get(planLink, function(plans) { if(!plans) plans = '';