From a51f42e7b8ffab9c152ef31ea9fd990dfbcadee5 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 10 Oct 2022 09:08:28 +0800 Subject: [PATCH] * code for task #71609. --- module/my/control.php | 14 +------------- module/my/model.php | 12 +++++------- module/my/view/task.html.php | 28 ++++++++++------------------ module/task/model.php | 14 +++----------- 4 files changed, 19 insertions(+), 49 deletions(-) diff --git a/module/my/control.php b/module/my/control.php index 8bd9ace132..da5454c0f8 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -487,24 +487,13 @@ EOF; $tasks = $this->task->getUserTasks($this->app->user->account, $type, 0, $pager, $sort, $queryID); } - $parents = array(); - $executionIDList = array(); + $parents = array(); foreach($tasks as $task) { - if($this->config->systemMode == 'new') $executionIDList[$task->execution] = $task->execution; if($task->parent > 0) $parents[$task->parent] = $task->parent; } $parents = $this->dao->select('*')->from(TABLE_TASK)->where('id')->in($parents)->fetchAll('id'); - if($this->config->systemMode == 'new') - { - $projects = $this->dao->select('t1.id,t1.name,t2.id as execution')->from(TABLE_PROJECT)->alias('t1') - ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.id=t2.project') - ->where('t2.id')->in($executionIDList) - ->andWhere('t1.type')->eq('project') - ->fetchAll('execution'); - } - foreach($tasks as $task) { if($task->parent > 0) @@ -543,7 +532,6 @@ EOF; $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->pager = $pager; $this->view->mode = 'task'; - $this->view->projects = isset($projects) ? $projects : array(); if($this->app->viewType == 'json') $this->view->tasks = array_values($this->view->tasks); $this->display(); diff --git a/module/my/model.php b/module/my/model.php index a0affe4020..52b5a6f647 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -337,8 +337,9 @@ class myModel extends model if($objectType == 'task') { $orderBy = strpos($orderBy, 'pri_') !== false ? str_replace('pri_', 'priOrder_', $orderBy) : 't1.' . $orderBy; - $objectList = $this->dao->select("t1.*, t2.name as executionName, t2.type as executionType, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder")->from($this->config->objectTables[$module])->alias('t1') + $objectList = $this->dao->select("t1.*, t3.id as project, t2.name as executionName, t2.multiple as executionMultiple, t3.name as projectName, t2.type as executionType, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder")->from($this->config->objectTables[$module])->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on("t1.execution = t2.id") + ->leftJoin(TABLE_PROJECT)->alias('t3')->on("t2.project = t3.id") ->where('t1.deleted')->eq(0) ->andWhere('t2.deleted')->eq(0) ->andWhere('t1.id')->in(array_keys($objectIDList)) @@ -571,11 +572,11 @@ class myModel extends model $query = str_replace('t1.`project`', 't2.`project`', $query); $orderBy = str_replace('pri_', 'priOrder_', $orderBy); - $tasks = $this->dao->select("t1.*, t2.id as executionID, t2.name as executionName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder") + $tasks = $this->dao->select("t1.*, t4.id as project, t2.id as executionID, t2.name as executionName, t2.multiple as executionMultiple, t4.name as projectName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder") ->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on("t1.execution = t2.id") ->leftJoin(TABLE_STORY)->alias('t3')->on('t1.story = t3.id') - ->leftJoin(TABLE_PROJECT)->alias('t4')->on("t1.project = t4.id") + ->leftJoin(TABLE_PROJECT)->alias('t4')->on("t2.project = t4.id") ->leftJoin(TABLE_TASKTEAM)->alias('t5')->on("t1.id = t5.task") ->where($query) ->andWhere('t1.deleted')->eq(0) @@ -602,10 +603,7 @@ class myModel extends model $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'task', false); $taskTeam = $this->dao->select('*')->from(TABLE_TASKTEAM)->where('task')->in(array_keys($tasks))->fetchGroup('task'); - if(!empty($taskTeam)) - { - foreach($taskTeam as $taskID => $team) $tasks[$taskID]->team = $team; - } + foreach($taskTeam as $taskID => $team) $tasks[$taskID]->team = $team; if($tasks) return $this->loadModel('task')->processTasks($tasks); return array(); diff --git a/module/my/view/task.html.php b/module/my/view/task.html.php index 289ab3f422..932f6125f5 100644 --- a/module/my/view/task.html.php +++ b/module/my/view/task.html.php @@ -69,12 +69,8 @@ task->pri;?>>priAB);?> task->name);?> - systemMode == 'new'):?> my->projects);?> task->execution);?> - - my->executions);?> - openedByAB);?> @@ -122,14 +118,12 @@ ?> children)) echo '';?> - systemMode == 'new'):?> - execution]->name) ? $projects[$task->execution]->name : '';?> - execution]->id) ? $projects[$task->execution]->id : 0;?> - - createLink('project', 'index', "projectID=$projectID"), $projectName) : '';?> + + projectName and $task->project) ? html::a($this->createLink('project', 'index', "projectID=$task->project"), $task->projectName) : '';?> + + + executionMultiple) echo html::a($this->createLink('execution', 'task', "executionID=$task->execution"), $task->executionName, '');?> - - createLink('execution', 'task', "executionID=$task->execution"), $task->executionName, '');?> openedBy);?> @@ -199,14 +193,12 @@ parent > 0) echo '' . $this->lang->task->childrenAB . ' ';?> createLink('task', 'view', "taskID=$child->id", '', '', $child->project), $child->name, null, "style='color: $child->color'");?> - systemMode == 'new'):?> - execution]->name) ? $projects[$child->execution]->name : '';?> - execution]->id) ? $projects[$child->execution]->id : 0;?> - - createLink('project', 'view', "projectID=$projectID"), $projectName) : '';?> + + projectName and $task->project) ? html::a($this->createLink('project', 'view', "projectID=$task->project"), $task->projectName) : '';?> + + + executionMultiple) echo html::a($this->createLink('execution', 'task', "executionID=$child->project"), $child->executionName, '');?> - - createLink('execution', 'task', "executionID=$child->project"), $child->executionName, '');?> openedBy);?> diff --git a/module/task/model.php b/module/task/model.php index 5b1d540cf7..bec9c5c16f 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -2595,11 +2595,11 @@ class taskModel extends model { if(!$this->loadModel('common')->checkField(TABLE_TASK, $type)) return array(); $orderBy = str_replace('pri_', 'priOrder_', $orderBy); - $tasks = $this->dao->select("t1.*, t2.id as executionID, t2.name as executionName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder") + $tasks = $this->dao->select("t1.*, t4.id as project, t2.id as executionID, t2.name as executionName, t4.name as projectName, t2.multiple as executionMultiple, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder") ->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on("t1.execution = t2.id") ->leftJoin(TABLE_STORY)->alias('t3')->on('t1.story = t3.id') - ->leftJoin(TABLE_PROJECT)->alias('t4')->on("t1.project = t4.id") + ->leftJoin(TABLE_PROJECT)->alias('t4')->on("t2.project = t4.id") ->leftJoin(TABLE_TASKTEAM)->alias('t5')->on("t5.task = t1.id and t5.account = '{$account}'") ->where('t1.deleted')->eq(0) ->andWhere('t2.deleted')->eq(0) @@ -2625,15 +2625,7 @@ class taskModel extends model $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'task', false); $taskTeam = $this->dao->select('*')->from(TABLE_TASKTEAM)->where('task')->in(array_keys($tasks))->fetchGroup('task'); - if(!empty($taskTeam)) - { - foreach($taskTeam as $taskID => $team) $tasks[$taskID]->team = $team; - } - - $projectList = array(); - foreach($tasks as $task) $projectList[$task->project] = $task->project; - $projectPairs = $this->dao->select('id,name')->from(TABLE_PROJECT)->where('id')->in($projectList)->fetchPairs('id'); - foreach($tasks as $task) $task->projectName = zget($projectPairs, $task->project); + foreach($taskTeam as $taskID => $team) $tasks[$taskID]->team = $team; if($tasks) return $this->processTasks($tasks); return array();