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 66c27f9ae7..68ddde12d2 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), true); + $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);