* Finish task #83942.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 <strong>Wait</strong> as the system judges that all its sub-stages statuses are <strong>Wait</strong>.';
|
||||
$lang->execution->action->suspendedbychild = '$date, the stage status is <strong>Suspended</strong> as the system judges that all its sub-stages statuses are <strong>Suspended</strong>.';
|
||||
$lang->execution->action->closedbychild = '$date, the stage status is <strong>Closed</strong> as the system judges that all its sub-stages are <strong>Closed</strong>.';
|
||||
$lang->execution->action->startbychildstart = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Started</strong>.';
|
||||
$lang->execution->action->startbychildactivate = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Activated</strong>.';
|
||||
$lang->execution->action->startbychildsuspend = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Suspended</strong>.';
|
||||
$lang->execution->action->startbychildclose = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Closed</strong>.';
|
||||
$lang->execution->action->startbychildcreate = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Created</strong>. ';
|
||||
$lang->execution->action->startbychild = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Activated</strong>.';
|
||||
|
||||
$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';
|
||||
|
||||
@@ -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 <strong>Wait</strong> as the system judges that all its sub-stages statuses are <strong>Wait</strong>.';
|
||||
$lang->execution->action->suspendedbychild = '$date, the stage status is <strong>Suspended</strong> as the system judges that all its sub-stages statuses are <strong>Suspended</strong>.';
|
||||
$lang->execution->action->closedbychild = '$date, the stage status is <strong>Closed</strong> as the system judges that all its sub-stages are <strong>Closed</strong>.';
|
||||
$lang->execution->action->startbychildstart = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Started</strong>.';
|
||||
$lang->execution->action->startbychildactivate = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Activated</strong>.';
|
||||
$lang->execution->action->startbychildsuspend = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Suspended</strong>.';
|
||||
$lang->execution->action->startbychildclose = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Closed</strong>.';
|
||||
$lang->execution->action->startbychildcreate = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Created</strong>. ';
|
||||
$lang->execution->action->startbychild = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Activated</strong>.';
|
||||
|
||||
$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';
|
||||
|
||||
@@ -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 <strong>Wait</strong> as the system judges that all its sub-stages statuses are <strong>Wait</strong>.';
|
||||
$lang->execution->action->suspendedbychild = '$date, the stage status is <strong>Suspended</strong> as the system judges that all its sub-stages statuses are <strong>Suspended</strong>.';
|
||||
$lang->execution->action->closedbychild = '$date, the stage status is <strong>Closed</strong> as the system judges that all its sub-stages are <strong>Closed</strong>.';
|
||||
$lang->execution->action->startbychildstart = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Started</strong>.';
|
||||
$lang->execution->action->startbychildactivate = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Activated</strong>.';
|
||||
$lang->execution->action->startbychildsuspend = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Suspended</strong>.';
|
||||
$lang->execution->action->startbychildclose = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Closed</strong>.';
|
||||
$lang->execution->action->startbychildcreate = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Created</strong>. ';
|
||||
$lang->execution->action->startbychild = '$date, the stage status is <strong>Doing</strong> as the system judges that its sub-stages are <strong>Activated</strong>.';
|
||||
|
||||
$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';
|
||||
|
||||
@@ -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, 系统判断由于子阶段 <strong>全部为未开始</strong> ,将阶段状态置为 <strong>未开始</strong> 。';
|
||||
$lang->execution->action->suspendedbychild = '$date, 系统判断由于子阶段 <strong>全部挂起</strong> ,将阶段状态置为 <strong>已挂起</strong> 。';
|
||||
$lang->execution->action->closedbychild = '$date, 系统判断由于子阶段 <strong>全部关闭</strong> ,将阶段状态置为 <strong>已关闭</strong> 。';
|
||||
$lang->execution->action->startbychildstart = '$date, 系统判断由于子阶段 <strong>开始</strong> ,将阶段状态置为 <strong>进行中</strong> 。';
|
||||
$lang->execution->action->startbychildactivate = '$date, 系统判断由于子阶段 <strong>激活</strong> ,将阶段状态置为 <strong>进行中</strong> 。';
|
||||
$lang->execution->action->startbychildsuspend = '$date, 系统判断由于子阶段 <strong>挂起</strong> ,将阶段状态置为 <strong>进行中</strong> 。';
|
||||
$lang->execution->action->startbychildclose = '$date, 系统判断由于子阶段 <strong>关闭</strong> ,将阶段状态置为 <strong>进行中</strong> 。';
|
||||
$lang->execution->action->startbychildcreate = '$date, 系统判断由于 <strong>创建</strong> 子阶段 ,将阶段状态置为 <strong>进行中</strong> 。';
|
||||
$lang->execution->action->startbychild = '$date, 系统判断由于子阶段 <strong>激活</strong> ,将阶段状态置为 <strong>进行中</strong> 。';
|
||||
|
||||
|
||||
$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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user