From fc2eda8fa645cb7b648087b309bdb26ce58715e0 Mon Sep 17 00:00:00 2001 From: jinianlan Date: Thu, 1 Aug 2019 17:38:49 +0800 Subject: [PATCH] * fix Bug 2671 --- module/story/view/tasks.html.php | 19 ++++++++++ module/task/model.php | 59 ++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/module/story/view/tasks.html.php b/module/story/view/tasks.html.php index 08ba9c6051..5f85b5299c 100644 --- a/module/story/view/tasks.html.php +++ b/module/story/view/tasks.html.php @@ -37,6 +37,25 @@ include '../../common/view/chart.html.php'; left;?>
+ children)):?> + + children as $key => $child):?> + + children)) ? ' table-child-bottom' : '';?> + + id;?> + lang->task->children . '">' . $this->lang->task->childrenAB . '' ?>name;?> + task->priList, $child->pri, $child->pri)?>'>pri == '0' ? '' : zget($lang->task->priList, $child->pri, $child->pri);?> + processStatus('task', $child);?> + assignedTo, $child->assignedTo);?> + estimate;?> + consumed;?> + left;?> +
+ + + + diff --git a/module/task/model.php b/module/task/model.php index 1796c611ec..2609e58603 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1832,13 +1832,49 @@ class taskModel extends model */ public function getStoryTasks($storyID, $projectID = 0) { - $tasks = $this->dao->select('id, name, assignedTo, pri, status, estimate, consumed, closedReason, `left`') + $tasks = $this->dao->select('id, parent, name, assignedTo, pri, status, estimate, consumed, closedReason, `left`') ->from(TABLE_TASK) ->where('story')->eq((int)$storyID) ->andWhere('deleted')->eq(0) ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() ->fetchAll('id'); + $parents = array(); + foreach($tasks as $task) + { + if($task->parent == -1) $parents[] = $task->id; + } + if(!empty($parents)) + { + /* Select children task. */ + $children = $this->dao->select('id, parent, name, assignedTo, pri, status, estimate, consumed, closedReason, `left`') + ->from(TABLE_TASK) + ->where('story')->eq((int)$storyID) + ->andwhere('parent')->in($parents) + ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() + ->fetchAll('id'); + + if(!empty($children)) + { + foreach($children as $child) + { + $tasks[$child->parent]->children[$child->id] = $child; + } + } + } + + foreach($tasks as $task) + { + if($task->parent > 0) + { + if(isset($tasks[$task->parent])) + { + $tasks[$task->parent]->children[$task->id] = $task; + unset($tasks[$task->id]); + } + } + } + foreach($tasks as $task) { /* Compute task progress. */ @@ -1854,8 +1890,27 @@ class taskModel extends model { $task->progress = round($task->consumed / ($task->consumed + $task->left), 2) * 100; } - } + if(!empty($task->children)) + { + foreach($task->children as $child) + { + /* Compute child progress. */ + if($child->consumed == 0 and $child->left == 0) + { + $child->progress = 0; + } + elseif($child->consumed != 0 and $child->left == 0) + { + $child->progress = 100; + } + else + { + $child->progress = round($child->consumed / ($child->consumed + $child->left), 2) * 100; + } + } + } + } return $tasks; }