From 226f798470d2470e825b81327615506b3a0b50d9 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Mon, 27 Feb 2023 08:08:07 +0000 Subject: [PATCH] * Finish task #85631. --- module/execution/model.php | 6 ++-- module/execution/view/create.html.php | 2 +- module/execution/view/edit.html.php | 2 +- module/programplan/config.php | 34 +++++++++++++++----- module/programplan/control.php | 1 + module/programplan/model.php | 44 ++++++++++++++++---------- module/programplan/view/edit.html.php | 2 ++ module/stage/config.php | 14 ++++++-- module/stage/model.php | 28 ++++++++++------ module/stage/view/batchcreate.html.php | 4 +++ module/stage/view/browse.html.php | 4 +++ module/stage/view/create.html.php | 4 ++- module/stage/view/edit.html.php | 4 ++- 13 files changed, 104 insertions(+), 45 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 3b5386d02f..9ba46a87ca 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -383,7 +383,7 @@ class executionModel extends model $type = 'sprint'; if($project) $type = zget($this->config->execution->modelList, $project->model, 'sprint'); - if($project->model == 'waterfall') + if($project->model == 'waterfall' and isset($this->config->setPercent) and $this->config->setPercent == 1) { $this->checkWorkload('create', $_POST['percent'], $project); if(dao::isError()) return false; @@ -432,7 +432,7 @@ class executionModel extends model } /* Check the workload format and total. */ - if(!empty($sprint->percent)) $this->checkWorkload('create', $sprint->percent, $sprint->project); + if(!empty($sprint->percent) and isset($this->config->setPercent) and $this->config->setPercent == 1) $this->checkWorkload('create', $sprint->percent, $sprint->project); /* Set planDuration and realDuration. */ if($this->config->edition == 'max') @@ -621,7 +621,7 @@ class executionModel extends model $execution = $this->loadModel('file')->processImgURL($execution, $this->config->execution->editor->edit['id'], $this->post->uid); /* Check the workload format and total. */ - if(!empty($execution->percent)) $this->checkWorkload('update', $execution->percent, $oldExecution); + if(!empty($execution->percent) and isset($this->config->setPercent) and $this->config->setPercent == 1) $this->checkWorkload('update', $execution->percent, $oldExecution); /* Set planDuration and realDuration. */ if($this->config->edition == 'max') diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php index dab4ad2d55..a1c6f81724 100644 --- a/module/execution/view/create.html.php +++ b/module/execution/view/create.html.php @@ -124,7 +124,7 @@
execution->typeDesc;?>
- + setPercent) and $config->setPercent == 1):?> stage->percent;?> diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index 18123bcfed..1c9a55e90b 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -144,7 +144,7 @@ - type == 'stage'):?> + type == 'stage' and isset($config->setPercent) and $config->setPercent == 1):?> stage->percent;?> diff --git a/module/programplan/config.php b/module/programplan/config.php index 3136c4559d..e5745773c6 100644 --- a/module/programplan/config.php +++ b/module/programplan/config.php @@ -5,7 +5,14 @@ $config->programplan->create->requiredFields = 'name,begin,end'; $config->programplan->edit->requiredFields = 'name,begin,end'; $config->programplan->datatable = new stdclass(); -$config->programplan->datatable->defaultField = array('id', 'name', 'percent', 'attribute', 'begin', 'end', 'realBegan', 'realEnd', 'actions'); +if(isset($config->setPercent) and $config->setPercent == 1) +{ + $config->programplan->datatable->defaultField = array('id', 'name', 'percent', 'attribute', 'begin', 'end', 'realBegan', 'realEnd', 'actions'); +} +else +{ + $config->programplan->datatable->defaultField = array('id', 'name', 'attribute', 'begin', 'end', 'realBegan', 'realEnd', 'actions'); +} $config->programplan->datatable->fieldList['id']['title'] = 'idAB'; $config->programplan->datatable->fieldList['id']['fixed'] = 'left'; @@ -17,10 +24,13 @@ $config->programplan->datatable->fieldList['name']['fixed'] = 'left'; $config->programplan->datatable->fieldList['name']['width'] = 'auto'; $config->programplan->datatable->fieldList['name']['required'] = 'yes'; -$config->programplan->datatable->fieldList['percent']['title'] = 'percent'; -$config->programplan->datatable->fieldList['percent']['fixed'] = 'no'; -$config->programplan->datatable->fieldList['percent']['width'] = '100'; -$config->programplan->datatable->fieldList['percent']['required'] = 'no'; +if(isset($config->setPercent) and $config->setPercent == 1) +{ + $config->programplan->datatable->fieldList['percent']['title'] = 'percent'; + $config->programplan->datatable->fieldList['percent']['fixed'] = 'no'; + $config->programplan->datatable->fieldList['percent']['width'] = '100'; + $config->programplan->datatable->fieldList['percent']['required'] = 'no'; +} $config->programplan->datatable->fieldList['attribute']['title'] = 'attribute'; $config->programplan->datatable->fieldList['attribute']['fixed'] = 'no'; @@ -53,10 +63,18 @@ $config->programplan->datatable->fieldList['actions']['width'] = '150'; $config->programplan->datatable->fieldList['actions']['required'] = 'yes'; $config->programplan->datatable->fieldList['actions']['sort'] = 'no'; -$config->programplan->customCreateFields = 'PM,percent,attribute,acl,milestone,realBegan,realEnd'; - $config->programplan->custom = new stdclass(); -$config->programplan->custom->createFields = 'PM,percent,attribute,acl,milestone'; + +if(isset($config->setPercent) and $config->setPercent == 1) +{ + $config->programplan->custom->createFields = 'PM,percent,attribute,acl,milestone'; + $config->programplan->customCreateFields = 'PM,percent,attribute,acl,milestone,realBegan,realEnd'; +} +else +{ + $config->programplan->custom->createFields = 'PM,attribute,acl,milestone'; + $config->programplan->customCreateFields = 'PM,attribute,acl,milestone,realBegan,realEnd'; +} $config->programplan->customAgilePlusCreateFields = 'PM,milestone,acl,desc,attribute'; diff --git a/module/programplan/control.php b/module/programplan/control.php index ccf3baa0a5..83f280143f 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -205,6 +205,7 @@ class programplan extends control if(strpos(",{$this->config->programplan->$customCreateFields},", ",{$field},") !== false) $visibleFields[$field] = ''; } } + if(empty($this->config->setPercent)) unset($visibleFields['percent'], $requiredFields['percent']); if($executionType != 'stage') unset($this->lang->execution->typeList[''], $this->lang->execution->typeList['stage']); diff --git a/module/programplan/model.php b/module/programplan/model.php index 5bd2ca475f..c46b69ee02 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -201,7 +201,7 @@ class programplanModel extends model $data->type = 'plan'; $data->text = empty($plan->milestone) ? $plan->name : $plan->name . $isMilestone ; $data->name = $plan->name; - $data->percent = $plan->percent; + if(isset($this->config->setPercent) and $this->config->setPercent == 1) $data->percent = $plan->percent; $data->attribute = zget($this->lang->stage->typeList, $plan->attribute); $data->milestone = zget($this->lang->programplan->milestoneList, $plan->milestone); $data->owner_id = $plan->PM; @@ -717,6 +717,7 @@ class programplanModel extends model $setCode = (isset($this->config->setCode) and $this->config->setCode == 1) ? true : false; $sameCodes = $this->checkCodeUnique($codes, isset($planIDList) ? $planIDList : ''); + $setPercent = (isset($this->config->setPercent) and $this->config->setPercent == 1) ? true : false; $datas = array(); foreach($names as $key => $name) { @@ -728,8 +729,8 @@ class programplanModel extends model $plan->project = $projectID; $plan->parent = $parentID ? $parentID : $projectID; $plan->name = $names[$key]; - if($setCode) $plan->code = $codes[$key]; - $plan->percent = $percents[$key]; + if($setCode) $plan->code = $codes[$key]; + if($setPercent) $plan->percent = $percents[$key]; $plan->attribute = (empty($parentID) or $parentAttribute == 'mix') ? $attributes[$key] : $parentAttribute; $plan->milestone = $milestone[$key]; $plan->begin = empty($begin[$key]) ? '0000-00-00' : $begin[$key]; @@ -753,7 +754,7 @@ class programplanModel extends model if(!empty($sameNames) and in_array($plan->name, $sameNames)) dao::$errors[$index]['name'] = empty($type) ? $this->lang->programplan->error->sameName : str_replace($this->lang->execution->stage, '', $this->lang->programplan->error->sameName); if($setCode and $sameCodes !== true and !empty($sameCodes) and in_array($plan->code, $sameCodes)) dao::$errors[$index]['code'] = sprintf($this->lang->error->repeat, $plan->type == 'stage' ? $this->lang->execution->code : $this->lang->code, $plan->code); - if($plan->percent and !preg_match("/^[0-9]+(.[0-9]{1,3})?$/", $plan->percent)) + if($setPercent and $plan->percent and !preg_match("/^[0-9]+(.[0-9]{1,3})?$/", $plan->percent)) { dao::$errors[$index]['percent'] = $this->lang->programplan->error->percentNumber; } @@ -806,13 +807,16 @@ class programplanModel extends model } } - $plan->percent = (float)$plan->percent; - $totalPercent += $plan->percent; + if($setPercent) + { + $plan->percent = (float)$plan->percent; + $totalPercent += $plan->percent; + } if($plan->milestone) $milestone = 1; } - if($totalPercent > 100) dao::$errors['percent'] = $this->lang->programplan->error->percentOver; + if($setPercent and $totalPercent > 100) dao::$errors['percent'] = $this->lang->programplan->error->percentOver; if(dao::isError()) return false; $this->loadModel('action'); @@ -877,7 +881,7 @@ class programplanModel extends model $this->dao->update(TABLE_PROJECT)->data($data) ->autoCheck() ->batchCheck($this->config->programplan->edit->requiredFields, 'notempty') - ->checkIF($plan->percent != '', 'percent', 'float') + ->checkIF($plan->percent != '' and $setPercent, 'percent', 'float') ->where('id')->eq($stageID) ->exec(); @@ -934,7 +938,7 @@ class programplanModel extends model $this->dao->insert(TABLE_PROJECT)->data($data) ->autoCheck() ->batchCheck($this->config->programplan->create->requiredFields, 'notempty') - ->checkIF($plan->percent != '', 'percent', 'float') + ->checkIF($plan->percent != '' and $setPercent, 'percent', 'float') ->exec(); if(!dao::isError()) @@ -1084,15 +1088,18 @@ class programplanModel extends model $planChanged = ($oldPlan->name != $plan->name || $oldPlan->milestone != $plan->milestone || $oldPlan->begin != $plan->begin || $oldPlan->end != $plan->end); + $setPercent = isset($this->config->setPercent) and $this->config->setPercent == 1 ? true : false; if($plan->parent > 0) { $plan->attribute = $parentStage->attribute == 'mix' ? $plan->attribute : $parentStage->attribute; $plan->acl = $parentStage->acl; - $parentPercent = $parentStage->percent; - - $childrenTotalPercent = $this->getTotalPercent($parentStage, true); - $childrenTotalPercent = $plan->parent == $oldPlan->parent ? ($childrenTotalPercent - $oldPlan->percent + $plan->percent) : ($childrenTotalPercent + $plan->percent); - if($childrenTotalPercent > 100) return dao::$errors['percent'][] = $this->lang->programplan->error->percentOver; + if($setPercent) + { + $parentPercent = $parentStage->percent; + $childrenTotalPercent = $this->getTotalPercent($parentStage, true); + $childrenTotalPercent = $plan->parent == $oldPlan->parent ? ($childrenTotalPercent - $oldPlan->percent + $plan->percent) : ($childrenTotalPercent + $plan->percent); + if($childrenTotalPercent > 100) return dao::$errors['percent'][] = $this->lang->programplan->error->percentOver; + } /* If child plan has milestone, update parent plan set milestone eq 0 . */ if($plan->milestone and $parentStage->milestone) $this->dao->update(TABLE_PROJECT)->set('milestone')->eq(0)->where('id')->eq($oldPlan->parent)->exec(); @@ -1105,9 +1112,12 @@ class programplanModel extends model /* The workload of the parent plan cannot exceed 100%. */ $oldPlan->parent = $plan->parent; - $totalPercent = $this->getTotalPercent($oldPlan); - $totalPercent = $totalPercent + $plan->percent; - if($totalPercent > 100) return dao::$errors['percent'][] = $this->lang->programplan->error->percentOver; + if($setPercent) + { + $totalPercent = $this->getTotalPercent($oldPlan); + $totalPercent = $totalPercent + $plan->percent; + if($totalPercent > 100) return dao::$errors['percent'][] = $this->lang->programplan->error->percentOver; + } } /* Set planDuration and realDuration. */ diff --git a/module/programplan/view/edit.html.php b/module/programplan/view/edit.html.php index 73ae92b6c7..83e047eeda 100644 --- a/module/programplan/view/edit.html.php +++ b/module/programplan/view/edit.html.php @@ -46,6 +46,7 @@ programplan->PM;?> + setPercent) and $config->setPercent == 1):?> programplan->percent;?> @@ -55,6 +56,7 @@ + programplan->attribute;?> diff --git a/module/stage/config.php b/module/stage/config.php index f77eb68cd9..1e76c319bd 100644 --- a/module/stage/config.php +++ b/module/stage/config.php @@ -1,5 +1,13 @@ -stage->create = new stdclass(); $config->stage->edit = new stdclass(); -$config->stage->create->requiredFields = 'name,percent,type'; -$config->stage->edit->requiredFields = 'name,percent,type'; +if(isset($config->setPercent) and $config->setPercent == 1) +{ + $config->stage->create->requiredFields = 'name,percent,type'; + $config->stage->edit->requiredFields = 'name,percent,type'; +} +else +{ + $config->stage->create->requiredFields = 'name,type'; + $config->stage->edit->requiredFields = 'name,type'; +} diff --git a/module/stage/model.php b/module/stage/model.php index c475e5e196..5303d6d651 100644 --- a/module/stage/model.php +++ b/module/stage/model.php @@ -27,10 +27,13 @@ class stageModel extends model ->add('createdDate', helper::today()) ->get(); - $totalPercent = $this->getTotalPercent($type); + if(isset($this->config->setPercent) and $this->config->setPercent == 1) + { + $totalPercent = $this->getTotalPercent($type); - if(!is_numeric($stage->percent)) return dao::$errors['message'][] = $this->lang->stage->error->notNum; - if(round($totalPercent + $stage->percent) > 100) return dao::$errors['message'][] = $this->lang->stage->error->percentOver; + if(!is_numeric($stage->percent)) return dao::$errors['message'][] = $this->lang->stage->error->notNum; + if(round($totalPercent + $stage->percent) > 100) return dao::$errors['message'][] = $this->lang->stage->error->percentOver; + } $this->dao->insert(TABLE_STAGE) ->data($stage) @@ -53,9 +56,12 @@ class stageModel extends model { $data = fixer::input('post')->get(); - $totalPercent = $this->getTotalPercent($type); - - if(round($totalPercent + array_sum($data->percent)) > 100) return dao::$errors['message'][] = $this->lang->stage->error->percentOver; + $setPercent = (isset($this->config->setPercent) and $this->config->setPercent == 1) ? true : false; + if($setPercent) + { + $totalPercent = $this->getTotalPercent($type); + if(round($totalPercent + array_sum($data->percent)) > 100) return dao::$errors['message'][] = $this->lang->stage->error->percentOver; + } $this->loadModel('action'); foreach($data->name as $i => $name) @@ -64,7 +70,7 @@ class stageModel extends model $stage = new stdclass(); $stage->name = $name; - $stage->percent = $data->percent[$i]; + if($setPercent) $stage->percent = $data->percent[$i]; $stage->type = $data->type[$i]; $stage->projectType = $type; $stage->createdBy = $this->app->user->account; @@ -100,9 +106,11 @@ class stageModel extends model ->add('editedDate', helper::today()) ->get(); - $totalPercent = $this->getTotalPercent($oldStage->projectType); - - if(round($totalPercent + $stage->percent - $oldStage->percent) > 100) return dao::$errors['message'][] = $this->lang->stage->error->percentOver; + if(isset($this->config->setPercent) and $this->config->setPercent == 1) + { + $totalPercent = $this->getTotalPercent($oldStage->projectType); + if(round($totalPercent + $stage->percent - $oldStage->percent) > 100) return dao::$errors['message'][] = $this->lang->stage->error->percentOver; + } $this->dao->update(TABLE_STAGE) ->data($stage) diff --git a/module/stage/view/batchcreate.html.php b/module/stage/view/batchcreate.html.php index 6184ee3eaf..8043dcf55b 100644 --- a/module/stage/view/batchcreate.html.php +++ b/module/stage/view/batchcreate.html.php @@ -22,7 +22,9 @@ stage->id;?> stage->name;?> + setPercent) and $config->setPercent == 1):?> stage->percent;?> + stage->type;?> @@ -31,7 +33,9 @@ + setPercent) and $config->setPercent == 1):?> + '') + $lang->stage->typeList, '', "class='form-control chosen'");?> diff --git a/module/stage/view/browse.html.php b/module/stage/view/browse.html.php index 32d8a50a9c..e5abf7647f 100644 --- a/module/stage/view/browse.html.php +++ b/module/stage/view/browse.html.php @@ -38,7 +38,9 @@ stage->id);?> stage->name);?> + setPercent) and $config->setPercent == 1):?> stage->percent);?> + stage->type);?> actions;?> @@ -48,7 +50,9 @@ id;?> name;?> + setPercent) and $config->setPercent == 1):?> percent;?> + stage->typeList, $stage->type);?> + setPercent) and $config->setPercent == 1):?> stage->percent;?>
- % + %
+ stage->type;?> stage->typeList, '', "class='form-control chosen'");?> diff --git a/module/stage/view/edit.html.php b/module/stage/view/edit.html.php index 4a258ee822..f23abace37 100644 --- a/module/stage/view/edit.html.php +++ b/module/stage/view/edit.html.php @@ -25,15 +25,17 @@ + setPercent) and $config->setPercent == 1):?> stage->percent;?>
percent, "class='form-control'");?> - % + %
+ stage->type;?> stage->typeList, $stage->type, "class='form-control chosen'");?>