* Code for task #65278.

This commit is contained in:
sunguangming
2022-08-17 16:51:28 +08:00
parent 583055fee3
commit 7f69b62231
9 changed files with 68 additions and 50 deletions
+1 -1
View File
@@ -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);
}
+25 -30
View File
@@ -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);
+1 -1
View File
@@ -14,7 +14,7 @@
<?php include '../../common/view/kindeditor.html.php';?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<?php if(!empty($task->team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
<?php if(!empty($task->members) and (!isset($task->members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
<div class="alert with-icon">
<i class="icon-exclamation-sign"></i>
<div class="content">
+5 -2
View File
@@ -281,8 +281,11 @@ foreach(explode(',', $config->task->edit->requiredFields) as $field)
<?php foreach($task->team as $member):?>
<?php
$memberStatus = 'wait';
if($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;
+28 -8
View File
@@ -21,7 +21,7 @@
<?php js::set('totalLeftError', sprintf($this->lang->task->error->leftEmptyAB, $this->lang->task->statusList[$task->status]));?>
<div id='mainContent' class='main-content'>
<div class='center-block' id='taskTeamEditor'>
<?php if(empty($task->team) and !isset($task->team[$app->user->account])):?>
<?php if(empty($task->members) and !isset($task->members[$app->user->account])):?>
<div class="alert with-icon">
<i class="icon-exclamation-sign"></i>
<div class="content">
@@ -56,27 +56,47 @@
</td>
</tr>
<?php foreach($task->team as $member):?>
<?php
$memberStatus = 'wait';
if($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;
?>
<tr>
<td class='w-250px'><?php echo html::select("team[]", $members, $member->account, "class='form-control chosen'")?></td>
<td class='w-250px'>
<?php echo html::select("team[]", $members, $member->account, "class='form-control chosen'" . ($memberDisabled ? ' disabled' : ''))?>
<?php echo html::hidden("source[]", $member->account);?>
<?php if($memberDisabled) echo html::hidden("team[]", $member->account);?>
</td>
<td>
<div class='input-group'>
<span class='input-group-addon'><?php echo $lang->task->estimate?></span>
<?php echo html::input("teamEstimate[]", (float)$member->estimate, "class='form-control text-center' placeholder='{$lang->task->hour}'")?>
<?php echo html::input("teamEstimate[]", (float)$member->estimate, "class='form-control text-center' placeholder='{$lang->task->hour}'" . ($memberDisabled ? ' readonly' : ''));?>
<span class='input-group-addon fix-border'><?php echo $lang->task->consumed?></span>
<?php echo html::input("teamConsumed[]", (float)$member->consumed, "class='form-control text-center' readonly placeholder='{$lang->task->hour}'")?>
<span class='input-group-addon fix-border'><?php echo $lang->task->left?></span>
<?php echo html::input("teamLeft[]", (float)$member->left, "class='form-control text-center' placeholder='{$lang->task->hour}'")?>
<?php echo html::input("teamLeft[]", (float)$member->left, "class='form-control text-center' placeholder='{$lang->task->hour}'" . ($memberDisabled ? ' readonly' : ''))?>
</div>
</td>
<td class='w-130px sort-handler'>
<button type="button" class="btn btn-link btn-sm btn-icon btn-add"><i class="icon icon-plus"></i></button>
<button type='button' class='btn btn-link btn-sm btn-icon btn-move'><i class='icon-move'></i></button>
<button type="button" class="btn btn-link btn-sm btn-icon btn-delete"><i class="icon icon-close"></i></button>
<button type="button" <?php echo $linearDisabled ? 'disabled' : '';?> class="btn btn-link btn-sm btn-icon btn-add"><i class="icon icon-plus"></i></button>
<button type='button' <?php echo $linearDisabled ? 'disabled' : '';?> class='btn btn-link btn-sm btn-icon btn-move'><i class='icon-move'></i></button>
<button type="button" <?php echo $linearDisabled ? 'disabled' : '';?> class="btn btn-link btn-sm btn-icon btn-delete"><i class="icon icon-close"></i></button>
</td>
</tr>
<?php endforeach;?>
<tr class='template'>
<td class='w-250px'><?php echo html::select("team[]", $members, '', "class='form-control chosen'")?></td>
<td class='w-250px'>
<?php echo html::select("team[]", $members, '', "class='form-control chosen'")?>
<?php echo html::hidden("source[]", '');?>
</td>
<td>
<div class='input-group'>
<span class='input-group-addon'><?php echo $lang->task->estimate?></span>
+1 -1
View File
@@ -17,7 +17,7 @@
<?php js::set('consumedEmpty', $lang->task->error->consumedEmptyAB);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<?php if(!empty($task->team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
<?php if(!empty($task->members) and (!isset($task->members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
<div class="alert with-icon">
<i class="icon-exclamation-sign"></i>
<div class="content">
+1 -1
View File
@@ -14,7 +14,7 @@
<?php include '../../common/view/kindeditor.html.php';?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<?php if(!empty($task->team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
<?php if(!empty($task->members) and (!isset($task->members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
<div class="alert with-icon">
<i class="icon-exclamation-sign"></i>
<div class="content">
+5 -5
View File
@@ -21,8 +21,8 @@
<?php endif;?>
#recordForm table .form-actions{padding:25px;}
</style>
<?php $team = array_keys($task->team);?>
<?php js::set('confirmRecord', (!empty($team) && $task->assignedTo != end($team)) ? $lang->task->confirmTransfer : $lang->task->confirmRecord);?>
<?php $members = $task->members;?>
<?php js::set('confirmRecord', (!empty($members) && $task->assignedTo != end($members)) ? $lang->task->confirmTransfer : $lang->task->confirmRecord);?>
<?php js::set('noticeSaveRecord', $lang->task->noticeSaveRecord);?>
<?php js::set('today', helper::today());?>
<div id='mainContent' class='main-content'>
@@ -45,7 +45,7 @@
<th class="thWidth"><?php echo $lang->task->consumed;?></th>
<th class="thWidth"><?php echo $lang->task->left;?></th>
<th><?php echo $lang->comment;?></th>
<th class='c-actions-2'><?php if(empty($task->team) or $task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account]))) echo $lang->actions;?></th>
<th class='c-actions-2'><?php if(empty($members) or $task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($members[$app->user->account]))) echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
@@ -57,7 +57,7 @@
<td title="<?php echo $estimate->consumed . ' ' . $lang->execution->workHour;?>"><?php echo $estimate->consumed . ' ' . $lang->execution->workHourUnit;?></td>
<td title="<?php echo $estimate->left . ' ' . $lang->execution->workHour;?>"><?php echo $estimate->left . ' ' . $lang->execution->workHourUnit;?></td>
<td class="text-left" title="<?php echo $estimate->work;?>"><?php echo $estimate->work;?></td>
<?php if(empty($task->team) or $task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($task->team[$app->user->account]))):?>
<?php if(empty($members) or $task->assignedTo == $this->app->user->account or ($task->mode == 'multi' and isset($members[$app->user->account]))):?>
<td align='center' class='c-actions'>
<?php
if($this->app->user->account == $estimate->account)
@@ -71,7 +71,7 @@
<?php endif;?>
<?php endforeach;?>
<?php endif;?>
<?php if(!empty($task->team) and (!isset($task->team[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
<?php if(!empty($members) and (!isset($members[$app->user->account]) or ($task->assignedTo != $app->user->account and $task->mode == 'linear'))):?>
</tbody>
</table>
</form>
+1 -1
View File
@@ -18,7 +18,7 @@
<div id='mainContent' class='main-content'>
<?php
/* IF it is multi-task, the suspened can only be restarted by the current user who it is assigned to. */
if(!empty($task->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'))):
?>
<div class="alert with-icon">
<i class="icon-exclamation-sign"></i>