diff --git a/module/execution/config.php b/module/execution/config.php index c7c4a3e23e..d676890ad2 100644 --- a/module/execution/config.php +++ b/module/execution/config.php @@ -16,7 +16,7 @@ $app->loadLang('task'); $config->execution->task = new stdclass(); $config->execution->create = new stdclass(); $config->execution->edit = new stdclass(); -$config->execution->create->requiredFields = 'name,code,begin,end'; +$config->execution->create->requiredFields = 'project,name,code,begin,end'; $config->execution->edit->requiredFields = 'name,code,begin,end'; $config->execution->customBatchEditFields = 'days,type,teamname,status,desc,PO,QD,PM,RD'; diff --git a/module/execution/control.php b/module/execution/control.php index c1a50c7c43..80a9d7810f 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1136,8 +1136,8 @@ class execution extends control die(js::confirm($this->lang->execution->importPlanStory, inlink('create', "productID=&executionID=$executionID©ExecutionID=&planID=$planID&confirm=yes"), inlink('create', "productID=&executionID=$executionID"), 'parent', 'parent')); } } - $this->view->title = $this->lang->execution->tips; - $this->view->tips = $this->fetch('execution', 'tips', "executionID=$executionID"); + $this->view->title = $this->lang->execution->tips; + $this->view->tips = $this->fetch('execution', 'tips', "executionID=$executionID"); $this->view->executionID = $executionID; $this->display(); exit; @@ -1180,7 +1180,7 @@ class execution extends control if(!empty($_POST)) { - $executionID = $copyExecutionID == '' ? $this->execution->create() : $this->execution->create($copyExecutionID); + $executionID = $this->execution->create($copyExecutionID); if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->execution->updateProducts($executionID); @@ -1226,7 +1226,7 @@ class execution extends control $this->view->title = $this->lang->execution->create; $this->view->position[] = $this->view->title; - $this->view->executions = array('' => '') + $this->executions; + $this->view->executions = array('' => '') + $this->execution->getList(); $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->allProducts = array(0 => '') + $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $this->view->acl = $acl; @@ -1234,6 +1234,7 @@ class execution extends control $this->view->name = $name; $this->view->code = $code; $this->view->team = $team; + $this->view->allProjects = array('' => '') + $this->project->getPairsByModel(); $this->view->executionID = $executionID; $this->view->productID = $productID; $this->view->products = $products; diff --git a/module/execution/js/create.js b/module/execution/js/create.js index ffdf92adb5..3d2311b7d5 100644 --- a/module/execution/js/create.js +++ b/module/execution/js/create.js @@ -1,6 +1,6 @@ -function setCopyProject(projectID) +function setCopyProject(executionID) { - location.href = createLink('project', 'create', 'productID=&projectID=0©ProjectID=' + projectID); + location.href = createLink('execution', 'create', 'productID=&executionID=0©ExecutionID=' + executionID); } $(function() diff --git a/module/execution/lang/de.php b/module/execution/lang/de.php index 5ea630779c..f67c7dbf5c 100644 --- a/module/execution/lang/de.php +++ b/module/execution/lang/de.php @@ -16,6 +16,7 @@ $lang->execution->id = $lang->executionCommon . ' ID'; $lang->execution->type = 'Typ'; $lang->execution->name = 'Name'; $lang->execution->code = 'Alias'; +$lang->execution->project = 'Project'; $lang->execution->statge = 'Stage'; $lang->execution->pri = 'Priorität'; $lang->execution->openedBy = 'OpenedBy'; diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php index 57ca932cf4..e15592884b 100644 --- a/module/execution/lang/en.php +++ b/module/execution/lang/en.php @@ -16,6 +16,7 @@ $lang->execution->id = $lang->executionCommon . ' ID'; $lang->execution->type = 'Type'; $lang->execution->name = "{$lang->executionCommon} Name"; $lang->execution->code = 'Code'; +$lang->execution->project = 'Project'; $lang->execution->statge = 'Stage'; $lang->execution->pri = 'Priority'; $lang->execution->openedBy = 'OpenedBy'; @@ -306,12 +307,7 @@ $lang->execution->fixFirstWithLeft = 'Update hours left too'; $lang->execution->unfinishedExecution = "This {$lang->executionCommon} has "; $lang->execution->unfinishedTask = "[%s] unfinished tasks. "; $lang->execution->unresolvedBug = "[%s] unresolved bugs. "; - -$lang->execution->action = new stdclass(); -$lang->execution->action->opened = '$date, created by $actor . $extra' . "\n"; -$lang->execution->action->managed = '$date, managed by $actor . $extra' . "\n"; -$lang->execution->action->edited = '$date, edited by $actor . $extra' . "\n"; -$lang->execution->action->extra = "The linked {$lang->productCommon}s are %s."; +$lang->execution->projectNotEmpty = 'Project cannot be empty.'; /* Statistics. */ $lang->execution->charts = new stdclass(); diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index e4cc78362e..59ad6c764d 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -17,6 +17,7 @@ $lang->execution->id = $lang->executionCommon . '编号'; $lang->execution->type = $lang->executionCommon . '类型'; $lang->execution->name = $lang->executionCommon . '名称'; $lang->execution->code = $lang->executionCommon . '代号'; +$lang->execution->project = '所属项目'; $lang->execution->execName = '执行名称'; $lang->execution->execCode = '执行代号'; $lang->execution->statge = '阶段'; @@ -310,12 +311,7 @@ $lang->execution->fixFirstWithLeft = '修改剩余工时'; $lang->execution->unfinishedExecution = "该{$lang->executionCommon}下还有"; $lang->execution->unfinishedTask = "[%s]个未完成的任务,"; $lang->execution->unresolvedBug = "[%s]个未解决的bug,"; - -$lang->execution->action = new stdclass(); -$lang->execution->action->opened = '$date, 由 $actor 创建。$extra' . "\n"; -$lang->execution->action->managed = '$date, 由 $actor 维护。$extra' . "\n"; -$lang->execution->action->edited = '$date, 由 $actor 编辑。$extra' . "\n"; -$lang->execution->action->extra = '相关产品为 %s。'; +$lang->execution->projectNotEmpty = '所属项目不能为空。'; /* 统计。*/ $lang->execution->charts = new stdclass(); diff --git a/module/execution/model.php b/module/execution/model.php index a2c6999a53..184905b82e 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -326,9 +326,15 @@ class executionModel extends model { $this->lang->execution->team = $this->lang->execution->teamname; + if(empty($_POST['project'])) + { + dao::$errors['message'][] = $this->lang->execution->projectNotEmpty; + return false; + } + /* Determine whether to add a sprint or a stage according to the model of the execution. */ - $execution = $this->getByID($this->session->PRJ); - $sprintType = $this->config->systemMode == 'new' ? zget($this->config->execution->modelList, $execution->model, '') : 'sprint'; + $project = $this->getByID($_POST['project']); + $sprintType = $this->config->systemMode == 'new' ? zget($this->config->execution->modelList, $project->model, '') : 'sprint'; /* If the execution model is a stage, determine whether the product is linked. */ if($sprintType == 'stage' and empty($this->post->products[0])) @@ -346,8 +352,7 @@ class executionModel extends model ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) ->setDefault('team', substr($this->post->name,0, 30)) - ->setIF($this->config->systemMode == 'new', 'project', $this->session->PRJ) - ->setIF($this->config->systemMode == 'new', 'parent', $this->session->PRJ) + ->setIF($this->config->systemMode == 'new', 'parent', $this->post->project) ->setIF($this->post->acl == 'open', 'whitelist', '') ->join('whitelist', ',') ->add('type', $sprintType) @@ -387,7 +392,7 @@ class executionModel extends model $this->file->updateObjectID($this->post->uid, $executionID, 'execution'); /* Update the path. */ - if(isset($this->config->maxVersion)) $this->loadModel('programplan')->setTreePath($executionID); + $this->setTreePath($executionID); /* Copy team of execution. */ if($copyExecutionID != '') @@ -419,7 +424,7 @@ class executionModel extends model $member->hours = $this->config->execution->defaultWorkhours; $this->dao->insert(TABLE_TEAM)->data($member)->exec(); - $this->addExecutionMembers($this->session->PRJ, array($member)); + $this->addExecutionMembers($sprint->project, array($member)); } /* Create doc lib. */ @@ -3547,4 +3552,29 @@ class executionModel extends model ->fetchPairs('project', 'name'); return $productpairs; } + + /** + ** Set stage tree path. + ** + ** @param int $executionID + ** @access public + ** @return bool + **/ + public function setTreePath($executionID) + { + $execution = $this->dao->select('id,type,parent,path,grade')->from(TABLE_PROJECT)->where('id')->eq($executionID)->fetch(); + $parent = $this->dao->select('id,type,parent,path,grade')->from(TABLE_PROJECT)->where('id')->eq($execution->parent)->fetch(); + + if($parent->type == 'project') + { + $path['path'] = ",{$parent->id},{$execution->id},"; + $path['grade'] = 1; + } + elseif($parent->type == 'stage') + { + $path['path'] = $parent->path . "{$execution->id},"; + $path['grade'] = $parent->grade + 1; + } + $this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($execution->id)->exec(); + } } diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php index 549c22b47e..9676214649 100644 --- a/module/execution/view/create.html.php +++ b/module/execution/view/create.html.php @@ -46,6 +46,11 @@