diff --git a/module/execution/control.php b/module/execution/control.php index a563257356..a4f501513b 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -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); diff --git a/module/execution/model.php b/module/execution/model.php index 5ff8526817..d589bd5496 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -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'); diff --git a/module/project/control.php b/module/project/control.php index 9b0badd995..6a7a9423d2 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -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. */ diff --git a/module/project/model.php b/module/project/model.php index fb71107d25..3c2f0fcbe3 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -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');