diff --git a/module/programplan/config/form.php b/module/programplan/config/form.php index ff3f70e4da..138026b78d 100644 --- a/module/programplan/config/form.php +++ b/module/programplan/config/form.php @@ -8,10 +8,18 @@ foreach($config->programplan->create->formFields as $field) $config->programplan if(!isset($config->programplan->edit)) $config->programplan->edit = new stdClass(); $config->programplan->edit->form = array(); +$config->programplan->edit->form['parent'] = array('required' => false, 'type' => 'int', 'default' => 0); +$config->programplan->edit->form['name'] = array('required' => true, 'type' => 'string', 'default' => ''); +$config->programplan->edit->form['code'] = array('required' => false, 'type' => 'string', 'default' => ''); +$config->programplan->edit->form['PM'] = array('required' => false, 'type' => 'string', 'default' => ''); +$config->programplan->edit->form['percent'] = array('required' => false, 'type' => 'float', 'default' => 0); +$config->programplan->edit->form['attribute'] = array('required' => false, 'type' => 'string', 'default' => ''); +$config->programplan->edit->form['acl'] = array('required' => false, 'type' => 'string', 'default' => ''); $config->programplan->edit->form['begin'] = array('required' => false, 'type' => 'string', 'default' => '0000-00-00'); $config->programplan->edit->form['end'] = array('required' => false, 'type' => 'string', 'default' => '0000-00-00'); $config->programplan->edit->form['realBegan'] = array('required' => false, 'type' => 'string', 'default' => '0000-00-00'); $config->programplan->edit->form['realEnd'] = array('required' => false, 'type' => 'string', 'default' => '0000-00-00'); +$config->programplan->edit->form['milestone'] = array('required' => false, 'type' => 'int', 'default' => 0); $config->programplan->edit->form['output'] = array('required' => false, 'type' => 'array', 'default' => array()); $config->programplan->ajaxCustom = new stdClass(); diff --git a/module/programplan/control.php b/module/programplan/control.php index 6a06e60899..2ee9fb8347 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -159,8 +159,7 @@ class programplan extends control if($changes) $this->programplanZen->afterEdit($plan, $changes); - $locate = isonlybody() ? 'parent' : inlink('browse', "program=$plan->program&type=lists"); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locate)); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'callback' => 'loadCurrentPage', 'closeModal' => true)); } $this->programplanZen->buildEditView($plan); diff --git a/module/programplan/model.php b/module/programplan/model.php index e89c843eec..b83bd1ab47 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -406,32 +406,6 @@ class programplanModel extends model return $returnJson ? json_encode($datas) : $datas; } - /** - * 获取阶段百分比。 - * Get total percent. - * - * @param object $stage - * @param bool $parent - * @access public - * @return int|float - */ - public function getTotalPercent(object $stage, bool $parent = false): int|float - { - /* When parent is equal to true, query the total workload of the subphase. */ - $executionID = $parent ? $stage->id : $stage->project; - $plans = $this->programplanTao->getStageList((int)$executionID, (int)$stage->product, $browseType = 'parent'); - - $totalPercent = 0; - $stageID = $stage->id; - foreach($plans as $id => $stage) - { - if($id == $stageID) continue; - $totalPercent += $stage->percent; - } - - return $totalPercent; - } - /** * 批量查询阶段关联的项目和属性并过滤日期。 * Get product and attribute for stage correlation. @@ -929,8 +903,9 @@ class programplanModel extends model $relatedExecutionsID = $this->loadModel('execution')->getRelatedExecutions($planID); $relatedExecutionsID = !empty($relatedExecutionsID) ? implode(',', array_keys($relatedExecutionsID)) : '0'; + /* Pass and unset the arguments after use. */ $plan->relatedExecutionsID = $relatedExecutionsID; - $plan->parentStage = $setCode; + $plan->setCode = $setCode; $result = $this->programplanTao->updateRow($plan, $oldPlan, $parentStage); if(!$result) return false; diff --git a/module/programplan/tao.php b/module/programplan/tao.php index dc5e0aee76..6d19b409a6 100644 --- a/module/programplan/tao.php +++ b/module/programplan/tao.php @@ -20,20 +20,24 @@ class programplanTao extends programplanModel * @access protected * @return bool */ - protected function updateRow(object $plan, object $oldPlan, object|null $parentStage): bool + protected function updateRow(object $plan, object $oldPlan, object|bool $parentStage): bool { $requiredFields = $this->config->programplan->edit->requiredFields ?? ''; $getname = ''; if($plan->relatedExecutionsID && $oldPlan->project && $parentStage && $oldPlan->parent) $getname = true; + $relatedExecutionsID = $plan->relatedExecutionsID; + $setCode = $plan->setCode; + unset($plan->relatedExecutionsID, $plan->setCode); + $this->dao->update(TABLE_PROJECT)->data($plan) ->autoCheck() ->batchCheckIF($requiredFields, $requiredFields, 'notempty') ->checkIF($plan->end != '0000-00-00', 'end', 'ge', $plan->begin) ->checkIF(!empty($plan->percent), 'percent', 'float') - ->checkIF(!empty($plan->name) && $getname, 'name', 'unique', "id in ({$plan->relatedExecutionsID}) and type in ('sprint','stage') and `project` = {$oldPlan->project} and `deleted` = '0' and `parent` = {$oldPlan->parent}") - ->checkIF(!empty($plan->code) and $plan->setCode, 'code', 'unique', "id != {$plan->id} and type in ('sprint','stage','kanban') and `deleted` = '0'") + ->checkIF(!empty($plan->name) && $getname, 'name', 'unique', "id in ({$relatedExecutionsID}) and type in ('sprint','stage') and `project` = {$oldPlan->project} and `deleted` = '0' and `parent` = {$oldPlan->parent}") + ->checkIF(!empty($plan->code) && $setCode, 'code', 'unique', "id != {$plan->id} and type in ('sprint','stage','kanban') and `deleted` = '0'") ->where('id')->eq($plan->id) ->exec(); @@ -569,4 +573,31 @@ class programplanTao extends programplanModel $this->dao->insert(TABLE_PROJECTSPEC)->data($spec)->exec(); return !dao::isError(); } + + /** + * 获取阶段百分比。 + * Get total percent. + * + * @param object $stage + * @param bool $parent + * @access public + * @return int|float + */ + protected function getTotalPercent(object $stage, bool $parent = false): int|float + { + /* When parent is equal to true, query the total workload of the subphase. */ + $executionID = $parent ? $stage->id : $stage->project; + $plans = $this->getStageList((int)$executionID, (int)$stage->product, 'parent'); + + $totalPercent = 0; + $stageID = $stage->id; + foreach($plans as $id => $stage) + { + if($id == $stageID) continue; + $totalPercent += $stage->percent; + } + + return $totalPercent; + } + }