diff --git a/module/execution/control.php b/module/execution/control.php index 774d2fd3fe..a4f703d5b6 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1525,6 +1525,7 @@ class execution extends control $this->loadModel('productplan'); $productPlans = array(0 => ''); $linkedBranches = array(); + $linkedBranchList = array(); $linkedProducts = $this->product->getProducts($executionID); $branches = $this->project->getBranchesByProject($executionID); $plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent'); @@ -1538,6 +1539,7 @@ class execution extends control if(!isset($allProducts[$productID])) $allProducts[$productID] = $linkedProduct->name; foreach($branches[$productID] as $branchID => $branch) { + $linkedBranchList[$branchID] = $branchID; $linkedBranches[$productID][$branchID] = $branchID; $productPlans[$productID][$branchID] = isset($plans[$productID][$branchID]) ? $plans[$productID][$branchID] : array(); if($branchID != BRANCH_MAIN and isset($plans[$productID][BRANCH_MAIN])) $productPlans[$productID][$branchID] += $plans[$productID][BRANCH_MAIN]; @@ -1581,7 +1583,7 @@ class execution extends control $this->view->unmodifiableBranches = $unmodifiableBranches; $this->view->multiBranchProducts = $this->product->getMultiBranchPairs(); $this->view->productPlans = $productPlans; - $this->view->branchGroups = $this->execution->getBranchByProduct(array_keys($linkedProducts), $this->config->systemMode == 'new' ? $execution->project : 0); + $this->view->branchGroups = $this->execution->getBranchByProduct(array_keys($linkedProducts), $this->config->systemMode == 'new' ? $execution->project : 0, 'noclosed', $linkedBranchList); $this->display(); } diff --git a/module/execution/model.php b/module/execution/model.php index f7d9f619dc..549b58d0d2 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1674,15 +1674,16 @@ class executionModel extends model /** * Get branch pairs by product id list. * - * @param array $products - * @param int $projectID - * @param string $param + * @param array $products + * @param int $projectID + * @param string $param + * @param string|array $appendBranch * @access public * @return array */ - public function getBranchByProduct($products, $projectID = 0, $param = 'noclosed') + public function getBranchByProduct($products, $projectID = 0, $param = 'noclosed', $appendBranch = '') { - $branchGroups = $this->loadModel('branch')->getByProducts($products, $param); + $branchGroups = $this->loadModel('branch')->getByProducts($products, $param, $appendBranch); if($projectID) { diff --git a/module/project/control.php b/module/project/control.php index a0645b14d4..fb5a0cfbce 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -542,15 +542,16 @@ class project extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locateLink)); } - $linkedBranches = array(); - $productPlans = array(0 => ''); - $allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed'); - $linkedProducts = $this->loadModel('product')->getProducts($projectID); - $parentProject = $this->program->getByID($project->parent); - $branches = $this->project->getBranchesByProject($projectID); - $plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent'); - $projectStories = $this->project->getStoriesByProject($projectID); - $projectBranches = $this->project->getBranchGroupByProject($projectID, array_keys($linkedProducts)); + $linkedBranches = array(); + $linkedBranchList = array(); + $productPlans = array(0 => ''); + $allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed'); + $linkedProducts = $this->loadModel('product')->getProducts($projectID); + $parentProject = $this->program->getByID($project->parent); + $branches = $this->project->getBranchesByProject($projectID); + $plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent'); + $projectStories = $this->project->getStoriesByProject($projectID); + $projectBranches = $this->project->getBranchGroupByProject($projectID, array_keys($linkedProducts)); /* If the story of the product which linked the project, you don't allow to remove the product. */ $unmodifiableProducts = array(); @@ -561,6 +562,7 @@ class project extends control if(!isset($allProducts[$productID])) $allProducts[$productID] = $linkedProduct->name; foreach($branches[$productID] as $branchID => $branch) { + $linkedBranchList[$branchID] = $branchID; $linkedBranches[$productID][$branchID] = $branchID; if($branch != BRANCH_MAIN) $productPlans[$productID][$branchID] = isset($plans[$productID][BRANCH_MAIN]) ? $plans[$productID][BRANCH_MAIN] : array(); $productPlans[$productID][$branchID] += isset($plans[$productID][$branchID]) ? $plans[$productID][$branchID] : array(); @@ -595,7 +597,7 @@ class project extends control $this->view->unmodifiableProducts = $unmodifiableProducts; $this->view->unmodifiableBranches = $unmodifiableBranches; $this->view->unmodifiableMainBranches = $unmodifiableMainBranches; - $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts), 'noclosed'); + $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts), 'noclosed', $linkedBranchList); $this->view->URSRPairs = $this->custom->getURSRPairs(); $this->view->parentProject = $parentProject; $this->view->parentProgram = $this->program->getByID($project->parent);