From c36eb40b06deee8c671eb1871ec4c939cbcdb98b Mon Sep 17 00:00:00 2001 From: fujia Date: Fri, 16 Jul 2010 09:02:20 +0000 Subject: [PATCH] + complete task #269:add start,complete and cancel to task. --- trunk/module/task/config.php | 6 +- trunk/module/task/control.php | 90 ++++++++++++++++++++++++ trunk/module/task/lang/zh-cn.php | 4 ++ trunk/module/task/model.php | 24 ++++++- trunk/module/task/view/cancel.html.php | 55 +++++++++++++++ trunk/module/task/view/complete.html.php | 57 +++++++++++++++ trunk/module/task/view/start.html.php | 59 ++++++++++++++++ trunk/module/task/view/view.html.php | 6 ++ 8 files changed, 298 insertions(+), 3 deletions(-) create mode 100644 trunk/module/task/view/cancel.html.php create mode 100644 trunk/module/task/view/complete.html.php create mode 100644 trunk/module/task/view/start.html.php diff --git a/trunk/module/task/config.php b/trunk/module/task/config.php index a124bdc330..204eb292e9 100644 --- a/trunk/module/task/config.php +++ b/trunk/module/task/config.php @@ -1,3 +1,5 @@ task->create->requiredFields = 'name,estimate,type,pri'; -$config->task->edit->requiredFields = $config->task->create->requiredFields; +$config->task->create->requiredFields = 'name,estimate,type,pri'; +$config->task->edit->requiredFields = $config->task->create->requiredFields; +$config->task->start->requiredFields = 'estimate'; +$config->task->complete->requiredFields = $config->task->start->requiredFields; diff --git a/trunk/module/task/control.php b/trunk/module/task/control.php index 6ce5aaeddc..bddb81a993 100644 --- a/trunk/module/task/control.php +++ b/trunk/module/task/control.php @@ -199,6 +199,96 @@ class task extends control die(js::reload('parent')); } + /* 开始一个任务。*/ + public function start($taskID) + { + /* 执行公共的操作。*/ + $this->commonAction($taskID); + + if(!empty($_POST)) + { + $this->loadModel('action'); + $changes = $this->task->changeStatus($taskID); + if(dao::isError()) die(js::error(dao::getError())); + + if($this->post->comment != '' or !empty($changes)) + { + $action = !empty($changes) ? 'Edited' : 'Commented'; + $actionID = $this->action->create('task', $taskID, $action, $this->post->comment); + $this->action->logHistory($actionID, $changes); + $this->sendmail($taskID, $actionID); + } + die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + } + + /* 赋值。*/ + $this->view->header->title = $this->view->project->name . $this->lang->colon .$this->lang->task->start; + $this->view->position[] = $this->lang->task->start; + $this->view->members = $this->loadModel('user')->setDeleted($this->view->members, $this->view->task->owner); + + $this->display(); + } + + /* 完成一个任务。*/ + public function complete($taskID) + { + /* 执行公共的操作。*/ + $this->commonAction($taskID); + + if(!empty($_POST)) + { + $this->loadModel('action'); + $changes = $this->task->changeStatus($taskID); + if(dao::isError()) die(js::error(dao::getError())); + + if($this->post->comment != '' or !empty($changes)) + { + $action = !empty($changes) ? 'Edited' : 'Commented'; + $actionID = $this->action->create('task', $taskID, $action, $this->post->comment); + $this->action->logHistory($actionID, $changes); + $this->sendmail($taskID, $actionID); + } + die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + } + + /* 赋值。*/ + $this->view->header->title = $this->view->project->name . $this->lang->colon .$this->lang->task->complete; + $this->view->position[] = $this->lang->task->complete; + $this->view->members = $this->loadModel('user')->setDeleted($this->view->members, $this->view->task->owner); + + $this->display(); + } + + /* 取消一个任务。*/ + public function cancel($taskID) + { + /* 执行公共的操作。*/ + $this->commonAction($taskID); + + if(!empty($_POST)) + { + $this->loadModel('action'); + $changes = $this->task->changeStatus($taskID); + if(dao::isError()) die(js::error(dao::getError())); + + if($this->post->comment != '' or !empty($changes)) + { + $action = !empty($changes) ? 'Edited' : 'Commented'; + $actionID = $this->action->create('task', $taskID, $action, $this->post->comment); + $this->action->logHistory($actionID, $changes); + $this->sendmail($taskID, $actionID); + } + die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + } + + /* 赋值。*/ + $this->view->header->title = $this->view->project->name . $this->lang->colon .$this->lang->task->cancel; + $this->view->position[] = $this->lang->task->cancel; + $this->view->members = $this->loadModel('user')->setDeleted($this->view->members, $this->view->task->owner); + + $this->display(); + } + /* 删除一个任务。*/ public function delete($projectID, $taskID, $confirm = 'no') { diff --git a/trunk/module/task/lang/zh-cn.php b/trunk/module/task/lang/zh-cn.php index 05045e7291..78652099d6 100644 --- a/trunk/module/task/lang/zh-cn.php +++ b/trunk/module/task/lang/zh-cn.php @@ -28,6 +28,8 @@ $lang->task->edit = "更新任务"; $lang->task->delete = "删除任务"; $lang->task->view = "查看任务"; $lang->task->logEfforts= "记录工时"; +$lang->task->start = "开始任务"; +$lang->task->complete = "完成任务"; $lang->task->close = "关闭任务"; $lang->task->cancel = "取消任务"; $lang->task->activate = "激活任务"; @@ -87,6 +89,8 @@ $lang->task->buttonActivate = '激活'; $lang->task->buttonLogEfforts = '记录工时'; $lang->task->buttonDelete = '删除'; $lang->task->buttonBackToList = '返回'; +$lang->task->buttonStart = '开始'; +$lang->task->buttonDone = '完成'; $lang->task->legendBasic = '基本信息'; $lang->task->legendEffort = '工时信息'; diff --git a/trunk/module/task/model.php b/trunk/module/task/model.php index 4fa0ec7148..de8f183cd8 100644 --- a/trunk/module/task/model.php +++ b/trunk/module/task/model.php @@ -67,7 +67,7 @@ class taskModel extends model public function update($taskID) { $oldTask = $this->getById($taskID); - $task = fixer::input('post') + $task = fixer::input('post') ->striptags('name') ->specialChars('desc') ->setDefault('story, estimate, left, consumed', 0) @@ -91,6 +91,28 @@ class taskModel extends model if(!dao::isError()) return common::createChanges($oldTask, $task); } + /* 改变一个任务的状态。*/ + public function changeStatus($taskID) + { + $oldTask = $this->getById($taskID); + $task = fixer::input('post') + ->setDefault('estimate, left, consumed', 0) + ->setIF($this->post->consumed > 0 and $this->post->left > 0 and $this->post->status == 'wait', 'status', 'doing') + ->remove('comment') + ->get(); + + $this->dao->update(TABLE_TASK)->data($task) + ->autoCheck() + ->batchCheckIF($task->status != 'cancel', $this->config->task->start->requiredFields, 'notempty') + ->checkIF($task->estimate != false, 'estimate', 'float') + ->checkIF($task->left != false, 'left', 'float') + ->checkIF($task->consumed != false, 'consumed', 'float') + ->checkIF($task->status == 'done', 'consumed', 'notempty') + ->checkIF($task->left == 0 and $task->status != 'cancel', 'status', 'equal', 'done') + ->where('id')->eq((int)$taskID)->exec(); + if(!dao::isError()) return common::createChanges($oldTask, $task); + } + /* 通过id获取一个任务信息。*/ public function getById($taskID) { diff --git a/trunk/module/task/view/cancel.html.php b/trunk/module/task/view/cancel.html.php new file mode 100644 index 0000000000..bcf3792d7e --- /dev/null +++ b/trunk/module/task/view/cancel.html.php @@ -0,0 +1,55 @@ +. + * + * @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com) + * @author Jia Fu + * @package task + * @version $Id: cancel.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $ + * @link http://www.zentaoms.com + */ +?> + +
+
+ + + + + + + + + + + + + + + + + +
name;?>
task->estimate;?>estimate;?>
task->consumed;?>consumed;?>
comment;?>
+ + +
+ +
+ diff --git a/trunk/module/task/view/complete.html.php b/trunk/module/task/view/complete.html.php new file mode 100644 index 0000000000..eec1fa9d8b --- /dev/null +++ b/trunk/module/task/view/complete.html.php @@ -0,0 +1,57 @@ +. + * + * @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com) + * @author Jia Fu + * @package task + * @version $Id: complete.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $ + * @link http://www.zentaoms.com + */ +?> + + +
+ + + + + + + + + + + + + + + + + +
name;?>
task->estimate;?>estimate, "class='text-3'");?>
task->consumed;?>consumed, "class='text-3'");?>
comment;?>
+ + +
+ +
+ + diff --git a/trunk/module/task/view/start.html.php b/trunk/module/task/view/start.html.php new file mode 100644 index 0000000000..bd3fbf3304 --- /dev/null +++ b/trunk/module/task/view/start.html.php @@ -0,0 +1,59 @@ +. + * + * @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com) + * @author Jia Fu + * @package task + * @version $Id: start.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $ + * @link http://www.zentaoms.com + */ +?> + + +
+ + + + + + + + + + + + + + + + + + + + + +
name;?>
task->estimate;?>estimate, "class='text-3'");?>
task->consumed;?>consumed, "class='text-3'");?>
task->left;?>left, "class='text-3'");?>
comment;?>
+ + +
+ +
+ diff --git a/trunk/module/task/view/view.html.php b/trunk/module/task/view/view.html.php index 3549d60519..9657cffcfa 100644 --- a/trunk/module/task/view/view.html.php +++ b/trunk/module/task/view/view.html.php @@ -37,6 +37,9 @@ if(!$task->deleted) { if(!common::printLink('task', 'edit', "taskID=$task->id", $lang->task->buttonEdit)) echo $lang->task->buttonEdit . ' '; + if(!($task->status == 'wait' and common::printLink('task', 'start', "taskID=$task->id", $lang->task->buttonStart))) echo $lang->task->buttonStart . ' '; + if(!(($task->status == 'wait' or $task->status == 'doing') and common::printLink('task', 'complete', "taskID=$task->id", $lang->task->buttonDone))) echo $lang->task->buttonDone . ' '; + if(!(($task->status == 'wait' or $task->status == 'doing') and common::printLink('task', 'cancel', "taskID=$task->id", $lang->task->buttonCancel))) echo $lang->task->buttonCancel . ' '; if(!common::printLink('task', 'delete',"projectID=$task->project&taskID=$task->id", $lang->task->buttonDelete, 'hiddenwin')) echo $lang->task->buttonDelete . ' '; } echo html::a($browseLink, $lang->goback); @@ -66,6 +69,9 @@ if(!$task->deleted) { if(!common::printLink('task', 'edit', "taskID=$task->id", $lang->task->buttonEdit)) echo $lang->task->buttonEdit . ' '; + if(!($task->status == 'wait' and common::printLink('task', 'start', "taskID=$task->id", $lang->task->buttonStart))) echo $lang->task->buttonStart . ' '; + if(!(($task->status == 'wait' or $task->status == 'doing') and common::printLink('task', 'complete', "taskID=$task->id", $lang->task->buttonDone))) echo $lang->task->buttonDone . ' '; + if(!(($task->status == 'wait' or $task->status == 'doing') and common::printLink('task', 'cancel', "taskID=$task->id", $lang->task->buttonCancel))) echo $lang->task->buttonCancel . ' '; if(!common::printLink('task', 'delete',"projectID=$task->project&taskID=$task->id", $lang->task->buttonDelete, 'hiddenwin')) echo $lang->task->buttonDelete . ' '; } echo html::a($browseLink, $lang->goback);