diff --git a/module/product/model.php b/module/product/model.php index 9596ae0a5b..56cdbcf30c 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -785,7 +785,7 @@ class productModel extends model * @access public * @return array */ - public function getExecutionPairsByProduct($productID, $branch = 0, $orderBy = 'id_asc,path_asc') + public function getExecutionPairsByProduct($productID, $branch = 0, $orderBy = 'id_asc') { if(!$this->session->PRJ || !$productID) return array(); @@ -799,25 +799,42 @@ class productModel extends model ->orderBy($orderBy) ->fetchAll('id'); - /* The waterfall project needs to show the hierarchy and remove the parent stage. */ $project = $this->loadModel('program')->getPRJByID($this->session->PRJ); + $executionList = array('0' => ''); + + /* The waterfall project needs to show the hierarchy and remove the parent stage. */ if($project->model == 'waterfall') { - foreach($executions as $execution) + foreach($executions as $id => $execution) { - if($execution->parent and isset($executions[$execution->parent])) $executions[$execution->id]->name = $executions[$execution->parent]->name . '/' . $execution->name; + if($execution->grade == 2 and isset($executions[$execution->parent])) + { + $execution->name = $executions[$execution->parent]->name . '/' . $execution->name; + $executions[$execution->parent]->children[$id] = $execution->name; + unset($executions[$id]); + } } - foreach($executions as $execution) if($execution->grade == 2) unset($executions[$execution->parent]); + foreach($executions as $execution) + { + if(isset($execution->children)) + { + $executionList = array_merge($executionList, $execution->children); + continue; + } + $executionList[$execution->id] = $execution->name; + } + } + else + { + foreach($executions as $execution) $executionList[$execution->id] = $execution->name; } - $executionList = array('0' => ''); - foreach($executions as $execution) $executionList[$execution->id] = $execution->name; return $executionList; } /** - * Get roadmap of a proejct + * Get roadmap of a proejct. * * @param int $productID * @param int $branch diff --git a/module/project/model.php b/module/project/model.php index cdea9ce3da..a16f3ac2d0 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1026,6 +1026,7 @@ class projectModel extends model ->fetchAll('id'); $project = $this->loadModel('program')->getPRJByID($projectID); + $executionList = array(); if($project->model == 'waterfall') { $executionProducts = $this->dao->select('t1.project,t1.product')->from(TABLE_PROJECTPRODUCT)->alias('t1') @@ -1036,27 +1037,44 @@ class projectModel extends model $products = $this->loadModel('product')->getProductPairsByProject($projectID); - foreach($executions as $executionID => $execution) + foreach($executions as $id => $execution) { - if($execution->parent and isset($executions[$execution->parent])) $executions[$execution->id]->name = $executions[$execution->parent]->name . '/' . $execution->name; + if($execution->grade == 2 and isset($executions[$execution->parent])) + { + $execution->name = $executions[$execution->parent]->name . '/' . $execution->name; + $executions[$execution->parent]->children[$id] = $execution; + unset($executions[$id]); + } } - foreach($executions as $executionID => $execution) + foreach($executions as $id => $execution) { - if($execution->grade == 2) unset($executions[$execution->parent]); - $linkProductID = $executionProducts[$executionID]; - $execution->name = $products[$linkProductID] . '/' . $execution->name; + if(isset($execution->children)) + { + foreach($execution->children as $id => $execution) + { + $linkProductID = $executionProducts[$id]; + $execution->name = $products[$linkProductID] . '/' . $execution->name; + $executionList[$id] = $execution; + } + } + else + { + $linkProductID = $executionProducts[$id]; + $execution->name = $products[$linkProductID] . '/' . $execution->name; + $executionList[$id] = $execution; + } } } if($pairs) { $executionPairs = array(); - foreach($executions as $execution) $executionPairs[$execution->id] = $execution->name; - $executions = $executionPairs; + foreach($executionList as $execution) $executionPairs[$execution->id] = $execution->name; + $executionList = $executionPairs; } - return $executions; + return $executionList; } /**