From 83ecf656d3e8ba7dfff9f0725bf70c954d9d0edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Tue, 21 Jun 2022 06:07:46 +0000 Subject: [PATCH] Merge branch 'sgm_parentplan' into 'master' * Code for feedback #397. See merge request easycorp/zentaopms!4033 (cherry picked from commit beaddb012c3dc8ef07e7bd5c754ae7d991758971) f0c23584 * Code for feedback #397. --- module/execution/model.php | 7 ++----- module/productplan/model.php | 24 ++++++++++-------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index ad8cf6b43e..024a6c7eca 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3984,18 +3984,15 @@ class executionModel extends model ->where('product')->in(array_keys($products)) ->andWhere('deleted')->eq(0) ->andWhere('branch')->in($branchIdList)->fi() - ->beginIF(strpos($param, 'skipparent') !== false)->andWhere('parent')->ne(-1)->fi() ->orderBy('begin desc') ->fetchAll('id'); $plans = $this->productplan->reorder4Children($plans); $productPlans = array(); - $parentTitle = array(); foreach($plans as $plan) { - if($plan->parent == '-1') $parentTitle[$plan->id] = $plan->title; - if($plan->parent > 0 and isset($parentTitle[$plan->parent])) $plan->title = $parentTitle[$plan->parent] . ' /' . $plan->title; - + if($plan->parent == '-1' and strpos($param, 'skipparent') !== false) continue; + if($plan->parent > 0 and isset($plans[$plan->parent])) $plan->title = $plans[$plan->parent]->title . ' /' . $plan->title; $productPlans[$plan->product][$plan->id] = $plan->title . " [{$plan->begin} ~ {$plan->end}]"; if($plan->begin == '2030-01-01' and $plan->end == '2030-01-01') $productPlans[$plan->product][$plan->id] = $plan->title . ' ' . $this->lang->productplan->future; } diff --git a/module/productplan/model.php b/module/productplan/model.php index be0161beef..6ce103d1fc 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -247,18 +247,13 @@ class productplanModel extends model ->orderBy('t1.begin desc') ->fetchAll('id'); - $plans = $this->reorder4Children($plans); - $planPairs = array(); - $parentTitle = array(); + $plans = $this->reorder4Children($plans); + $planPairs = array(); $this->app->loadLang('branch'); foreach($plans as $plan) { - if($plan->parent == '-1') - { - $parentTitle[$plan->id] = $plan->title; - if($skipParent) continue; - } - if($plan->parent > 0 and isset($parentTitle[$plan->parent])) $plan->title = $parentTitle[$plan->parent] . ' /' . $plan->title; + if($skipParent and $plan->parent == '-1') continue; + if($plan->parent > 0 and isset($plans[$plan->parent])) $plan->title = $plans[$plan->parent]->title . ' /' . $plan->title; $planPairs[$plan->id] = $plan->title . " [{$plan->begin} ~ {$plan->end}]"; if($plan->begin == $this->config->productplan->future and $plan->end == $this->config->productplan->future) $planPairs[$plan->id] = $plan->title . ' ' . $this->lang->productplan->future; if($plan->productType != 'normal') $planPairs[$plan->id] = ($plan->branchName ? $plan->branchName : $this->lang->branch->main) . ' / ' . $planPairs[$plan->id]; @@ -351,7 +346,6 @@ class productplanModel extends model $plans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN) ->where('deleted')->eq(0) ->beginIF($products)->andWhere('product')->in($products)->fi() - ->beginIF(strpos($param, 'skipparent') !== false)->andWhere('parent')->ne(-1)->fi() ->beginIF(strpos($param, 'unexpired') !== false)->andWhere('end')->ge($date)->fi() ->orderBy($orderBy) ->fetchAll('id'); @@ -366,8 +360,8 @@ class productplanModel extends model if($field == 'name') { - if($plan->parent == '-1') $parentTitle[$plan->id] = $plan->title; - if($plan->parent > 0 and isset($parentTitle[$plan->parent])) $plan->title = $parentTitle[$plan->parent] . ' /' . $plan->title; + if($plan->parent == '-1' and strpos($param, 'skipparent') !== false) continue; + if($plan->parent > 0 and isset($plans[$plan->parent])) $plan->title = $plans[$plan->parent]->title . ' /' . $plan->title; $planGroup[$plan->product][$plan->branch][$plan->id] = $plan->title . " [{$plan->begin} ~ {$plan->end}]"; if($plan->begin == $this->config->productplan->future and $plan->end == $this->config->productplan->future) $planGroup[$plan->product][$plan->branch][$plan->id] = $plan->title . ' ' . $this->lang->productplan->future; } @@ -419,17 +413,19 @@ class productplanModel extends model */ public function getBranchPlanPairs($productID, $branches = '', $skipParent = false) { - $plans = $this->dao->select('branch,id,title,begin,end')->from(TABLE_PRODUCTPLAN) + $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($skipParent)->andWhere('parent')->ne(-1)->fi() ->orderBy('begin desc') ->fetchAll('id'); $planPairs = array(); foreach($plans as $planID => $plan) { + if($skipParent and $plan->parent == '-1') continue; + + if($plan->parent > 0 and isset($plans[$plan->parent])) $plan->title = $plans[$plan->parent]->title . ' /' . $plan->title; $planPairs[$plan->branch][$planID] = $plan->title . ' [' . $plan->begin . '~' . $plan->end . ']'; } return $planPairs;