diff --git a/module/programplan/control.php b/module/programplan/control.php index c57644f0b0..1d11bb6cf9 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -252,6 +252,7 @@ class programplan extends control $this->view->plan = $plan; $this->view->parentStageList = $this->programplan->getParentStageList($this->session->project, $planID, $plan->product); $this->view->enableOptionalAttr = (empty($parentStage) or (!empty($parentStage) and $parentStage->attribute == 'mix')); + $this->view->isTopStage = $this->programplan->checkTopStage($planID); $this->display(); } diff --git a/module/programplan/js/edit.js b/module/programplan/js/edit.js index 2a527ca7ea..0eb9d72561 100644 --- a/module/programplan/js/edit.js +++ b/module/programplan/js/edit.js @@ -27,7 +27,7 @@ $(function() changeParentStage(parent); }); - $('#submit').click(function(event) + $('#submit').click(function() { if(plan.parent != $('#parent').val() && $('#parent').val() != 0) { @@ -45,5 +45,16 @@ $(function() if(!result) return false; } + + var currentAttribute = $('#attribute').val(); + var currentParent = $('#parent').val(); + var hasChangedAttribute = (currentAttribute && currentAttribute != 'mix' && plan.attribute != currentAttribute); + var hasChangedParent = ((isTopStage && $('#parent').val() != 0) || (!isTopStage && plan.parent != $('#parent').val())); + if(hasChangedAttribute && !hasChangedParent) + { + var result = confirm(changeAttrLang.replace('%s', stageTypeList[currentAttribute])); + + if(!result) return false; + } }) }) diff --git a/module/programplan/model.php b/module/programplan/model.php index aeb5ba9f7b..eb3e863f00 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -1498,6 +1498,21 @@ class programplanModel extends model return $subStageList ? false : true; } + /** + * Change whether it is the top stage. + * + * @param int $planID + * @access public + * @return bool + */ + public function checkTopStage($planID) + { + $parentID = $this->dao->select('parent')->from(TABLE_EXECUTION)->where('id')->eq($planID)->fetch('parent'); + $parentType = $this->dao->select('type')->from(TABLE_EXECUTION)->where('id')->eq($parentID)->fetch('type'); + + return $parentType == 'project'; + } + /** * Update sub-stage attribute. * diff --git a/module/programplan/view/edit.html.php b/module/programplan/view/edit.html.php index c2f7c23ac4..72b42e3340 100644 --- a/module/programplan/view/edit.html.php +++ b/module/programplan/view/edit.html.php @@ -15,6 +15,7 @@ stage->typeList);?> programplan->confirmChangeAttr);?> +