diff --git a/module/action/model.php b/module/action/model.php index 1907cb753d..52b1243bc6 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -325,6 +325,22 @@ class actionModel extends model } } } + elseif($actionName == 'finished' and $objectType == 'todo') + { + $action->appendLink = ''; + if(strpos($action->extra, ':')!== false) + { + list($extra, $id) = explode(':', $action->extra); + $action->extra = strtolower($extra); + if($id) + { + $table = $this->config->objectTables[$action->extra]; + $field = $this->config->action->objectNameFields[$action->extra]; + $name = $this->dao->select($field)->from($table)->where('id')->eq($id)->fetch($field); + if($name) $action->appendLink = html::a(helper::createLink($action->extra, 'view', "id=$id"), "#$id " . $name); + } + } + } $action->history = isset($histories[$actionID]) ? $histories[$actionID] : array(); $actionName = strtolower($action->action); diff --git a/module/bug/control.php b/module/bug/control.php index 0912d2d749..085655bdec 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -247,6 +247,14 @@ class bug extends control $actionID = $this->action->create('bug', $bugID, 'Opened'); $this->bug->sendmail($bugID, $actionID); + $extras = str_replace(array(',', ' '), array('&', ''), $extras); + parse_str($extras, $output); + if(isset($output['todoID'])) + { + $this->dao->update(TABLE_TODO)->set('status')->eq('done')->where('id')->eq($output['todoID'])->exec(); + $this->action->create('todo', $output['todoID'], 'finished', '', "BUG:$bugID"); + } + $location = $this->createLink('bug', 'browse', "productID={$this->post->product}&branch=$branch&type=byModule¶m={$this->post->module}"); $response['locate'] = isset($_SESSION['bugList']) ? $this->session->bugList : $location; $this->send($response); @@ -304,6 +312,13 @@ class bug extends control $deadline = $bug->deadline; $color = $bug->color; } + if(isset($todoID)) + { + $todo = $this->loadModel('todo')->getById($todoID); + $title = $todo->name; + $steps = $todo->desc; + $pri = $todo->pri; + } /* If projectID is setted, get builds and stories of this project. */ if($projectID) diff --git a/module/story/control.php b/module/story/control.php index b78433997c..f3ae1cb61a 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -37,10 +37,11 @@ class story extends control * @param int $projectID * @param int $bugID * @param int $planID + * @param int $todoID * @access public * @return void */ - public function create($productID = 0, $branch = 0, $moduleID = 0, $storyID = 0, $projectID = 0, $bugID = 0, $planID = 0) + public function create($productID = 0, $branch = 0, $moduleID = 0, $storyID = 0, $projectID = 0, $bugID = 0, $planID = 0, $todoID = 0) { if(!empty($_POST)) { @@ -75,6 +76,12 @@ class story extends control $actionID = $this->action->create('story', $storyID, $action, '', $extra); $this->story->sendmail($storyID, $actionID); + if($todoID > 0) + { + $this->dao->update(TABLE_TODO)->set('status')->eq('done')->where('id')->eq($todoID)->exec(); + $this->action->create('todo', $todoID, 'finished', '', "STORY:$storyID"); + } + if($this->post->newStory) { $response['message'] = $this->lang->story->successSaved . $this->lang->story->newStory; @@ -156,6 +163,15 @@ class story extends control } } + if($todoID > 0) + { + $todo = $this->loadModel('todo')->getById($todoID); + $source = 'todo'; + $title = $todo->name; + $spec = $todo->desc; + $pri = $todo->pri; + } + /* Set Custom*/ foreach(explode(',', $this->config->story->list->customCreateFields) as $field) $customFields[$field] = $this->lang->story->$field; $this->view->customFields = $customFields; diff --git a/module/task/control.php b/module/task/control.php index a619af168a..5532939675 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -39,10 +39,11 @@ class task extends control * @param int $storyID * @param int $moduleID * @param int $taskID + * @param int $todoID * @access public * @return void */ - public function create($projectID = 0, $storyID = 0, $moduleID = 0, $taskID = 0) + public function create($projectID = 0, $storyID = 0, $moduleID = 0, $taskID = 0, $todoID = 0) { $task = new stdClass(); $task->module = $moduleID; @@ -63,6 +64,14 @@ class task extends control $projectID = $task->project; } + if($todoID > 0) + { + $todo = $this->loadModel('todo')->getById($todoID); + $task->name = $todo->name; + $task->pri = $todo->pri; + $task->desc = $todo->desc; + } + $project = $this->project->getById($projectID); $taskLink = $this->createLink('project', 'browse', "projectID=$projectID&tab=task"); $storyLink = $this->session->storyList ? $this->session->storyList : $this->createLink('project', 'story', "projectID=$projectID"); @@ -115,6 +124,12 @@ class task extends control $this->send($response); } + if($todoID > 0) + { + $this->dao->update(TABLE_TODO)->set('status')->eq('done')->where('id')->eq($todoID)->exec(); + $this->action->create('todo', $todoID, 'finished', '', "TASK:$taskID"); + } + /* Locate the browser. */ if($this->post->after == 'continueAdding') { diff --git a/module/todo/control.php b/module/todo/control.php index 580db82dec..8ed528c181 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -279,6 +279,7 @@ class todo extends control $this->view->users = $this->user->getPairs('noletter'); $this->view->actions = $this->loadModel('action')->getList('todo', $todoID); $this->view->from = $from; + $this->view->projects = $this->loadModel('project')->getPairs(); $this->display(); } diff --git a/module/todo/js/view.js b/module/todo/js/view.js index e69de29bb2..c60317fea0 100644 --- a/module/todo/js/view.js +++ b/module/todo/js/view.js @@ -0,0 +1,9 @@ +$(function() +{ + $('#toTaskButton').click(function() + { + var projectID = $(this).closest('.input-group').find('#project').val(); + var link = createLink('task', 'create', 'projectID=' + projectID + '&storyID=0&moduleID=0&taskID=0&todoID=' + todoID); + parent.location.href = link; + }) +}); diff --git a/module/todo/lang/en.php b/module/todo/lang/en.php index a15c2185eb..a8bac3c891 100644 --- a/module/todo/lang/en.php +++ b/module/todo/lang/en.php @@ -24,6 +24,11 @@ $lang->todo->import2Today = "Import to Today"; $lang->todo->import = "Import"; $lang->todo->legendBasic = "Basic Info"; +$lang->todo->reasonList['story'] = "Transfer Story"; +$lang->todo->reasonList['task'] = "Transfer Task"; +$lang->todo->reasonList['bug'] = "Transfer Bug"; +$lang->todo->reasonList['done'] = "Done"; + $lang->todo->id = 'ID'; $lang->todo->account = 'Owner'; $lang->todo->date = 'Date'; @@ -83,5 +88,5 @@ $lang->todo->periods['before'] = 'Undone'; $lang->todo->periods['all'] = 'All'; $lang->todo->action = new stdclass(); -$lang->todo->action->finished = array('main' => '$date, is finished by $actor.'); +$lang->todo->action->finished = array('main' => '$date, is $extra by $actor.', 'extra' => 'reasonList'); $lang->todo->action->marked = array('main' => '$date, is marked by $actor as $extra.', 'extra' => 'statusList'); diff --git a/module/todo/lang/zh-cn.php b/module/todo/lang/zh-cn.php index d28c4187f1..793b25e2c9 100644 --- a/module/todo/lang/zh-cn.php +++ b/module/todo/lang/zh-cn.php @@ -24,6 +24,11 @@ $lang->todo->import2Today = "导入到今天"; $lang->todo->import = "导入"; $lang->todo->legendBasic = "基本信息"; +$lang->todo->reasonList['story'] = "转需求"; +$lang->todo->reasonList['task'] = "转任务"; +$lang->todo->reasonList['bug'] = "转Bug"; +$lang->todo->reasonList['done'] = "完成"; + $lang->todo->id = '编号'; $lang->todo->account = '所有者'; $lang->todo->date = '日期'; @@ -83,5 +88,5 @@ $lang->todo->periods['before'] = '未完'; $lang->todo->periods['all'] = '所有'; $lang->todo->action = new stdclass(); -$lang->todo->action->finished = array('main' => '$date, 由 $actor完成'); +$lang->todo->action->finished = array('main' => '$date, 由 $actor $extra。$appendLink', 'extra' => 'reasonList'); $lang->todo->action->marked = array('main' => '$date, 由 $actor 标记为$extra。', 'extra' => 'statusList'); diff --git a/module/todo/view/view.html.php b/module/todo/view/view.html.php index 5a9138e896..e562341050 100644 --- a/module/todo/view/view.html.php +++ b/module/todo/view/view.html.php @@ -84,7 +84,28 @@ $browseLink = $this->createLink('user', 'todo', "account=$todo->account"); } - common::printIcon('todo', 'finish', "id=$todo->id", $todo, 'button', '', 'hiddenwin', 'showinonlybody btn-success'); + if($todo->status != 'done') + { + echo "
"; + echo html::a($this->createLink('todo', 'finish', "id=$todo->id", 'html', true), " " . $lang->todo->finish, 'hiddenwin', "class='btn showinonlybody btn-success'"); + $createStoryPriv = common::hasPriv('story', 'create'); + $createTaskPriv = common::hasPriv('task', 'create'); + $createBugPriv = common::hasPriv('bug', 'create'); + if($createStoryPriv or $createTaskPriv or $createBugPriv) + { + $isonlybody = isonlybody(); + unset($_GET['onlybody']); + echo ""; + echo ""; + if($isonlybody) $_GET['onlybody'] = 'yes'; + } + echo "
"; + } + if($todo->account == $app->user->account) { common::printIcon('todo', 'edit', "todoID=$todo->id"); @@ -94,6 +115,23 @@ ?> + +id);?> todo->thisIsPrivate;?>