* fix a bug #683.

This commit is contained in:
wangyidong
2015-04-14 13:08:16 +08:00
parent 91d2f6be1f
commit 18d8f179fe
+3 -3
View File
@@ -1033,11 +1033,11 @@ class taskModel extends model
$estimate = $this->getEstimateById($estimateID);
$task = $this->getById($estimate->task);
$this->dao->delete()->from(TABLE_TASKESTIMATE)->where('id')->eq($estimateID)->exec();
$lastEstimate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($estimate->task)->orderBy('id desc')->fetch();
$lastEstimate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($estimate->task)->orderBy('date desc')->fetch();
$consumed = $task->consumed - $estimate->consumed;
$left = $lastEstimate->left;
$left = $lastEstimate ? $lastEstimate->left : 0;
$oldStatus = $task->status;
if($left == 0) $task->status = 'done';
if($left == 0 and $consumed != 0) $task->status = 'done';
$this->dao->update(TABLE_TASK)
->set("consumed")->eq($consumed)
->set('`left`')->eq($left)