diff --git a/module/execution/model.php b/module/execution/model.php
index 3df5779489..38257a2002 100644
--- a/module/execution/model.php
+++ b/module/execution/model.php
@@ -960,6 +960,16 @@ class executionModel extends model
}
}
+ /* Update the status of the parent stage. */
+ if($oldExecution->type == 'stage')
+ {
+ $parent = $this->getByID($oldExecution->parent);
+ if($parent->type == 'stage' and $parent->status == 'closed')
+ {
+ $this->dao->update(TABLE_EXECUTION)->set('status')->eq('doing')->where('id')->eq($parent->id)->exec();
+ }
+ }
+
if(!dao::isError()) return common::createChanges($oldExecution, $execution);
}
@@ -1001,6 +1011,23 @@ class executionModel extends model
if(!dao::isError())
{
+ /* 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('score')->create('execution', 'close', $oldExecution);
return common::createChanges($oldExecution, $execution);
}
@@ -1574,7 +1601,7 @@ class executionModel extends model
*/
public function getChildExecutions($executionID)
{
- return $this->dao->select('id, name')->from(TABLE_EXECUTION)->where('parent')->eq((int)$executionID)->fetchPairs();
+ return $this->dao->select('id, name, status')->from(TABLE_EXECUTION)->where('deleted')->eq(0)->andWhere('parent')->eq((int)$executionID)->fetchAll('id');
}
/**
diff --git a/module/execution/view/all.html.php b/module/execution/view/all.html.php
index 102388d861..c3f27fc413 100644
--- a/module/execution/view/all.html.php
+++ b/module/execution/view/all.html.php
@@ -185,12 +185,21 @@
echo common::hasPriv('programplan', 'create') ? html::a('javascript:alert("' . $this->lang->programplan->error->createdTask . '");', '', '', 'class="btn ' . $disabled . '"') : '';
}
- common::printIcon('programplan', 'edit', "planID=$execution->id&projectID=$projectID", $execution, 'list', '', '', 'iframe', true);
+ common::printIcon('programplan', 'edit', "stageID=$execution->id&projectID=$projectID", $execution, 'list', '', '', 'iframe', true);
$disabled = !empty($execution->children) ? ' disabled' : '';
+ if($execution->status != 'closed' and common::hasPriv('execution', 'close', $execution))
+ {
+ common::printIcon('execution', 'close', "stageID=$execution->id", $execution, 'list', 'off', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->close);
+ }
+ elseif($execution->status == 'closed' and common::hasPriv('execution', 'activate', $execution))
+ {
+ common::printIcon('execution', 'activate', "stageID=$execution->id", $execution, 'list', 'magic', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->activate);
+ }
+
if(common::hasPriv('execution', 'delete', $execution))
{
- common::printIcon('execution', 'delete', "planID=$execution->id&confirm=no", $execution, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete);
+ common::printIcon('execution', 'delete', "stageID=$execution->id&confirm=no", $execution, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete);
}
?>
@@ -257,7 +266,7 @@
if($child->grade == 1 && $this->loadModel('programplan')->isCreateTask($child->id))
{
- common::printIcon('programplan', 'create', "program={$child->parent}&productID=$productID&planID=$child->id", $child, 'list', 'split', '', '', '', '', $this->lang->programplan->createSubPlan);
+ common::printIcon('programplan', 'create', "program={$child->parent}&productID=$productID&stageID=$child->id", $child, 'list', 'split', '', '', '', '', $this->lang->programplan->createSubPlan);
}
else
{
@@ -265,12 +274,21 @@
echo html::a('javascript:alert("' . $this->lang->programplan->error->createdTask . '");', '', '', 'class="btn ' . $disabled . '"');
}
- common::printIcon('programplan', 'edit', "planID=$child->id&projectID=$projectID", $child, 'list', '', '', 'iframe', true);
+ common::printIcon('programplan', 'edit', "stageID=$child->id&projectID=$projectID", $child, 'list', '', '', 'iframe', true);
$disabled = !empty($child->children) ? ' disabled' : '';
+ if(common::hasPriv('execution', 'close', $child) and $execution->status != 'closed')
+ {
+ common::printIcon('execution', 'close', "stageID=$child->id", $child, 'list', 'off', '' , $disabled . ' iframe', true, '', $this->lang->programplan->close);
+ }
+ elseif(common::hasPriv('execution', 'activate', $child) and $execution->status == 'closed')
+ {
+ common::printIcon('execution', 'activate', "stageID=$child->id", $child, 'list', 'magic', 'hiddenwin' , $disabled . ' iframe', true, '', $this->lang->programplan->activate);
+ }
+
if(common::hasPriv('execution', 'delete', $child))
{
- common::printIcon('execution', 'delete', "planID=$child->id&confirm=no", $child, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete);
+ common::printIcon('execution', 'delete', "stageID=$child->id&confirm=no", $child, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete);
}
?>
diff --git a/module/programplan/lang/en.php b/module/programplan/lang/en.php
index a3c80fa711..b9ead0dd32 100644
--- a/module/programplan/lang/en.php
+++ b/module/programplan/lang/en.php
@@ -16,6 +16,8 @@ $lang->programplan->list = 'Stage List';
$lang->programplan->create = 'Create';
$lang->programplan->edit = 'Edit';
$lang->programplan->delete = 'Delete Stage';
+$lang->programplan->close = 'Close Stage';
+$lang->programplan->activate = 'Activate Stage';
$lang->programplan->createSubPlan = 'Create Sub Stage';
$lang->programplan->parent = 'Parent Stage';
diff --git a/module/programplan/lang/zh-cn.php b/module/programplan/lang/zh-cn.php
index 494b212d51..2f5390d35e 100644
--- a/module/programplan/lang/zh-cn.php
+++ b/module/programplan/lang/zh-cn.php
@@ -16,6 +16,8 @@ $lang->programplan->list = '阶段列表';
$lang->programplan->create = '设置阶段';
$lang->programplan->edit = '编辑';
$lang->programplan->delete = '删除阶段';
+$lang->programplan->close = '关闭阶段';
+$lang->programplan->activate = '激活阶段';
$lang->programplan->createSubPlan = '创建二级阶段';
$lang->programplan->parent = '父阶段';