* adjust for multi task.

This commit is contained in:
wangyidong
2022-08-26 14:50:48 +08:00
parent 098e89233d
commit 3a5f4201ed
6 changed files with 61 additions and 51 deletions
+4 -1
View File
@@ -1087,12 +1087,15 @@ class task extends control
return print(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
}
$assignedTo = empty($task->assignedTo) ? $this->app->user->account : $task->assignedTo;
if(!empty($task->team)) $assignedTo = $this->task->getAssignedTo4Multi($task->team, $task);
$this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->start;
$this->view->position[] = $this->lang->task->start;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->members = $this->loadModel('user')->getTeamMemberPairs($task->execution, 'execution', 'nodeleted');
$this->view->assignedTo = $task->assignedTo == '' ? $this->app->user->account : $task->assignedTo;
$this->view->assignedTo = $assignedTo;
$this->display();
}
-20
View File
@@ -1,26 +1,6 @@
$(function()
{
$('.record-estimate-toggle').modalTrigger({width:900, type:'iframe', afterHide: function(){parent.location.href=parent.location.href;}});
$('#modalTeam').on('change', 'select#team', function()
{
$(this).closest('tr').find('input[id^=teamEstimate]').closest('.input-group').toggleClass('required', $(this).val() != '')
var $teamSource = $(this).siblings('[name^=teamSource]');
if($teamSource.val() == '') return;
var $tr = $(this).closest('tr');
var consumed = 0;
var estimate = $tr.attr('data-left');;
if($(this).val() == $teamSource.val())
{
consumed = $tr.attr('data-consumed');
estimate = $tr.attr('data-estimate');
}
$tr.find('[name^=teamConsumed]').val(consumed);
$tr.find('[name^=teamEstimate]').val(estimate);
});
$('#modalTeam select:enabled').change()
})
/**
+39 -26
View File
@@ -790,24 +790,18 @@ class taskModel extends model
}
$currentTask->estimate = 0;
$currentTask->consumed = 0;
$currentTask->left = 0;
foreach($team as $member)
{
$currentTask->estimate += (float)$member->estimate;
$currentTask->consumed += (float)$member->consumed;
$currentTask->left += (float)$member->left;
}
$oldTask->team = $oldTeam;
if($this->app->rawMethod == 'edit')
{
if(empty($oldTask->team) and isset($oldTask->consumed)) $currentTask->consumed += (float)$oldTask->consumed;
$efforts = $this->getTaskEstimate($oldTask->id);
$currentTask->consumed = 0;
foreach($efforts as $effort) $currentTask->consumed += (float)$effort->consumed;
$efforts = $this->getTaskEstimate($oldTask->id);
$currentTask->consumed = 0;
foreach($efforts as $effort) $currentTask->consumed += (float)$effort->consumed;
}
$oldTask->team = $oldTeam;
if(!empty($task))
{
@@ -1594,11 +1588,7 @@ class taskModel extends model
public function updateTeam($taskID)
{
$oldTask = $this->getById($taskID);
if($this->post->estimate < 0 or $this->post->left < 0 or $this->post->consumed < 0)
{
dao::$errors[] = $this->lang->task->error->recordMinus;
return false;
}
if($this->post->estimate < 0 or $this->post->left < 0 or $this->post->consumed < 0) return dao::$errors[] = $this->lang->task->error->recordMinus;
$now = helper::now();
$task = fixer::input('post')
@@ -1617,7 +1607,7 @@ class taskModel extends model
if(count(array_filter($this->post->team)) > 1)
{
$teams = $this->manageTaskTeam($oldTask->mode, $taskID, $task->status);
if(!empty($teams)) $task = $this->computeHours4Multiple($oldTask, $task, array(), $autoStatus = false);
if(!empty($teams)) $task = $this->computeHours4Multiple($oldTask, $task);
}
if(empty($teams)) $task->mode = '';
@@ -1797,7 +1787,7 @@ class taskModel extends model
$consumed = 0;
$left = $task->left;
$now = helper::now();
$lastDate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($taskID)->orderBy('date_desc')->limit(1)->fetch('date');
$lastDate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($taskID)->orderBy('date_desc,id_desc')->limit(1)->fetch('date');
foreach($estimates as $estimate)
{
@@ -1823,7 +1813,7 @@ class taskModel extends model
$data->lastEditedDate = $now;
if(helper::isZeroDate($task->realStarted)) $data->realStarted = $now;
if($left == 0 and strpos('done,cancel,closed', $task->status) === false)
if($left == 0 and strpos('done,cancel,closed,pause', $task->status) === false)
{
$data->status = 'done';
$data->assignedTo = $task->openedBy;
@@ -1845,6 +1835,13 @@ class taskModel extends model
$data->status = 'doing';
$data->assignedTo = $this->app->user->account;
$data->assignedDate = $now;
$data->finishedBy = '';
$data->canceledBy = '';
$data->closedBy = '';
$data->closedReason = '';
$data->finishedDate = '0000-00-00';
$data->canceledDate = '0000-00-00';
$data->closedDate = '0000-00-00';
}
if(!empty($task->team))
@@ -1971,6 +1968,8 @@ class taskModel extends model
if(count($finishedUsers) == count($oldTask->team))
{
$task->status = 'done';
$task->assignedTo = $task->openedBy;
$task->assignedDate = $now;
$task->finishedBy = $this->app->user->account;
$task->finishedDate = $task->finishedDate;
}
@@ -2923,13 +2922,18 @@ class taskModel extends model
if($currentTeam->status != 'done') $newTeamInfo->left = $left;
if($currentTeam->status != 'done' and $newTeamInfo->consumed > 0 and $left == 0) $newTeamInfo->status = 'done';
if($task->mode == 'multi' and $currentTeam->status == 'done' and $left > 0) $newTeamInfo->status = 'doing';
if($task->mode == 'multi' and $currentTeam->status == 'done' and ($newTeamInfo->consumed == 0 and $left == 0))
{
$newTeamInfo->status = 'doing';
$newTeamInfo->left = $currentTeam->estimate;
}
$this->dao->update(TABLE_TASKTEAM)->data($newTeamInfo)->where('id')->eq($currentTeam->id)->exec();
$data = $this->computeHours4Multiple($task, $data);
}
}
$this->dao->delete()->from(TABLE_TASKESTIMATE)->where('id')->eq($estimateID)->exec();
if(!empty($task->team)) $data = $this->computeHours4Multiple($task, $data);
$this->dao->update(TABLE_TASK)->data($data) ->where('id')->eq($estimate->task)->exec();
if($task->parent > 0) $this->updateParentStatus($task->id);
if($task->story) $this->loadModel('story')->setStage($task->story);
@@ -3444,18 +3448,27 @@ class taskModel extends model
if($action == 'recordestimate' and $task->parent == -1) return false;
if($action == 'delete' and $task->parent < 0) return false;
if(!empty($task->team) and $task->mode == 'linear')
if(!empty($task->team))
{
global $app;
if($action == 'assignto') return false;
if($action == 'start')
if($task->mode == 'linear')
{
if($task->assignedTo != $app->user->account) return false;
if($action == 'assignto') return false;
if($action == 'start')
{
if($task->assignedTo != $app->user->account) return false;
$currentTeam = (new self())->getTeamByAccount($task->team, $app->user->account);
if($currentTeam and $currentTeam->status == 'wait') return true;
}
if($action == 'finish' and $task->assignedTo != $app->user->account) return false;
}
elseif($task->mode == 'multi')
{
$currentTeam = (new self())->getTeamByAccount($task->team, $app->user->account);
if($currentTeam and $currentTeam->status == 'wait') return true;
if($action == 'start' and $currentTeam and $currentTeam->status == 'wait') return true;
if($action == 'finish' and (empty($currentTeam) or $currentTeam->status == 'done')) return false;
}
if($action == 'finish' and $task->assignedTo != $app->user->account) return false;
}
if($action == 'start') return $task->status == 'wait';
+1 -1
View File
@@ -67,7 +67,7 @@
?>
</td>
</tr>
<tr>
<tr class='<?php if($task->mode == 'multi') echo 'hidden'?>'>
<th><?php echo (!empty($task->team) and $task->mode == 'linear') ? $lang->task->transferTo : $lang->task->assign;?></th>
<td>
<?php
+1 -1
View File
@@ -43,7 +43,7 @@
</div>
<form method='post' target='hiddenwin' <?php if($app->rawMethod == 'start') echo "onsubmit='return checkLeft();'"?>>
<table class='table table-form'>
<tr>
<tr class='<?php if($task->mode == 'multi') echo 'hidden'?>'>
<th class='w-90px'><?php echo $lang->task->assignedTo;?></th>
<td class='w-p25-f'>
<?php
+16 -2
View File
@@ -13,6 +13,9 @@ if($task->mode == 'linear' and strpos('|closed|cancel|pause|', $task->status) !=
$memberDisabled = true;
$sortDisabled = true;
}
$hourDisabled = $memberDisabled;
if($task->mode == 'multi' and $app->rawMethod == 'activate') $hourDisabled = false;
?>
<tr class='member-<?php echo $memberStatus;?>' data-estimate='<?php echo (float)$member->estimate?>' data-consumed='<?php echo (float)$member->consumed?>' data-left='<?php echo (float)$member->left?>'>
<td class='w-250px'>
@@ -23,16 +26,18 @@ if($task->mode == 'linear' and strpos('|closed|cancel|pause|', $task->status) !=
<td>
<div class='input-group'>
<span class="input-group-addon <?php echo zget($requiredFields, 'estimate', '', ' required');?>"><?php echo $lang->task->estimate?></span>
<?php echo html::input("teamEstimate[]", (float)$member->estimate, "class='form-control text-center' placeholder='{$lang->task->hour}'" . ($memberDisabled ? ' readonly' : ''))?>
<?php echo html::input("teamEstimate[]", (float)$member->estimate, "class='form-control text-center' placeholder='{$lang->task->hour}'" . ($hourDisabled ? ' 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}'" . ($memberDisabled ? ' readonly' : ''))?>
<?php echo html::input("teamLeft[]", (float)$member->left, "class='form-control text-center' placeholder='{$lang->task->hour}'" . ($hourDisabled ? ' readonly' : ''))?>
</div>
</td>
<td class='w-130px sort-handler'>
<button type="button" <?php echo $memberDisabled ? 'disabled' : '';?> class="btn btn-link btn-sm btn-icon btn-add"><i class="icon icon-plus"></i></button>
<?php if(isset($task->mode) and $task->mode == 'linear'):?>
<button type="button" <?php echo $sortDisabled ? 'disabled' : '';?> class='btn btn-link btn-sm btn-icon btn-move'><i class='icon-move'></i></button>
<?php endif;?>
<button type="button" <?php echo $memberDisabled ? 'disabled' : '';?> class="btn btn-link btn-sm btn-icon btn-delete"><i class="icon icon-close"></i></button>
</td>
</tr>
@@ -62,7 +67,9 @@ if($task->mode == 'linear' and strpos('|closed|cancel|pause|', $task->status) !=
</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>
<?php if(empty($task->mode) or $task->mode == 'linear'):?>
<button type='button' class='btn btn-link btn-sm btn-icon btn-move'><i class='icon-move'></i></button>
<?php endif;?>
<button type="button" class="btn btn-link btn-sm btn-icon btn-delete"><i class="icon icon-close"></i></button>
</td>
</tr>
@@ -78,6 +85,10 @@ if($task->mode == 'linear' and strpos('|closed|cancel|pause|', $task->status) !=
<script>
$(document).ready(function()
{
<?php if(isset($task->mode) and $task->mode == 'multi'):?>
$('tr.teamTemplate').closest('tbody.sortable').sortable('destroy');
<?php endif;?>
/* Init task team manage dialog */
var $taskTeamEditor = $('tr.teamTemplate').closest('table').batchActionForm(
{
@@ -159,11 +170,14 @@ $(document).ready(function()
return false;
}
<?php if($app->rawMethod == 'edit'):?>
if(totalLeft == 0 && (taskStatus == 'doing' || taskStatus == 'pause'))
{
bootbox.alert(totalLeftError);
return false;
}
<?php endif;?>
return true;
}