+ add the feature of history.
* rewrite model by DAO.
This commit is contained in:
@@ -34,12 +34,15 @@ class task extends control
|
||||
/* 添加任务。*/
|
||||
public function create($projectID = 0, $storyID = 0)
|
||||
{
|
||||
$project = $this->project->getById($projectID);
|
||||
$project = $this->project->findById($projectID);
|
||||
$browseProjectLink = $this->createLink('project', 'browse', "projectID=$projectID&tab=task");
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->task->create($projectID);
|
||||
$taskID = $this->task->create($projectID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
$this->loadModel('action');
|
||||
$this->action->create('task', $taskID, 'Opened', '');
|
||||
die(js::locate($browseProjectLink, 'parent'));
|
||||
}
|
||||
|
||||
@@ -64,14 +67,21 @@ class task extends control
|
||||
/* 编辑任务。*/
|
||||
public function edit($taskID)
|
||||
{
|
||||
$task = $this->task->getById($taskID);
|
||||
$project = $this->project->getById($task->project);
|
||||
$browseProjectLink = $this->createLink('project', 'browse', "projectID=$project->id&tab=task");
|
||||
$task = $this->task->findByID($taskID);
|
||||
$project = $this->project->findByID($task->project);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->task->update($taskID);
|
||||
die(js::locate($browseProjectLink, 'parent'));
|
||||
$this->loadModel('action');
|
||||
$changes = $this->task->update($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);
|
||||
}
|
||||
die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent'));
|
||||
}
|
||||
|
||||
$stories = $this->story->getProjectStoryPair($project->id);
|
||||
@@ -80,7 +90,7 @@ class task extends control
|
||||
$members = array('' => '') + $members;
|
||||
|
||||
$header['title'] = $project->name . $this->lang->colon . $this->lang->task->edit;
|
||||
$position[] = html::a($browseProjectLink, $project->name);
|
||||
$position[] = html::a($this->createLink('project', 'browse', "project=$task->project"), $project->name);
|
||||
$position[] = $this->lang->task->edit;
|
||||
|
||||
$this->assign('header', $header);
|
||||
@@ -92,6 +102,25 @@ class task extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/* 查看任务。*/
|
||||
public function view($taskID)
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$task = $this->task->findByID($taskID);
|
||||
$project = $this->project->findByID($task->project);
|
||||
|
||||
$header['title'] = $project->name . $this->lang->colon . $this->lang->task->view;
|
||||
$position[] = html::a($this->createLink('project', 'browse', "projectID=$task->project"), $project->name);
|
||||
$position[] = $this->lang->task->view;
|
||||
|
||||
$this->assign('header', $header);
|
||||
$this->assign('position', $position);
|
||||
$this->assign('project', $project);
|
||||
$this->assign('task', $task);
|
||||
$this->assign('actions', $this->action->getList('task', $taskID));
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/* 删除一个任务。*/
|
||||
public function delete($projectID, $taskID, $confirm = 'no')
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ $lang->task->index = "任务一览";
|
||||
$lang->task->create = "新增任务";
|
||||
$lang->task->edit = "更新任务";
|
||||
$lang->task->delete = "删除任务";
|
||||
$lang->task->browse = "浏览任务";
|
||||
$lang->task->view = "查看任务";
|
||||
$lang->task->ajaxGetUserTasks = "ajax:我的任务";
|
||||
|
||||
$lang->task->confirmDelete = "您确定要删除这个任务吗?";
|
||||
@@ -46,3 +46,10 @@ $lang->task->desc = '描述';
|
||||
$lang->task->statusList->wait = '未开始';
|
||||
$lang->task->statusList->doing = '进行中';
|
||||
$lang->task->statusList->done = '已完成';
|
||||
|
||||
$lang->task->buttonEdit = '编辑';
|
||||
$lang->task->buttonBackToList = '返回';
|
||||
|
||||
$lang->task->legendBasic = '基本信息';
|
||||
$lang->task->legendDesc = '任务描述';
|
||||
$lang->task->legendAction = '操作';
|
||||
|
||||
@@ -28,50 +28,78 @@ class taskModel extends model
|
||||
/* 新增一个任务。*/
|
||||
public function create($projectID)
|
||||
{
|
||||
extract($_POST);
|
||||
$sql = "INSERT INTO " . TABLE_TASK . " (`name`, `project`, `story`, `owner`, `estimate`, `left`, `desc`) VALUES('$name', '$projectID', '$storyID', '$owner', '$estimate', '$estimate', '$desc')";
|
||||
return $this->dbh->exec($sql);
|
||||
$task = fixer::input('post')
|
||||
->striptags('name')
|
||||
->specialChars('desc')
|
||||
->cleanFloat('estimate')
|
||||
->add('project', (int)$projectID)
|
||||
->setIF($this->post->estimate == '', 'estimate', 0)
|
||||
->get();
|
||||
$task->left = $task->estimate;
|
||||
|
||||
$this->dao->insert(TABLE_TASK)->data($task)
|
||||
->autoCheck()
|
||||
->check('name', 'notempty')
|
||||
->checkIF($task->estimate != '', 'estimate', 'float')
|
||||
->exec();
|
||||
if(!dao::isError()) return $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/* 更新一个任务。*/
|
||||
public function update($taskID)
|
||||
{
|
||||
extract($_POST);
|
||||
$sql = "UPDATE " . TABLE_TASK . " SET `name` = '$name', `story` = '$storyID', `owner` = '$owner', estimate = '$estimate', `consumed` = '$consumed', `left` = '$left', `status` = '$status', `desc` = '$desc' WHERE id = '$taskID' LIMIT 1";
|
||||
return $this->dbh->exec($sql);
|
||||
$oldTask = $this->findByID($taskID);
|
||||
$task = fixer::input('post')
|
||||
->striptags('name')
|
||||
->specialChars('desc')
|
||||
->cleanFloat('estimate, left, consumed')
|
||||
->setIF($this->post->estimate == '', 'estimate', 0)
|
||||
->setIF($this->post->left == '', 'left', 0)
|
||||
->setIF($this->post->consumed == '', 'consumed', 0)
|
||||
->remove('comment')
|
||||
->get();
|
||||
$this->dao->update(TABLE_TASK)->data($task)
|
||||
->autoCheck()
|
||||
->check('name', 'notempty')
|
||||
->checkIF($task->estimate != '', 'estimate', 'float')
|
||||
->checkIF($task->left != '', 'left', 'float')
|
||||
->checkIF($task->consumed != '', 'consumed', 'float')
|
||||
->where('id')->eq((int)$taskID)->exec();
|
||||
if(!dao::isError()) return common::createChanges($oldTask, $task);
|
||||
}
|
||||
|
||||
/* 删除一个任务。*/
|
||||
public function delete($taskID)
|
||||
{
|
||||
$sql = "DELETE FROM " . TABLE_TASK . " WHERE id = '$taskID'";
|
||||
return $this->dbh->exec($sql);
|
||||
return $this->dao->delete()->from(TABLE_TASK)->where('id')->eq((int)$taskID)->limit(1)->exec();
|
||||
}
|
||||
|
||||
/* 通过id获取一个任务信息。*/
|
||||
public function getById($taskID)
|
||||
public function findByID($taskID)
|
||||
{
|
||||
return $this->dbh->query("SELECT * FROM " . TABLE_TASK . " WHERE id = '$taskID'")->fetch();
|
||||
return $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t3.realname AS ownerRealName')
|
||||
->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_STORY)->alias('t2')
|
||||
->on('t1.story = t2.id')
|
||||
->leftJoin(TABLE_USER)->alias('t3')
|
||||
->on('t1.owner = t3.account')
|
||||
->where('t1.id')->eq((int)$taskID)
|
||||
->fetch();
|
||||
}
|
||||
|
||||
/* 获得某一个项目的任务列表。*/
|
||||
public function getProjectTasks($projectID)
|
||||
public function getProjectTasks($projectID, $orderBy = 'status|desc', $pager = null)
|
||||
{
|
||||
$tasks = array();
|
||||
$sql = "SELECT T1.*, T2.title AS storyTitle, T3.realname AS ownerRealName FROM " . TABLE_TASK . " AS T1 LEFT JOIN " . TABLE_STORY . " AS T2 ON T1.story = T2.id LEFT JOIN " . TABLE_USER . " AS T3 ON T1.owner = T3.account WHERE T1.project = '$projectID' ORDER BY T1.story";
|
||||
$stmt = $this->dbh->query($sql);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/* 获得用户的任务列表。*/
|
||||
public function getUserTasks($account, $status = 'all')
|
||||
{
|
||||
$sql = "SELECT T1.*, T2.name AS projectName, T2.id AS projectID, T3.id AS storyID, T3.title AS storyTitle FROM " . TABLE_TASK . " AS T1
|
||||
LEFT JOIN " .TABLE_PROJECT . " AS T2 ON T1.project = T2.id
|
||||
LEFT JOIN " . TABLE_STORY . " AS T3 ON T1.story = T3.id
|
||||
WHERE T1.owner = '$account'";
|
||||
if($status != 'all') $sql .= " AND T1.status" . helper::dbIN($status);
|
||||
return $this->dbh->query($sql)->fetchAll();
|
||||
return $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t3.realname AS ownerRealName')
|
||||
->from(TABLE_TASK)->alias('t1')
|
||||
->leftJoin(TABLE_STORY)->alias('t2')
|
||||
->on('t1.story = t2.id')
|
||||
->leftJoin(TABLE_USER)->alias('t3')
|
||||
->on('t1.owner = t3.account')
|
||||
->where('t1.project')->eq((int)$projectID)
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/* 获得用户的任务id=>name列表。*/
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div id='doc3'>
|
||||
<form method='post'>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table align='center' class='table-1 a-left'>
|
||||
<caption><?php echo $lang->task->create;?></caption>
|
||||
<tr>
|
||||
@@ -33,28 +33,26 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->story;?></th>
|
||||
<td><?php echo html::select('storyID', $stories, $storyID, 'class=select-3');?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->owner;?></th>
|
||||
<td><?php echo html::select('owner', $members, '', 'class=select-3');?>
|
||||
<td><?php echo html::select('story', $stories, $storyID, 'class=select-1');?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->name;?></th>
|
||||
<td><input type='text' name='name' class='text-3' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->estimate;?></th>
|
||||
<td><input type='text' name='estimate' class='text-3' /></td>
|
||||
<td><input type='text' name='name' class='text-1' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->desc;?></th>
|
||||
<td><textarea name='desc' rows='5' class='area-1'></textarea>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'>
|
||||
<?php echo html::submitButton() . html::resetButton();?>
|
||||
</td>
|
||||
<th class='rowhead'><?php echo $lang->task->owner;?></th>
|
||||
<td><?php echo html::select('owner', $members, '', 'class=select-3');?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->estimate;?></th>
|
||||
<td><input type='text' name='estimate' class='text-3' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'><?php echo html::submitButton() . html::resetButton();?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div id='doc3'>
|
||||
<form method='post'>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table align='center' class='table-1 a-left'>
|
||||
<caption><?php echo $header['title'];?></caption>
|
||||
<tr>
|
||||
@@ -33,16 +33,20 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->story;?></th>
|
||||
<td><?php echo html::select('storyID', $stories, $task->story, 'class=select-3');?>
|
||||
<td><?php echo html::select('story', $stories, $task->story, 'class=select-1');?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->name;?></th>
|
||||
<td><input type='text' name='name' value='<?php echo $task->name;?>' class='text-1' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->desc;?></th>
|
||||
<td><textarea name='desc' rows='5' class='area-1'><?php echo $task->desc;?></textarea>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->owner;?></th>
|
||||
<td><?php echo html::select('owner', $members, $task->owner, 'class=select-3');?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->name;?></th>
|
||||
<td><input type='text' name='name' value='<?php echo $task->name;?>' class='text-3' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->estimate;?></th>
|
||||
<td><input type='text' name='estimate' value='<?php echo $task->estimate;?>' class='text-3' /></td>
|
||||
@@ -59,13 +63,12 @@
|
||||
<th class='rowhead'><?php echo $lang->task->status;?></th>
|
||||
<td><?php echo html::select('status', (array)$lang->task->statusList, $task->status, 'class=select-3');?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->desc;?></th>
|
||||
<td><textarea name='desc' rows='5' class='area-1'><?php echo $task->desc;?></textarea>
|
||||
<th class='rowhead'><?php echo $lang->comment;?></th>
|
||||
<td><textarea name='comment' rows='5' class='area-1'></textarea>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'><input type='submit' name='submit' value='<?php echo $lang->save;?>' class='button-s' /></td>
|
||||
<td colspan='2' class='a-center'><?php echo html::submitButton() . html::resetButton();?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
91
trunk/module/task/view/view.html.php
Normal file
91
trunk/module/task/view/view.html.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* The view 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 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package task
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
|
||||
<div class='yui-d0'>
|
||||
<div id='titlebar'>
|
||||
<div id='main'>TASK #<?php echo $task->id . $lang->colon . $task->name;?></div>
|
||||
<div>
|
||||
<?php
|
||||
if(common::hasPriv('task', 'edit')) echo html::a($this->createLink('task', 'edit', "taskID=$task->id"), $lang->task->buttonEdit);
|
||||
if(common::hasPriv('project', 'task')) echo html::a($app->session->taskList, $lang->task->buttonBackToList);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='yui-d0'>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php echo $lang->task->legendBasic;?></legend>
|
||||
<table align='center' class='table-1 a-left'>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->project;?></th>
|
||||
<td><?php echo $project->name;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->story;?></th>
|
||||
<td><?php echo $task->storyTitle;?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->owner;?></th>
|
||||
<td><?php echo $task->ownerRealName;?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->estimate;?></th>
|
||||
<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>
|
||||
<th class='rowhead'><?php echo $lang->task->left;?></th>
|
||||
<td><?php echo $task->left;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->task->status;?></th>
|
||||
<td><?php $lang->show($lang->task->statusList, $task->status);?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?php echo $lang->task->legendDesc;?></legend>
|
||||
<div><?php echo nl2br($task->desc);?></div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?php echo $lang->task->legendAction;?></legend>
|
||||
<div class='a-center' style='font-size:16px; font-weight:bold'>
|
||||
<?php
|
||||
if(common::hasPriv('task', 'edit')) echo html::a($this->createLink('task', 'edit', "taskID=$task->id"), $lang->task->buttonEdit);
|
||||
if(common::hasPriv('project', 'task')) echo html::a($app->session->taskList, $lang->task->buttonBackToList);
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php include '../../common/action.html.php';?>
|
||||
|
||||
</div>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
Reference in New Issue
Block a user