diff --git a/module/project/control.php b/module/project/control.php
index 2e77c90004..6bb41ae591 100644
--- a/module/project/control.php
+++ b/module/project/control.php
@@ -1288,6 +1288,19 @@ class project extends control
$linkedProducts = $this->project->getProducts($project->id);
$linkedBranches = array();
+
+ /* If the story of the product which linked the execution, 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);
+ $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);
+ }
+
foreach($linkedProducts as $product)
{
if(!isset($allProducts[$product->id])) $allProducts[$product->id] = $product->name;
@@ -1326,21 +1339,22 @@ class project extends control
$rdUsers = $this->user->getPairs('noclosed|nodeleted|devfirst', $project->RD, $this->config->maxCount);
if(!empty($this->config->user->moreLink)) $this->config->moreLinks["RD"] = $this->config->user->moreLink;
- $this->view->title = $title;
- $this->view->position = $position;
- $this->view->projects = $projects;
- $this->view->project = $project;
- $this->view->poUsers = $poUsers;
- $this->view->pmUsers = $pmUsers;
- $this->view->qdUsers = $qdUsers;
- $this->view->rdUsers = $rdUsers;
- $this->view->users = $this->user->getPairs('nodeleted|noclosed');
- $this->view->groups = $this->loadModel('group')->getPairs();
- $this->view->allProducts = $allProducts;
- $this->view->linkedProducts = $linkedProducts;
- $this->view->productPlans = $productPlans;
- $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts), '', $linkedBranches);
- $this->view->isStage = $PRJData->model == 'waterfall' ? true : false;
+ $this->view->title = $title;
+ $this->view->position = $position;
+ $this->view->projects = $projects;
+ $this->view->project = $project;
+ $this->view->poUsers = $poUsers;
+ $this->view->pmUsers = $pmUsers;
+ $this->view->qdUsers = $qdUsers;
+ $this->view->rdUsers = $rdUsers;
+ $this->view->users = $this->user->getPairs('nodeleted|noclosed');
+ $this->view->groups = $this->loadModel('group')->getPairs();
+ $this->view->allProducts = $allProducts;
+ $this->view->linkedProducts = $linkedProducts;
+ $this->view->notRemoveProducts = $notRemoveProducts;
+ $this->view->productPlans = $productPlans;
+ $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts), '', $linkedBranches);
+ $this->view->isStage = $PRJData->model == 'waterfall' ? true : false;
$this->display();
}
@@ -1994,6 +2008,19 @@ class project extends control
$allProducts = $this->product->getProductPairsByProject($project->project);
$linkedProducts = $this->project->getProducts($project->id);
$linkedBranches = array();
+
+ /* If the story of the product which linked the execution, 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);
+ $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);
+ }
+
// Merge allProducts and linkedProducts for closed product.
foreach($linkedProducts as $product)
{
@@ -2002,12 +2029,13 @@ class project extends control
}
/* Assign. */
- $this->view->title = $title;
- $this->view->position = $position;
- $this->view->allProducts = $allProducts;
- $this->view->project = $project;
- $this->view->linkedProducts = $linkedProducts;
- $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($allProducts), '', $linkedBranches);
+ $this->view->title = $title;
+ $this->view->position = $position;
+ $this->view->allProducts = $allProducts;
+ $this->view->project = $project;
+ $this->view->linkedProducts = $linkedProducts;
+ $this->view->notRemoveProducts = $notRemoveProducts;
+ $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($allProducts), '', $linkedBranches);
$this->display();
}
diff --git a/module/project/js/edit.js b/module/project/js/edit.js
index 4e011bb888..4e1fb36f85 100644
--- a/module/project/js/edit.js
+++ b/module/project/js/edit.js
@@ -6,3 +6,17 @@ $().ready(function()
$('#branch0').removeAttr("disabled");
});
});
+
+$(function()
+{
+ /* If the story of the product which linked the execution under the project, you don't allow to remove the product. */
+ $("#productsBox select").each(function()
+ {
+ var isExisted = $.inArray($(this).attr('data-last'), notRemoveProducts);
+ if(isExisted != -1)
+ {
+ $(this).prop('disabled', true).trigger("chosen:updated");
+ $(this).siblings('div').find('span').attr('title', tip);
+ }
+ });
+})
diff --git a/module/project/lang/de.php b/module/project/lang/de.php
index f9f6321450..85ef809a51 100644
--- a/module/project/lang/de.php
+++ b/module/project/lang/de.php
@@ -275,6 +275,7 @@ $lang->project->confirmUnlinkMember = "Möchten Sie den Benutzer vom {$lan
$lang->project->confirmUnlinkStory = "Möchten Sie die Story vom {$lang->executionCommon} entfernen?";
$lang->project->confirmUnlinkProjectStory = "Do you want to unlink this Story from the project?";
$lang->project->notAllowedUnlinkStory = "This {$lang->SRCommon} is linked to the {$lang->executionCommon} of the project. Remove it from the {$lang->executionCommon}, then try again.";
+$lang->project->notAllowRemoveProducts = "The story of this product is linked with the {$lang->executionCommon}. Unlink it before doing any action.";
$lang->project->errorNoLinkedProducts = "Kein verknüpftes {$lang->productCommon} in {$lang->executionCommon} gefunden. Sie werden auf die {$lang->productCommon} Seite geleitet.";
$lang->project->errorSameProducts = "{$lang->executionCommon} Kann nicht mit mehreren identischen {$lang->productCommon} verknüpft werden";
$lang->project->accessDenied = "Zugriff zu {$lang->executionCommon} verweigert!";
diff --git a/module/project/lang/en.php b/module/project/lang/en.php
index 70bd25c2b7..dfa3462df5 100644
--- a/module/project/lang/en.php
+++ b/module/project/lang/en.php
@@ -275,6 +275,7 @@ $lang->project->confirmUnlinkMember = "Do you want to unlink this User fro
$lang->project->confirmUnlinkStory = "Do you want to unlink this Story from {$lang->executionCommon}?";
$lang->project->confirmUnlinkProjectStory = "Do you want to unlink this Story from the project?";
$lang->project->notAllowedUnlinkStory = "This {$lang->SRCommon} is linked to the {$lang->executionCommon} of the project. Remove it from the {$lang->executionCommon}, then try again.";
+$lang->project->notAllowRemoveProducts = "The story of this product is linked with the {$lang->executionCommon}. Unlink it before doing any action.";
$lang->project->errorNoLinkedProducts = "No {$lang->productCommon} is linked to {$lang->executionCommon}. You will be directed to {$lang->productCommon} page to link one.";
$lang->project->errorSameProducts = "{$lang->executionCommon} cannot be linked to the same {$lang->productCommon} twice.";
$lang->project->accessDenied = "Your access to {$lang->executionCommon} is denied!";
diff --git a/module/project/lang/fr.php b/module/project/lang/fr.php
index 3d7133ed3f..bd48158bb0 100644
--- a/module/project/lang/fr.php
+++ b/module/project/lang/fr.php
@@ -275,6 +275,7 @@ $lang->project->confirmUnlinkMember = "Voulez-vous retirer cet utilisateur
$lang->project->confirmUnlinkStory = "Voulez-vous retirer cette Story du {$lang->executionCommon} ?";
$lang->project->confirmUnlinkProjectStory = "Do you want to unlink this Story from the project?";
$lang->project->notAllowedUnlinkStory = "This {$lang->SRCommon} is linked to the {$lang->executionCommon} of the project. Remove it from the {$lang->executionCommon}, then try again.";
+$lang->project->notAllowRemoveProducts = "The story of this product is linked with the {$lang->executionCommon}. Unlink it before doing any action.";
$lang->project->errorNoLinkedProducts = "Aucun {$lang->productCommon} n'est associé à ce {$lang->executionCommon}. Vous allez être redirigé vers la page {$lang->productCommon} pour en associer un.";
$lang->project->errorSameProducts = "Ce {$lang->executionCommon} ne peut pas être associé deux fois au même {$lang->productCommon}. Imaginez un peu les résultats !";
$lang->project->accessDenied = "Votre accès au {$lang->executionCommon} est refusé ! Désolé.";
diff --git a/module/project/lang/vi.php b/module/project/lang/vi.php
index 9a4aa3cbe1..37c33fc8d6 100644
--- a/module/project/lang/vi.php
+++ b/module/project/lang/vi.php
@@ -275,6 +275,7 @@ $lang->project->confirmUnlinkMember = "Bạn có muốn hủy liên kết
$lang->project->confirmUnlinkStory = "Bạn có muốn hủy liên kết câu chuyện này từ {$lang->executionCommon}?";
$lang->project->confirmUnlinkProjectStory = "Do you want to unlink this Story from the project?";
$lang->project->notAllowedUnlinkStory = "This {$lang->SRCommon} is linked to the {$lang->executionCommon} of the project. Remove it from the {$lang->executionCommon}, then try again.";
+$lang->project->notAllowRemoveProducts = "The story of this product is linked with the {$lang->executionCommon}. Unlink it before doing any action.";
$lang->project->errorNoLinkedProducts = "Không có {$lang->productCommon} liên kết tới {$lang->executionCommon}. Bạn sẽ được chuyển tới trang {$lang->productCommon} để liên kết.";
$lang->project->errorSameProducts = "{$lang->executionCommon} không thể liên kết tới {$lang->productCommon} giống nhau 2 lần.";
$lang->project->accessDenied = "Truy cập của bạn tới {$lang->executionCommon} bị từ chối!";
diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php
index ab6fb1cc3c..1585661676 100644
--- a/module/project/lang/zh-cn.php
+++ b/module/project/lang/zh-cn.php
@@ -275,6 +275,7 @@ $lang->project->confirmUnlinkMember = "您确定从该{$lang->executionCom
$lang->project->confirmUnlinkStory = "您确定从该{$lang->executionCommon}中移除该{$lang->SRCommon}吗?";
$lang->project->confirmUnlinkProjectStory = "您确定从该项目中移除该{$lang->SRCommon}吗?";
$lang->project->notAllowedUnlinkStory = "该{$lang->SRCommon}已经与项目下{$lang->executionCommon}相关联,请从{$lang->executionCommon}中移除后再操作。";
+$lang->project->notAllowRemoveProducts = "该产品中的需求已与该{$lang->executionCommon}进行了关联,请取消关联后再操作。";
$lang->project->errorNoLinkedProducts = "该{$lang->executionCommon}没有关联的{$lang->productCommon},系统将转到{$lang->productCommon}关联页面";
$lang->project->errorSameProducts = "{$lang->executionCommon}不能关联多个相同的{$lang->productCommon}。";
$lang->project->accessDenied = "您无权访问该{$lang->executionCommon}!";
diff --git a/module/project/lang/zh-tw.php b/module/project/lang/zh-tw.php
index b6d447f132..76b07aa60e 100644
--- a/module/project/lang/zh-tw.php
+++ b/module/project/lang/zh-tw.php
@@ -269,6 +269,7 @@ $lang->project->confirmUnlinkMember = "您確定從該{$lang->executionCom
$lang->project->confirmUnlinkStory = "您確定從該{$lang->executionCommon}中移除該{$lang->SRCommon}嗎?";
$lang->project->confirmUnlinkProjectStory = "您確定從該項目中移除該{$lang->SRCommon}嗎?";
$lang->project->notAllowedUnlinkStory = "該{$lang->SRCommon}已經與項目下{$lang->executionCommon}相關聯,請從{$lang->executionCommon}中移除後再操作。";
+$lang->project->notAllowRemoveProducts = "該產品中的需求已與該{$lang->executionCommon}進行了關聯,請取消關聯後再操作。";
$lang->project->errorNoLinkedProducts = "該{$lang->executionCommon}沒有關聯的{$lang->productCommon},系統將轉到{$lang->productCommon}關聯頁面";
$lang->project->errorSameProducts = "{$lang->executionCommon}不能關聯多個相同的{$lang->productCommon}。";
$lang->project->accessDenied = "您無權訪問該{$lang->executionCommon}!";
diff --git a/module/project/view/edit.html.php b/module/project/view/edit.html.php
index 2f1ef806ad..2dfe3adda5 100644
--- a/module/project/view/edit.html.php
+++ b/module/project/view/edit.html.php
@@ -188,4 +188,6 @@