From 3e427c11a4dca28d4c544a74cde6dc23ff5e20ae Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 26 May 2022 11:35:01 +0800 Subject: [PATCH 1/6] * Fix bug #22943. --- module/task/view/recordestimate.html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/task/view/recordestimate.html.php b/module/task/view/recordestimate.html.php index 4153a61e18..18a612f7a8 100644 --- a/module/task/view/recordestimate.html.php +++ b/module/task/view/recordestimate.html.php @@ -45,7 +45,7 @@ task->consumed;?> task->left;?> comment;?> - team) or $task->assignedTo == $this->app->user->account) echo $lang->actions;?> + team) or ($task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account])))) echo $lang->actions;?> @@ -57,7 +57,7 @@ consumed . ' ' . $lang->execution->workHourUnit;?> left . ' ' . $lang->execution->workHourUnit;?> work;?> - team) or $task->assignedTo == $this->app->user->account):?> + team) or ($task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account])))):?> app->user->admin or $this->app->user->account == $estimate->account) From 017019f6af6d6f5d1b1284290a6cb760d6482239 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 26 May 2022 11:35:47 +0800 Subject: [PATCH 2/6] * Fix bug #22952,22979. --- module/task/control.php | 9 +++++---- module/task/model.php | 29 +++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index 27b9b5b746..40a271bd81 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -1215,11 +1215,12 @@ class task extends control { $teams = array_keys($task->team); - $task->nextBy = $this->task->getNextUser($teams, $task->assignedTo); - $task->myConsumed = $task->team[$task->assignedTo]->consumed; + $task->nextBy = $this->task->getNextUser($teams, $this->app->user->account); + $task->myConsumed = $task->team[$this->app->user->account]->consumed; - $lastAccount = end($teams); - if($lastAccount != $task->assignedTo) + $lastAccount = end($teams); + $finishedUsers = $this->task->getFinishedUsers($taskID, $teams); + if(($lastAccount != $task->assignedTo and $task->mode == 'linear') or ($task->mode == 'multi' and count($teams) != count($finishedUsers))) { $members = $this->task->getMemberPairs($task); } diff --git a/module/task/model.php b/module/task/model.php index 595ee7de3a..b40317faf5 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -819,7 +819,6 @@ class taskModel extends model $currentTask->consumed += (float)$member->consumed; $currentTask->left += (float)$member->left; } - $currentTask->consumed += (float)$oldTask->consumed; if(!empty($task)) { @@ -839,15 +838,15 @@ class taskModel extends model $currentTask->finishedDate = ''; } - if($currentTask->consumed > 0 && $currentTask->left == 0) + if($currentTask->consumed > 0 and $currentTask->left == 0) { - if(isset($team[$currentTask->assignedTo]) && $oldTask->assignedTo != $teams[count($teams) - 1]) + if(($oldTask->mode == 'linear' and isset($team[$currentTask->assignedTo]) and $oldTask->assignedTo != $teams[count($teams) - 1]) or ($oldTask->mode == 'multi' and count($finisedUsers) != count($teams))) { $currentTask->status = 'doing'; $currentTask->finishedBy = ''; $currentTask->finishedDate = ''; } - elseif($oldTask->assignedTo == $teams[count($teams) - 1]) + elseif(($oldTask->mode == 'linear' and $oldTask->assignedTo == $teams[count($teams) - 1]) or $oldTask->mode == 'multi') { $currentTask->status = 'done'; $currentTask->finishedBy = $this->app->user->account; @@ -1834,9 +1833,9 @@ class taskModel extends model $this->dao->update(TABLE_TEAM)->set('left')->eq(0)->set('consumed')->eq($task->consumed) ->where('root')->eq((int)$taskID) ->andWhere('type')->eq('task') - ->andWhere('account')->eq($oldTask->assignedTo)->exec(); + ->andWhere('account')->eq($this->app->user->account)->exec(); - $skipMembers = $this->loadModel('execution')->getTeamSkip($oldTask->team, $oldTask->assignedTo, $task->assignedTo); + $skipMembers = $oldTask->mode == 'linear' ? $this->loadModel('execution')->getTeamSkip($oldTask->team, $oldTask->assignedTo, $task->assignedTo) : $this->getFinishedUsers($oldTask->id, array_keys($oldTask->team)); foreach($skipMembers as $account => $team) $this->dao->update(TABLE_TEAM)->set('left')->eq(0)->where('root')->eq($taskID)->andWhere('type')->eq('task')->andWhere('account')->eq($account)->exec(); $task = $this->computeHours4Multiple($oldTask, $task); @@ -3548,6 +3547,24 @@ class taskModel extends model return $members; } + /** + * Get the users who finished the multiple task. + * + * @param int $taskID + * @param string|array $team + * @access public + * @return array + */ + public function getFinishedUsers($taskID = 0, $team = array()) + { + return $this->dao->select('actor')->from(TABLE_ACTION) + ->where('objectType')->eq('task') + ->andWhere('objectID')->eq($taskID) + ->andWhere('actor')->in($team) + ->andWhere('action')->eq('finished') + ->fetchPairs('actor'); + } + /** * Build task menu. * From c7aaf74e9d6e379f2c31b07034ca6728d28e3333 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 26 May 2022 11:36:18 +0800 Subject: [PATCH 3/6] * Optimize the code. --- module/mail/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/mail/model.php b/module/mail/model.php index 652894eecb..8459d4fbe7 100644 --- a/module/mail/model.php +++ b/module/mail/model.php @@ -722,7 +722,7 @@ class mailModel extends model } } - if($objectType == 'meeting') $rooms = $this->loadmodel('meetingroom')->getpairs(); + if($objectType == 'meeting') $rooms = $this->loadModel('meetingroom')->getpairs(); if($objectType == 'review') $this->app->loadLang('baseline'); /* Get mail content. */ From b43eed49d089d757b76a821a6a14827c31ab288f Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 26 May 2022 11:39:23 +0800 Subject: [PATCH 4/6] * Modify the logic of the return button. --- lib/base/front/front.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/base/front/front.class.php b/lib/base/front/front.class.php index 9fc799236e..5803c0f4e6 100644 --- a/lib/base/front/front.class.php +++ b/lib/base/front/front.class.php @@ -501,6 +501,8 @@ class baseHTML $gobackList = isset($_COOKIE['goback']) ? json_decode($_COOKIE['goback'], true) : array(); $gobackLink = isset($gobackList[$tab]) ? $gobackList[$tab] : ''; + if(strpos($misc, 'data-app') === false) $misc .= ' data-app="' . $tab . '"'; + /* If the link of the referer is not the link of the current page or the link of the index, the cookie and gobackLink will be updated. */ if(!preg_match("/(m=|\/)(index|search|$currentModule)(&f=|-)(index|buildquery|$currentMethod)(&|-|\.)?/", strtolower($refererLink))) { @@ -509,7 +511,7 @@ class baseHTML setcookie('goback', json_encode($gobackList), $config->cookieLife, $config->webRoot, '', $config->cookieSecure, false); } - return "{$label}"; + return "{$label}"; } /** From eb3f621a926fa9584f483ca1052622c6f0d85337 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 26 May 2022 11:41:09 +0800 Subject: [PATCH 5/6] * Modify the logic of the back button. --- lib/base/front/front.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base/front/front.class.php b/lib/base/front/front.class.php index 5803c0f4e6..6af2e1c1e1 100644 --- a/lib/base/front/front.class.php +++ b/lib/base/front/front.class.php @@ -501,7 +501,7 @@ class baseHTML $gobackList = isset($_COOKIE['goback']) ? json_decode($_COOKIE['goback'], true) : array(); $gobackLink = isset($gobackList[$tab]) ? $gobackList[$tab] : ''; - if(strpos($misc, 'data-app') === false) $misc .= ' data-app="' . $tab . '"'; + if(strpos($misc, 'data-app') === false) $misc .= " data-app='" . $tab . "'"; /* If the link of the referer is not the link of the current page or the link of the index, the cookie and gobackLink will be updated. */ if(!preg_match("/(m=|\/)(index|search|$currentModule)(&f=|-)(index|buildquery|$currentMethod)(&|-|\.)?/", strtolower($refererLink))) From 8c2654c7d201a34f42910618018d3a4a0af182d6 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 26 May 2022 13:55:49 +0800 Subject: [PATCH 6/6] * Fix bug #22979. --- module/task/model.php | 6 +++++- module/task/view/recordestimate.html.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/module/task/model.php b/module/task/model.php index b40317faf5..338e64fcbe 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -819,6 +819,7 @@ class taskModel extends model $currentTask->consumed += (float)$member->consumed; $currentTask->left += (float)$member->left; } + if(empty($oldTask->team)) $currentTask->consumed += (float)$oldTask->consumed; if(!empty($task)) { @@ -840,7 +841,8 @@ class taskModel extends model if($currentTask->consumed > 0 and $currentTask->left == 0) { - if(($oldTask->mode == 'linear' and isset($team[$currentTask->assignedTo]) and $oldTask->assignedTo != $teams[count($teams) - 1]) or ($oldTask->mode == 'multi' and count($finisedUsers) != count($teams))) + $finisedUsers = $this->getFinishedUsers($oldTask->id, $teams); + if(($oldTask->mode == 'linear' and isset($team[$currentTask->assignedTo]) and $oldTask->assignedTo != $teams[count($teams) - 1]) or ($oldTask->mode == 'multi' and count($finisedUsers) != (count($teams) -1))) { $currentTask->status = 'doing'; $currentTask->finishedBy = ''; @@ -3557,11 +3559,13 @@ class taskModel extends model */ public function getFinishedUsers($taskID = 0, $team = array()) { + $task = $this->getById($taskID); return $this->dao->select('actor')->from(TABLE_ACTION) ->where('objectType')->eq('task') ->andWhere('objectID')->eq($taskID) ->andWhere('actor')->in($team) ->andWhere('action')->eq('finished') + ->andWhere('date')->ge($task->activatedDate) ->fetchPairs('actor'); } diff --git a/module/task/view/recordestimate.html.php b/module/task/view/recordestimate.html.php index 18a612f7a8..27858044a1 100644 --- a/module/task/view/recordestimate.html.php +++ b/module/task/view/recordestimate.html.php @@ -45,7 +45,7 @@ task->consumed;?> task->left;?> comment;?> - team) or ($task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account])))) echo $lang->actions;?> + team) or $task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account]))) echo $lang->actions;?> @@ -57,7 +57,7 @@ consumed . ' ' . $lang->execution->workHourUnit;?> left . ' ' . $lang->execution->workHourUnit;?> work;?> - team) or ($task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account])))):?> + team) or $task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account]))):?> app->user->admin or $this->app->user->account == $estimate->account)