* compute task estimate.
This commit is contained in:
@@ -438,17 +438,66 @@ class task extends control
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$changes = $this->task->record($taskID);
|
||||
$actionID = $this->action->create('task', $taskID, 'Recorded', $this->post->comment, (float)$this->post->consumed);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
$this->task->record($taskID);
|
||||
if(isonlybody()) die(js::reload('parent.parent'));
|
||||
die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->task->record;
|
||||
$this->session->set('estimateList', $this->app->getURI(true));
|
||||
|
||||
$this->view->estimates = $this->task->getTaskEstimate($taskID);
|
||||
$this->view->title = $this->lang->task->record;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit consumed and estimate.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function editEstimate($estimateID)
|
||||
{
|
||||
$estimate = $this->task->getEstimateById($estimateID);
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->task->updateEstimate($estimateID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
$url = $this->session->estimateList ? $this->session->estimateList : inlink('record', "taskID={$estimate->task}");
|
||||
die(js::locate($url, 'parent'));
|
||||
}
|
||||
|
||||
$estimate = $this->task->getEstimateById($estimateID);
|
||||
|
||||
$this->view->title = $this->lang->task->editEstimate;
|
||||
$this->view->position[] = $this->lang->task->editEstimate;
|
||||
$this->view->estimate = $estimate;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete estimate.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @param string $confirm
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteEstimate($estimateID, $confirm = 'no')
|
||||
{
|
||||
if($confirm == 'no')
|
||||
{
|
||||
die(js::confirm($this->lang->task->confirmDeleteEstimate, $this->createLink('task', 'deleteEstimate', "estimateID=$estimateID&confirm=yes")));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->task->deleteEstimate($estimateID);
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish a task.
|
||||
*
|
||||
|
||||
1
module/task/css/common.css
Normal file
1
module/task/css/common.css
Normal file
@@ -0,0 +1 @@
|
||||
.text-6{width:75%;}
|
||||
@@ -51,6 +51,7 @@ $lang->task->beforeConsumed = 'Before consumed';
|
||||
$lang->task->consumedThisTime = 'This time consumed';
|
||||
$lang->task->estStarted = 'Estimate start';
|
||||
$lang->task->realStarted = 'Real start';
|
||||
$lang->task->date = 'Date';
|
||||
$lang->task->deadline = 'Deadline';
|
||||
$lang->task->deadlineAB = 'Deadline';
|
||||
$lang->task->status = 'Status';
|
||||
@@ -77,6 +78,8 @@ $lang->task->closedReason = 'Closed Reason';
|
||||
$lang->task->lastEditedBy = 'Last Edited By';
|
||||
$lang->task->lastEditedDate = 'Last Edited Date';
|
||||
$lang->task->lastEdited = 'Last Edited';
|
||||
$lang->task->editEstimate = 'Edit estimate';
|
||||
$lang->task->deleteEstimate = 'Delete estimate';
|
||||
|
||||
$lang->task->ditto = 'Ditto';
|
||||
|
||||
@@ -127,16 +130,17 @@ $lang->task->legendLife = 'Lifetime';
|
||||
$lang->task->legendDesc = 'Desc';
|
||||
$lang->task->legendAction = 'Action';
|
||||
|
||||
$lang->task->ajaxGetUserTasks = "API:My tasks";
|
||||
$lang->task->ajaxGetProjectTasks = "API:Project tasks";
|
||||
$lang->task->confirmDelete = "Are you sure you want to delete this task?";
|
||||
$lang->task->copyStoryTitle = "Same as story";
|
||||
$lang->task->afterSubmit = "After created";
|
||||
$lang->task->successSaved = "Successfully saved";
|
||||
$lang->task->delayWarning = " <strong class='delayed f-14px'> Postponed %s days </strong>";
|
||||
$lang->task->remindBug = "This task from Bug, update the Bug:%s or not?";
|
||||
$lang->task->confirmChangeProject = 'Change project will change module, story and assignedTo also, are you sure?';
|
||||
$lang->task->confirmFinish = '"Left" is 0, this task will be done. Are you sure?';
|
||||
$lang->task->ajaxGetUserTasks = "API:My tasks";
|
||||
$lang->task->ajaxGetProjectTasks = "API:Project tasks";
|
||||
$lang->task->confirmDelete = "Are you sure you want to delete this task?";
|
||||
$lang->task->confirmDeleteEstimate = "Are you sure you want to delete this estimate?";
|
||||
$lang->task->copyStoryTitle = "Same as story";
|
||||
$lang->task->afterSubmit = "After created";
|
||||
$lang->task->successSaved = "Successfully saved";
|
||||
$lang->task->delayWarning = " <strong class='delayed f-14px'> Postponed %s days </strong>";
|
||||
$lang->task->remindBug = "This task from Bug, update the Bug:%s or not?";
|
||||
$lang->task->confirmChangeProject = 'Change project will change module, story and assignedTo also, are you sure?';
|
||||
$lang->task->confirmFinish = '"Left" is 0, this task will be done. Are you sure?';
|
||||
|
||||
$lang->task->error = new stdclass();
|
||||
$lang->task->error->consumed = '"Consumed" must be number';
|
||||
|
||||
@@ -51,6 +51,7 @@ $lang->task->beforeConsumed = '之前消耗';
|
||||
$lang->task->consumedThisTime = '本次消耗';
|
||||
$lang->task->estStarted = '预计开始';
|
||||
$lang->task->realStarted = '实际开始';
|
||||
$lang->task->date = '日期';
|
||||
$lang->task->deadline = '截止日期';
|
||||
$lang->task->deadlineAB = '截止';
|
||||
$lang->task->status = '任务状态';
|
||||
@@ -77,6 +78,8 @@ $lang->task->closedReason = '关闭原因';
|
||||
$lang->task->lastEditedBy = '最后修改';
|
||||
$lang->task->lastEditedDate = '最后修改日期';
|
||||
$lang->task->lastEdited = '最后编辑';
|
||||
$lang->task->editEstimate = '编辑工时';
|
||||
$lang->task->deleteEstimate = '删除工时';
|
||||
|
||||
$lang->task->ditto = '同上';
|
||||
|
||||
@@ -127,16 +130,17 @@ $lang->task->legendLife = '任务的一生';
|
||||
$lang->task->legendDesc = '任务描述';
|
||||
$lang->task->legendAction = '操作';
|
||||
|
||||
$lang->task->ajaxGetUserTasks = "接口:我的任务";
|
||||
$lang->task->ajaxGetProjectTasks = "接口:项目任务";
|
||||
$lang->task->confirmDelete = "您确定要删除这个任务吗?";
|
||||
$lang->task->copyStoryTitle = "同需求";
|
||||
$lang->task->afterSubmit = "添加之后";
|
||||
$lang->task->successSaved = "成功添加,";
|
||||
$lang->task->delayWarning = " <strong class='delayed f-14px'> 延期%s天 </strong>";
|
||||
$lang->task->remindBug = "该任务为Bug转化得到,是否更新Bug:%s ?";
|
||||
$lang->task->confirmChangeProject = '修改项目会导致相应的所属模块、相关需求和指派人发生变化,确定吗?';
|
||||
$lang->task->confirmFinish = '"预计剩余"为0,确认将任务状态改为"已完成"吗?';
|
||||
$lang->task->ajaxGetUserTasks = "接口:我的任务";
|
||||
$lang->task->ajaxGetProjectTasks = "接口:项目任务";
|
||||
$lang->task->confirmDelete = "您确定要删除这个任务吗?";
|
||||
$lang->task->confirmDeleteEstimate = "您确定要删除这个记录吗?";
|
||||
$lang->task->copyStoryTitle = "同需求";
|
||||
$lang->task->afterSubmit = "添加之后";
|
||||
$lang->task->successSaved = "成功添加,";
|
||||
$lang->task->delayWarning = " <strong class='delayed f-14px'> 延期%s天 </strong>";
|
||||
$lang->task->remindBug = "该任务为Bug转化得到,是否更新Bug:%s ?";
|
||||
$lang->task->confirmChangeProject = '修改项目会导致相应的所属模块、相关需求和指派人发生变化,确定吗?';
|
||||
$lang->task->confirmFinish = '"预计剩余"为0,确认将任务状态改为"已完成"吗?';
|
||||
|
||||
$lang->task->error = new stdclass();
|
||||
$lang->task->error->consumed = '"已经消耗"必须为数字';
|
||||
|
||||
@@ -431,26 +431,42 @@ class taskModel extends model
|
||||
*/
|
||||
public function record($taskID)
|
||||
{
|
||||
$oldTask = $this->getById($taskID);
|
||||
$estimate = fixer::input('post')
|
||||
->setDefault('account', $this->app->user->account)
|
||||
->setDefault('task', $taskID)
|
||||
->setDefault('date', date(DT_DATE1))
|
||||
->cleanFloat('consumed, left')
|
||||
->remove('comment')
|
||||
->get();
|
||||
$this->dao->insert(TABLE_TASKESTIMATE)->data($estimate)
|
||||
->autoCheck()
|
||||
->exec();
|
||||
$record = fixer::input('post')->get();
|
||||
$estimates = array();
|
||||
$task = $this->getById($taskID);
|
||||
foreach(array_keys($record->id) as $id)
|
||||
{
|
||||
if($record->dates[$id])
|
||||
{
|
||||
if(!$record->consumed[$id]) die(js::alert('ii'));
|
||||
$estimates[$id]->date = $record->dates[$id];
|
||||
$estimates[$id]->task = $taskID;
|
||||
$estimates[$id]->consumed = $record->consumed[$id];
|
||||
$estimates[$id]->left = $record->left[$id];
|
||||
$estimates[$id]->comment = $record->comment[$id];
|
||||
}
|
||||
}
|
||||
|
||||
$consumed = 0;
|
||||
$left = 0;
|
||||
foreach($estimates as $estimate)
|
||||
{
|
||||
$consumed += $estimate->consumed;
|
||||
$left = $estimate->left;
|
||||
$comment = $estimate->comment;
|
||||
unset($estimate->comment);
|
||||
$this->dao->insert(TABLE_TASKESTIMATE)->data($estimate)
|
||||
->autoCheck()
|
||||
->exec();
|
||||
$estimateID = $this->dao->lastInsertID();
|
||||
$this->loadModel('action')->create('task', $taskID, 'Recorded', $comment, $estimateID);
|
||||
}
|
||||
|
||||
$consumed = $oldTask->consumed + $estimate->consumed;
|
||||
$this->dao->update(TABLE_TASK)
|
||||
->set('consumed')->eq($consumed)
|
||||
->set('`left`')->eq($estimate->left)
|
||||
->set('consumed')->eq($task->consumed + $consumed)
|
||||
->set('`left`')->eq($left)
|
||||
->where('id')->eq($taskID)
|
||||
->exec();
|
||||
$task = $this->getById($taskID);
|
||||
if(!dao::isError()) return common::createChanges($oldTask, $task);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -808,6 +824,103 @@ class taskModel extends model
|
||||
return $taskCounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task estimate.
|
||||
*
|
||||
* @param int $taskID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getTaskEstimate($taskID)
|
||||
{
|
||||
$estimates = $this->dao->select('*')
|
||||
->from(TABLE_TASKESTIMATE)
|
||||
->where('task')->eq($taskID)
|
||||
->fetchAll();
|
||||
$comments = $this->dao->select('extra, comment')
|
||||
->from(TABLE_ACTION)
|
||||
->where('objectType')->eq('task')
|
||||
->andWhere('objectID')->eq($taskID)
|
||||
->andWhere('action')->eq('recorded')
|
||||
->fetchPairs('extra');
|
||||
foreach($estimates as $estimate)
|
||||
{
|
||||
$estimate->comment = $comments[$estimate->id];
|
||||
}
|
||||
return $estimates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get estimate by id.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @access public
|
||||
* @return object.
|
||||
*/
|
||||
public function getEstimateById($estimateID)
|
||||
{
|
||||
$estimate = $this->dao->select('*')
|
||||
->from(TABLE_TASKESTIMATE)
|
||||
->where('id')->eq($estimateID)
|
||||
->fetch();
|
||||
$comment = $this->dao->select('comment')
|
||||
->from(TABLE_ACTION)
|
||||
->where('objectType')->eq('task')
|
||||
->andWhere('action')->eq('recorded')
|
||||
->andWhere('extra')->eq($estimateID)
|
||||
->orderBy('id desc')
|
||||
->fetch();
|
||||
$estimate->comment = $comment->comment;
|
||||
return $estimate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update estimate.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updateEstimate($estimateID)
|
||||
{
|
||||
$oldEstimate = $this->getEstimateById($estimateID);
|
||||
$estimate = fixer::input('post')->remove('comment')->get();
|
||||
$task = $this->getById($oldEstimate->task);
|
||||
$this->dao->update(TABLE_TASKESTIMATE)->data($estimate)
|
||||
->autoCheck()
|
||||
->check('consumed', 'notempty')
|
||||
->where('id')->eq((int)$estimateID)
|
||||
->exec();
|
||||
$this->loadModel('action')->create('task', $oldEstimate->task, 'Recorded', $this->post->comment, $estimateID);
|
||||
$consumed = $task->estimate + $estimate->consumed - $oldEstimate->consumed;
|
||||
$lastEstimate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($task->id)->orderBy('id desc')->fetch();
|
||||
if($lastEstimate and $estimateID == $lastEstimate->id)
|
||||
{
|
||||
$left = $estimate->left;
|
||||
}
|
||||
else
|
||||
{
|
||||
$left = $task->left;
|
||||
}
|
||||
$this->dao->update(TABLE_TASK)
|
||||
->set('consumed')->eq($consumed)
|
||||
->set('`left`')->eq($left)
|
||||
->where('id')->eq($task->id)
|
||||
->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete estimate.
|
||||
*
|
||||
* @param int $estimateID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteEstimate($estimateID)
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_TASKESTIMATE)->where('id')->eq($estimateID)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch process tasks.
|
||||
*
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<td><?php echo html::input("estimate[$i]", '', 'class=text-1');?></td>
|
||||
<td><?php echo html::input("desc[$i]", '', "class=text-1");?></td>
|
||||
<td><?php echo html::select("pri[$i]", (array)$lang->task->priList, $pri, 'class=select-1');?></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<?php endfor;?>
|
||||
<tr><td colspan='8' class='a-center'><?php echo html::submitButton() . html::resetButton();?></td></tr>
|
||||
</table>
|
||||
|
||||
29
module/task/view/editestimate.html.php
Normal file
29
module/task/view/editestimate.html.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/datepicker.html.php';?>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table class='table-1 a-left'>
|
||||
<caption><?php echo $lang->task->editEstimate;?></caption>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->date;?></th>
|
||||
<td><?php echo html::input('date', $estimate->date, 'class="select-3 date"');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->consumed;?></th>
|
||||
<td><?php echo html::input('consumed', $estimate->consumed, 'class="select-3"');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->left;?></th>
|
||||
<td><?php echo html::input('left', $estimate->left, 'class="select-3"');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->comment;?></th>
|
||||
<td><?php echo html::textarea('comment', $estimate->comment, "class=text-5");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'>
|
||||
<?php echo html::submitButton() . html::resetButton();?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -11,30 +11,48 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/datepicker.html.php';?>
|
||||
<?php js::set('confirmFinish', $lang->task->confirmFinish);?>
|
||||
<form method='post' target='hiddenwin' onsubmit='return checkLeft();'>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table class='table-1'>
|
||||
<caption><?php echo $task->name;?></caption>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->beforeConsumed;?></th>
|
||||
<td><?php echo $task->consumed . ' ' . $lang->task->hour;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->consumedThisTime;?></th>
|
||||
<td><?php echo html::input('consumed', '', "class='text-2'") . $lang->task->hour;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->left;?></th>
|
||||
<td><?php echo html::input('left', '', "class='text-2'") . $lang->task->hour;?></td>
|
||||
<th class="w-id"><?php echo $lang->idAB;?></th>
|
||||
<th class="w-100px"><?php echo $lang->task->date;?></th>
|
||||
<th class="w-60px"><?php echo $lang->task->consumed;?></th>
|
||||
<th class="w-60px"><?php echo $lang->task->left;?></th>
|
||||
<th><?php echo $lang->comment;?></th>
|
||||
<th><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='rowhead'><?php echo $lang->comment;?></td>
|
||||
<td><?php echo html::textarea('comment', '', "rows='6' class='area-1'");?></td>
|
||||
<?php foreach($estimates as $estimate):?>
|
||||
<tr class="a-center">
|
||||
<td><?php echo $estimate->id;?></td>
|
||||
<td><?php echo $estimate->date;?></td>
|
||||
<td><?php echo $estimate->consumed;?></td>
|
||||
<td><?php echo $estimate->left;?></td>
|
||||
<td><?php echo $estimate->comment;?></td>
|
||||
<td align='center'>
|
||||
<?php
|
||||
common::printIcon('task', 'editEstimate', "estimateID=$estimate->id", '', 'list', '', '', '', true);
|
||||
common::printIcon('task', 'deleteEstimate', "estimateID=$estimate->id", '', 'list', '', 'hiddenwin');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?php for($i = 1; $i <= 5; $i++):?>
|
||||
<tr class="a-center">
|
||||
<td><?php echo $i . html::hidden("id[$i]", $i);?></td>
|
||||
<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><?php echo '';?></td>
|
||||
<td align='center'></td>
|
||||
</tr>
|
||||
<?php endfor;?>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'><?php echo html::submitButton(); ?></td>
|
||||
<td colspan='6' class='a-center'><?php echo html::submitButton() . html::resetButton(); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php include '../../common/view/action.html.php';?>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user