+ complete task #269:add start,complete and cancel to task.

This commit is contained in:
fujia
2010-07-16 09:02:20 +00:00
parent 49c78490a9
commit c36eb40b06
8 changed files with 298 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
<?php
$config->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;

View File

@@ -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')
{

View File

@@ -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 = '工时信息';

View File

@@ -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)
{

View File

@@ -0,0 +1,55 @@
<?php
/**
* The cancel file of task module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com)
* @author Jia Fu <fujia@cnezsoft.com>
* @package task
* @version $Id: cancel.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $
* @link http://www.zentaoms.com
*/
?>
<?php include '../../common/view/header.html.php';?>
<form method='post' target='hiddenwin'>
<div class='yui-d0'>
<table class='table-1'>
<caption><?php echo $task->name;?></caption>
<tr>
<td class='rowhead'><?php echo $lang->task->estimate;?></td>
<td><?php echo $task->estimate;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->task->consumed;?></th>
<td><?php echo $task->consumed;?></td>
</tr>
<tr>
<td class='rowhead'><?php echo $lang->comment;?></td>
<td><?php echo html::textarea('comment', '', "rows='6' class='area-1'");?></td>
</tr>
<tr>
<td colspan='2' class='a-center'>
<?php
echo html::submitButton();
echo html::hidden('status', 'cancel');
?>
<input type='button' value='<?php echo $lang->task->buttonBackToList;?>' class='button-s'
onclick='location.href="<?php echo $this->session->taskList;?>"' />
</td>
</tr>
</table>
<?php include '../../common/view/action.html.php';?>
</div>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -0,0 +1,57 @@
<?php
/**
* The complete file of task module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com)
* @author Jia Fu <fujia@cnezsoft.com>
* @package task
* @version $Id: complete.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $
* @link http://www.zentaoms.com
*/
?>
<?php include '../../common/view/header.html.php';?>
<form method='post' target='hiddenwin'>
<div class='yui-d0'>
<table class='table-1'>
<caption><?php echo $task->name;?></caption>
<tr>
<td class='rowhead'><?php echo $lang->task->estimate;?></td>
<td><?php echo html::input('estimate', $task->estimate, "class='text-3'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->task->consumed;?></th>
<td><?php echo html::input('consumed', $task->consumed, "class='text-3'");?></td>
</tr>
<tr>
<td class='rowhead'><?php echo $lang->comment;?></td>
<td><?php echo html::textarea('comment', '', "rows='6' class='area-1'");?></td>
</tr>
<tr>
<td colspan='2' class='a-center'>
<?php
echo html::submitButton();
echo html::hidden('status', 'done');
echo html::hidden('left', 0);
?>
<input type='button' value='<?php echo $lang->task->buttonBackToList;?>' class='button-s'
onclick='location.href="<?php echo $this->session->taskList;?>"' />
</td>
</tr>
</table>
<?php include '../../common/view/action.html.php';?>
</div>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* The start file of task module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com)
* @author Jia Fu <fujia@cnezsoft.com>
* @package task
* @version $Id: start.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $
* @link http://www.zentaoms.com
*/
?>
<?php include '../../common/view/header.html.php';?>
<form method='post' target='hiddenwin'>
<div class='yui-d0'>
<table class='table-1'>
<caption><?php echo $task->name;?></caption>
<tr>
<td class='rowhead'><?php echo $lang->task->estimate;?></td>
<td><?php echo html::input('estimate', $task->estimate, "class='text-3'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->task->consumed;?></th>
<td><?php echo html::input('consumed', $task->consumed, "class='text-3'");?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->task->left;?></th>
<td><?php echo html::input('left', $task->left, "class='text-3'");?></td>
</tr>
<tr>
<td class='rowhead'><?php echo $lang->comment;?></td>
<td><?php echo html::textarea('comment', '', "rows='6' class='area-1'");?></td>
</tr>
<tr>
<td colspan='2' class='a-center'>
<?php
echo html::submitButton();
echo html::hidden('status', 'doing');
?>
<input type='button' value='<?php echo $lang->task->buttonBackToList;?>' class='button-s'
onclick='location.href="<?php echo $this->session->taskList;?>"' />
</td>
</tr>
</table>
<?php include '../../common/view/action.html.php';?>
</div>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -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);