From 69255bb181b791411614f4bef39e1f8463cfe1bc Mon Sep 17 00:00:00 2001 From: wumo Date: Fri, 30 Mar 2018 14:35:20 +0800 Subject: [PATCH] * Update the status of parent tasks after batch create tasks. --- module/task/model.php | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/module/task/model.php b/module/task/model.php index ec34c23a50..34801568a5 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -155,6 +155,10 @@ class taskModel extends model $storyIDs = array(); $taskNames = array(); $preStory = 0; + + /* Judge whether the current task is a parent. */ + $parentID = !empty($this->post->parent[0]) ? $this->post->parent[0] : 0; + foreach($tasks->story as $key => $storyID) { if(empty($tasks->name[$key])) continue; @@ -180,7 +184,6 @@ class taskModel extends model $result = $this->loadModel('common')->removeDuplicate('task', $tasks, "project=$projectID and story " . helper::dbIN($storyIDs)); $tasks = $result['data']; - $story = 0; $module = 0; $type = ''; @@ -255,6 +258,7 @@ class taskModel extends model $this->computeWorkingHours($tasks->parent[0]); if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchCreate'); + if($parentID) $this->updateParentStatus($taskID); return $mails; } @@ -308,25 +312,28 @@ class taskModel extends model $childrenStatus = $this->dao->select('id,status')->from(TABLE_TASK)->where('parent')->eq($parentID)->andWhere('deleted')->eq(0)->fetchPairs('status', 'status'); $status = ''; - if(isset($childrenStatus['doing'])) + if(count($childrenStatus) == 1) { - $status = 'doing'; + $status = current($childrenStatus); } - elseif(isset($childrenStatus['pause']) and !isset($childrenStatus['wait'])) + else { - $status = 'pause'; - } - elseif(isset($childrenStatus['done']) and !isset($childrenStatus['wait'])) - { - $status = 'done'; - } - elseif(isset($childrenStatus['closed']) and !isset($childrenStatus['wait'])) - { - $status = 'closed'; - } - elseif(isset($childrenStatus['cancel']) and !isset($childrenStatus['wait'])) - { - $status = 'cancel'; + if(isset($childrenStatus['doing']) or isset($childrenStatus['pause']) or isset($childrenStatus['wait'])) + { + $status = 'doing'; + } + elseif(isset($childrenStatus['done'])) + { + $status = 'done'; + } + elseif(isset($childrenStatus['closed'])) + { + $status = 'closed'; + } + elseif(isset($childrenStatus['cancel'])) + { + $status = 'cancel'; + } } $parentTask = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($parentID)->fetch();