diff --git a/module/execution/control.php b/module/execution/control.php
index 20e6f3a674..552b9c99ee 100644
--- a/module/execution/control.php
+++ b/module/execution/control.php
@@ -1809,6 +1809,8 @@ class execution extends control
$comment = $project->hasProduct ? join(',', $_POST['products']) : '';
$this->loadModel('action')->create($this->objectType, $executionID, 'opened', '', $comment);
+ $this->loadModel('programplan')->computeProgress($executionID, 'create');
+
$message = $this->executeHooks($executionID);
if($message) $this->lang->saveSuccess = $message;
@@ -2233,6 +2235,8 @@ class execution extends control
$this->action->logHistory($actionID, $changes);
}
+ if($execution->type == 'stage') $this->loadModel('programplan')->computeProgress($executionID, 'start');
+
$this->loadModel('common')->syncPPEStatus($executionID);
$this->executeHooks($executionID);
if(isonlybody() and $from == 'kanban')
@@ -2322,6 +2326,9 @@ class execution extends control
$actionID = $this->action->create($this->objectType, $executionID, 'Suspended', $this->post->comment);
$this->action->logHistory($actionID, $changes);
}
+
+ if($execution->type == 'stage') $this->loadModel('programplan')->computeProgress($executionID, 'suspend');
+
$this->executeHooks($executionID);
if(isonlybody() and $from == 'kanban')
{
@@ -2360,6 +2367,8 @@ class execution extends control
$this->execution->activate($executionID);
if(dao::isError()) return print(js::error(dao::getError()));
+ if($execution->type == 'stage') $this->loadModel('programplan')->computeProgress($executionID, 'activate');
+
$this->executeHooks($executionID);
if(isonlybody() and $from == 'kanban')
{
@@ -2406,6 +2415,8 @@ class execution extends control
$this->execution->close($executionID);
if(dao::isError()) return print(js::error(dao::getError()));
+ if($execution->type == 'stage') $this->loadModel('programplan')->computeProgress($executionID, 'close');
+
$this->executeHooks($executionID);
if(isonlybody() and $from == 'kanban')
{
@@ -3078,6 +3089,8 @@ class execution extends control
$this->execution->updateUserView($executionID);
$this->loadModel('common')->syncPPEStatus($executionID);
+ if($execution->type == 'stage') $this->loadModel('programplan')->computeProgress($executionID);
+
$this->session->set('execution', '');
$message = $this->executeHooks($executionID);
if($message) $this->lang->saveSuccess = $message;
diff --git a/module/execution/lang/de.php b/module/execution/lang/de.php
index 7ee7f5d3e9..6f7fd0d75d 100644
--- a/module/execution/lang/de.php
+++ b/module/execution/lang/de.php
@@ -547,11 +547,29 @@ $lang->execution->action->startbychildactivate = '$date, activating the sub stag
$lang->execution->action->waitbychilddelete = '$date, deleting the sub stage sets the execution status as waitting.' . "\n";
$lang->execution->action->closebychilddelete = '$date, deleting the sub stage sets the execution status as closing.' . "\n";
$lang->execution->action->closebychildclose = '$date, closing the sub stage sets the execution status as closing.' . "\n";
+$lang->execution->action->waitbychild = '$date, the stage status is Wait as the system judges that all its sub-stages statuses are Wait.';
+$lang->execution->action->suspendedbychild = '$date, the stage status is Suspended as the system judges that all its sub-stages statuses are Suspended.';
+$lang->execution->action->closedbychild = '$date, the stage status is Closed as the system judges that all its sub-stages are Closed.';
+$lang->execution->action->startbychildstart = '$date, the stage status is Doing as the system judges that its sub-stages are Started.';
+$lang->execution->action->startbychildactivate = '$date, the stage status is Doing as the system judges that its sub-stages are Activated.';
+$lang->execution->action->startbychildsuspend = '$date, the stage status is Doing as the system judges that its sub-stages are Suspended.';
+$lang->execution->action->startbychildclose = '$date, the stage status is Doing as the system judges that its sub-stages are Closed.';
+$lang->execution->action->startbychildcreate = '$date, the stage status is Doing as the system judges that its sub-stages are Created. ';
+$lang->execution->action->startbychild = '$date, the stage status is Doing as the system judges that its sub-stages are Activated.';
$lang->execution->startbychildactivate = 'activated';
$lang->execution->waitbychilddelete = 'stop';
$lang->execution->closebychilddelete = 'closed';
$lang->execution->closebychildclose = 'closed';
+$lang->execution->waitbychild = 'activated';
+$lang->execution->suspendedbychild = 'suspended';
+$lang->execution->closedbychild = 'closed';
+$lang->execution->startbychildstart = 'started';
+$lang->execution->startbychildactivate = 'activated';
+$lang->execution->startbychildsuspend = 'activated';
+$lang->execution->startbychildclose = 'activated';
+$lang->execution->startbychildcreate = 'activated';
+$lang->execution->startbychild = 'activated';
$lang->execution->statusColorList = array();
$lang->execution->statusColorList['wait'] = '#0991FF';
diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php
index 12c5dcb84d..ce6efa9485 100644
--- a/module/execution/lang/en.php
+++ b/module/execution/lang/en.php
@@ -547,11 +547,29 @@ $lang->execution->action->startbychildactivate = '$date, activating the sub stag
$lang->execution->action->waitbychilddelete = '$date, deleting the sub stage sets the execution status as waitting.' . "\n";
$lang->execution->action->closebychilddelete = '$date, deleting the sub stage sets the execution status as closing.' . "\n";
$lang->execution->action->closebychildclose = '$date, closing the sub stage sets the execution status as closing.' . "\n";
+$lang->execution->action->waitbychild = '$date, the stage status is Wait as the system judges that all its sub-stages statuses are Wait.';
+$lang->execution->action->suspendedbychild = '$date, the stage status is Suspended as the system judges that all its sub-stages statuses are Suspended.';
+$lang->execution->action->closedbychild = '$date, the stage status is Closed as the system judges that all its sub-stages are Closed.';
+$lang->execution->action->startbychildstart = '$date, the stage status is Doing as the system judges that its sub-stages are Started.';
+$lang->execution->action->startbychildactivate = '$date, the stage status is Doing as the system judges that its sub-stages are Activated.';
+$lang->execution->action->startbychildsuspend = '$date, the stage status is Doing as the system judges that its sub-stages are Suspended.';
+$lang->execution->action->startbychildclose = '$date, the stage status is Doing as the system judges that its sub-stages are Closed.';
+$lang->execution->action->startbychildcreate = '$date, the stage status is Doing as the system judges that its sub-stages are Created. ';
+$lang->execution->action->startbychild = '$date, the stage status is Doing as the system judges that its sub-stages are Activated.';
$lang->execution->startbychildactivate = 'activated';
$lang->execution->waitbychilddelete = 'stop';
$lang->execution->closebychilddelete = 'closed';
$lang->execution->closebychildclose = 'closed';
+$lang->execution->waitbychild = 'activated';
+$lang->execution->suspendedbychild = 'suspended';
+$lang->execution->closedbychild = 'closed';
+$lang->execution->startbychildstart = 'started';
+$lang->execution->startbychildactivate = 'activated';
+$lang->execution->startbychildsuspend = 'activated';
+$lang->execution->startbychildclose = 'activated';
+$lang->execution->startbychildcreate = 'activated';
+$lang->execution->startbychild = 'activated';
$lang->execution->statusColorList = array();
$lang->execution->statusColorList['wait'] = '#0991FF';
diff --git a/module/execution/lang/fr.php b/module/execution/lang/fr.php
index dbc35313b1..cc7f6e8bd5 100644
--- a/module/execution/lang/fr.php
+++ b/module/execution/lang/fr.php
@@ -547,11 +547,29 @@ $lang->execution->action->startbychildactivate = '$date, activating the sub stag
$lang->execution->action->waitbychilddelete = '$date, deleting the sub stage sets the execution status as waitting.' . "\n";
$lang->execution->action->closebychilddelete = '$date, deleting the sub stage sets the execution status as closing.' . "\n";
$lang->execution->action->closebychildclose = '$date, closing the sub stage sets the execution status as closing.' . "\n";
+$lang->execution->action->waitbychild = '$date, the stage status is Wait as the system judges that all its sub-stages statuses are Wait.';
+$lang->execution->action->suspendedbychild = '$date, the stage status is Suspended as the system judges that all its sub-stages statuses are Suspended.';
+$lang->execution->action->closedbychild = '$date, the stage status is Closed as the system judges that all its sub-stages are Closed.';
+$lang->execution->action->startbychildstart = '$date, the stage status is Doing as the system judges that its sub-stages are Started.';
+$lang->execution->action->startbychildactivate = '$date, the stage status is Doing as the system judges that its sub-stages are Activated.';
+$lang->execution->action->startbychildsuspend = '$date, the stage status is Doing as the system judges that its sub-stages are Suspended.';
+$lang->execution->action->startbychildclose = '$date, the stage status is Doing as the system judges that its sub-stages are Closed.';
+$lang->execution->action->startbychildcreate = '$date, the stage status is Doing as the system judges that its sub-stages are Created. ';
+$lang->execution->action->startbychild = '$date, the stage status is Doing as the system judges that its sub-stages are Activated.';
$lang->execution->startbychildactivate = 'activated';
$lang->execution->waitbychilddelete = 'stop';
$lang->execution->closebychilddelete = 'closed';
$lang->execution->closebychildclose = 'closed';
+$lang->execution->waitbychild = 'activated';
+$lang->execution->suspendedbychild = 'suspended';
+$lang->execution->closedbychild = 'closed';
+$lang->execution->startbychildstart = 'started';
+$lang->execution->startbychildactivate = 'activated';
+$lang->execution->startbychildsuspend = 'activated';
+$lang->execution->startbychildclose = 'activated';
+$lang->execution->startbychildcreate = 'activated';
+$lang->execution->startbychild = 'activated';
$lang->execution->statusColorList = array();
$lang->execution->statusColorList['wait'] = '#0991FF';
diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php
index dd5445a1c7..7a21b6c54d 100644
--- a/module/execution/lang/zh-cn.php
+++ b/module/execution/lang/zh-cn.php
@@ -547,11 +547,30 @@ $lang->execution->action->startbychildactivate = '$date, 系统判断由于子
$lang->execution->action->waitbychilddelete = '$date, 系统判断由于子阶段删除,将' . $lang->executionCommon . '状态置为未开始。' . "\n";
$lang->execution->action->closebychilddelete = '$date, 系统判断由于子阶段删除,将' . $lang->executionCommon . '状态置为已关闭。' . "\n";
$lang->execution->action->closebychildclose = '$date, 系统判断由于子阶段关闭,将' . $lang->executionCommon . '状态置为已关闭。' . "\n";
+$lang->execution->action->waitbychild = '$date, 系统判断由于子阶段 全部为未开始 ,将阶段状态置为 未开始 。';
+$lang->execution->action->suspendedbychild = '$date, 系统判断由于子阶段 全部挂起 ,将阶段状态置为 已挂起 。';
+$lang->execution->action->closedbychild = '$date, 系统判断由于子阶段 全部关闭 ,将阶段状态置为 已关闭 。';
+$lang->execution->action->startbychildstart = '$date, 系统判断由于子阶段 开始 ,将阶段状态置为 进行中 。';
+$lang->execution->action->startbychildactivate = '$date, 系统判断由于子阶段 激活 ,将阶段状态置为 进行中 。';
+$lang->execution->action->startbychildsuspend = '$date, 系统判断由于子阶段 挂起 ,将阶段状态置为 进行中 。';
+$lang->execution->action->startbychildclose = '$date, 系统判断由于子阶段 关闭 ,将阶段状态置为 进行中 。';
+$lang->execution->action->startbychildcreate = '$date, 系统判断由于 创建 子阶段 ,将阶段状态置为 进行中 。';
+$lang->execution->action->startbychild = '$date, 系统判断由于子阶段 激活 ,将阶段状态置为 进行中 。';
+
$lang->execution->startbychildactivate = '激活了';
$lang->execution->waitbychilddelete = '停止了';
$lang->execution->closebychilddelete = '关闭了';
$lang->execution->closebychildclose = '关闭了';
+$lang->execution->waitbychild = '激活了';
+$lang->execution->suspendedbychild = '挂起了';
+$lang->execution->closedbychild = '关闭了';
+$lang->execution->startbychildstart = '开始了';
+$lang->execution->startbychildactivate = '激活了';
+$lang->execution->startbychildsuspend = '激活了';
+$lang->execution->startbychildclose = '激活了';
+$lang->execution->startbychildcreate = '激活了';
+$lang->execution->startbychild = '激活了';
$lang->execution->statusColorList = array();
$lang->execution->statusColorList['wait'] = '#0991FF';
diff --git a/module/execution/model.php b/module/execution/model.php
index d8beaadca8..0dcb765c03 100755
--- a/module/execution/model.php
+++ b/module/execution/model.php
@@ -1078,17 +1078,6 @@ class executionModel extends model
$this->action->logHistory($actionID, $changes);
}
- /* Update the status of the parent stage. */
- if($oldExecution->type == 'stage')
- {
- $parent = $this->getByID($oldExecution->parent);
- if($parent->type == 'stage' and in_array($parent->status, array('closed', 'wait')))
- {
- $this->dao->update(TABLE_EXECUTION)->set('status')->eq('doing')->where('id')->eq($parent->id)->exec();
- $this->loadModel('action')->create('execution', $parent->id, 'startbychildactivate');
- }
- }
-
return $changes;
}
@@ -1141,27 +1130,6 @@ class executionModel extends model
$this->action->logHistory($actionID, $changes);
}
- /* Update the status of the parent stage. */
- if($oldExecution->type == 'stage')
- {
- $parent = $this->getByID($oldExecution->parent);
- if($parent->type == 'stage')
- {
- $isClosed = true;
- $children = $this->getChildExecutions($oldExecution->parent);
- foreach($children as $childID => $childExecution)
- {
- if($childExecution->status != 'closed') $isClosed = false;
- }
-
- if($isClosed)
- {
- $this->dao->update(TABLE_EXECUTION)->set('status')->eq('closed')->where('id')->eq($parent->id)->exec();
- $this->loadModel('action')->create('execution', $parent->id, 'closebychildclose');
- }
- }
- }
-
$this->loadModel('score')->create('execution', 'close', $oldExecution);
return $changes;
}
diff --git a/module/programplan/model.php b/module/programplan/model.php
index 7d2c7f50fb..f50d0ccf92 100755
--- a/module/programplan/model.php
+++ b/module/programplan/model.php
@@ -971,6 +971,8 @@ class programplanModel extends model
{
$this->action->create('execution', $stageID, 'opened');
}
+
+ $this->computeProgress($stageID, 'create');
}
}
@@ -1380,4 +1382,73 @@ class programplanModel extends model
return $parentStage;
}
+
+ /**
+ * Compute stage status.
+ *
+ * @param int $stage
+ * @param strihg $action
+ * @access public
+ * @return void
+ */
+ public function computeProgress($stageID, $action = '')
+ {
+ $stage = $this->loadModel('execution')->getByID($stageID);
+ if(empty($stage) or empty($stage->path) or $stage->type != 'stage') return false;
+
+ $this->loadModel('execution');
+ $this->loadModel('action');
+ $action = strtolower($action);
+ $parentIdList = explode(',', trim($stage->path, ','));
+ $parentIdList = array_reverse($parentIdList);
+ foreach($parentIdList as $id)
+ {
+ $parent = $this->execution->getByID($id);
+ if($parent->type != 'stage' or $id == $stageID) continue;
+
+ $statusCount = array();
+ $children = $this->execution->getChildExecutions($parent->id);
+ foreach($children as $childID => $childExecution) $statusCount[$childExecution->status] = empty($statusCount[$childExecution->status]) ? 1 : $statusCount[$childExecution->status] ++;
+
+ if(isset($statusCount['wait']) and count($statusCount) == 1)
+ {
+ if($parent->status != 'wait')
+ {
+ $parentStatus = 'wait';
+ $parentAction = 'waitbychild';
+ }
+ }
+ elseif(isset($statusCount['suspended']) and count($statusCount) == 1)
+ {
+ if($parent->status != 'suspended')
+ {
+ $parentStatus = 'suspended';
+ $parentAction = 'suspendedbychild';
+ }
+ }
+ elseif(isset($statusCount['closed']) and count($statusCount) == 1)
+ {
+ if($parent->status != 'closed')
+ {
+ $parentStatus = 'closed';
+ $parentAction = 'closedbychild';
+ }
+ }
+ else
+ {
+ if($parent->status != 'doing')
+ {
+ $parentStatus = 'doing';
+ $parentAction = 'startbychild' . $action;
+ }
+ }
+
+ if(isset($parentStatus))
+ {
+ $this->dao->update(TABLE_EXECUTION)->set('status')->eq($parentStatus)->where('id')->eq($id)->exec();
+ $this->action->create('execution', $id, $parentAction, '', $parentAction);
+ }
+ unset($parentStatus, $parentAction);
+ }
+ }
}