diff --git a/module/execution/model.php b/module/execution/model.php index 3c2f11638b..7f9a361063 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3654,16 +3654,32 @@ class executionModel extends model public function getPlans($products) { $this->loadModel('productplan'); - $productPlans = array(); - foreach($products as $productID => $product) + + $branchIDList = array(); + foreach($products as $product) { - $planInfo = $this->productplan->getPairs($product->id, implode(',', $product->branches)); - foreach($planInfo as $planID => $plan) - { - if(empty($planID)) continue; - $productPlans[$productID][$planID] = $plan; - } + foreach($product->branches as $branchID) $branchIDList[$branchID] = $branchID; } + + $plans = $this->dao->select('id,title,product,parent,begin,end')->from(TABLE_PRODUCTPLAN) + ->where('product')->in(array_keys($products)) + ->andWhere('deleted')->eq(0) + ->andWhere('branch')->in($branchIDList)->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; + + $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; + } + return $productPlans; } diff --git a/module/productplan/model.php b/module/productplan/model.php index b7acbb6005..893a17f060 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -184,7 +184,7 @@ class productplanModel extends model $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("$branch")->fi() + ->beginIF($branch !== '')->andWhere('branch')->eq($branch)->fi() ->beginIF($expired == 'unexpired')->andWhere('end')->ge($date)->fi() ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi() ->orderBy('begin desc')