* Rename estimate to effort except object properties and column name.
This commit is contained in:
+24
-24
@@ -1785,30 +1785,30 @@ class taskModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete estimate.
|
||||
* 删除工时并更新任务。 Delete the work hour from the task.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @param int $effortID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteWorkhour(int $estimateID)
|
||||
public function deleteWorkhour(int $effortID)
|
||||
{
|
||||
$estimate = $this->getEffortByID($estimateID);
|
||||
$task = $this->getById($estimate->objectID);
|
||||
$now = helper::now();
|
||||
$effort = $this->getEffortByID($effortID);
|
||||
$task = $this->getById($effort->objectID);
|
||||
$now = helper::now();
|
||||
|
||||
/* Compute the left and consumed workhour of the task. */
|
||||
$consumed = $task->consumed - $estimate->consumed;
|
||||
$consumed = $task->consumed - $effort->consumed;
|
||||
$left = $task->left;
|
||||
if($estimate->isLast)
|
||||
if($effort->isLast)
|
||||
{
|
||||
$lastTwoEstimates = $this->dao->select('*')->from(TABLE_EFFORT)
|
||||
->where('objectID')->eq($estimate->objectID)
|
||||
$lastTwoEfforts = $this->dao->select('*')->from(TABLE_EFFORT)
|
||||
->where('objectID')->eq($effort->objectID)
|
||||
->andWhere('objectType')->eq('task')
|
||||
->orderBy('date desc,id desc')->limit(2)->fetchAll();
|
||||
$lastTwoEstimate = isset($lastTwoEstimates[1]) ? $lastTwoEstimates[1] : '';
|
||||
if($lastTwoEstimate) $left = $lastTwoEstimate->left;
|
||||
if(empty($lastTwoEstimate) and $left == 0) $left = $task->estimate;
|
||||
$lastTwoEfforts = isset($lastTwoEfforts[1]) ? $lastTwoEfforts[1] : '';
|
||||
if($lastTwoEfforts) $left = $lastTwoEfforts->left;
|
||||
if(empty($lastTwoEfforts) and $left == 0) $left = $task->estimate;
|
||||
}
|
||||
|
||||
/* Define and prepare one new task object to update the task. */
|
||||
@@ -1816,7 +1816,7 @@ class taskModel extends model
|
||||
$data->consumed = $consumed;
|
||||
$data->left = $left;
|
||||
$data->status = ($left == 0 && $consumed != 0) ? 'done' : $task->status;
|
||||
if($estimate->isLast and $consumed == 0 and $task->status != 'wait')
|
||||
if($effort->isLast and $consumed == 0 and $task->status != 'wait')
|
||||
{
|
||||
$data->status = 'wait';
|
||||
$data->left = $task->estimate;
|
||||
@@ -1829,7 +1829,7 @@ class taskModel extends model
|
||||
$data->closedDate = null;
|
||||
if($task->assignedTo == 'closed') $data->assignedTo = $this->app->user->account;
|
||||
}
|
||||
elseif($estimate->isLast and $left != 0 and strpos('done,pause,cancel,closed', $task->status) !== false)
|
||||
elseif($effort->isLast and $left != 0 and strpos('done,pause,cancel,closed', $task->status) !== false)
|
||||
{
|
||||
$data->status = 'doing';
|
||||
$data->finishedBy = '';
|
||||
@@ -1857,25 +1857,25 @@ class taskModel extends model
|
||||
if(!empty($task->team))
|
||||
{
|
||||
/* 获取要删除的工时的团队,如果要删除的工时的用户不是团队成员则不做任何处理。*/
|
||||
$currentTeam = $this->getTeamByAccount($task->team, $estimate->account, array('effortID' => $estimateID, 'order' => $estimate->order));
|
||||
$currentTeam = $this->getTeamByAccount($task->team, $effort->account, array('effortID' => $effortID, 'order' => $effort->order));
|
||||
if($currentTeam)
|
||||
{
|
||||
$left = $currentTeam->left;
|
||||
if($task->mode == 'multi') /* 如果任务是多人并行任务。注:多人串行任务的mode是linear。*/
|
||||
{
|
||||
/* 获取要删除的工时对应的用户的工时信息列表。*/
|
||||
$accountEstimates = $this->getTaskEfforts($currentTeam->task, $estimate->account, $estimateID);
|
||||
$lastEstimate = array_pop($accountEstimates);
|
||||
if($lastEstimate->id == $estimateID)
|
||||
$accountEfforts = $this->getTaskEfforts($currentTeam->task, $effort->account, $effortID);
|
||||
$lastEffort = array_pop($accountEfforts);
|
||||
if($lastEffort->id == $effortID)
|
||||
{
|
||||
$lastTwoEstimate = array_pop($accountEstimates);
|
||||
if($lastTwoEstimate) $left = $lastTwoEstimate->left;
|
||||
$lastTwoEfforts = array_pop($accountEfforts);
|
||||
if($lastTwoEfforts) $left = $lastTwoEfforts->left;
|
||||
}
|
||||
}
|
||||
|
||||
/* 更新要删除的工时对应的用户的任务信息。*/
|
||||
$newTeamInfo = new stdclass();
|
||||
$newTeamInfo->consumed = $currentTeam->consumed - $estimate->consumed;
|
||||
$newTeamInfo->consumed = $currentTeam->consumed - $effort->consumed;
|
||||
if($currentTeam->status != 'done') $newTeamInfo->left = $left;
|
||||
if($currentTeam->status == 'done' and $left > 0 and $task->mode == 'multi')
|
||||
{
|
||||
@@ -1894,11 +1894,11 @@ class taskModel extends model
|
||||
}
|
||||
|
||||
/* 删除工时;如果任务是多人任务,则重新计算工时。*/
|
||||
$this->dao->update(TABLE_EFFORT)->set('deleted')->eq('1')->where('id')->eq($estimateID)->exec();
|
||||
$this->dao->update(TABLE_EFFORT)->set('deleted')->eq('1')->where('id')->eq($effortID)->exec();
|
||||
if(!empty($task->team)) $data = $this->computeMultipleHours($task, $data);
|
||||
|
||||
/* 更新任务、父任务状态、需求阶段。*/
|
||||
$this->dao->update(TABLE_TASK)->data($data) ->where('id')->eq($estimate->objectID)->exec();
|
||||
$this->dao->update(TABLE_TASK)->data($data) ->where('id')->eq($effort->objectID)->exec();
|
||||
if($task->parent > 0) $this->updateParentStatus($task->id);
|
||||
if($task->story) $this->loadModel('story')->setStage($task->story);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user