* adjust the delete feature of taskk module.
This commit is contained in:
@@ -162,6 +162,8 @@ class task extends control
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$task = $this->task->getById($taskID);
|
||||
if(!$task) die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
|
||||
$project = $this->project->getById($task->project);
|
||||
|
||||
/* 设置菜单。*/
|
||||
@@ -198,8 +200,10 @@ class task extends control
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->task->delete($taskID);
|
||||
die(js::locate($this->createLink('project', 'browse', "projectID=$projectID"), 'parent'));
|
||||
$story = $this->dao->select('story')->from(TABLE_TASK)->where('id')->eq($taskID)->fetch('story');
|
||||
$this->task->delete(TABLE_TASK, $taskID);
|
||||
if($story) $this->loadModel('story')->setStage($story);
|
||||
die(js::locate($this->session->taskList, 'parent'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,15 +87,6 @@ class taskModel extends model
|
||||
if(!dao::isError()) return common::createChanges($oldTask, $task);
|
||||
}
|
||||
|
||||
/* 删除一个任务。*/
|
||||
public function delete($taskID)
|
||||
{
|
||||
$story = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($taskID)->fetch('story');
|
||||
$this->dao->delete()->from(TABLE_TASK)->where('id')->eq((int)$taskID)->limit(1)->exec();
|
||||
if($story) $this->loadModel('story')->setStage($story);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 通过id获取一个任务信息。*/
|
||||
public function getById($taskID)
|
||||
{
|
||||
@@ -124,6 +115,7 @@ class taskModel extends model
|
||||
->leftJoin(TABLE_USER)->alias('t3')
|
||||
->on('t1.owner = t3.account')
|
||||
->where('t1.project')->eq((int)$projectID)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->onCaseOf($status == 'needConfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->endCase()
|
||||
->onCaseOf($status != 'all' and $status != 'needConfirm')->andWhere('t1.status')->in($status)->endCase()
|
||||
->andWhere('t3.company')->eq($this->app->company->id)
|
||||
@@ -143,6 +135,7 @@ class taskModel extends model
|
||||
->leftJoin(TABLE_USER)->alias('t2')
|
||||
->on('t1.owner = t2.account')
|
||||
->where('t1.project')->eq((int)$projectID)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->onCaseOf($status != 'all')->andWhere('t1.status')->in($status)->endCase()
|
||||
->andWhere('t2.company')->eq($this->app->company->id)
|
||||
->orderBy($orderBy)
|
||||
@@ -161,6 +154,7 @@ class taskModel extends model
|
||||
->leftjoin(TABLE_STORY)->alias('t3')
|
||||
->on('t1.story = t3.id')
|
||||
->where('t1.owner')->eq($account)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->onCaseOf($status != 'all')->andWhere('t1.status')->in($status)->endCase()
|
||||
->fetchAll();
|
||||
if($tasks) return $this->processTasks($tasks);
|
||||
@@ -175,7 +169,8 @@ class taskModel extends model
|
||||
->from(TABLE_TASK)->alias('t1')
|
||||
->leftjoin(TABLE_PROJECT)->alias('t2')
|
||||
->on('t1.project = t2.id')
|
||||
->where('t1.owner')->eq($account);
|
||||
->where('t1.owner')->eq($account)
|
||||
->andWhere('t1.deleted')->eq(0);
|
||||
if($status != 'all') $sql->andwhere('t1.status')->in($status);
|
||||
$stmt = $sql->query();
|
||||
while($task = $stmt->fetch())
|
||||
@@ -188,22 +183,24 @@ class taskModel extends model
|
||||
/* 获得story对应的task id=>name列表。*/
|
||||
public function getStoryTaskPairs($storyID, $projectID = 0)
|
||||
{
|
||||
$sql = $this->dao->select('id, name')
|
||||
return $this->dao->select('id, name')
|
||||
->from(TABLE_TASK)
|
||||
->where('story')->eq((int)$storyID);
|
||||
if($projectID > 0) $sql->andwhere('project')->eq((int)$projectID);
|
||||
return $sql->fetchPairs();
|
||||
->where('story')->eq((int)$storyID)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->onCaseOf($projectID)->andWhere('project')->eq($projectID)->endCase()
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/* 获得story对应的task数量。*/
|
||||
public function getStoryTaskCounts($stories, $projectID = 0)
|
||||
{
|
||||
$sql = $this->dao->select('story, COUNT(*) AS tasks')
|
||||
$taskCounts = $this->dao->select('story, COUNT(*) AS tasks')
|
||||
->from(TABLE_TASK)
|
||||
->where('story')->in($stories);
|
||||
if($projectID > 0) $sql->andwhere('project')->eq((int)$projectID);
|
||||
$sql->groupBy('story');
|
||||
$taskCounts = $sql->fetchPairs();
|
||||
->where('story')->in($stories)
|
||||
->andWhere('deleted')->eq(0)
|
||||
->onCaseOf($projectID)->andWhere('project')->eq($projectID)->endCase()
|
||||
->groupBy('story')
|
||||
->fetchPairs();
|
||||
foreach($stories as $storyID) if(!isset($taskCounts[$storyID])) $taskCounts[$storyID] = 0;
|
||||
return $taskCounts;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<div class='yui-d0'>
|
||||
<div id='titlebar'>
|
||||
<div id='main'>TASK #<?php echo $task->id . $lang->colon . $task->name;?></div>
|
||||
<div id='main' class='<?php if($task->deleted) echo 'deleted';?>'>TASK #<?php echo $task->id . $lang->colon . $task->name;?></div>
|
||||
<div>
|
||||
<?php
|
||||
$browseLink = $app->session->taskList != false ? $app->session->taskList : $this->createLink('project', 'browse', "projectID=$task->project");
|
||||
@@ -34,8 +34,11 @@
|
||||
//if(!($task->status != 'closed' and $task->status != 'cancel' and common::printLink('task', 'close', "taskID=$task->id", $lang->task->buttonClose))) echo $lang->task->buttonClose . ' ';
|
||||
//if(!($task->status != 'closed' and $task->status != 'cancel' and common::printLink('task', 'cancel', "taskID=$task->id", $lang->task->buttonCancel))) echo $lang->task->buttonCancel . ' ';
|
||||
//if(!($task->status == 'closed' or $task->status == 'cancel' and common::printLink('task', 'activate', "taskID=$task->id", $lang->task->buttonActivate))) echo $lang->task->buttonActivate . ' ';
|
||||
if(!common::printLink('task', 'edit', "taskID=$task->id", $lang->task->buttonEdit)) echo $lang->task->buttonEdit . ' ';
|
||||
if(!common::printLink('task', 'delete',"projectID=$task->project&taskID=$task->id", $lang->task->buttonDelete, 'hiddenwin')) echo $lang->task->buttonDelete . ' ';
|
||||
if(!$task->deleted)
|
||||
{
|
||||
if(!common::printLink('task', 'edit', "taskID=$task->id", $lang->task->buttonEdit)) echo $lang->task->buttonEdit . ' ';
|
||||
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);
|
||||
?>
|
||||
</div>
|
||||
@@ -60,8 +63,11 @@
|
||||
//if(!($task->status != 'closed' and $task->status != 'cancel' and common::printLink('task', 'close', "taskID=$task->id", $lang->task->buttonClose))) echo $lang->task->buttonClose . ' ';
|
||||
//if(!($task->status != 'closed' and $task->status != 'cancel' and common::printLink('task', 'cancel', "taskID=$task->id", $lang->task->buttonCancel))) echo $lang->task->buttonCancel . ' ';
|
||||
//if(!($task->status == 'closed' or $task->status == 'cancel' and common::printLink('task', 'activate', "taskID=$task->id", $lang->task->buttonActivate))) echo $lang->task->buttonActivate . ' ';
|
||||
if(!common::printLink('task', 'edit', "taskID=$task->id", $lang->task->buttonEdit)) echo $lang->task->buttonEdit . ' ';
|
||||
if(!common::printLink('task', 'delete',"projectID=$task->project&taskID=$task->id", $lang->task->buttonDelete, 'hiddenwin')) echo $lang->task->buttonDelete . ' ';
|
||||
if(!$task->deleted)
|
||||
{
|
||||
if(!common::printLink('task', 'edit', "taskID=$task->id", $lang->task->buttonEdit)) echo $lang->task->buttonEdit . ' ';
|
||||
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);
|
||||
?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user