* Merge task estimate to effort.
This commit is contained in:
@@ -439,9 +439,10 @@ class personnelModel extends model
|
||||
$taskIDList = array_merge($taskIDList, $taskID);
|
||||
}
|
||||
|
||||
$userHours = $this->dao->select('account, sum(`left`) as `left`, sum(consumed) as consumed')->from(TABLE_TASKESTIMATE)
|
||||
$userHours = $this->dao->select('account, sum(`left`) as `left`, sum(consumed) as consumed')->from(TABLE_EFFORT)
|
||||
->where('account')->in($accounts)
|
||||
->andWhere('task')->in($taskIDList)
|
||||
->andWhere('objectID')->in($taskIDList)
|
||||
->andWhere('objectType')->eq('task')
|
||||
->groupBy('account')
|
||||
->fetchAll('account');
|
||||
return $userHours;
|
||||
|
||||
@@ -504,9 +504,10 @@ class projectModel extends model
|
||||
{
|
||||
$projects = array();
|
||||
|
||||
$totalConsumeds = $this->dao->select('t2.project,ROUND(SUM(t1.consumed), 1) AS totalConsumed')->from(TABLE_TASKESTIMATE)->alias('t1')
|
||||
->leftJoin(TABLE_TASK)->alias('t2')->on('t1.task=t2.id')
|
||||
$totalConsumeds = $this->dao->select('t2.project,ROUND(SUM(t1.consumed), 1) AS totalConsumed')->from(TABLE_EFFORT)->alias('t1')
|
||||
->leftJoin(TABLE_TASK)->alias('t2')->on('t1.objectID=t2.id')
|
||||
->where('t2.project')->in($projectIdList)
|
||||
->andWhere('t1.objectType')->eq('task')
|
||||
->beginIF($time == 'THIS_YEAR')->andWhere('LEFT(t1.`date`, 4)')->eq(date('Y'))->fi()
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t2.parent')->lt(1)
|
||||
|
||||
@@ -668,7 +668,7 @@ class reportModel extends model
|
||||
*/
|
||||
public function getUserYearEfforts($accounts, $year)
|
||||
{
|
||||
$effort = $this->dao->select('count(*) as count, sum(consumed) as consumed')->from(TABLE_TASKESTIMATE)
|
||||
$effort = $this->dao->select('count(*) as count, sum(consumed) as consumed')->from(TABLE_EFFORT)
|
||||
->where('LEFT(date, 4)')->eq($year)
|
||||
->beginIF($accounts)->andWhere('account')->in($accounts)->fi()
|
||||
->fetch();
|
||||
|
||||
@@ -1213,7 +1213,7 @@ class task extends control
|
||||
$this->view->title = $this->lang->task->editEstimate;
|
||||
$this->view->position[] = $this->lang->task->editEstimate;
|
||||
$this->view->estimate = $estimate;
|
||||
$this->view->task = $this->task->getById($estimate->task);
|
||||
$this->view->task = $this->task->getById($estimate->objectID);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
+49
-39
@@ -486,17 +486,10 @@ class taskModel extends model
|
||||
|
||||
$clonedTaskID = $this->dao->lastInsertID();
|
||||
|
||||
/* Update the table by judging the beginning of the version number. */
|
||||
if($this->config->edition == 'open')
|
||||
{
|
||||
/* ZenTao Pms update TABLE_TASKESTIMATE. */
|
||||
$this->dao->update(TABLE_TASKESTIMATE)->set('task')->eq($clonedTaskID)->where('task')->eq($oldParentTask->id)->exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ZenTao Pro and ZenTao Biz update TABLE_EFFORT. */
|
||||
$this->dao->update(TABLE_EFFORT)->set('objectID')->eq($clonedTaskID)->where('objectID')->eq($oldParentTask->id)->exec();
|
||||
}
|
||||
$this->dao->update(TABLE_EFFORT)->set('objectID')->eq($clonedTaskID)
|
||||
->where('objectID')->eq($oldParentTask->id)
|
||||
->andWhere('objectType')->eq('task')
|
||||
->exec();
|
||||
}
|
||||
|
||||
$this->updateParentStatus($taskID);
|
||||
@@ -1849,7 +1842,7 @@ class taskModel extends model
|
||||
$left = $task->left;
|
||||
$now = helper::now();
|
||||
$oldStatus = $task->status;
|
||||
$lastDate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($taskID)->orderBy('date_desc,id_desc')->limit(1)->fetch('date');
|
||||
$lastDate = $this->dao->select('*')->from(TABLE_EFFORT)->where('objectID')->eq($taskID)->andWhere('objectType')->eq('task')->orderBy('date_desc,id_desc')->limit(1)->fetch('date');
|
||||
|
||||
foreach($estimates as $estimate)
|
||||
{
|
||||
@@ -1952,12 +1945,12 @@ class taskModel extends model
|
||||
*/
|
||||
public function resetEffortLeft($taskID, $members)
|
||||
{
|
||||
$table = $this->config->edition == 'open' ? TABLE_TASKESTIMATE : TABLE_EFFORT;
|
||||
foreach($members as $account)
|
||||
{
|
||||
$this->dao->update($table)->set('`left`')->eq(0)->where('account')->eq($account)
|
||||
->beginIF($this->config->edition == 'open')->andWhere('task')->eq($taskID)->fi()
|
||||
->beginIF($this->config->edition != 'open')->andWhere('objectID')->eq($taskID)->andWhere('objectType')->eq('task')->fi()
|
||||
$this->dao->update(TABLE_EFFORT)->set('`left`')->eq(0)
|
||||
->where('account')->eq($account)
|
||||
->andWhere('objectID')->eq($taskID)
|
||||
->andWhere('objectType')->eq('task')
|
||||
->orderBy('date_desc,id_desc')
|
||||
->limit('1')
|
||||
->exec();
|
||||
@@ -2789,15 +2782,14 @@ class taskModel extends model
|
||||
/**
|
||||
* Update estimate order for linear task team.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @param int $effortID
|
||||
* @param int $order
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updateEstimateOrder($estimateID, $order)
|
||||
public function updateEstimateOrder($effortID, $order)
|
||||
{
|
||||
$table = $this->config->edition == 'open' ? TABLE_TASKESTIMATE : TABLE_EFFORT;
|
||||
$this->dao->update($table)->set('`order`')->eq((int)$order)->where('id')->eq($estimateID)->exec();
|
||||
$this->dao->update(TABLE_EFFORT)->set('`order`')->eq((int)$order)->where('id')->eq($effortID)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2812,15 +2804,6 @@ class taskModel extends model
|
||||
*/
|
||||
public function getTaskEstimate($taskID, $account = '', $append = '', $orderBy = 'date,id')
|
||||
{
|
||||
if($this->config->edition == 'open')
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_TASKESTIMATE)
|
||||
->where('task')->eq($taskID)
|
||||
->beginIF($account)->andWhere('account')->eq($account)->fi()
|
||||
->beginIF($append)->orWhere('id')->eq($append)->fi()
|
||||
->orderBy($orderBy)
|
||||
->fetchAll();
|
||||
}
|
||||
return $this->dao->select('*')->from(TABLE_EFFORT)->where('objectID')->eq($taskID)
|
||||
->andWhere('objectType')->eq('task')
|
||||
->andWhere('deleted')->eq('0')
|
||||
@@ -2833,18 +2816,22 @@ class taskModel extends model
|
||||
/**
|
||||
* Get estimate by id.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @param int $effortID
|
||||
* @access public
|
||||
* @return object.
|
||||
*/
|
||||
public function getEstimateById($estimateID)
|
||||
public function getEstimateById($effortID)
|
||||
{
|
||||
$estimate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)
|
||||
->where('id')->eq($estimateID)
|
||||
$estimate = $this->dao->select('*')->from(TABLE_EFFORT)
|
||||
->where('id')->eq($effortID)
|
||||
->fetch();
|
||||
|
||||
/* If the estimate is the last of its task, status of task will be checked. */
|
||||
$lastID = $this->dao->select('id')->from(TABLE_TASKESTIMATE)->where('task')->eq($estimate->task)->orderBy('date_desc,id_desc')->limit(1)->fetch('id');
|
||||
$lastID = $this->dao->select('id')->from(TABLE_EFFORT)
|
||||
->where('objectID')->eq($estimate->objectID)
|
||||
->andWhere('objectType')->eq('task')
|
||||
->orderBy('date_desc,id_desc')->limit(1)->fetch('id');
|
||||
|
||||
$estimate->isLast = $lastID == $estimate->id;
|
||||
return $estimate;
|
||||
}
|
||||
@@ -2898,14 +2885,17 @@ class taskModel extends model
|
||||
if($estimate->left < 0) return dao::$errors[] = sprintf($this->lang->error->ge, $this->lang->task->left, '0');
|
||||
|
||||
$task = $this->getById($oldEstimate->task);
|
||||
$this->dao->update(TABLE_TASKESTIMATE)->data($estimate)
|
||||
$this->dao->update(TABLE_EFFORT)->data($estimate)
|
||||
->autoCheck()
|
||||
->where('id')->eq((int)$estimateID)
|
||||
->exec();
|
||||
|
||||
$consumed = $task->consumed + $estimate->consumed - $oldEstimate->consumed;
|
||||
$lastEstimate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($task->id)->orderBy('date_desc,id_desc')->limit(1)->fetch();
|
||||
$left = ($lastEstimate and $estimateID == $lastEstimate->id) ? $estimate->left : $task->left;
|
||||
$lastEstimate = $this->dao->select('*')->from(TABLE_EFFORT)
|
||||
->where('objectID')->eq($task->id)
|
||||
->andWhere('objectType')->eq('task')
|
||||
->orderBy('date_desc,id_desc')->limit(1)->fetch();
|
||||
|
||||
$now = helper::now();
|
||||
$data = new stdClass();
|
||||
@@ -2974,7 +2964,10 @@ class taskModel extends model
|
||||
$left = $task->left;
|
||||
if($estimate->isLast)
|
||||
{
|
||||
$lastTwoEstimates = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($estimate->task)->orderBy('date desc,id desc')->limit(2)->fetchAll();
|
||||
$lastTwoEstimates = $this->dao->select('*')->from(TABLE_EFFORT)
|
||||
->where('objectID')->eq($estimate->task)
|
||||
->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;
|
||||
@@ -3041,7 +3034,7 @@ class taskModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
$this->dao->delete()->from(TABLE_TASKESTIMATE)->where('id')->eq($estimateID)->exec();
|
||||
$this->dao->update(TABLE_EFFORT)->set('deleted')->eq('1')->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();
|
||||
@@ -3618,7 +3611,24 @@ class taskModel extends model
|
||||
*/
|
||||
public function addTaskEstimate($data)
|
||||
{
|
||||
$this->dao->insert(TABLE_TASKESTIMATE)->data($data)->autoCheck()->exec();
|
||||
$oldTask = $this->getById($data->task);
|
||||
|
||||
$relation = $this->loadModel('action')->getRelatedFields('task', $data->task);
|
||||
|
||||
$effort = new stdclass();
|
||||
$effort->objectType = 'task';
|
||||
$effort->objectID = $data->task;
|
||||
$effort->execution = $oldTask->execution;
|
||||
$effort->product = $relation['product'];
|
||||
$effort->project = (int)$relation['project'];
|
||||
$effort->account = $data->account;
|
||||
$effort->date = $data->date;
|
||||
$effort->consumed = $data->consumed;
|
||||
$effort->left = $data->left;
|
||||
$effort->work = isset($data->work) ? $data->work : '';
|
||||
$effort->vision = $this->config->vision;
|
||||
$this->dao->insert(TABLE_EFFORT)->data($effort)->autoCheck()->exec();
|
||||
|
||||
return $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ class upgradeModel extends model
|
||||
/* Means open source/pro upgrade to biz or max. */
|
||||
if($this->config->edition != 'open')
|
||||
{
|
||||
if($fromEdition == 'open') $this->loadModel('effort')->convertEstToEffort();
|
||||
if($fromEdition == 'open') $this->convertEstToEffort();
|
||||
if($fromEdition == 'open' or $fromEdition == 'pro')
|
||||
{
|
||||
$this->importBuildinModules();
|
||||
@@ -552,6 +552,7 @@ class upgradeModel extends model
|
||||
case '17_6':
|
||||
$this->updateStoryFile();
|
||||
$this->convertTaskteam();
|
||||
$this->convertEstToEffort();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7264,18 +7265,44 @@ class upgradeModel extends model
|
||||
|
||||
$this->dao->insert(TABLE_TASKTEAM)->data($oldTeam)->exec();
|
||||
|
||||
if($this->config->edition == 'open')
|
||||
{
|
||||
$this->dao->update(TABLE_TASKESTIMATE)->set('`order`')->eq($order)->where('task')->eq($oldTeam->task)->exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->dao->update(TABLE_EFFORT)->set('`order`')->eq($order)->where('objectType')->eq('task')->andWhere('objectID')->eq($oldTeam->task)->exec();
|
||||
}
|
||||
$this->dao->update(TABLE_EFFORT)->set('`order`')->eq($order)->where('objectType')->eq('task')->andWhere('objectID')->eq($oldTeam->task)->exec();
|
||||
$order ++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->dao->delete()->from(TABLE_TEAM)->where('type')->eq('task')->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert estimate to effort.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function convertEstToEffort()
|
||||
{
|
||||
$estimates = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->orderBy('id')->fetchAll();
|
||||
|
||||
$this->loadModel('action');
|
||||
foreach($estimates as $estimate)
|
||||
{
|
||||
$relation = $this->action->getRelatedFields('task', $estimate->task);
|
||||
|
||||
$effort = new stdclass();
|
||||
$effort->objectType = 'task';
|
||||
$effort->objectID = $estimate->task;
|
||||
$effort->product = $relation['product'];
|
||||
$effort->project = (int)$relation['project'];
|
||||
$effort->account = $estimate->account;
|
||||
$effort->work = empty($estimate->work) ? $this->lang->effort->handleTask : $estimate->work;
|
||||
$effort->date = $estimate->date;
|
||||
$effort->left = $estimate->left;
|
||||
$effort->consumed = $estimate->consumed;
|
||||
$effort->vision = $this->config->vision;
|
||||
|
||||
$this->dao->insert(TABLE_EFFORT)->data($effort)->exec();
|
||||
$this->dao->delete()->from(TABLE_TASKESTIMATE)->where('id')->eq($estimate->id)->exec();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-20
@@ -483,26 +483,14 @@ class weeklyModel extends model
|
||||
->andWhere("deleted")->eq(0)
|
||||
->fetchPairs();
|
||||
|
||||
if($this->config->edition != 'open')
|
||||
{
|
||||
$AC = $this->dao->select('sum(consumed) as consumed')
|
||||
->from(TABLE_EFFORT)
|
||||
->where('objectType')->eq('task')
|
||||
->andWhere('objectID')->in($taskIdList)
|
||||
->andWhere('execution')->in($executionIdList)
|
||||
->andWhere('date')->ge($monday)
|
||||
->andWhere('date')->lt($nextMonday)
|
||||
->fetch('consumed');
|
||||
}
|
||||
else
|
||||
{
|
||||
$AC = $this->dao->select('sum(consumed) as consumed')
|
||||
->from(TABLE_TASKESTIMATE)
|
||||
->where('task')->in($taskIdList)
|
||||
->andWhere('date')->ge($monday)
|
||||
->andWhere('date')->lt($nextMonday)
|
||||
->fetch('consumed');
|
||||
}
|
||||
$AC = $this->dao->select('sum(consumed) as consumed')
|
||||
->from(TABLE_EFFORT)
|
||||
->where('objectType')->eq('task')
|
||||
->andWhere('objectID')->in($taskIdList)
|
||||
->andWhere('execution')->in($executionIdList)
|
||||
->andWhere('date')->ge($monday)
|
||||
->andWhere('date')->lt($nextMonday)
|
||||
->fetch('consumed');
|
||||
|
||||
if(is_null($AC)) $AC = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user