From 7f69b622317f1bbd4d751d272a340bb7af837ba9 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Wed, 17 Aug 2022 16:51:28 +0800 Subject: [PATCH] * Code for task #65278. --- module/task/control.php | 2 +- module/task/model.php | 55 +++++++++++------------- module/task/view/assignto.html.php | 2 +- module/task/view/edit.html.php | 7 ++- module/task/view/editteam.html.php | 36 ++++++++++++---- module/task/view/finish.html.php | 2 +- module/task/view/pause.html.php | 2 +- module/task/view/recordestimate.html.php | 10 ++--- module/task/view/start.html.php | 2 +- 9 files changed, 68 insertions(+), 50 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index ef65ffd47c..f1b1b9e646 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -832,7 +832,7 @@ class task extends control /* Compute next assignedTo. */ if(!empty($task->team)) { - $task->nextUser = $this->task->getNextUser(array_keys($task->team), $task->assignedTo); + $task->nextUser = $this->task->getAssignedTo4Multi($task->members, $task); $members = $this->task->getMemberPairs($task); } diff --git a/module/task/model.php b/module/task/model.php index 9c2cc0ef54..5559058583 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -1527,49 +1527,37 @@ class taskModel extends model ->setDefault('lastEditedDate', $now) ->setDefault('assignedDate', $now) ->stripTags($this->config->task->editor->assignto['id'], $this->config->allowedTags) - ->remove('comment,showModule,team,teamEstimate,teamConsumed,teamLeft') + ->remove('comment,showModule,team,teamEstimate,teamConsumed,teamLeft,source') ->get(); $teams = array(); - if(count(array_unique(array_filter($this->post->team))) > 1) + if($this->post->multiple and count(array_filter($this->post->team)) > 1) { + $this->dao->delete()->from(TABLE_TASKTEAM)->where('task')->eq($taskID)->exec(); foreach($this->post->team as $row => $account) { - if(empty($account) or isset($team[$account])) continue; + if(empty($account)) continue; + $source = $this->post->source[$row]; $member = new stdClass(); - $member->account = $account; $member->task = $taskID; + $member->order = $row; + $member->type = (!empty($source) and $source != $account) ? 'replace' : 'new'; + $member->account = $account; $member->estimate = $this->post->teamEstimate[$row] ? $this->post->teamEstimate[$row] : 0; $member->consumed = $this->post->teamConsumed[$row] ? $this->post->teamConsumed[$row] : 0; $member->left = $this->post->teamLeft[$row] === '' ? 0 : $this->post->teamLeft[$row]; - $member->order = $row; - $teams[$account] = $member; - if($oldTask->status == 'done') $member->left = 0; + if($task->status == 'done') $member->left = 0; + + $memberMethod = ($oldTask->mode == 'multi' and isset($teams[$account])) ? 'update' : 'insert'; + $this->manageTaskTeam($member, $memberMethod); + + $teams[$account] = $account; } - } - /* Save team. */ - $this->dao->delete()->from(TABLE_TASKTEAM)->where('task')->eq($taskID)->exec(); - if(!empty($teams)) - { - foreach($teams as $member) $this->dao->insert(TABLE_TASKTEAM)->data($member)->autoCheck()->exec(); - - /* Assign the left hours to zero who will be skipped. */ - $skipMembers = $this->loadModel('execution')->getTeamSkip($oldTask->team, $oldTask->assignedTo, isset($task->assignedTo) ? $task->assignedTo : $oldTask->assignedTo); - foreach($skipMembers as $account => $team) $this->dao->update(TABLE_TASKTEAM)->set('left')->eq(0)->where('task')->eq($taskID)->andWhere('account')->eq($account)->exec(); - - $task = $this->computeHours4Multiple($oldTask, $task, array(), $autoStatus = false); - if($task->status == 'wait') - { - reset($teams); - $task->assignedTo = key($teams); - } - } - else - { - $task->mode = ''; + if(!empty($teams)) $task = $this->computeHours4Multiple($oldTask, $task, array(), $autoStatus = false); } + if(empty($teams)) $task->mode = ''; if($oldTask->parent > 0) $this->updateParentStatus($taskID); @@ -2235,8 +2223,15 @@ class taskModel extends model /* Check parent Task. */ if($task->parent > 0) $task->parentName = $this->dao->findById($task->parent)->from(TABLE_TASK)->fetch('name'); - $task->team = $this->dao->select('*')->from(TABLE_TASKTEAM)->where('task')->eq($taskID)->orderBy('order')->fetchAll('id'); - foreach($children as $child) $child->team = array(); + $task->members = array(); + $task->team = $this->dao->select('*')->from(TABLE_TASKTEAM)->where('task')->eq($taskID)->orderBy('order')->fetchAll('id'); + foreach($task->team as $member) $task->members[$member->account] = $member->account; + + foreach($children as $child) + { + $child->team = array(); + $child->members = array(); + } $task = $this->loadModel('file')->replaceImgURL($task, 'desc'); if($setImgSize) $task->desc = $this->file->setImgSize($task->desc); diff --git a/module/task/view/assignto.html.php b/module/task/view/assignto.html.php index 50f162d9d9..1a2d1b4554 100644 --- a/module/task/view/assignto.html.php +++ b/module/task/view/assignto.html.php @@ -14,7 +14,7 @@
- team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?> + members) and (!isset($task->members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
diff --git a/module/task/view/edit.html.php b/module/task/view/edit.html.php index 1ab35fb6f3..39d546547e 100644 --- a/module/task/view/edit.html.php +++ b/module/task/view/edit.html.php @@ -281,8 +281,11 @@ foreach(explode(',', $config->task->edit->requiredFields) as $field) team as $member):?> consumed > 0) $memberStatus = 'doing'; - if(strpos($task->finishedList, ",{$member->account},") !== false) $memberStatus = 'done'; + if($member->consumed > 0) + { + $memberStatus = 'doing'; + if($member->left == 0) $memberStatus = 'done'; + } $memberDisabled = false; $linearDisabled = false; diff --git a/module/task/view/editteam.html.php b/module/task/view/editteam.html.php index 407837db23..6069841af6 100755 --- a/module/task/view/editteam.html.php +++ b/module/task/view/editteam.html.php @@ -21,7 +21,7 @@ lang->task->error->leftEmptyAB, $this->lang->task->statusList[$task->status]));?>
- team) and !isset($task->team[$app->user->account])):?> + members) and !isset($task->members[$app->user->account])):?>
@@ -56,27 +56,47 @@ team as $member):?> + consumed > 0) + { + $memberStatus = 'doing'; + if($member->left == 0) $memberStatus = 'done'; + } + + $memberDisabled = false; + $linearDisabled = false; + if($memberStatus == 'done') $memberDisabled = true; + if($memberDisabled and $task->mode == 'linear') $linearDisabled = true; + ?> - account, "class='form-control chosen'")?> + + account, "class='form-control chosen'" . ($memberDisabled ? ' disabled' : ''))?> + account);?> + account);?> +
task->estimate?> - estimate, "class='form-control text-center' placeholder='{$lang->task->hour}'")?> + estimate, "class='form-control text-center' placeholder='{$lang->task->hour}'" . ($memberDisabled ? ' readonly' : ''));?> task->consumed?> consumed, "class='form-control text-center' readonly placeholder='{$lang->task->hour}'")?> task->left?> - left, "class='form-control text-center' placeholder='{$lang->task->hour}'")?> + left, "class='form-control text-center' placeholder='{$lang->task->hour}'" . ($memberDisabled ? ' readonly' : ''))?>
- - - + + + - + + + +
task->estimate?> diff --git a/module/task/view/finish.html.php b/module/task/view/finish.html.php index 2ca48a2d6e..27f302d708 100644 --- a/module/task/view/finish.html.php +++ b/module/task/view/finish.html.php @@ -17,7 +17,7 @@ task->error->consumedEmptyAB);?>
- team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?> + members) and (!isset($task->members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
diff --git a/module/task/view/pause.html.php b/module/task/view/pause.html.php index 79e8979635..9948de0593 100644 --- a/module/task/view/pause.html.php +++ b/module/task/view/pause.html.php @@ -14,7 +14,7 @@
- team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?> + members) and (!isset($task->members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
diff --git a/module/task/view/recordestimate.html.php b/module/task/view/recordestimate.html.php index cfb3432d34..0fa5a6789e 100644 --- a/module/task/view/recordestimate.html.php +++ b/module/task/view/recordestimate.html.php @@ -21,8 +21,8 @@ #recordForm table .form-actions{padding:25px;} -team);?> -assignedTo != end($team)) ? $lang->task->confirmTransfer : $lang->task->confirmRecord);?> +members;?> +assignedTo != end($members)) ? $lang->task->confirmTransfer : $lang->task->confirmRecord);?> task->noticeSaveRecord);?>
@@ -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;?> + assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($members[$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]))):?> + assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($members[$app->user->account]))):?> app->user->account == $estimate->account) @@ -71,7 +71,7 @@ - team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?> + user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?> diff --git a/module/task/view/start.html.php b/module/task/view/start.html.php index b99e88a42b..c474b6e698 100644 --- a/module/task/view/start.html.php +++ b/module/task/view/start.html.php @@ -18,7 +18,7 @@
team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))): + if(!empty($task->members) and (!isset($task->members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))): ?>