diff --git a/module/testtask/control.php b/module/testtask/control.php index 014e9bcd73..5dc9b49b24 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -198,7 +198,7 @@ class testtask extends control * @access public * @return void */ - public function cases($taskID, $browseType = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function cases($taskID, $browseType = 'byModule', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Save the session. */ $this->app->loadLang('testcase'); @@ -220,11 +220,11 @@ class testtask extends control { $modules = ''; if($moduleID) $modules = $this->loadModel('tree')->getAllChildID($moduleID); - $this->view->runs = $this->testtask->getRuns($taskID, $modules, $pager); + $this->view->runs = $this->testtask->getRuns($taskID, $modules, $orderBy, $pager); } elseif($browseType == 'assignedtome') { - $this->view->runs = $this->testtask->getUserRuns($taskID, $this->session->user->account, $pager); + $this->view->runs = $this->testtask->getUserRuns($taskID, $this->session->user->account, $orderBy, $pager); } /* Save testcaseIDs session for get the pre and next testcase. */ @@ -241,6 +241,8 @@ class testtask extends control $this->view->users = $this->loadModel('user')->getPairs('noclosed'); $this->view->moduleTree = $this->loadModel('tree')->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createTestTaskLink'), $extra = $taskID); $this->view->browseType = $browseType; + $this->view->param = $param; + $this->view->orderBy = $orderBy; $this->view->taskID = $taskID; $this->view->moduleID = $moduleID; $this->view->treeClass = $browseType == 'bymodule' ? '' : 'hidden'; diff --git a/module/testtask/model.php b/module/testtask/model.php index 745ab8d193..77b079e7f2 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -176,12 +176,15 @@ class testtaskModel extends model * @access public * @return array */ - public function getRuns($taskID, $moduleID, $pager = null) + public function getRuns($taskID, $moduleID, $orderBy, $pager = null) { + $orderBy = strpos($orderBy, 'assignedTo') !== false ? ('t1.' . $orderBy) : ('t2.' . $orderBy); + return $this->dao->select('t2.*,t1.*')->from(TABLE_TESTRUN)->alias('t1') ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id') ->where('t1.task')->eq((int)$taskID) ->beginIF($moduleID)->andWhere('t2.module')->in($moduleID)->fi() + ->orderBy($orderBy) ->page($pager) ->fetchAll('', false); } @@ -195,12 +198,15 @@ class testtaskModel extends model * @access public * @return array */ - public function getUserRuns($taskID, $user, $pager = null) + public function getUserRuns($taskID, $user, $orderBy, $pager = null) { + $orderBy = strpos($orderBy, 'assignedTo') !== false ? ('t1.' . $orderBy) : ('t2.' . $orderBy); + return $this->dao->select('t2.*,t1.*')->from(TABLE_TESTRUN)->alias('t1') ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id') ->where('t1.task')->eq((int)$taskID) ->andWhere('t1.assignedTo')->eq($user) + ->orderBy($orderBy) ->page($pager) ->fetchAll(); } diff --git a/module/testtask/view/cases.html.php b/module/testtask/view/cases.html.php index 1c3c60d0a6..6037f3a6e5 100644 --- a/module/testtask/view/cases.html.php +++ b/module/testtask/view/cases.html.php @@ -11,7 +11,6 @@ */ ?> -