diff --git a/module/build/control.php b/module/build/control.php index 50a6307618..09736c9ac9 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -72,7 +72,7 @@ class build extends control if($this->app->tab == 'project') { $this->project->setMenu($projectID); - $executions = $this->execution->getPairs($projectID, 'all', 'stagefilter'); + $executions = $this->execution->getPairs($projectID, 'all', 'stagefilter|leaf'); $executionID = empty($executionID) ? key($executions) : $executionID; $productGroups = $executionID ? $this->product->getProducts($executionID) : array(); $branchGroups = $executionID ? $this->project->getBranchesByProject($executionID) : array(); @@ -81,7 +81,7 @@ class build extends control elseif($this->app->tab == 'execution') { $execution = $this->execution->getByID($executionID); - $executions = $this->execution->getPairs($execution->project); + $executions = $this->execution->getPairs($execution->project, 'all', 'stagefilter|leaf'); $projectID = $execution->project; $productGroups = $this->product->getProducts($executionID); $branchGroups = $this->project->getBranchesByProject($executionID); @@ -92,7 +92,7 @@ class build extends control { $execution = $this->execution->getByID($executionID); $projectID = $execution ? $execution->project : 0; - $executions = $this->execution->getPairs($projectID); + $executions = $this->execution->getPairs($projectID, 'all', 'stagefilter|leaf'); $productGroups = $this->product->getProducts($executionID); $branchGroups = $this->project->getBranchesByProject($executionID); } diff --git a/module/doc/control.php b/module/doc/control.php index 9316978bdd..7447ef0ef7 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -158,6 +158,12 @@ class doc extends control { if($execution->multiple) { + if($execution->type == 'stage' and $execution->grade > 1) + { + $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($execution->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); + $execution->name = implode('/', $parentExecutions); + } + $executionPrefix = isset($projects[$execution->project]) ? $projects[$execution->project] . '/' : ''; $executions[$executionID] = $executionPrefix . $execution->name; } @@ -240,7 +246,16 @@ class doc extends control if(!empty($lib->execution)) { $execution = $this->execution->getByID($lib->execution); - if($execution->type == 'stage') $this->lang->doc->execution = str_replace($this->lang->executionCommon, $this->lang->project->stage, $this->lang->doc->execution); + if($execution->type == 'stage') + { + if($execution->grade > 1) + { + $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($execution->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); + $execution->name = implode('/', $parentExecutions); + } + + $this->lang->doc->execution = str_replace($this->lang->executionCommon, $this->lang->project->stage, $this->lang->doc->execution); + } $this->view->execution = $execution; } diff --git a/module/doc/model.php b/module/doc/model.php index cb32efbaf0..ce35927a4f 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1580,6 +1580,11 @@ class docModel extends model $orderedExecutions = array(); foreach($executions as $id => $execution) { + if($execution->type == 'stage' and $execution->grade != 1) + { + $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($execution->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); + $execution->name = implode('/', $parentExecutions); + } $execution->name = zget($projectPairs, $execution->project) . ' / ' . $execution->name; if($execution->status != 'done' and $execution->status != 'closed' and $execution->PM == $this->app->user->account) 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 44527218a6..3ec0b8fdf8 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; } @@ -1319,7 +1287,7 @@ class executionModel extends model * * @param int $projectID * @param string $type all|sprint|stage|kanban - * @param string $mode all|noclosed|stagefilter|withdelete|multiple or empty + * @param string $mode all|noclosed|stagefilter|withdelete|multiple|leaf or empty * @access public * @return array */ @@ -1356,16 +1324,34 @@ class executionModel extends model ->orderBy($orderBy) ->fetchAll(); + /* If mode == leaf, only show leaf executions. */ + $allExecutions = $this->dao->select('id,name,parent')->from(TABLE_EXECUTION) + ->where('type')->notin(array('program', 'project')) + ->beginIf($projectID)->andWhere('project')->eq($projectID)->fi() + ->fetchAll('id'); + + $parents = array(); + foreach($allExecutions as $exec) + { + $parents[$exec->parent] = true; + } + $pairs = array(); $noMultiples = array(); foreach($executions as $execution) { + if(strpos($mode, 'leaf') !== false and isset($parents[$execution->id])) continue; // Only show leaf. if(strpos($mode, 'noclosed') !== false and ($execution->status == 'done' or $execution->status == 'closed')) continue; if(strpos($mode, 'stagefilter') !== false and isset($executionModel) and $executionModel == 'waterfall' and in_array($execution->attribute, array('request', 'design', 'review'))) continue; // Some stages of waterfall not need. if(empty($execution->multiple)) $noMultiples[$execution->id] = $execution->project; - $pairs[$execution->id] = $execution->name; + /* Set execution name. */ + $paths = array_slice(explode(',', trim($execution->path, ',')), 1); + $executionName = ''; + foreach($paths as $path) $executionName .= '/' . $allExecutions[$path]->name; + + $pairs[$execution->id] = $executionName; } if($noMultiples) @@ -1671,6 +1657,11 @@ class executionModel extends model if($execution->parent < 0 and $execution->type == 'stage') unset($executions[$key]); if($execution->projectName) $execution->name = $execution->projectName . ' / ' . $execution->name; } + elseif($param === 'hasParentName') + { + $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($execution->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); + $executions[$execution->id]->name = implode('/', $parentExecutions); + } else { if(isset($executions[$execution->parent]) and $execution->type == 'stage') diff --git a/module/kanban/control.php b/module/kanban/control.php index ad818eafd1..b7d34684d0 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -1382,7 +1382,7 @@ class kanban extends control $this->view->projects = array($this->lang->kanban->allProjects) + $this->project->getPairsByProgram('', 'all', false, '', '', '', 'multiple'); $this->view->selectedProjectID = $selectedProjectID; $this->view->lanePairs = $this->kanban->getLanePairsByGroup($groupID); - $this->view->executions2Imported = $this->execution->getStatData($selectedProjectID, 'undone', 0, 0, false, '', 'id_asc', $pager); + $this->view->executions2Imported = $this->execution->getStatData($selectedProjectID, 'undone', 0, 0, false, 'hasParentName', 'id_asc', $pager); $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $this->view->pager = $pager; $this->view->kanbanID = $kanbanID; diff --git a/module/kanban/model.php b/module/kanban/model.php index 7b2a72261f..b9e6bbb158 100755 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -1281,6 +1281,9 @@ class kanbanModel extends model } $objectCard->execType = $object->type; $objectCard->progress = isset($executionProgress[$objectID]->progress) ? $executionProgress[$objectID]->progress : 0; + + $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($object->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); + $objectCard->name = implode('/', $parentExecutions); } $objectCard->desc = strip_tags(htmlspecialchars_decode($object->desc)); diff --git a/module/product/model.php b/module/product/model.php index 6aa6f7d2ba..27e201ca0f 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -1438,7 +1438,7 @@ class productModel extends model } $orderBy = $hasWaterfall ? 't2.begin_asc,t2.id_asc' : 't2.begin_desc,t2.id_desc'; - $executions = $this->dao->select('t2.id,t2.name,t2.grade,t2.parent,t2.attribute,t2.multiple,t3.name as projectName')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $executions = $this->dao->select('t2.id,t2.name,t2.grade,t2.path,t2.parent,t2.attribute,t2.multiple,t3.name as projectName')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project = t2.id') ->leftJoin(TABLE_PROJECT)->alias('t3')->on('t2.project = t3.id') ->where('t1.product')->eq($productID) @@ -1452,38 +1452,35 @@ class productModel extends model ->orderBy($orderBy) ->fetchAll('id'); - /* The waterfall project needs to show the hierarchy and remove the parent stage. */ - $executionPairs = array('0' => ''); - if($hasWaterfall) + /* Only show leaf executions. */ + $allExecutions = $this->dao->select('id,name,attribute,parent')->from(TABLE_EXECUTION)->where('type')->notin(array('program', 'project'))->fetchAll('id'); + $parents = array(); + foreach($allExecutions as $exec) { - foreach($executions as $id => $execution) - { - if($execution->grade == 2 and isset($executions[$execution->parent])) - { - $execution->name = $executions[$execution->parent]->name . '/' . $execution->name; - $executions[$execution->parent]->children[$id] = $execution->name; - unset($executions[$id]); - } - } - - foreach($executions as $execution) - { - if(isset($execution->children)) - { - $executionPairs = $executionPairs + $execution->children; - continue; - } - if(strpos($mode, 'stagefilter') !== false and in_array($execution->attribute, array('request', 'design', 'review'))) continue; // Some stages of waterfall not need. - $executionPairs[$execution->id] = $execution->name; - } + $parents[$exec->parent] = true; } - else + + $executionPairs = array('0' => ''); + foreach($executions as $execID=> $execution) { - $this->app->loadLang('project'); - foreach($executions as $execution) + if(isset($parents[$execID])) continue; // Only show leaf. + if(strpos($mode, 'stagefilter') !== false and in_array($execution->attribute, array('request', 'design', 'review'))) continue; // Some stages of waterfall not need. + + if(empty($execution->multiple)) { - $executionPairs[$execution->id] = $execution->name; - if(empty($execution->multiple)) $executionPairs[$execution->id] = $execution->projectName . "({$this->lang->project->disableExecution})"; + $this->app->loadLang('project'); + $executionPairs[$execution->id] = $execution->projectName . "({$this->lang->project->disableExecution})"; + } + else + { + $paths = array_slice(explode(',', trim($execution->path, ',')), 1); + $executionName = $projectID != 0 ? '' : $execution->projectName; + foreach($paths as $path) + { + $executionName .= '/' . $allExecutions[$path]->name; + } + + $executionPairs[$execID] = $executionName; } } diff --git a/module/programplan/control.php b/module/programplan/control.php index aeb5713f72..c22213af94 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -212,8 +212,9 @@ class programplan extends control */ public function edit($planID = 0, $projectID = 0) { - $this->app->loadLang('project'); + $this->loadModel('project'); $this->app->loadLang('execution'); + $this->app->loadLang('stage'); $plan = $this->programplan->getByID($planID); global $lang; @@ -234,12 +235,14 @@ class programplan extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locate)); } - $this->app->loadLang('stage'); - $this->view->title = $this->lang->programplan->edit; - $this->view->position[] = $this->lang->programplan->edit; - $this->view->parentStage = $this->programplan->getParentStageList($this->session->project, $planID, $plan->product); - $this->view->isCreateTask = $this->programplan->isCreateTask($planID); - $this->view->plan = $plan; + $parentStage = $this->project->getByID($plan->parent, 'stage'); + + $this->view->title = $this->lang->programplan->edit; + $this->view->position[] = $this->lang->programplan->edit; + $this->view->isCreateTask = $this->programplan->isCreateTask($planID); + $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->display(); } @@ -328,4 +331,19 @@ class programplan extends control return $this->send(array('result' => 'success')); } } + + public function ajaxGetAttribute($stageID) + { + $this->app->loadLang('stage'); + + $attribute = $this->dao->select('attribute')->from(TABLE_EXECUTION)->where('id')->eq($stageID)->fetch('attribute'); + if(empty($attribute) or $attribute == 'mix') + { + return print(html::select('attribute', $this->lang->stage->typeList, $attribute, "class='form-control chosen'")); + } + else + { + return print(zget($this->lang->stage->typeList, $attribute)); + } + } } diff --git a/module/programplan/js/edit.js b/module/programplan/js/edit.js new file mode 100644 index 0000000000..25d3eb9efc --- /dev/null +++ b/module/programplan/js/edit.js @@ -0,0 +1,10 @@ +function changeParentStage(stageID) +{ + $.get(createLink('programplan', 'ajaxGetAttribute', 'stageID=' + stageID), function(attribute) + { + $('#attributeType td').html(attribute); + $("#attribute" + "_chosen").remove(); + $("#attribute").next('.picker').remove(); + $("#attribute").chosen(); + }) +} diff --git a/module/programplan/model.php b/module/programplan/model.php index 65e805587c..f50d0ccf92 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -726,7 +726,7 @@ class programplanModel extends model $plan->name = $names[$key]; if($setCode) $plan->code = $codes[$key]; $plan->percent = $percents[$key]; - $plan->attribute = empty($parentID) ? $attributes[$key] : $parentAttribute; + $plan->attribute = (empty($parentID) or $parentAttribute == 'mix') ? $attributes[$key] : $parentAttribute; $plan->milestone = $milestone[$key]; $plan->begin = empty($begin[$key]) ? '0000-00-00' : $begin[$key]; $plan->end = empty($end[$key]) ? '0000-00-00' : $end[$key]; @@ -971,6 +971,8 @@ class programplanModel extends model { $this->action->create('execution', $stageID, 'opened'); } + + $this->computeProgress($stageID, 'create'); } } @@ -1361,7 +1363,6 @@ class programplanModel extends model ->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->where('t1.product')->eq($productID) ->andWhere('t2.project')->eq($executionID) - ->andWhere('t2.grade')->eq(1) ->andWhere('t2.deleted')->eq(0) ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi() ->orderBy('t2.id desc') @@ -1381,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); + } + } } diff --git a/module/programplan/view/edit.html.php b/module/programplan/view/edit.html.php index 3cb46b97eb..f3669098b1 100644 --- a/module/programplan/view/edit.html.php +++ b/module/programplan/view/edit.html.php @@ -25,7 +25,7 @@