+ add the task count in the project story list page.

This commit is contained in:
wangchunsheng
2009-11-27 02:05:58 +00:00
parent 06ecd7aa1c
commit c9eb3da45f
3 changed files with 42 additions and 13 deletions
+28 -1
View File
@@ -43,7 +43,11 @@ class taskModel extends model
->check('name', 'notempty')
->checkIF($task->estimate != '', 'estimate', 'float')
->exec();
if(!dao::isError()) return $this->dao->lastInsertID();
if(!dao::isError())
{
//$this->dao->update(TABLE_STORY)->set('status')->eq('doing')->where('id')->eq()
return $this->dao->lastInsertID();
}
}
/* 更新一个任务。*/
@@ -150,4 +154,27 @@ class taskModel extends model
}
return $tasks;
}
/* 获得story对应的task id=>name列表。*/
public function getStoryTaskPairs($storyID, $projectID = 0)
{
$sql = $this->dao->select('name, id')
->from(TABLE_TASK)
->where('story')->eq((int)$storyID);
if($projectID > 0) $sql->andwhere('project')->eq((int)$projectID);
return $sql->fetchPairs();
}
/* 获得story对应的task数量。*/
public function getStoryTaskCounts($stories, $projectID = 0)
{
$sql = $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();
foreach($stories as $storyID) if(!isset($taskCounts[$storyID])) $taskCounts[$storyID] = 0;
return $taskCounts;
}
}