* finish task #40111

This commit is contained in:
zenggang
2021-07-14 14:44:48 +08:00
parent 49892661bf
commit c29583f980
4 changed files with 6 additions and 4 deletions

View File

@@ -1433,7 +1433,7 @@ class execution extends control
$position[] = $this->lang->execution->edit;
$allProducts = array(0 => '');
$executionProsucts = $this->execution->getProducts($execution->project);
$executionProsucts = $this->execution->getProducts($execution->project, true, 'noclosed');
foreach($executionProsucts as $product) $allProducts[$product->id] = $product->name;
$linkedProducts = $this->execution->getProducts($execution->id);

View File

@@ -1579,7 +1579,7 @@ class executionModel extends model
* @access public
* @return array
*/
public function getProducts($executionID, $withBranch = true)
public function getProducts($executionID, $withBranch = true, $status = 'all')
{
if(defined('TUTORIAL'))
{
@@ -1592,6 +1592,7 @@ class executionModel extends model
->on('t1.product = t2.id')
->where('t1.project')->eq((int)$executionID)
->andWhere('t2.deleted')->eq(0)
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->products)->fi();
if(!$withBranch) return $query->fetchPairs('id', 'name');
return $query->fetchAll('id');

View File

@@ -441,7 +441,7 @@ class project extends control
$linkedBranches = array();
$productPlans = array(0 => '');
$allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed');
$linkedProducts = $this->project->getProducts($projectID);
$linkedProducts = $this->project->getProducts($projectID, true, 'noclosed');
$parentProject = $this->program->getByID($project->parent);
/* If the story of the product which linked the project, you don't allow to remove the product. */

View File

@@ -490,11 +490,12 @@ class projectModel extends model
* @access public
* @return array
*/
public function getProducts($projectID, $withBranch = true)
public function getProducts($projectID, $withBranch = true, $status = 'all')
{
$query = $this->dao->select('t2.id, t2.name, t2.type, t1.branch, t1.plan')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->where('t1.project')->eq((int)$projectID)
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
->beginIF(!$this->app->user->admin)->andWhere('t1.product')->in($this->app->user->view->products)->fi()
->andWhere('t2.deleted')->eq(0);
if(!$withBranch) return $query->fetchPairs('id', 'name');