禅道升级
3706
如何在后台实现把禅道数据库中的最初预计工时改成24 已解决 悬赏10积分
提问者落叶终未有
答案数1
阅读数2364
发表时间2016-06-23 18:01:43
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();
// if($record->left[$id] === '') die();
// if(strlen($record->work[$id]) > 255) die();
$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();
// if($record->left[$id] === '') die();
// if(strlen($record->work[$id]) > 255) die();
$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.2
安装包类型:源码包
操作系统:Windows 7
客户端浏览器:Chrome
答案列表
石洋洋
2016-06-24 08:41:29
推荐直接到数据库中批量更新,要在后台实现界面功能的话可以自己跟踪一下代码调试代码,直接看代码很难看出哪里有问题的。
回复
|
联系我们
联系人
张淑钧/高级客户经理
电话(微信)
13156280939
QQ号码
2082428410
联系邮箱
zhangshujun@chandao.com