+ add the feature of import task to a project.

This commit is contained in:
wangchunsheng
2010-03-28 14:33:08 +00:00
parent afbf9dedf3
commit 1fd3942fcc
8 changed files with 173 additions and 12 deletions

View File

@@ -29,6 +29,7 @@ $lang->action->desc->edited = '$date, 由 <strong>$actor</strong> 编辑。';
$lang->action->desc->closed = '$date, 由 <strong>$actor</strong> 关闭。';
$lang->action->desc->commented = '$date, 由 <strong>$actor</strong> 发表评论。';
$lang->action->desc->activated = '$date, 由 <strong>$actor</strong> 激活。';
$lang->action->desc->moved = '$date, 由 <strong>$actor</strong> 移动,之前为 "$extra"';
$lang->action->desc->diff1 = '修改了 <strong><i>%s</i></strong>,旧值为 "%s",新值为 "%s"。<br />';
$lang->action->desc->diff2 = '修改了 <strong><i>%s</i></strong>,区别为:<blockquote>%s</blockquote>';
@@ -40,6 +41,7 @@ $lang->action->label->commented = '评论了';
$lang->action->label->activated = '激活了';
$lang->action->label->resolved = '解决了';
$lang->action->label->reviewed = '评审了';
$lang->action->label->moved = '移动了';
$lang->action->label->story = '需求|story|view|storyID=%s';
$lang->action->label->task = '任务|task|view|taskID=%s';
$lang->action->label->bug = 'Bug|bug|view|bugID=%s';

View File

@@ -109,6 +109,7 @@ $lang->resource->project->edit = 'edit';
$lang->resource->project->delete = 'delete';
$lang->resource->project->task = 'task';
$lang->resource->project->grouptask = 'groupTask';
$lang->resource->project->importtask = 'importTask';
$lang->resource->project->story = 'story';
$lang->resource->project->build = 'build';
$lang->resource->project->bug = 'bug';

View File

@@ -73,7 +73,7 @@ class project extends control
}
/* 浏览某一个项目下面的任务。*/
public function task($projectID = 0, $orderBy = 'statusasc,iddesc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function task($projectID = 0, $status = 'all', $orderBy = 'status_asc,id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* 公共的操作。*/
$project = $this->commonAction($projectID);
@@ -91,7 +91,7 @@ class project extends control
/* 分页操作。*/
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $orderBy, $pager);
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $status, $orderBy, $pager);
/* 赋值。*/
$this->view->tasks = $tasks ? $tasks : array();
@@ -122,7 +122,7 @@ class project extends control
$this->view->position[] = $this->lang->project->task;
/* 获得任务列表,并将其分组。*/
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $groupBy);
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $status = 'all', $groupBy);
$groupBy = strtolower(str_replace('`', '', $groupBy));
$taskLang = $this->lang->task;
$groupByList = array();
@@ -159,8 +159,26 @@ class project extends control
$this->display();
}
/* 将之前未完成的项目任务导入。*/
public function importTask($projectID)
{
if(!empty($_POST))
{
$this->project->importTask($projectID);
die(js::locate(inlink('task', "projectID=$projectID"), 'parent'));
}
$project = $this->commonAction($projectID);
$this->view->header->title = $project->name . $this->lang->colon . $this->lang->project->importTask;
$this->view->position[] = html::a(inlink('browse', "projectID=$projectID"), $project->name);
$this->view->position[] = $this->lang->project->importTask;
$this->view->tasks2Imported = $this->project->getTasks2Imported($projectID);
$this->display();
}
/* 浏览某一个项目下面的需求。*/
public function story($projectID = 0, $orderBy = 'statusdesc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function story($projectID = 0, $orderBy = 'status_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* 加载story, user模块加载task模块的语言。*/
$this->loadModel('story');
@@ -199,7 +217,7 @@ class project extends control
}
/* 浏览某一个项目下面的bug。*/
public function bug($projectID = 0, $orderBy = 'status,iddesc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function bug($projectID = 0, $orderBy = 'status,id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* 加载bug和user模块。*/
$this->loadModel('bug');

View File

@@ -38,6 +38,8 @@ $lang->project->linkStory = '关联需求';
$lang->project->unlinkStory = '移除需求';
$lang->project->manageTasks = '任务管理';
$lang->project->linkTask = '关联任务';
$lang->project->importTask = '导入任务';
$lang->project->import = '导入';
$lang->project->manageChilds = '关联子项目';
$lang->project->confirmDelete = '您确定删除项目[%s]吗?';
$lang->project->confirmUnlinkMember = '您确定从该项目中移除该用户吗?';

View File

@@ -100,7 +100,7 @@ class projectModel extends model
/* 获得项目id=>name列表。*/
public function getPairs()
{
return $this->dao->select('id,name')->from(TABLE_PROJECT)->where('iscat')->eq(0)->andwhere('company')->eq($this->app->company->id)->orderBy('status, enddesc')->fetchPairs();
return $this->dao->select('id,name')->from(TABLE_PROJECT)->where('iscat')->eq(0)->andwhere('company')->eq($this->app->company->id)->orderBy('status, end_desc')->fetchPairs();
}
/* 获得完整的列表。*/
@@ -108,7 +108,7 @@ class projectModel extends model
{
$sql = $this->dao->select('*')->from(TABLE_PROJECT)->where('iscat')->eq(0)->andwhere('company')->eq($this->app->company->id);
if($status != 'all') $sql->andWhere('status')->in($status);
return $sql->orderBy('status, enddesc')->fetchAll();
return $sql->orderBy('status, end_desc')->fetchAll();
}
/* 通过Id获取项目信息。*/
@@ -156,6 +156,64 @@ class projectModel extends model
->fetchPairs();
}
/* 获得可以被导入的任务列表。*/
public function getTasks2Imported($projectID)
{
$this->loadModel('task');
$releatedProjects = $this->getRelatedProjects($projectID);
if(!$releatedProjects) return array();
$tasks = array();
foreach($releatedProjects as $releatedProjectID => $releatedProjectName)
{
$projectTasks = $this->task->getProjectTasks($releatedProjectID, 'wait,doing,cancel');
if(!$projectTasks) continue;
$tasks = array_merge($tasks, $projectTasks);
}
return $tasks;
}
/* 导入任务。*/
public function importTask($projectID)
{
$tasks = $this->dao->select('id, project, owner, story')->from(TABLE_TASK)->where('id')->in($this->post->tasks)->fetchAll('id');
/* 更新task表。*/
foreach($tasks as $task)
{
/* 记录owner和story。*/
$owners[$task->owner] = $task->project;
$stories[$task->story] = $task->story;
$status = $task->consumed > 0 ? 'doing' : 'wait';
$this->dao->update(TABLE_TASK)->set('project')->eq($projectID)->set('status')->eq($status)->where('id')->in($this->post->tasks)->exec();
$this->loadModel('action')->create('task', $task->id, 'moved', '', $task->project);
}
/* 将没有关联进来的用户加入到团队中。*/
$teamMembers = $this->getTeamMemberPairs($projectID);
foreach($owners as $account => $preProjectID)
{
if(!isset($teamMembers[$account]))
{
$role = $this->dao->select('*')->from(TABLE_TEAM)->where('project')->eq($preProjectID)->andWhere('account')->eq($account)->fetch();
$role->project = $projectID;
$role->joinDate = helper::today();
$this->dao->insert(TABLE_TEAM)->data($role)->exec();
}
}
/* 将没有关联的需求关联到项目中。*/
$projectStories = $this->loadModel('story')->getProjectStoryPairs($projectID);
foreach($stories as $storyID)
{
if(!isset($projectStories[$storyID]))
{
$story = $this->dao->findById($storyID)->fields("$projectID as project, id as story, product, version")->from(TABLE_STORY)->fetch();
$this->dao->insert(TABLE_PROJECTSTORY)->data($story)->exec();
}
}
}
/* 获得相关的子项目列表。*/
public function getChildProjects($projectID)
{
@@ -286,7 +344,7 @@ class projectModel extends model
/* 没有指定结束日期的情况。*/
if($project->end == '0000-00-00')
{
$sets = $sql->orderBy('datedesc')->limit(14)->fetchAll('name');
$sets = $sql->orderBy('date_desc')->limit(14)->fetchAll('name');
$sets = array_reverse($sets);
/* 如果没有记录,手工补齐。*/

View File

@@ -0,0 +1,75 @@
<?php
/**
* The importtask view file of project 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 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package project
* @version $Id$
* @link http://www.zentao.cn
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/tablesorter.html.php';?>
<div class='yui-d0'>
<form method='post' target='hiddenwin'>
<table class='table-1 fixed tablesorter'>
<thead>
<tr class='colhead'>
<th class='w-p15'><?php echo $lang->task->project;?></th>
<th><?php echo $lang->task->id;?></th>
<th><?php echo $lang->task->pri;?></th>
<th class='w-p20'><?php echo $lang->task->name;?></th>
<th><?php echo $lang->task->owner;?></th>
<th><?php echo $lang->task->left;?></th>
<th><?php echo $lang->task->type;?></th>
<th><?php echo $lang->task->deadline;?></th>
<th><?php echo $lang->task->status;?></th>
<th class='w-p20'><?php echo $lang->task->story;?></th>
<th class='w-50px'><?php echo $lang->project->import;?></th>
</tr>
</thead>
<tbody>
<?php foreach($tasks2Imported as $task):?>
<?php $class = $task->owner == $app->user->account ? 'style=color:red' : '';?>
<tr class='a-center'>
<td><?php echo $projects[$task->project];?></td>
<td><?php if(!common::printLink('task', 'view', "task=$task->id", sprintf('%03d', $task->id))) printf('%03d', $task->id);?></td>
<td><?php echo $task->pri;?></td>
<td class='a-left nobr'><?php if(!common::printLink('task', 'view', "task=$task->id", $task->name)) echo $task->name;?></td>
<td <?php echo $class;?>><?php echo $task->ownerRealName;?></td>
<td><?php echo $task->left;?></td>
<td><?php echo $lang->task->typeList[$task->type];?></td>
<td class=<?php if(isset($task->delay)) echo 'delayed';?>><?php if(substr($task->deadline, 0, 4) > 0) echo $task->deadline;?></td>
<td class=<?php echo $task->status;?> ><?php echo $lang->task->statusList[$task->status];?></td>
<td class='a-left nobr'>
<?php
if($task->storyID)
{
if(common::hasPriv('story', 'view')) echo html::a($this->createLink('story', 'view', "storyid=$task->storyID"), $task->storyTitle);
else echo $task->storyTitle;
}
?>
</td>
<td><input type='checkbox' name='tasks[]' value='<?php echo $task->id;?>' /></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div class='a-right'><?php echo html::submitButton($lang->project->importTask);?></div>
</form>
</div>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -27,7 +27,7 @@
<?php include './taskheader.html.php';?>
<div class='yui-d0'>
<table class='table-1 fixed colored'>
<?php $vars = "projectID=$project->id&orderBy=%s&recTotal=$recTotal&recPerPage=$recPerPage"; ?>
<?php $vars = "projectID=$project->id&status=all&orderBy=%s&recTotal=$recTotal&recPerPage=$recPerPage"; ?>
<thead>
<tr class='colhead'>
<th><?php common::printOrderLink('id', $orderBy, $vars, $lang->task->id);?></th>
@@ -36,7 +36,7 @@
<th><?php common::printOrderLink('owner', $orderBy, $vars, $lang->task->owner);?></th>
<th><?php common::printOrderLink('estimate', $orderBy, $vars, $lang->task->estimate);?></th>
<th><?php common::printOrderLink('consumed', $orderBy, $vars, $lang->task->consumed);?></th>
<th><?php common::printOrderLink('`left`', $orderBy, $vars, $lang->task->left);?></th>
<th><?php common::printOrderLink('left', $orderBy, $vars, $lang->task->left);?></th>
<th><?php common::printOrderLink('type', $orderBy, $vars, $lang->task->type);?></th>
<th><?php common::printOrderLink('deadline', $orderBy, $vars, $lang->task->deadline);?></th>
<th><?php common::printOrderLink('status', $orderBy, $vars, $lang->task->status);?></th>

View File

@@ -12,11 +12,16 @@
echo "<span id='byowner'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=owner", $lang->project->groupTaskByOwner); echo '</span>' ;
echo "<span id='byestimate'>"; common::printLink('project', 'groupTask', "project=$project->id&groupby=estimate",$lang->project->groupTaskByEstimate); echo '</span>' ;
echo "<span id='byconsumed'>"; common::printLink('project', 'groupTask', "project=$project->id&groupby=consumed",$lang->project->groupTaskByConsumed); echo '</span>' ;
echo "<span id='byleft'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=`left`", $lang->project->groupTaskByLeft); echo '</span>' ;
echo "<span id='byleft'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=left", $lang->project->groupTaskByLeft); echo '</span>' ;
echo "<span id='bytype'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=type", $lang->project->groupTaskByType); echo '</span>' ;
echo "<span id='bydeadline'>"; common::printLink('project', 'groupTask', "project=$project->id&groupby=deadline",$lang->project->groupTaskByDeadline); echo '</span>' ;
?>
</div>
<div class='f-right'><?php common::printLink('task', 'create', "project=$project->id", $lang->task->create); ?></div>
<div class='f-right'>
<?php
common::printLink('task', 'create', "project=$project->id", $lang->task->create);
common::printLink('project', 'importTask', "project=$project->id", $lang->project->importTask);
?>
</div>
</div>
</div>