+ add the task count in the project story list page.
This commit is contained in:
+13
-11
@@ -111,7 +111,7 @@ class project extends control
|
||||
/* 加载story, user模块,加载task模块的语言。*/
|
||||
$this->loadModel('story');
|
||||
$this->loadModel('user');
|
||||
$this->app->loadLang('task');
|
||||
$this->loadModel('task');
|
||||
|
||||
/* 记录用户当前选择的列表。*/
|
||||
$this->app->session->set('storyList', $this->app->getURI(true));
|
||||
@@ -126,18 +126,20 @@ class project extends control
|
||||
|
||||
/* 分页操作。*/
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$stories = $this->story->getProjectStories($projectID, $orderBy, $pager);
|
||||
$users = $this->user->getPairs($this->app->company->id, 'noletter');
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$stories = $this->story->getProjectStories($projectID, $orderBy, $pager);
|
||||
$storyTasks = $this->task->getStoryTaskCounts(array_keys($stories), $projectID);
|
||||
$users = $this->user->getPairs($this->app->company->id, 'noletter');
|
||||
|
||||
/* 赋值。*/
|
||||
$this->assign('header', $header);
|
||||
$this->assign('position', $position);
|
||||
$this->assign('stories', $stories);
|
||||
$this->assign('tabID', 'story');
|
||||
$this->assign('pager', $pager->get());
|
||||
$this->assign('orderBy', $orderBy);
|
||||
$this->assign('users', $users);
|
||||
$this->assign('header', $header);
|
||||
$this->assign('position', $position);
|
||||
$this->assign('stories', $stories);
|
||||
$this->assign('storyTasks', $storyTasks);
|
||||
$this->assign('tabID', 'story');
|
||||
$this->assign('pager', $pager->get());
|
||||
$this->assign('orderBy', $orderBy);
|
||||
$this->assign('users', $users);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ function selectProject(projectID)
|
||||
<tr class='a-center'>
|
||||
<td><?php if($canView) echo html::a($viewLink, sprintf('%03d', $story->id)); else printf('%03d', $story->id);?></td>
|
||||
<td><?php echo $story->pri;?></td>
|
||||
<td class='a-left'><nobr><?php echo $story->title;?></nobr></td>
|
||||
<td class='a-left'><nobr><?php echo $story->title . ' (' . $storyTasks[$story->id] . ')';?></nobr></td>
|
||||
<td><?php echo $users[$story->assignedTo];?></td>
|
||||
<td><?php echo $users[$story->openedBy];?></td>
|
||||
<td><?php echo $story->estimate;?></td>
|
||||
|
||||
+28
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user