禅道使用
3698
记录工时 的剩余计算已解决 悬赏10积分
提问者落叶终未有
答案数1
阅读数2391
发表时间2016-06-21 17:48:54
public function recordEstimate($taskID)
{
$record = fixer::input('post')->get();
$estimates = array();
$task = $this->getById($taskID);
$oldStatus = $task->status;
foreach(array_keys($record->id) as $id)
{
if($record->dates[$id])
{
if(!$record->consumed[$id]) die(js::alert($this->lang->task->error->consumedThisTime));
if($record->left[$id] === '') die(js::alert($this->lang->task->error->left));
if(strlen($record->work[$id]) > 255) die(js::alert($this->lang->task->error->work));
$estimates[$id] = new stdclass();
$estimates[$id]->date = $record->dates[$id];
$estimates[$id]->task = $taskID;
$estimates[$id]->consumed = $record->consumed[$id];
$estimates[$id]->left = $record->left[$id];
$estimates[$id]->work = $record->work[$id];
$estimates[$id]->account = $this->app->user->account;
}
}
if(empty($estimates)) return;
$consumed = 0;
$left = $task->left;
$now = helper::now();
$this->loadModel('action');
foreach($estimates as $estimate)
{
$consumed += $estimate->consumed;
$left = $estimate->left;
$work = $estimate->work;
$this->addTaskEstimate($estimate);
$estimateID = $this->dao->lastInsertID();
$actionID = $this->action->create('task', $taskID, 'RecordEstimate', $work, $estimate->consumed);
}
$data = new stdClass();
$data->consumed = $task->consumed + $consumed;
$data->left = $left;
$data->status = $task->status;
$data->lastEditedBy = $this->app->user->account;
$data->lastEditedDate = $now;
if($left == 0)
{
$task->status = 'done';
$data->status = $task->status;
$data->assignedTo = $task->openedBy;
$data->assignedDate = $now;
$data->finishedBy = $this->app->user->account;
$data->finishedDate = $now;
}
else if($task->status == 'wait')
{
$task->status = 'doing';
$data->status = $task->status;
$data->assignedTo = $this->app->user->account;
$data->assignedDate = $now;
$data->realStarted = date('Y-m-d');
}
else if($task->status == 'pause')
{
$task->status = 'doing';
$data->status = $task->status;
$data->assignedTo = $this->app->user->account;
$data->assignedDate = $now;
}
$this->dao->update(TABLE_TASK)->data($data)->where('id')->eq($taskID)->exec();
$oldTask = new stdClass();
$newTask = new stdClass();
$oldTask->consumed = $task->consumed;
$newTask->consumed = $task->consumed + $consumed;
$oldTask->left = $task->left;
$newTask->left = $left;
$oldTask->status = $oldStatus;
$newTask->status = $task->status;
$changes = common::createChanges($oldTask, $newTask);
$this->action->logHistory($actionID, $changes);
if($task->story) $this->loadModel('story')->setStage($task->story);
}
{
$record = fixer::input('post')->get();
$estimates = array();
$task = $this->getById($taskID);
$oldStatus = $task->status;
foreach(array_keys($record->id) as $id)
{
if($record->dates[$id])
{
if(!$record->consumed[$id]) die(js::alert($this->lang->task->error->consumedThisTime));
if($record->left[$id] === '') die(js::alert($this->lang->task->error->left));
if(strlen($record->work[$id]) > 255) die(js::alert($this->lang->task->error->work));
$estimates[$id] = new stdclass();
$estimates[$id]->date = $record->dates[$id];
$estimates[$id]->task = $taskID;
$estimates[$id]->consumed = $record->consumed[$id];
$estimates[$id]->left = $record->left[$id];
$estimates[$id]->work = $record->work[$id];
$estimates[$id]->account = $this->app->user->account;
}
}
if(empty($estimates)) return;
$consumed = 0;
$left = $task->left;
$now = helper::now();
$this->loadModel('action');
foreach($estimates as $estimate)
{
$consumed += $estimate->consumed;
$left = $estimate->left;
$work = $estimate->work;
$this->addTaskEstimate($estimate);
$estimateID = $this->dao->lastInsertID();
$actionID = $this->action->create('task', $taskID, 'RecordEstimate', $work, $estimate->consumed);
}
$data = new stdClass();
$data->consumed = $task->consumed + $consumed;
$data->left = $left;
$data->status = $task->status;
$data->lastEditedBy = $this->app->user->account;
$data->lastEditedDate = $now;
if($left == 0)
{
$task->status = 'done';
$data->status = $task->status;
$data->assignedTo = $task->openedBy;
$data->assignedDate = $now;
$data->finishedBy = $this->app->user->account;
$data->finishedDate = $now;
}
else if($task->status == 'wait')
{
$task->status = 'doing';
$data->status = $task->status;
$data->assignedTo = $this->app->user->account;
$data->assignedDate = $now;
$data->realStarted = date('Y-m-d');
}
else if($task->status == 'pause')
{
$task->status = 'doing';
$data->status = $task->status;
$data->assignedTo = $this->app->user->account;
$data->assignedDate = $now;
}
$this->dao->update(TABLE_TASK)->data($data)->where('id')->eq($taskID)->exec();
$oldTask = new stdClass();
$newTask = new stdClass();
$oldTask->consumed = $task->consumed;
$newTask->consumed = $task->consumed + $consumed;
$oldTask->left = $task->left;
$newTask->left = $left;
$oldTask->status = $oldStatus;
$newTask->status = $task->status;
$changes = common::createChanges($oldTask, $newTask);
$this->action->logHistory($actionID, $changes);
if($task->story) $this->loadModel('story')->setStage($task->story);
}
就是我输入日期工时 那个剩余工时会自动的写出来 如果不行 把上面的代码解释一下也行 谢谢了
禅道版本:8.2.1
安装包类型:源码包
操作系统:Windows 7
客户端浏览器:Chrome
答案列表
🍟 警告,不要在重复的提问了。 再有下次,就直接禁帐号了。
回复
|
联系我们
联系人
高丽亚/高级客户经理
电话(微信)
17667930330
QQ号码
3645260865
联系邮箱
gaoliya@chandao.com