From 7405efe5c7e87386add8af77da44c3a513ef2cb6 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 9 Dec 2022 15:39:55 +0800 Subject: [PATCH] * Code for task#78690. --- module/product/control.php | 2 +- module/productplan/model.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index 368b71b08b..8f1001d8f1 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -1056,7 +1056,7 @@ class product extends control $param = strtolower($param); if(strpos($param, 'forstory') === false) { - $plans = $this->loadModel('productplan')->getPairs($productID, $branch, $expired, strpos($param, 'skipparent') !== false); + $plans = $this->loadModel('productplan')->getPairs($productID, empty($branch) ? 'all' : $branch, $expired, strpos($param, 'skipparent') !== false); } else { diff --git a/module/productplan/model.php b/module/productplan/model.php index 04bfe7f712..ad8a367e33 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -466,10 +466,23 @@ class productplanModel extends model */ public function getBranchPlanPairs($productID, $branches = '', $skipParent = false) { + $branchQuery = ''; + if($branches !== '' and $branches !== 'all') + { + $branchQuery .= '('; + if(!is_array($branches)) $branches = explode(',', $branches); + foreach($branches as $branchID) + { + $branchQuery .= "CONCAT(',', branch, ',') LIKE '%,$branchID,%'"; + if($branchID != end($branches)) $branchQuery .= ' OR '; + } + $branchQuery .= ')'; + } + $plans = $this->dao->select('parent,branch,id,title,begin,end')->from(TABLE_PRODUCTPLAN) ->where('product')->eq($productID) ->andWhere('deleted')->eq(0) - ->beginIF($branches != '')->andWhere('branch')->in($branches)->fi() + ->beginIF(!empty($branchQuery))->andWhere($branchQuery)->fi() ->orderBy('begin desc') ->fetchAll('id'); @@ -482,6 +495,7 @@ class productplanModel extends model if($plan->parent > 0 and isset($plans[$plan->parent])) $plan->title = $plans[$plan->parent]->title . ' /' . $plan->title; $planPairs[$branch][$planID] = $plan->title . ' [' . $plan->begin . '~' . $plan->end . ']'; + if($branch !== BRANCH_MAIN) $planPairs[BRANCH_MAIN][$planID] = $plan->title . ' [' . $plan->begin . '~' . $plan->end . ']'; } } return $planPairs;