From 4403b96bf8dd746393d797bc021481d0c5f7c41c Mon Sep 17 00:00:00 2001 From: Yagami Date: Tue, 7 Feb 2023 16:05:18 +0800 Subject: [PATCH] * Finish task #83947. --- module/execution/model.php | 45 ++++++++++++++------------------------ module/task/control.php | 42 ++++------------------------------- 2 files changed, 20 insertions(+), 67 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index d8beaadca8..44527218a6 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1725,44 +1725,31 @@ class executionModel extends model ->beginIF($limit)->limit($limit)->fi() ->fetchAll('id'); - if(isset($project->model) and $project->model == 'waterfall' and $project->hasProduct and $project->division) + if(isset($project->model) and $project->model == 'waterfall') { - $executionList = array(); - $executionProducts = $this->dao->select('t1.project,t1.product')->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'); - $products = $this->loadModel('product')->getProductPairsByProject($projectID, 'all', $executionProducts); + $parents = array(); + foreach($allExecutions as $id => $execution) $parents[$execution->parent] = $execution->parent; foreach($executions as $id => $execution) { - if($execution->grade == 2 and isset($executions[$execution->parent])) + if(isset($parents[$execution->id])) { - $execution->name = $executions[$execution->parent]->name . '/' . $execution->name; - $executions[$execution->parent]->children[$id] = $execution; unset($executions[$id]); + continue; } - } - foreach($executions as $id => $execution) - { - if(isset($execution->children)) - { - foreach($execution->children as $id => $execution) - { - $execution->name = (isset($executionProducts[$id]) ? $products[$executionProducts[$id]] . '/' : '') . $execution->name; - $executionList[$id] = $execution; - } - } - else - { - $execution->name = (isset($executionProducts[$id]) ? $products[$executionProducts[$id]] . '/' : '') . $execution->name; - $executionList[$id] = $execution; - } + $executionName = ''; + $paths = array_slice(explode(',', trim($execution->path, ',')), 1); + foreach($paths as $path) $executionName .= '/' . $allExecutions[$path]->name; + + if($executionName) $execution->name = ltrim($executionName, '/'); } - $executions = $executionList; } $projects = array(); @@ -1785,7 +1772,7 @@ class executionModel extends model foreach($executions as $execution) { $executionPairs[$execution->id] = ''; - $executionPairs[$execution->id] .= isset($projects[$execution->project]) ? ($projects[$execution->project] . ' / ') : ''; + $executionPairs[$execution->id] .= isset($projects[$execution->project]) ? ($projects[$execution->project] . '/') : ''; $executionPairs[$execution->id] .= $execution->name; if(empty($execution->multiple)) $executionPairs[$execution->id] = $projects[$execution->project] . "({$this->lang->project->disableExecution})"; diff --git a/module/task/control.php b/module/task/control.php index 62dcdb2d99..465ba77563 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -298,33 +298,16 @@ class task extends control /* Set Custom*/ foreach(explode(',', $this->config->task->customCreateFields) as $field) $customFields[$field] = $this->lang->task->$field; - $executions = array(); if(!empty($projectID)) { - $executionList = $this->execution->getByProject($projectID, 'all', 0, true); - $project = $this->loadModel('project')->getByID($projectID); - $replace = substr(current($executionList), 0, strpos(current($executionList), '/')); + $executions = $this->execution->getByProject($projectID, 'all', 0, true); $executionKey = 0; - $executionModifyList = $this->execution->getByIdList(array_keys($executionList)); + $executionModifyList = $this->execution->getByIdList(array_keys($executions)); foreach($executionModifyList as $modifykey) { if(!common::canModify('execution', $modifykey)) $executionKey = $modifykey->id; - if($executionKey) unset($executionList[$executionKey]); - } - $executionAll = $executionList; - - if(isset($project->model) and $project->model == 'waterfall') - { - foreach($executionList as $key => $val) - { - $values = str_replace($replace, $project->name, $val); - $executions[$key] = $values; - } - } - else - { - $executions = $executionList; + if($executionKey) unset($executions[$executionKey]); } } @@ -642,24 +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)) - { - $executionList = $this->execution->getPairs($task->project); - $project = $this->loadModel('project')->getByID($task->project); - - if(isset($project->model) and $project->model == 'waterfall') - { - foreach($executionList as $key=>$val) - { - $values = $project->name . '/' . $val; - $executions[$key] = $values; - } - } - else - { - $executions = $executionList; - } - } + if(!empty($task->project)) $executions = $this->execution->getByProject($task->project, '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;