diff --git a/module/my/control.php b/module/my/control.php
index f0dfff94f5..428f26c3eb 100755
--- a/module/my/control.php
+++ b/module/my/control.php
@@ -75,18 +75,19 @@ class my extends control
/**
* My work view.
*
- * @param string $mode
- * @param string $type
- * @param string $orderBy
- * @param int $recTotal
- * @param int $recPerPage
- * @param int $pageID
+ * @param string $mode
+ * @param string $type
+ * @param string|int $param
+ * @param string $orderBy
+ * @param int $recTotal
+ * @param int $recPerPage
+ * @param int $pageID
* @access public
* @return void
*/
- public function work($mode = 'task', $type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
+ public function work($mode = 'task', $type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
- echo $this->fetch('my', $mode, "type=$type&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID");
+ echo $this->fetch('my', $mode, "type=$type¶m=$param&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID");
$this->showWorkCount($recTotal, $recPerPage, $pageID);
}
@@ -210,20 +211,21 @@ EOF;
/**
* My contribute view.
*
- * @param string $mode
- * @param string $type
- * @param string $orderBy
- * @param int $recTotal
- * @param int $recPerPage
- * @param int $pageID
+ * @param string $mode
+ * @param string $type
+ * @param string|int $param
+ * @param string $orderBy
+ * @param int $recTotal
+ * @param int $recPerPage
+ * @param int $pageID
* @access public
* @return void
*/
- public function contribute($mode = 'task', $type = 'openedBy', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
+ public function contribute($mode = 'task', $type = 'openedBy', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
if(($mode == 'issue' or $mode == 'risk') and $type == 'openedBy') $type = 'createdBy';
- echo $this->fetch('my', $mode, "type=$type&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID");
+ echo $this->fetch('my', $mode, "type=$type¶m=$param&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID");
}
/**
@@ -596,15 +598,16 @@ EOF;
/**
* My test case.
*
- * @param string $type assigntome|openedbyme
- * @param string $orderBy
- * @param int $recTotal
- * @param int $recPerPage
- * @param int $pageID
+ * @param string $type assigntome|openedbyme
+ * @param string|int $param
+ * @param string $orderBy
+ * @param int $recTotal
+ * @param int $recPerPage
+ * @param int $pageID
* @access public
* @return void
*/
- public function testcase($type = 'assigntome', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
+ public function testcase($type = 'assigntome', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->loadModel('testcase');
$this->loadModel('testtask');
@@ -620,20 +623,24 @@ EOF;
/* Append id for secend sort. */
$sort = common::appendOrder($orderBy);
+ $queryID = ($type == 'bysearch') ? (int)$param : 0;
$cases = array();
- if($type == 'assigntome')
- {
- $cases = $this->testcase->getByAssignedTo($this->app->user->account, $sort, $pager, 'skip');
- }
- elseif($type == 'openedbyme')
- {
- $cases = $this->testcase->getByOpenedBy($this->app->user->account, $sort, $pager, 'skip');
- }
+ if($type == 'assigntome') $cases = $this->testcase->getByAssignedTo($this->app->user->account, $sort, $pager, 'skip');
+ if($type == 'openedbyme') $cases = $this->testcase->getByOpenedBy($this->app->user->account, $sort, $pager, 'skip');
+ if($type == 'bysearch' and $this->app->rawMethod == 'contribute') $cases = $this->my->getTestcasesBySearch($queryID, 'openedbyme', $orderBy, $pager);
+ if($type == 'bysearch' and $this->app->rawMethod == 'work') $cases = $this->my->getTestcasesBySearch($queryID, 'assigntome', $orderBy, $pager);
+
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', $type == 'assigntome' ? false : true);
$cases = $this->testcase->appendData($cases, $type == 'assigntome' ? 'run' : 'case');
+ /* Build the search form. */
+ $currentMethod = $this->app->rawMethod;
+ $actionURL = $this->createLink('my', $currentMethod, "mode=testcase&type=bysearch¶m=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}");
+ $this->config->testcase->search['onMenuBar'] = 'yes';
+ $this->my->buildTestcaseSearchForm($queryID, $actionURL, $currentMethod);
+
/* Assign. */
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->myTestCase;
$this->view->position[] = $this->lang->my->myTestCase;
diff --git a/module/my/lang/en.php b/module/my/lang/en.php
index 344033dd8f..5aa236aa2a 100644
--- a/module/my/lang/en.php
+++ b/module/my/lang/en.php
@@ -43,6 +43,7 @@ $lang->my->testcase = 'My Case';
$lang->my->storyConcept = 'Story Concept';
$lang->my->pri = 'Priority';
$lang->my->alert = 'You can click on your profile at the top right and select "Preference" to modify your information. ';
+$lang->my->assignedToMe = 'AssignedToMe';
$lang->my->indexAction = 'My Index';
$lang->my->calendarAction = 'My Calendar';
diff --git a/module/my/lang/zh-cn.php b/module/my/lang/zh-cn.php
index a0a4e36334..265f0899b7 100644
--- a/module/my/lang/zh-cn.php
+++ b/module/my/lang/zh-cn.php
@@ -43,6 +43,7 @@ $lang->my->testcase = '我的用例';
$lang->my->storyConcept = $config->URAndSR ? '默认需求概念组合' : '默认需求概念';
$lang->my->pri = '优先级';
$lang->my->alert = '后续您可以点击右上方的头像,选择“个性化设置”修改信息。';
+$lang->my->assignedToMe = '指派给我';
$lang->my->indexAction = '地盘仪表盘';
$lang->my->calendarAction = '我的日程';
diff --git a/module/my/model.php b/module/my/model.php
index bbe114d790..b36f80cd30 100644
--- a/module/my/model.php
+++ b/module/my/model.php
@@ -374,4 +374,88 @@ class myModel extends model
}
return $objectList;
}
+
+ /**
+ * Build search form.
+ *
+ * @param int $queryID
+ * @param string $actionURL
+ * @param string $type
+ * @access public
+ * @return void
+ */
+ public function buildTestCaseSearchForm($queryID, $actionURL, $type)
+ {
+ $products = $this->dao->select('id,name')->from(TABLE_PRODUCT)
+ ->where('deleted')->eq(0)
+ ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi()
+ ->orderBy('order_asc')
+ ->fetchPairs();
+
+ $queryName = $type == 'contribute' ? 'contributeTestcase' : 'workTestcase';
+ $this->app->loadConfig('testcase');
+ $this->config->testcase->search['module'] = $queryName;
+ $this->config->testcase->search['queryID'] = $queryID;
+ $this->config->testcase->search['actionURL'] = $actionURL;
+ $this->config->testcase->search['params']['product']['values'] = $products;
+ $this->config->testcase->search['params']['lib']['values'] = $this->loadModel('caselib')->getLibraries();
+
+ unset($this->config->testcase->search['fields']['module']);
+
+ $this->loadModel('search')->setSearchParams($this->config->testcase->search);
+ }
+
+ /**
+ * Get testcases by search.
+ *
+ * @param int $queryID
+ * @param string $type
+ * @param string $orderBy
+ * @param int $pager
+ * @access public
+ * @return array
+ */
+ public function getTestcasesBySearch($queryID, $type, $orderBy, $pager)
+ {
+ $queryName = $type == 'openedbyme' ? 'contributeTestcaseQuery' : 'workTestcaseQuery';
+ if($queryID)
+ {
+ $query = $this->loadModel('search')->getQuery($queryID);
+ if($query)
+ {
+ $this->session->set($queryName, $query->sql);
+ $this->session->set($queryName . 'Form', $query->form);
+ }
+ else
+ {
+ $this->session->set($queryName, ' 1 = 1');
+ }
+ }
+ else
+ {
+ if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1');
+ }
+
+ $myTestcaseQuery = $this->session->$queryName;
+ $myTestcaseQuery = preg_replace('/`(\w+)`/', 't1.`$1`', $myTestcaseQuery);
+
+ if($type == 'openedbyme')
+ {
+ $cases = $this->dao->select('*')->from(TABLE_CASE)->alias('t1')
+ ->where($myTestcaseQuery)
+ ->andWhere('t1.openedBy')->eq($this->app->user->account)
+ ->andWhere('t1.deleted')->eq(0)
+ ->orderBy($orderBy)->page($pager)->fetchAll('id');
+ }
+ else
+ {
+ $cases = $this->dao->select('t1.*')->from(TABLE_CASE)->alias('t1')
+ ->leftJoin(TABLE_TESTRUN)->alias('t2')->on('t1.id = t2.case')
+ ->where($myTestcaseQuery)
+ ->andWhere('t2.assignedTo')->eq($this->app->user->account)
+ ->andWhere('t1.deleted')->eq(0)
+ ->orderBy($orderBy)->page($pager)->fetchAll('id');
+ }
+ return $cases;
+ }
}
diff --git a/module/my/view/testcase.html.php b/module/my/view/testcase.html.php
index c2e68cf59e..0aae03d69e 100644
--- a/module/my/view/testcase.html.php
+++ b/module/my/view/testcase.html.php
@@ -19,11 +19,20 @@
+
rawMethod == 'contribute' ? 'contributeTestcase' : 'workTestcase');?>>
testcase->noCase;?>
diff --git a/module/testcase/model.php b/module/testcase/model.php
index 44d49ed6f8..bf16af9520 100644
--- a/module/testcase/model.php
+++ b/module/testcase/model.php
@@ -609,7 +609,7 @@ class testcaseModel extends model
*/
public function getByAssignedTo($account, $orderBy = 'id_desc', $pager = null, $auto = 'no')
{
- return $this->dao->select('t1.*,t2.project,t2.pri,t2.title,t2.type,t2.openedBy,t2.color,t2.product,t2.branch,t2.module,t2.status,t3.name as taskName')->from(TABLE_TESTRUN)->alias('t1')
+ return $this->dao->select('t1.task,t1.case,t1.version,t1.assignedTo,t1.lastRunner,t1.lastRunDate,t1.lastRunResult,t1.status,t2.id as id,t2.project,t2.pri,t2.title,t2.type,t2.openedBy,t2.color,t2.product,t2.branch,t2.module,t2.status,t3.name as taskName')->from(TABLE_TESTRUN)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
->leftJoin(TABLE_TESTTASK)->alias('t3')->on('t1.task = t3.id')
->where('t1.assignedTo')->eq($account)