* code for task#790.

* add pager for my-task and user-task page.
This commit is contained in:
chencongzhi520@gmail.com
2012-05-14 03:15:45 +00:00
parent e1a11f234a
commit 8892a241c8
5 changed files with 27 additions and 6 deletions
+7 -2
View File
@@ -115,19 +115,24 @@ class my extends control
* @access public
* @return void
*/
public function task($type = 'assignedto')
public function task($type = 'assignedto', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* Save session. */
$this->session->set('taskList', $this->app->getURI(true));
$this->session->set('storyList', $this->app->getURI(true));
/* Load pager. */
$this->app->loadClass('pager', $static = true);
$pager = pager::init($recTotal, $recPerPage, $pageID);
/* Assign. */
$this->view->header->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->task;
$this->view->position[] = $this->lang->my->task;
$this->view->tabID = 'task';
$this->view->tasks = $this->loadModel('task')->getUserTasks($this->app->user->account, $type);
$this->view->tasks = $this->loadModel('task')->getUserTasks($this->app->user->account, $type, 0, $pager);
$this->view->type = $type;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->pager = $pager;
$this->display();
}
+10 -1
View File
@@ -73,7 +73,16 @@
<?php endforeach;?>
</tbody>
<?php if($canBatchClose):?>
<tfoot><tr><td colspan='11'><?php echo html::selectAll() . html::selectReverse() . html::submitButton($lang->close)?></td></tr></tfoot>
<tfoot>
<tr>
<td colspan='11'>
<div class='f-left'><?php echo html::selectAll() . html::selectReverse() . html::submitButton($lang->close)?></div>
<?php $pager->show();?>
</td>
</tr>
</tfoot>
<?php else:?>
<tfoot><tr><td colspan='11'><?php $pager->show();?></td></tr></tfoot>
<?php endif;?>
</table>
<?php if($canBatchClose) echo '</form>';?>
+2 -1
View File
@@ -477,7 +477,7 @@ class taskModel extends model
* @access public
* @return array
*/
public function getUserTasks($account, $type = 'assignedto', $limit = 0)
public function getUserTasks($account, $type = 'assignedto', $limit = 0, $pager = null)
{
$type = strtolower($type);
$tasks = $this->dao->select('t1.*, t2.id as projectID, t2.name as projectName, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion')
@@ -494,6 +494,7 @@ class taskModel extends model
->beginIF($type == 'canceledby')->andWhere('t1.canceledby')->eq($account)->fi()
->orderBy('id desc')
->beginIF($limit > 0)->limit($limit)->fi()
->page($pager)
->fetchAll();
if($tasks) return $this->processTasks($tasks);
return array();
+7 -2
View File
@@ -87,11 +87,15 @@ class user extends control
* @access public
* @return void
*/
public function task($account)
public function task($account, $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* Save the session. */
$this->session->set('taskList', $this->app->getURI(true));
/* Load pager. */
$this->app->loadClass('pager', $static = true);
$pager = pager::init($recTotal, $recPerPage, $pageID);
/* Set the menu. */
$this->lang->set('menugroup.user', 'company');
$this->user->setMenu($this->user->getPairs('noempty|noclosed'), $account);
@@ -102,8 +106,9 @@ class user extends control
$this->view->header = $header;
$this->view->position = $position;
$this->view->tabID = 'task';
$this->view->tasks = $this->loadModel('task')->getUserTasks($account);
$this->view->tasks = $this->loadModel('task')->getUserTasks($account, 'assignedto', 0, $pager);
$this->view->user = $this->dao->findByAccount($account)->from(TABLE_USER)->fetch();
$this->view->pager = $pager;
$this->display();
}
+1
View File
@@ -40,5 +40,6 @@
<td class='<?php echo $task->status;?>'><?php echo $lang->task->statusList[$task->status];?></td>
<?php endforeach;?>
</tbody>
<tfoot><tr><td colspan='9'><?php $pager->show();?></td></tr></tfoot>
</table>
<?php include '../../common/view/footer.html.php';?>