* Adjust the code.

This commit is contained in:
hufangzhou
2021-01-27 14:36:17 +08:00
parent 64e01f669f
commit 1704f684f4
3 changed files with 17 additions and 34 deletions
+8 -15
View File
@@ -1001,16 +1001,12 @@ class program extends control
$linkedProducts = $programID != $project->parent ? array() : $this->project->getProducts($projectID);
$parentProgram = $this->program->getPGMByID($programID);
/* If the story of the product which linked the execution under the project, you don't allow to remove the product. */
$projectStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->fetchAll('story');
$projectStoryIdList = array_keys($projectStories);
/* If the story of the product which linked the project, you don't allow to remove the product. */
$notRemoveProducts = array();
foreach($linkedProducts as $productID => $linkedProduct)
{
$productStories = $this->loadModel('story')->getProductStories($productID);
$productStoryIdList = array_keys($productStories);
$storyIntersect = array_intersect($projectStoryIdList, $productStoryIdList);
if(!empty($storyIntersect)) array_push($notRemoveProducts, $productID);
$projectStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->andWhere('product')->eq($productID)->fetchAll('story');
if(!empty($projectStories)) array_push($notRemoveProducts, $productID);
}
foreach($linkedProducts as $product)
@@ -1735,19 +1731,16 @@ class program extends control
$this->loadModel('product');
$project = $this->project->getById($projectID);
/* If the story of the product which linked the execution under the project, you don't allow to remove the product. */
$allProducts = $this->program->getPGMProductPairs($project->parent, 'assign', 'noclosed');
$linkedProducts = $this->project->getProducts($project->id);
$linkedBranches = array();
$projectStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->fetchAll('story');
$projectStoryIdList = array_keys($projectStories);
$notRemoveProducts = array();
/* If the story of the product which linked the project, you don't allow to remove the product. */
$notRemoveProducts = array();
foreach($linkedProducts as $productID => $linkedProduct)
{
$productStories = $this->loadModel('story')->getProductStories($productID);
$productStoryIdList = array_keys($productStories);
$storyIntersect = array_intersect($projectStoryIdList, $productStoryIdList);
if(!empty($storyIntersect)) array_push($notRemoveProducts, $productID);
$projectStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->andWhere('product')->eq($productID)->fetchAll('story');
if(!empty($projectStories)) array_push($notRemoveProducts, $productID);
}
/* Merge allProducts and linkedProducts for closed product. */