diff --git a/module/execution/model.php b/module/execution/model.php index d4b91ec336..0befdfc3c6 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1720,6 +1720,47 @@ class executionModel extends model ->beginIF($limit)->limit($limit)->fi() ->fetchAll('id'); + /* Add product name and parent stage name to stage name. */ + if(isset($project->model) and $project->model == 'waterfall') + { + $executionProducts = array(); + if($project->hasProduct and $project->division) + { + $executionList = array(); + $executionProducts = $this->dao->select('t1.project, t2.name')->from(TABLE_PROJECTPRODUCT)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->where('project')->in(array_keys($executions)) + ->andWhere('t2.deleted')->eq(0) + ->fetchPairs(); + } + + $allExecutions = $this->dao->select('id,name,parent')->from(TABLE_EXECUTION) + ->where('type')->eq('stage') + ->andWhere('deleted')->eq('0') + ->beginIf($projectID)->andWhere('project')->eq($projectID)->fi() + ->fetchAll('id'); + + $parents = array(); + foreach($allExecutions as $id => $execution) $parents[$execution->parent] = $execution->parent; + + foreach($executions as $id => $execution) + { + if(isset($parents[$execution->id])) + { + unset($executions[$id]); + continue; + } + + $executionName = ''; + $paths = array_slice(explode(',', trim($execution->path, ',')), 1); + foreach($paths as $path) $executionName .= '/' . $allExecutions[$path]->name; + + if($executionName) $execution->name = ltrim($executionName, '/'); + if(isset($executionProducts[$id])) $execution->name = $executionProducts[$id] . '/' . $execution->name; + } + + } + $projects = array(); if(empty($projectID)) { diff --git a/module/task/control.php b/module/task/control.php index c5dc2d13e3..b30caf7f8d 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -300,7 +300,7 @@ class task extends control if(!empty($projectID)) { - $executions = $this->execution->getPairs($projectID, 'all', 'leaf'); + $executions = $this->execution->getByProject($projectID, 'all', 0, true); $executionKey = 0; $executionModifyList = $this->execution->getByIdList(array_keys($executions)); @@ -625,7 +625,7 @@ class task extends control if(isset($this->view->members['closed']) or $this->view->task->status == 'closed') $this->view->members['closed'] = 'Closed'; $executions = array(); - if(!empty($task->project)) $executions = $this->execution->getPairs($task->project, 'all', 'leaf'); + if(!empty($task->project)) $executions = $this->execution->getByProject($projectID, 'all', 0, true); $this->view->title = $this->lang->task->edit . 'TASK' . $this->lang->colon . $this->view->task->name; $this->view->position[] = $this->lang->task->common;