diff --git a/module/action/lang/en.php b/module/action/lang/en.php
index d045effa17..bfc56b0c8b 100755
--- a/module/action/lang/en.php
+++ b/module/action/lang/en.php
@@ -322,6 +322,11 @@ $lang->action->label->importfromgitlab = 'Issue associate created';
$lang->action->label->archived = 'Archived';
$lang->action->label->restore = 'Restore';
$lang->action->label->mergedbranch = 'Merge Branch';
+$lang->action->label->startedbychild = 'started';
+$lang->action->label->finishedbychild = 'finished';
+$lang->action->label->closedbychild = 'closed';
+$lang->action->label->activatedbychild = 'activated';
+$lang->action->label->createchild = 'activated';
/* Dynamic information is grouped by object. */
$lang->action->dynamicAction = new stdclass;
diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php
index 30d5b50672..0e37b51d33 100755
--- a/module/action/lang/zh-cn.php
+++ b/module/action/lang/zh-cn.php
@@ -322,6 +322,11 @@ $lang->action->label->importfromgitlab = '从Gitlab关联创建了';
$lang->action->label->archived = '归档了';
$lang->action->label->restore = '还原了';
$lang->action->label->mergedbranch = '合并分支';
+$lang->action->label->startedbychild = '开始了';
+$lang->action->label->finishedbychild = '完成了';
+$lang->action->label->closedbychild = '关闭了';
+$lang->action->label->activatedbychild = '激活了';
+$lang->action->label->createchild = '激活了';
/* 动态信息按照对象分组 */
$lang->action->dynamicAction = new stdclass();
diff --git a/module/action/model.php b/module/action/model.php
index ca1ef97a30..8e38ef3475 100755
--- a/module/action/model.php
+++ b/module/action/model.php
@@ -467,7 +467,7 @@ class actionModel extends model
$name = $this->dao->select('name')->from(TABLE_TESTSUITE)->where('id')->eq($action->extra)->fetch('name');
if($name) $action->extra = common::hasPriv('caselib', 'browse') ? html::a(helper::createLink('caselib', 'browse', "libID=$action->extra"), $name) : $name;
}
- elseif(strpos('importfromstorylib,importfromrisklib,importfromissuelib,importfromopportunitylib', $actionName)!== false)
+ elseif(strpos('importfromstorylib,importfromrisklib,importfromissuelib,importfromopportunitylib', $actionName) !== false)
{
$name = $this->dao->select('name')->from(TABLE_ASSETLIB)->where('id')->eq($action->extra)->fetch('name');
if($name) $action->extra = common::hasPriv('assetlib', $action->objectType) ? html::a(helper::createLink('assetlib', $action->objectType, "libID=$action->extra"), $name) : $name;
@@ -707,7 +707,7 @@ class actionModel extends model
{
$desc = $this->lang->$objectType->action->rejectreviewed;
}
- elseif($action->objectType == 'productplan' and in_array($action->action, array('startedbychild','finishedbychild','closedbychild','activatedbychild')))
+ elseif($action->objectType == 'productplan' and in_array($action->action, array('startedbychild','finishedbychild','closedbychild','activatedbychild', 'createchild')))
{
$desc = $this->lang->$objectType->action->changebychild;
}
diff --git a/module/productplan/control.php b/module/productplan/control.php
index bf38515c12..a1af2406bf 100644
--- a/module/productplan/control.php
+++ b/module/productplan/control.php
@@ -66,6 +66,9 @@ class productplan extends control
$this->executeHooks($planID);
+ if($parent > 0) $this->productplan->updateParentStatus($parent);
+ if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
+
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $planID));
if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => 'parent.refreshPlan()'));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('productplan', 'browse', "productID=$productID&branch=$branchID&browseType=wait")));
@@ -358,6 +361,8 @@ class productplan extends control
if($plan->parent > 0) $this->view->parentPlan = $this->productplan->getById($plan->parent);
if($plan->parent == '-1') $this->view->childrenPlans = $this->productplan->getChildren($plan->id);
+ if($plan->branch > 0) $this->view->branchStatus = $this->loadModel('branch')->getById($plan->branch, $plan->product, 'status');
+
$this->loadModel('datatable');
$this->view->modulePairs = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, 'all');
$this->view->title = "PLAN #$plan->id $plan->title/" . zget($products, $plan->product, '');
@@ -398,6 +403,18 @@ class productplan extends control
public function start($planID, $confirm = 'no')
{
$plan = $this->productplan->getByID($planID);
+
+ if($_POST)
+ {
+ $changes = $this->productplan->start($planID);
+ if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
+
+ $actionID = $this->loadModel('action')->create('productplan', $planID, 'started');
+ $this->action->logHistory($actionID, $changes);
+
+ return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
+ }
+
if(!isonlybody())
{
if($confirm == 'no')
@@ -406,22 +423,14 @@ class productplan extends control
}
else
{
- $changes = $this->productplan->updateStatus($planID, 'doing');
- if(dao::isError()) die(js::error(dao::getError()));
+ $this->productplan->updateStatus($planID, 'doing', 'started');
+ if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
else
{
- if(!empty($_POST))
- {
- $changes = $this->productplan->updateStatus($planID, 'doing');
- if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
-
- return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess,'locate' => 'parent'));
- }
-
$this->view->plan = $plan;
$this->display();
}
@@ -443,9 +452,9 @@ class productplan extends control
}
else
{
- $changes = $this->productplan->updateStatus($planID, 'done');
- if(dao::isError()) die(js::error(dao::getError()));
+ $this->productplan->updateStatus($planID, 'done', 'finished');
+ if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
@@ -466,9 +475,9 @@ class productplan extends control
}
else
{
- $changes = $this->productplan->updateStatus($planID, 'closed');
- if(dao::isError()) die(js::error(dao::getError()));
+ $this->productplan->updateStatus($planID, 'closed', 'closed');
+ if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
@@ -489,9 +498,9 @@ class productplan extends control
}
else
{
- $changes = $this->productplan->updateStatus($planID, 'doing');
- if(dao::isError()) die(js::error(dao::getError()));
+ $this->productplan->updateStatus($planID, 'doing', 'activated');
+ if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
diff --git a/module/productplan/css/browse.css b/module/productplan/css/browse.css
index b5607f9b1b..6faa03c442 100644
--- a/module/productplan/css/browse.css
+++ b/module/productplan/css/browse.css
@@ -24,7 +24,8 @@ td.c-branch {overflow: hidden; text-align: left !important; text-overflow: ellip
.plan-name {position: relative; display: flex; align-items: center;}
.plan-name > span {flex: none;}
-#productplanList .c-title.has-child > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 62px);}
+[lang^='zh-'] #productplanList .c-title.has-child > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 62px);}
+[lang^='en'] #productplanList .c-title.has-child > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 67px);}
#productplanList .c-title.has-child > .plan-name > a {overflow:hidden; max-width: calc(100% - 16px);}
#productplanList .c-title > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 46px);}
#productplanList .plan-name.expired > .label.label-danger {margin-left:3px; }
diff --git a/module/productplan/lang/en.php b/module/productplan/lang/en.php
index 502b26c1cc..9b81014ee9 100644
--- a/module/productplan/lang/en.php
+++ b/module/productplan/lang/en.php
@@ -18,12 +18,11 @@ $lang->productplan->delete = "Delete Plan";
$lang->productplan->start = "Start Plan";
$lang->productplan->finish = "Finish Plan";
$lang->productplan->close = "Close Plan";
+$lang->productplan->activate = "Activate Plan";
$lang->productplan->startAB = "Start";
$lang->productplan->finishAB = "Finish";
$lang->productplan->closeAB = "Close";
$lang->productplan->activateAB = "Activate";
-$lang->productplan->view = "Plan Detail";
-$lang->productplan->activate = "Activate Plan";
$lang->productplan->view = "View";
$lang->productplan->bugSummary = "Total %s Bugs on this page.";
$lang->productplan->basicInfo = 'Basic Info';
@@ -102,6 +101,7 @@ $lang->productplan->parentActionList['startedbychild'] = 'starting productplan->parentActionList['finishedbychild'] = 'finishing all productplan sets the plan status as Done.';
$lang->productplan->parentActionList['closedbychild'] = 'closing all productplan sets the plan status as Closed.';
$lang->productplan->parentActionList['activatedbychild'] = 'activating the productplan sets the plan status as Doing.';
+$lang->productplan->parentActionList['createchild'] = 'creating a child productplan sets the plan status as Doing.';
$lang->productplan->endList[7] = '1 Week';
$lang->productplan->endList[14] = '2 Weeks';
diff --git a/module/productplan/lang/zh-cn.php b/module/productplan/lang/zh-cn.php
index d06030bd28..fd6d0e2d24 100644
--- a/module/productplan/lang/zh-cn.php
+++ b/module/productplan/lang/zh-cn.php
@@ -101,6 +101,7 @@ $lang->productplan->parentActionList['startedbychild'] = '系统判断由于
$lang->productplan->parentActionList['finishedbychild'] = '系统判断由于子计划 全部完成 ,将计划状态置为 已完成 。';
$lang->productplan->parentActionList['closedbychild'] = '系统判断由于子计划 全部关闭 ,将计划状态置为 已关闭 。';
$lang->productplan->parentActionList['activatedbychild'] = '系统判断由于子计划 激活 ,将计划状态置为 进行中 。';
+$lang->productplan->parentActionList['createchild'] = '系统判断由于 创建 子计划 ,将计划状态置为 进行中 。';
$lang->productplan->endList[7] = '一星期';
$lang->productplan->endList[14] = '两星期';
diff --git a/module/productplan/model.php b/module/productplan/model.php
index 5520e788e0..8a1d88be5a 100644
--- a/module/productplan/model.php
+++ b/module/productplan/model.php
@@ -501,6 +501,7 @@ class productplanModel extends model
->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin)
->where('id')->eq((int)$planID)
->exec();
+
if(!dao::isError())
{
$this->file->updateObjectID($this->post->uid, $planID, 'plan');
@@ -509,142 +510,114 @@ class productplanModel extends model
}
/**
- * Update a plan's status.
- *
- * @param int $planID
- * @param string $status
+ * Start a plan.
+ *
+ * @param int $planID
* @access public
- * @return string
+ * @return array
*/
- public function updateStatus($planID, $status = '')
+ public function start($planID)
{
- $planID = (int)$planID;
$oldPlan = $this->getByID($planID);
- if($oldPlan->parent > 0)
- {
- $parentPlan = $this->getByID($oldPlan->parent);
- $parentChange = false;
- }
+ $plan = fixer::input('post')
+ ->add('status', 'doing')
+ ->stripTags($this->config->productplan->editor->start['id'], $this->config->allowedTags)
+ ->remove('uid')
+ ->get();
- if($status == 'doing' and !empty($_POST))
- {
- $plan = fixer::input('post')
- ->add('status', $status)
- ->stripTags($this->config->productplan->editor->start['id'], $this->config->allowedTags)
- ->remove('uid')
- ->get();
+ $this->checkDate4Plan($oldPlan, $plan->begin, $plan->end);
+ if(dao::isError()) return false;
- $this->checkDate4Plan($oldPlan, $plan->begin, $plan->end);
- if(dao::isError()) return false;
- $plan = $this->loadModel('file')->processImgURL($plan, $this->config->productplan->editor->start['id'], $this->post->uid);
+ $plan = $this->loadModel('file')->processImgURL($plan, $this->config->productplan->editor->start['id'], $this->post->uid);
- $this->dao->update(TABLE_PRODUCTPLAN)
- ->data($plan)
- ->autoCheck()
- ->batchCheck($this->config->productplan->start->requiredFields, 'notempty')
- ->checkIF(!empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin)
- ->where('id')->eq($planID)
- ->exec();
-
- $this->file->updateObjectID($this->post->uid, $planID, 'productplan');
-
- if(isset($parentPlan) and $parentPlan->status != 'doing')
- {
- $this->dao->update(TABLE_PRODUCTPLAN)->set('status')->eq($status)->where('id')->eq($oldPlan->parent)->exec();
- $parentChange = true;
- }
- }
- elseif($status == 'doing' and isset($parentPlan) and $parentPlan->status != 'doing')
- {
- $this->dao->update(TABLE_PRODUCTPLAN)
- ->set('`status`')->eq($status)
- ->where('id')->eq($planID)
- ->orWhere('id')->eq($oldPlan->parent)
- ->exec();
- if($parentPlan->status != 'doing') $parentChange = true;
- }
- elseif($status == 'done' and isset($parentPlan))
- {
- $parentDone = true;
- $childPlans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($oldPlan->parent)->andWhere('deleted')->eq(0)->fetchAll();
- foreach($childPlans as $childPlan )
- {
- if(in_array($childPlan->status, array('wait', 'doing')) and $planID != $childPlan->id)
- {
- $parentDone = false;
- break;
- }
- }
- if($parentDone) $parentChange = true;
- $this->dao->update(TABLE_PRODUCTPLAN)
- ->set('`status`')->eq($status)
- ->where('id')->eq($planID)
- ->beginIF($parentDone)->orWhere('id')->eq($oldPlan->parent)->fi()
- ->exec();
- }
- elseif($status == 'closed' and isset($parentPlan))
- {
- $parentClosed = true;
- $childPlans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($oldPlan->parent)->andWhere('deleted')->eq(0)->fetchAll();
- foreach($childPlans as $childPlan)
- {
- if(in_array($childPlan->status, array('wait', 'doing', 'done')) and $planID != $childPlan->id)
- {
- $parentClosed = false;
- break;
- }
- }
- if($parentClosed) $parentChange = true;
- $this->dao->update(TABLE_PRODUCTPLAN)
- ->set('`status`')->eq($status)
- ->where('id')->eq($planID)
- ->beginIF($parentClosed)->orWhere('id')->eq($oldPlan->parent)->fi()
- ->exec();
- }
- else
- {
- $this->dao->update(TABLE_PRODUCTPLAN)
- ->set('`status`')->eq($status)
- ->where('id')->eq($planID)
- ->exec();
- }
+ $this->dao->update(TABLE_PRODUCTPLAN)
+ ->data($plan)
+ ->autoCheck()
+ ->batchCheck($this->config->productplan->start->requiredFields, 'notempty')
+ ->checkIF(!empty($plan->begin) and !empty($plan->end), 'end', 'ge', $plan->begin)
+ ->where('id')->eq($planID)
+ ->exec();
if(dao::isError()) return false;
- if(!isset($plan)) $plan = $this->getByID($planID);
- if(!dao::isError())
+ if($oldPlan->parent > 0) $this->updateParentStatus($oldPlan->parent, 'started');
+ $this->file->updateObjectID($this->post->uid, $planID, 'productplan');
+
+ return common::createChanges($oldPlan, $plan);
+ }
+
+ /**
+ * Update a plan's status.
+ *
+ * @param int $planID
+ * @param string $status doing|done|closed
+ * @param string $action started|finished|closed|activated
+ * @access public
+ * @return array
+ */
+ public function updateStatus($planID, $status = '', $action = '')
+ {
+ $oldPlan = $this->getByID($planID);
+
+ $plan = new stdclass();
+ $plan->status = $status;
+
+ $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->where('id')->eq($planID)->exec();
+
+ if(dao::isError()) return false;
+
+ $changes = common::createChanges($oldPlan, $plan);
+ $actionID = $this->loadModel('action')->create('productplan', $planID, $action);
+ $this->action->logHistory($actionID, $changes);
+
+ if($oldPlan->parent > 0) $this->updateParentStatus($oldPlan->parent, $action);
+
+ return !dao::isError();
+ }
+
+ /**
+ * Update a parent plan's status.
+ *
+ * @param int $parentID
+ * @param string $action started|finished|closed|activated
+ * @access public
+ * @return void
+ */
+ public function updateParentStatus($parentID, $action)
+ {
+ $parent = $this->getByID($parentID);
+ $childStatus = $this->dao->select('status')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($parentID)->andWhere('deleted')->eq(0)->fetchPairs();
+
+ switch($action)
{
- $method = $this->app->rawMethod;
- if($method == 'start')
- {
- $action = 'started';
- if(isset($parentChange) and $parentChange) $parentAction = 'startedbychild';
- }
- elseif($method == 'finish')
- {
- $action = 'finished';
- if(isset($parentChange) and $parentChange) $parentAction = 'finishedbychild';
- }
- elseif($method == 'close')
- {
- $action = 'closed';
- if(isset($parentChange) and $parentChange) $parentAction = 'closedbychild';
- }
- elseif($method == 'activate')
- {
- $action = 'activated';
- if(isset($parentChange) and $parentChange) $parentAction = 'activatedbychild';
- }
-
- if(isset($action))
- {
- $changes = common::createChanges($oldPlan, $plan);
- $actionID = $this->loadModel('action')->create('productplan', $planID, $action);
- $this->action->loghistory($actionID, $changes);
-
- if(isset($parentChange) and $parentChange) $actionID = $this->action->create('productplan', $oldPlan->parent, $parentAction, '', $parentAction);
- }
+ case 'started':
+ $parentStatus = 'doing';
+ $parentAction = $parent->status != 'doing' ? 'startedbychild' : '';
+ break;
+ case 'finished':
+ if(count($childStatus) == 1 and $parent->status != 'done')
+ {
+ $parentStatus = 'done';
+ $parentAction = 'finishedbychild';
+ }
+ break;
+ case 'closed':
+ if(count($childStatus) == 1 and $parent->status != 'closed')
+ {
+ $parentAction = 'closedbychild';
+ $parentStatus = 'closed';
+ }
+ break;
+ case 'activated':
+ $parentStatus = 'doing';
+ $parentAction = $parent->status != 'doing' ? 'activatedbychild' : '';
+ break;
}
+
+ if(isset($parentStatus)) $this->dao->update(TABLE_PRODUCTPLAN)->set('status')->eq($parentStatus)->where('id')->eq($parentID)->exec();
+ if(isset($parentAction)) $this->loadModel('action')->create('productplan', $parentID, $parentAction, '', $parentAction);
+
+ return !dao::isError();
}
/**
diff --git a/module/productplan/view/browsebylist.html.php b/module/productplan/view/browsebylist.html.php
index e8211be927..236571474e 100644
--- a/module/productplan/view/browsebylist.html.php
+++ b/module/productplan/view/browsebylist.html.php
@@ -78,7 +78,6 @@
loadModel('file');?>
-
end < $today and in_array($plan->status, array('wait', 'doing')))
+ if($plan->expired and in_array($plan->status, array('wait', 'doing')))
{
$class .= ' expired';
$expired = "{$this->lang->productplan->expired}";
@@ -159,12 +158,13 @@
$attr = "data-id='{$plan->id}' data-width='550px'";
$isOnlyBody = true;
}
- common::printIcon('productplan', 'start', "planID=$plan->id", $plan, 'list', 'play', '', $class, $isOnlyBody);
+ common::printIcon('productplan', 'start', "planID=$plan->id", $plan, 'list', 'play', '', $class, $isOnlyBody, $attr);
common::printIcon('productplan', 'finish', "planID=$plan->id", $plan, 'list', 'checked', '', $class, false, $attr);
common::printIcon('productplan', 'close', "planID=$plan->id", $plan, 'list', 'off', '', $class, false, $attr);
}
- $attr = $plan->expired ? "disabled='disabled'" : '';
+ $attr = $plan->expired ? "disabled='disabled'" : '';
+ $disabled = '';
if(common::hasPriv('execution', 'create', $plan) and $plan->parent >= 0)
{
$disabled = '';
@@ -191,13 +191,13 @@
common::printIcon('productplan', 'edit', "planID=$plan->id", $plan, 'list');
if(common::hasPriv('productplan', 'create', $plan))
{
- if($plan->parent > 0 or in_array($plan->status, array('done', 'closed')))
+ if($plan->parent > 0)
{
echo " ";
}
else
{
- echo html::a($this->createLink('productplan', 'create', "product=$productID&branch=$branch&parent={$plan->id}"), "", '', "class='btn' title='{$this->lang->productplan->children}'");
+ echo html::a($this->createLink('productplan', 'create', "product=$productID&branch=$branch&parent={$plan->id}"), "", '', "class='btn {$disabled}' title='{$this->lang->productplan->children}'");
}
}
diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php
index e966ae107a..23c5979e8c 100644
--- a/module/productplan/view/view.html.php
+++ b/module/productplan/view/view.html.php
@@ -63,7 +63,7 @@
common::printLink('productplan', 'activate', "planID=$plan->id", "{$lang->productplan->activateAB}", '', "class='btn btn-link {$class}' target='hiddenwin' title='{$lang->productplan->activate}'", '', false, $plan);
}
- $class = in_array($plan->status, array('done', 'closed')) ? 'disabled' : '';
+ $class= (isset($branchStatus) and $branchStatus == 'closed') ? 'disabled' : '';
if(common::hasPriv('productplan', 'create', $plan) and $plan->parent <= 0) echo html::a($this->createLink('productplan', 'create', "product={$plan->product}&branch={$plan->branch}&parent={$plan->id}"), " " . $this->lang->productplan->children , '', "class='btn btn-link {$class}' title='{$this->lang->productplan->children}'");
if(common::hasPriv('productplan', 'edit', $plan)) echo html::a($this->createLink('productplan', 'edit', "planID=$plan->id"), " " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->edit}'");
if(common::hasPriv('productplan', 'delete', $plan) and $plan->parent >= 0) echo html::a($this->createLink('productplan', 'delete', "planID=$plan->id"), " " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->delete}' target='hiddenwin'");