* finish task #2694.

This commit is contained in:
chenfeiCF
2016-11-17 09:02:25 +08:00
parent 71a3f01096
commit 45ff373197
5 changed files with 160 additions and 74 deletions
+70 -2
View File
@@ -967,6 +967,74 @@ class projectModel extends model
return $query->fetchAll('id');
}
/**
* Build story search form.
*
* @param array $products
* @param array $branchGroups
* @param array $modules
* @param int $queryID
* @param string $actionURL
* @param string $type
* @access public
* @return void
*/
public function buildStorySearchForm($products, $branchGroups, $modules, $queryID, $actionURL, $type = 'projectStory')
{
$branchPairs = array();
$productType = 'normal';
$productNum = count($products);
foreach($products as $product)
{
$productPairs[$product->id] = $product->name;
if($product->type != 'normal')
{
$productType = $product->type;
if($product->branch)
{
$branchPairs[$product->branch] = (count($products) > 1 ? $product->name . '/' : '') . $branchGroups[$product->id][$product->branch];
}
else
{
$productBranches = isset($branchGroups[$product->id]) ? $branchGroups[$product->id] : array(0);
if(count($products) > 1)
{
foreach($productBranches as $branchID => $branchName) $productBranches[$branchID] = $product->name . '/' . $branchName;
}
$branchPairs += $productBranches;
}
}
}
/* Build search form. */
if($type == 'projectStory')
{
$this->config->product->search['module'] = 'projectStory';
unset($this->config->product->search['fields']['stage']);
unset($this->config->product->search['params']['stage']);
}
$this->config->product->search['actionURL'] = $actionURL;
$this->config->product->search['queryID'] = $queryID;
$this->config->product->search['params']['product']['values'] = $productPairs + array('all' => $this->lang->product->allProductsOfProject);
$this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts($products);
if(count($products) == 1) $this->config->product->search['params']['module']['values'] = $modules;
unset($this->lang->story->statusList['draft']);
if(count($products) >= 2) unset($this->config->product->search['fields']['module']);
if($productType == 'normal')
{
unset($this->config->product->search['fields']['branch']);
unset($this->config->product->search['params']['branch']);
}
else
{
$this->config->product->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$productType]);
$this->config->product->search['params']['branch']['values'] = array('' => '') + $branchPairs;
}
$this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $this->lang->story->statusList);
$this->loadModel('search')->setSearchParams($this->config->product->search);
}
/**
* Get projects to import
*
@@ -1917,7 +1985,7 @@ class projectModel extends model
}
/**
* Build search form.
* Build task search form.
*
* @param int $projectID
* @param array $projects
@@ -1926,7 +1994,7 @@ class projectModel extends model
* @access public
* @return void
*/
public function buildSearchForm($projectID, $projects, $queryID, $actionURL)
public function buildTaskSearchForm($projectID, $projects, $queryID, $actionURL)
{
$this->config->project->search['actionURL'] = $actionURL;
$this->config->project->search['queryID'] = $queryID;