* Code for task#78690.

This commit is contained in:
xieqiyu
2022-12-09 15:39:55 +08:00
parent 68973d2a19
commit 7405efe5c7
2 changed files with 16 additions and 2 deletions
+1 -1
View File
@@ -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
{
+15 -1
View File
@@ -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;