diff --git a/module/task/control.php b/module/task/control.php index c97890ac3f..58c30f95ff 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -778,7 +778,7 @@ class task extends control if(!empty($task->team) and $task->mode == 'multi') { - return $this->editTeam($executionID, $task, $kanbanGroup, $from); + return $this->editTeam($executionID, $taskID, $kanbanGroup, $from); } if(!empty($_POST)) @@ -1343,9 +1343,9 @@ class task extends control $task->nextBy = $this->task->getAssignedTo4Multi($members, $task); $task->myConsumed = isset($task->team[$this->app->user->account]) ? $task->team[$this->app->user->account]->consumed : 0; - $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))) + $lastAccount = end($task->members); + $finishedUsers = $this->task->getFinishedUsers($taskID, $task->members); + if(($lastAccount != $task->assignedTo and $task->mode == 'linear') or ($task->mode == 'multi' and count($task->members) != count($finishedUsers))) { $members = $this->task->getMemberPairs($task); } @@ -2314,15 +2314,15 @@ class task extends control * Update assign of multi task. * * @param int $requestID - * @param object $task + * @param object $taskID * @param string $kanbanGroup * @param string $from * @access public * @return void */ - public function editTeam($executionID, $task, $kanbanGroup = 'default', $from = '') + public function editTeam($executionID, $taskID, $kanbanGroup = 'default', $from = '') { - $taskID = $task->id; + $task = $this->task->getById($taskID); $this->commonAction($taskID); if(!empty($_POST)) @@ -2344,7 +2344,6 @@ class task extends control if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'success')); if(isonlybody()) { - $task = $this->task->getById($taskID); $execution = $this->execution->getByID($task->execution); if(($this->app->tab == 'execution' or ($this->config->vision == 'lite' and $this->app->tab == 'project' and $this->session->kanbanview == 'kanban')) and $execution->type == 'kanban') diff --git a/module/task/js/editteam.js b/module/task/js/editteam.js index fa8c7e5ac5..bc08f7bfbd 100644 --- a/module/task/js/editteam.js +++ b/module/task/js/editteam.js @@ -1,84 +1,18 @@ $(document).ready(function() { - /* show team menu. */ - $('[name=multiple]').change(function() + $('#submit').click(function() { - var checked = $(this).prop('checked'); - if(checked) + var memberCount = 0; + $('select[name^=team]').each(function() { - $('#teamTr').removeClass('hidden'); - $('.modeBox').removeClass('hidden'); - $('#mode').removeAttr('disabled').trigger('chosen:updated'); - $('#parent').val(''); - $('#parent').trigger('chosen:updated'); - $('#parent').closest('tr').addClass('hidden'); - $('#estimate').attr('disabled', 'disabled'); - $('#left').attr('disabled', 'disabled'); - - var mode = $('#mode').val(); - if((mode == 'linear' && currentUser != oldAssignedTo) || !team[currentUser]) $('[name=assignedTo]').attr('disabled', 'disabled').trigger('chosen:updated'); - } - else - { - $('#teamTr').addClass('hidden'); - $('.modeBox').addClass('hidden'); - $('#mode').attr('disabled', 'disabled').trigger('chosen:updated'); - $('#parent').closest('tr').removeClass('hidden'); - $('#estimate').removeAttr('disabled'); - $('#left').removeAttr('disabled'); - $('[name=assignedTo]').removeAttr('disabled').trigger('chosen:updated'); - } - }); -}); - -$('#confirmButton').click(function() -{ - /* Unique team. */ - $('select[name^=team]').each(function(i) - { - value = $(this).val(); - if(value == '') return; - $('select[name^=team]').each(function(j) - { - if(i <= j) return; - if(value == $(this).val()) $(this).closest('tr').addClass('hidden'); + if($(this).find('option:selected').text() == '') return; + memberCount++; }) + + if(memberCount < 2) + { + alert(teamMemberError); + return false; + } }); - - $('select[name^=team]').closest('tr.hidden').remove(); - - var memberCount = ''; - var totalEstimate = 0; - var totalConsumed = oldConsumed; - var totalLeft = 0; - $('select[name^=team]').each(function() - { - if($(this).find('option:selected').text() == '') return; - - memberCount++; - - estimate = parseFloat($(this).parents('td').next('td').find('[name^=teamEstimate]').val()); - if(!isNaN(estimate)) totalEstimate += estimate; - - consumed = parseFloat($(this).parents('td').next('td').find('[name^=teamConsumed]').val()); - if(!isNaN(consumed)) totalConsumed += consumed; - - left = parseFloat($(this).parents('td').next('td').find('[name^=teamLeft]').val()); - if(!isNaN(left)) totalLeft += left; - }) - $('#estimate').val(totalEstimate); - $('#consumedSpan').html(totalConsumed); - $('#left').val(totalLeft); - - if(memberCount < 2) - { - alert(teamMemberError); - return false; - } - if(totalLeft == 0 && (taskStatus == 'doing' || taskStatus == 'pause')) - { - alert(totalLeftError); - return false; - } - $('.close').click(); }); diff --git a/module/task/lang/de.php b/module/task/lang/de.php index f13c0a871a..11a3f5bdc2 100644 --- a/module/task/lang/de.php +++ b/module/task/lang/de.php @@ -54,6 +54,7 @@ $lang->task->progressTips = 'Genutzt/(Genutzt+Rest)'; $lang->task->copy = 'Aufgabe kopieren'; $lang->task->waitTask = 'Waiting Task'; $lang->task->allModule = 'All Module'; +$lang->task->replace = 'Replace'; $lang->task->common = 'Aufgabe'; $lang->task->id = 'ID'; diff --git a/module/task/lang/en.php b/module/task/lang/en.php index 3e336ba269..4e6744a092 100755 --- a/module/task/lang/en.php +++ b/module/task/lang/en.php @@ -54,6 +54,7 @@ $lang->task->progressTips = 'Cost/(Cost+Left)'; $lang->task->copy = 'Copy Task'; $lang->task->waitTask = 'Waiting Task'; $lang->task->allModule = 'All Module'; +$lang->task->replace = 'Replace'; $lang->task->common = 'Task'; $lang->task->id = 'ID'; diff --git a/module/task/lang/fr.php b/module/task/lang/fr.php index 91dd8615aa..c4607d4ab8 100644 --- a/module/task/lang/fr.php +++ b/module/task/lang/fr.php @@ -54,6 +54,7 @@ $lang->task->progressTips = 'Coût/(Coût+Reste)'; $lang->task->copy = 'Copier Tâche'; $lang->task->waitTask = 'Tâche en attente'; $lang->task->allModule = 'Tous Modules'; +$lang->task->replace = 'Replace'; $lang->task->common = 'Tâche'; $lang->task->id = 'ID'; diff --git a/module/task/lang/vi.php b/module/task/lang/vi.php index 488a1fccea..6f95ef4be4 100644 --- a/module/task/lang/vi.php +++ b/module/task/lang/vi.php @@ -52,6 +52,7 @@ $lang->task->progressTips = 'Đã làm/(Đã làm + Còn lại)'; $lang->task->copy = 'Copy nhiệm vụ'; $lang->task->waitTask = 'Đang đợi nhiệm vụ'; $lang->task->allModule = 'Tất cả Module'; +$lang->task->replace = 'Replace'; $lang->task->common = 'Nhiệm vụ'; $lang->task->id = 'ID'; diff --git a/module/task/lang/zh-cn.php b/module/task/lang/zh-cn.php index 1cf5f78984..1e5b535d6f 100755 --- a/module/task/lang/zh-cn.php +++ b/module/task/lang/zh-cn.php @@ -54,6 +54,7 @@ $lang->task->progressTips = '已消耗/(已消耗+剩余)'; $lang->task->copy = '复制任务'; $lang->task->waitTask = '未开始的任务'; $lang->task->allModule = '所有模块'; +$lang->task->replace = '替换'; $lang->task->common = '任务'; $lang->task->id = '编号'; diff --git a/module/task/model.php b/module/task/model.php index 0e8e79fdc4..150d680fec 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -1591,10 +1591,15 @@ 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) + foreach($this->post->team as $i => $account) { - dao::$errors[] = $this->lang->task->error->recordMinus; - return false; + if(!$account) continue; + + if($this->post->teamConsumed[$i] == 0 and $this->post->teamLeft[$i] == 0) + { + dao::$errors[] = $this->lang->task->noticeTaskStart; + return false; + } } $now = helper::now(); @@ -3695,8 +3700,7 @@ class taskModel extends model $assignedToTitle = implode($this->lang->comma, $teamMembers); } - - if(empty($task->assignedTo)) + elseif(empty($task->assignedTo)) { $btnTextClass = 'text-primary'; $assignedToText = $this->lang->task->noAssigned; diff --git a/module/task/view/editteam.html.php b/module/task/view/editteam.html.php index b8d4bb8f17..c42ae0753b 100755 --- a/module/task/view/editteam.html.php +++ b/module/task/view/editteam.html.php @@ -37,7 +37,7 @@ -
+ execution&taskID=$task->id")?>' id='teamForm'> @@ -47,6 +47,7 @@ estimate, "class='form-control' {$disabled}");?> + status);?> - +
account)?> + account);?> + transfer) echo "({$lang->task->replace})";?> + estimate?> consumed?> left?>