sprint_sunjun_201

This commit is contained in:
sunjun
2022-06-10 04:29:30 +00:00
parent 32aaa90fd0
commit e21aff2d5d
6 changed files with 278 additions and 21 deletions
+233 -3
View File
@@ -397,8 +397,8 @@ class myModel extends model
$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();
$this->config->testcase->search['params']['product']['values'] = array('' => '') + $products;
$this->config->testcase->search['params']['lib']['values'] = array('' => '') + $this->loadModel('caselib')->getLibraries();
unset($this->config->testcase->search['fields']['module']);
@@ -418,13 +418,14 @@ class myModel extends model
public function getTestcasesBySearch($queryID, $type, $orderBy, $pager)
{
$queryName = $type == 'contribute' ? 'contributeTestcaseQuery' : 'workTestcaseQuery';
$queryForm = $type == 'openedbyme' ? 'contributeTestcaseForm' : 'workTestcaseForm';
if($queryID)
{
$query = $this->loadModel('search')->getQuery($queryID);
if($query)
{
$this->session->set($queryName, $query->sql);
$this->session->set($queryName . 'Form', $query->form);
$this->session->set($queryForm, $query->form);
}
else
{
@@ -718,4 +719,233 @@ class myModel extends model
return $risks;
}
/**
* Build Story search form.
*
* @param int $queryID
* @param string $actionURL
* @param string $type
* @access public
* @return void
*/
public function buildStorySearchForm($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();
$productIdList = array_keys($products);
$branchParam = '';
$queryName = $type == 'contribute' ? 'contributeStory' : 'workStory';
$this->app->loadConfig('product');
$this->config->product->search['module'] = $queryName;
$this->config->product->search['queryID'] = $queryID;
$this->config->product->search['actionURL'] = $actionURL;
$this->config->product->search['params']['product']['values'] = array('' => '') + $products;
$this->config->product->search['params']['plan']['values'] = array('' => '') + $this->loadModel('productplan')->getPairs($productIdList, $branchParam);
unset($this->config->product->search['fields']['module']);
$this->loadModel('search')->setSearchParams($this->config->product->search);
}
/**
* Get stories by search.
*
* @param int $queryID
* @param string $type
* @param string $orderBy
* @param int $pager
* @access public
* @return array
*/
public function getStoriesBySearch($queryID, $type, $orderBy, $pager)
{
$queryName = $type == 'contribute' ? 'contributeStoryQuery' : 'workStoryQuery';
$queryForm = $type == 'contribute' ? 'contributeStoryForm' : 'workStoryForm';
if($queryID)
{
$query = $this->loadModel('search')->getQuery($queryID);
if($query)
{
$this->session->set($queryName, $query->sql);
$this->session->set($queryForm, $query->form);
}
else
{
$this->session->set($queryName, ' 1 = 1');
}
}
else
{
if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1');
}
$myStoryQuery = $this->session->$queryName;
$myStoryQuery = preg_replace('/`(\w+)`/', 't1.`$1`', $myStoryQuery);
$storyIDList = array();
if($type == 'contribute')
{
$storiesAssignedByMe = $this->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'story');
foreach($storiesAssignedByMe as $storyID => $story)
{
$storyIDList[$storyID] = $storyID;
}
$stories = $this->dao->select('distinct t1.*, t2.name as productTitle, t4.title as planTitle')->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_PLANSTORY)->alias('t3')->on('t1.id = t3.plan')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t4')->on('t3.plan = t4.id')
->leftJoin(TABLE_STORYREVIEW)->alias('t5')->on('t1.id = t5.story')
->where($myStoryQuery)
->andWhere('t1.type')->eq('story')
->andWhere('t1.openedBy',1)->eq($this->app->user->account)
->orWhere('t5.reviewer')->eq($this->app->user->account)
->orWhere('t1.closedBy')->eq($this->app->user->account)
->orWhere('t1.id')->in($storyIDList)
->markRight(1)
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)
->page($pager, 't1.id')
->fetchAll('id');
}
else
{
$stories = $this->dao->select('distinct t1.*, t2.name as productTitle, t4.title as planTitle')->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_PLANSTORY)->alias('t3')->on('t1.id = t3.plan')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t4')->on('t3.plan = t4.id')
->leftJoin(TABLE_STORYREVIEW)->alias('t5')->on('t1.id = t5.story')
->where($myStoryQuery)
->andWhere('t1.type')->eq('story')
->andWhere('t1.assignedTo',1)->eq($this->app->user->account)
->orWhere('t5.reviewer')->eq($this->app->user->account)
->markRight(1)
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)
->page($pager, 't1.id')
->fetchAll('id');
}
return $stories;
}
/**
* Build Requirement search form.
*
* @param int $queryID
* @param string $actionURL
* @param string $type
* @access public
* @return void
*/
public function buildRequirementSearchForm($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();
$productIdList = array_keys($products);
$branchParam = '';
$queryName = $type == 'contribute' ? 'contributeRequirement' : 'workRequirement';
$this->app->loadConfig('product');
$this->config->product->search['module'] = $queryName;
$this->config->product->search['queryID'] = $queryID;
$this->config->product->search['actionURL'] = $actionURL;
$this->config->product->search['params']['product']['values'] = array('' => '') + $products;
$this->config->product->search['params']['plan']['values'] = array('' => '') + $this->loadModel('productplan')->getPairs($productIdList, $branchParam);
$this->lang->story->title = str_replace($this->lang->SRCommon, $this->lang->URCommon, $this->lang->story->title);
$this->lang->story->create = str_replace($this->lang->SRCommon, $this->lang->URCommon, $this->lang->story->create);
$this->config->product->search['fields']['title'] = $this->lang->story->title;
unset($this->config->product->search['fields']['plan']);
unset($this->config->product->search['fields']['stage']);
unset($this->config->product->search['fields']['module']);
$this->loadModel('search')->setSearchParams($this->config->product->search);
}
/**
* Get requirements by search.
*
* @param int $queryID
* @param string $type
* @param string $orderBy
* @param int $pager
* @access public
* @return array
*/
public function getRequirementsBySearch($queryID, $type, $orderBy, $pager)
{
$queryName = $type == 'contribute' ? 'contributeRequirementQuery' : 'workRequirementQuery';
$queryForm = $type == 'contribute' ? 'contributeRequirementForm' : 'workRequirementForm';
if($queryID)
{
$query = $this->loadModel('search')->getQuery($queryID);
if($query)
{
$this->session->set($queryName, $query->sql);
$this->session->set($queryForm, $query->form);
}
else
{
$this->session->set($queryName, ' 1 = 1');
}
}
else
{
if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1');
}
$myRequirementQuery = $this->session->$queryName;
$myRequirementQuery = preg_replace('/`(\w+)`/', 't1.`$1`', $myRequirementQuery);
$requirementIDList = array();
if($type == 'contribute')
{
$requirementsAssignedByMe = $this->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'requirement');
foreach($requirementsAssignedByMe as $requirementID => $requirement)
{
$requirementIDList[$requirementID] = $requirementID;
}
$requirements = $this->dao->select('distinct t1.*, t2.name as productTitle')->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_STORYREVIEW)->alias('t3')->on('t1.id = t3.story')
->where($myRequirementQuery)
->andWhere('t1.type')->eq('requirement')
->andWhere('t1.openedBy',1)->eq($this->app->user->account)
->orWhere('t1.closedBy')->eq($this->app->user->account)
->orWhere('t5.reviewer')->eq($this->app->user->account)
->orWhere('t1.id')->in($requirementIDList)
->markRight(1)
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)
->page($pager, 't1.id')
->fetchAll('id');
}
else
{
$requirements = $this->dao->select('distinct t1.*, t2.name as productTitle')->from(TABLE_STORY)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_STORYREVIEW)->alias('t3')->on('t1.id = t3.story')
->where($myRequirementQuery)
->andWhere('t1.type')->eq('requirement')
->andWhere('t1.assignedTo',1)->eq($this->app->user->account)
->orWhere('t3.reviewer')->eq($this->app->user->account)
->markRight(1)
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)
->page($pager, 't1.id')
->fetchAll('id');
}
return $requirements;
}
}