From d6f9976aaec0752a6c48e0ceb989be519ff2b14b Mon Sep 17 00:00:00 2001 From: lanzongjun Date: Thu, 8 Dec 2022 11:06:04 +0800 Subject: [PATCH 1/2] * Finish Bug #30480 --- module/product/control.php | 2 +- module/productplan/model.php | 20 ++++++++++++++++++++ module/project/control.php | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index f4bcefe82b..368b71b08b 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -356,7 +356,7 @@ class product extends control $this->view->productName = $productName; $this->view->moduleID = $moduleID; $this->view->stories = $stories; - $this->view->plans = $this->loadModel('productplan')->getPairs($productID, ($branch === 'all' or empty($branch)) ? '' : $branch, 'unexpired', true); + $this->view->plans = $this->loadModel('productplan')->getPairs($productID, ($branch === 'all' or empty($branch)) ? '' : $branch, 'unexpired,noclosed', true); $this->view->productPlans = isset($productPlans) ? array(0 => '') + $productPlans : array(); $this->view->summary = $this->product->summary($stories, $storyType); $this->view->moduleTree = $moduleTree; diff --git a/module/productplan/model.php b/module/productplan/model.php index 74d0f09a85..04bfe7f712 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -1355,4 +1355,24 @@ class productplanModel extends model if(!empty($unlinkBugs)) $this->dao->update(TABLE_BUG)->set('plan')->eq(0)->where('plan')->eq($plan->parent)->andWhere('id')->in($unlinkBugs)->exec(); $this->dao->update(TABLE_BUG)->set('plan')->eq($plan->id)->where('plan')->eq($plan->parent)->exec(); } + + /** + * Get plan list by ids. + * + * @param array $planIds + * @param boo $order + * @access public + * @return array + */ + public function getListByIds($planIds, $order = false) + { + $plans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN) + ->where('id')->in($planIds) + ->orderBy('begin desc') + ->fetchAll('id'); + + if($order) $plans = $this->relationBranch($plans); + + return $plans; + } } diff --git a/module/project/control.php b/module/project/control.php index 11669e7579..3182e042dd 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -739,7 +739,7 @@ class project extends control { $linkedBranchList[$branchID] = $branchID; - if($branch != BRANCH_MAIN) $productPlans[$productID] = isset($plans[$productID][BRANCH_MAIN]) ? $plans[$productID][BRANCH_MAIN] : array(); + if(!isset($productPlans[$productID])) $productPlans[$productID] = isset($plans[$productID][BRANCH_MAIN]) ? $plans[$productID][BRANCH_MAIN] : array(); $productPlans[$productID] += isset($plans[$productID][$branchID]) ? $plans[$productID][$branchID] : array(); if(!empty($projectStories[$productID][$branchID]) or !empty($projectBranches[$productID][$branchID])) @@ -751,6 +751,17 @@ class project extends control } } + $productPlansOrder = array(); + foreach($productPlans as $productID => $plan) + { + $orderPlans = $this->loadModel('productPlan')->getListByIds(array_keys($plan)); + $orderPlansMap = array_keys($orderPlans); + foreach($orderPlansMap as $planMapID) + { + $productPlansOrder[$productID][$planMapID] = $productPlans[$productID][$planMapID]; + } + } + if($project->model != 'kanban') $canChangeModel = $this->project->checkCanChangeModel($projectID, $project->model); $this->view->title = $this->lang->project->edit; @@ -764,7 +775,7 @@ class project extends control $this->view->projectID = $projectID; $this->view->allProducts = array('0' => '') + $allProducts; $this->view->multiBranchProducts = $this->loadModel('product')->getMultiBranchPairs(); - $this->view->productPlans = array_filter($productPlans); + $this->view->productPlans = array_filter($productPlansOrder); $this->view->linkedProducts = $linkedProducts; $this->view->branches = $branches; $this->view->executions = $this->execution->getPairs($projectID); From 0f4ef051bf2e93f62b58ae789a2f51e6586a5fcc Mon Sep 17 00:00:00 2001 From: lanzongjun Date: Thu, 8 Dec 2022 13:44:28 +0800 Subject: [PATCH 2/2] * Finish Bug #30480 --- module/project/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/project/control.php b/module/project/control.php index 3182e042dd..247cd85ae8 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -754,7 +754,7 @@ class project extends control $productPlansOrder = array(); foreach($productPlans as $productID => $plan) { - $orderPlans = $this->loadModel('productPlan')->getListByIds(array_keys($plan)); + $orderPlans = $this->loadModel('productPlan')->getListByIds(array_keys($plan), true); $orderPlansMap = array_keys($orderPlans); foreach($orderPlansMap as $planMapID) {