* compute consumed and left when delete estimate.

This commit is contained in:
zhujinyong
2013-02-27 00:58:19 +00:00
parent 7e41cf5888
commit 8cb3cd7965
2 changed files with 5 additions and 1 deletions

View File

@@ -836,6 +836,7 @@ class taskModel extends model
$estimates = $this->dao->select('*')
->from(TABLE_TASKESTIMATE)
->where('task')->eq($taskID)
->orderBy('id')
->fetchAll();
$comments = $this->dao->select('extra, comment')
->from(TABLE_ACTION)
@@ -918,7 +919,10 @@ class taskModel extends model
*/
public function deleteEstimate($estimateID)
{
$estimate = $this->getEstimateById($estimateID);
$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();
$this->dao->update(TABLE_TASK)->set("consumed = consumed - {$estimate->consumed}")->set('`left`')->eq($lastEstimate->left)->where('id')->eq($estimate->task)->exec();
}
/**

View File

@@ -45,7 +45,7 @@
<td><?php echo html::input("dates[$i]", '', "class='text-6 date'");?></td>
<td><?php echo html::input("consumed[$i]", '', "class='text-1'");?></td>
<td><?php echo html::input("left[$i]", '', "class='text-1'");?></td>
<td><?php echo html::textarea("comment[$i]", '', "class='text-1' rows='1'");?></td>
<td class="a-left"><?php echo html::textarea("comment[$i]", '', "class='text-1' rows='1'");?></td>
<td><?php echo '';?></td>
<td align='center'></td>
</tr>