diff --git a/module/common/control.php b/module/common/control.php index 87ffcce780..8231c4c048 100644 --- a/module/common/control.php +++ b/module/common/control.php @@ -342,7 +342,7 @@ class common extends control */ public function printRPN($backLink, $preAndNext = '') { - global $lang; + global $lang, $app; if(isonlybody()) return false; echo ""; @@ -351,18 +351,20 @@ class common extends control if(isset($preAndNext->pre) and $preAndNext->pre) { + $id = (!$_SESSION[$typeOnlyCondition] and $app->getModuleName() == 'testcase' and isset($preAndNext->pre->case)) ? 'case' : 'id'; $title = isset($preAndNext->pre->title) ? $preAndNext->pre->title : $preAndNext->pre->name; - $title = '#' . $preAndNext->pre->id . ' ' . $title; + $title = '#' . $preAndNext->pre->$id . ' ' . $title; echo ""; - echo html::a($this->inLink('view', "ID={$preAndNext->pre->id}"), ' ', '', "id='pre' class='icon-pre' title='{$title}'"); + echo html::a($this->inLink('view', "ID={$preAndNext->pre->$id}"), ' ', '', "id='pre' class='icon-pre' title='{$title}'"); echo ""; } if(isset($preAndNext->next) and $preAndNext->next) { + $id = (!$_SESSION[$typeOnlyCondition] and $app->getModuleName() == 'testcase' and isset($preAndNext->next->case)) ? 'case' : 'id'; $title = isset($preAndNext->next->title) ? $preAndNext->next->title : $preAndNext->next->name; - $title = '#' . $preAndNext->next->id . ' ' . $title; + $title = '#' . $preAndNext->next->$id . ' ' . $title; echo ""; - echo html::a($this->inLink('view', "ID={$preAndNext->next->id}"), ' ', '', "id='next' class='icon-next' title='$title'"); + echo html::a($this->inLink('view', "ID={$preAndNext->next->$id}"), ' ', '', "id='next' class='icon-next' title='$title'"); echo ""; } } diff --git a/module/common/model.php b/module/common/model.php index 45ed64d876..e66967bd4b 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -627,7 +627,6 @@ class commonModel extends model $nextID = $tmpObjectIDs[$nextKey]; $preAndNextObject->next = $objects[$objectIDs[$nextID]]; } - return $preAndNextObject; } diff --git a/module/testcase/config.php b/module/testcase/config.php index bdba18a54a..fa2dbc6348 100644 --- a/module/testcase/config.php +++ b/module/testcase/config.php @@ -25,16 +25,16 @@ global $lang; $config->testcase->search['module'] = 'testcase'; $config->testcase->search['fields']['title'] = $lang->testcase->title; $config->testcase->search['fields']['id'] = $lang->testcase->id; -$config->testcase->search['fields']['module'] = $lang->testcase->module; $config->testcase->search['fields']['keywords'] = $lang->testcase->keywords; $config->testcase->search['fields']['lastEditedBy'] = $lang->testcase->lastEditedByAB; $config->testcase->search['fields']['type'] = $lang->testcase->type; -$config->testcase->search['fields']['pri'] = $lang->testcase->pri; $config->testcase->search['fields']['openedBy'] = $lang->testcase->openedBy; $config->testcase->search['fields']['status'] = $lang->testcase->status; $config->testcase->search['fields']['product'] = $lang->testcase->product; $config->testcase->search['fields']['stage'] = $lang->testcase->stage; +$config->testcase->search['fields']['module'] = $lang->testcase->module; +$config->testcase->search['fields']['pri'] = $lang->testcase->pri; $config->testcase->search['fields']['openedDate'] = $lang->testcase->openedDate; $config->testcase->search['fields']['lastEditedDate'] = $lang->testcase->lastEditedDateAB; diff --git a/module/testtask/control.php b/module/testtask/control.php index d10b58099b..e2ad667cab 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -215,6 +215,7 @@ class testtask extends control /* Set the browseType and moduleID. */ $browseType = strtolower($browseType); $moduleID = ($browseType == 'bymodule') ? (int)$param : 0; + $queryID = ($browseType == 'bysearch') ? (int)$param : 0; /* Get task and product info, set menu. */ $task = $this->testtask->getById($taskID); @@ -231,6 +232,48 @@ class testtask extends control { $this->view->runs = $this->testtask->getUserRuns($taskID, $this->session->user->account, $orderBy, $pager); } + /* By search. */ + elseif($browseType == 'bysearch') + { + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set('testcaseQuery', $query->sql); + $this->session->set('testcaseForm', $query->form); + } + else + { + $this->session->set('testcaseQuery', ' 1 = 1'); + } + } + else + { + if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1'); + } + + $queryProductID = $productID; + $allProduct = "`product` = 'all'"; + $caseQuery = $this->session->testcaseQuery; + if(strpos($this->session->testcaseQuery, $allProduct) !== false) + { + $products = array_keys($this->loadModel('product')->getPrivProducts()); + $caseQuery = str_replace($allProduct, '1', $this->session->testcaseQuery); + $caseQuery = $caseQuery . ' AND `product`' . helper::dbIN(array_keys($products)); + $queryProductID = 'all'; + } + + $caseQuery = $this->loadModel('search')->replaceDynamic($caseQuery); + $caseQuery = preg_replace('/`(\w+)`/', 't2.`$1`', $caseQuery); + $this->view->runs = $this->dao->select('t2.*,t1.*')->from(TABLE_TESTRUN)->alias('t1') + ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id') + ->where($caseQuery) + ->andWhere('t1.task')->eq($taskID) + ->orderBy(strpos($orderBy, 'assignedTo') !== false ? ('t1.' . $orderBy) : ('t2.' . $orderBy)) + ->page($pager) + ->fetchAll(); + } $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); /* Save testcaseIDs session for get the pre and next testcase. */ @@ -238,6 +281,13 @@ class testtask extends control foreach($this->view->runs as $run) $testcaseIDs .= ',' . $run->case; $this->session->set('testcaseIDs', $testcaseIDs . ','); + /* Build the search form. */ + $this->loadModel('testcase'); + $this->config->testcase->search['params']['product']['values']= array($productID => $this->products[$productID], 'all' => $this->lang->testcase->allProduct); + $this->config->testcase->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'case'); + $this->config->testcase->search['actionURL'] = inlink('cases', "taskID=$taskID&browseType=bySearch&queryID=myQueryID"); + $this->loadModel('search')->setSearchParams($this->config->testcase->search); + $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases; $this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->position[] = $this->lang->testtask->cases; diff --git a/module/testtask/js/cases.js b/module/testtask/js/cases.js index ca3896a217..c7ee62f297 100644 --- a/module/testtask/js/cases.js +++ b/module/testtask/js/cases.js @@ -4,8 +4,33 @@ function browseByModule(active) $('.divider').removeClass('hidden'); $('#bymoduleTab').addClass('active'); $('#' + active + 'Tab').removeClass('active'); + $('#querybox').addClass('hidden'); } +/* Swtich to search module. */ +function browseBySearch(active) +{ + $('#querybox').removeClass('hidden'); + $('.side').addClass('hidden'); + $('.divider').addClass('hidden'); + $('#' + active + 'Tab').removeClass('active'); + $('#bysearchTab').addClass('active'); + $('#bymoduleTab').removeClass('active'); +} + +function changeAction(url) +{ + $('#batchForm').attr('action', url); +} + +$(document).ready(function() +{ + setModal4List('runCase', 'caseList', function(){$(".results").colorbox({width:900, height:550, iframe:true, transition:'none'});}); + $('#' + browseType + 'Tab').addClass('active'); + $('#module' + moduleID).addClass('active'); + if(browseType == 'bysearch') ajaxGetSearchForm(); +}); + $(document).ready(function() { $("a.iframe").colorbox({width:900, height:550, iframe:true, transition:'none', onCleanup:function(){parent.location.href=parent.location.href;}}); diff --git a/module/testtask/js/linkcase.js b/module/testtask/js/linkcase.js index e69de29bb2..cc46c2038f 100644 --- a/module/testtask/js/linkcase.js +++ b/module/testtask/js/linkcase.js @@ -0,0 +1 @@ +$(function(){ajaxGetSearchForm();}) diff --git a/module/testtask/view/cases.html.php b/module/testtask/view/cases.html.php index 5b78baa6f0..73e9af8c0b 100644 --- a/module/testtask/view/cases.html.php +++ b/module/testtask/view/cases.html.php @@ -23,6 +23,7 @@ var moduleID = ''; echo "" . $lang->testtask->byModule . " "; echo "" . html::a($this->inlink('cases', "taskID=$taskID&browseType=all¶m=0"), $lang->testtask->allCases) . ""; echo "" . html::a($this->inlink('cases', "taskID=$taskID&browseType=assignedtome¶m=0"), $lang->testtask->assignedToMe) . ""; + echo "{$lang->testcase->bySearch} "; ?>
@@ -33,6 +34,7 @@ var moduleID = ''; ?>
+
diff --git a/module/testtask/view/linkcase.html.php b/module/testtask/view/linkcase.html.php index 53921ad792..9f3a8c79cb 100644 --- a/module/testtask/view/linkcase.html.php +++ b/module/testtask/view/linkcase.html.php @@ -75,5 +75,4 @@
-