From bef31945493298705b2eba6b15942e6d7a16e50e Mon Sep 17 00:00:00 2001 From: z Date: Tue, 24 Nov 2020 15:34:00 +0800 Subject: [PATCH] * code for task #8496. --- module/custom/config.php | 9 ++++++-- module/custom/model.php | 7 +++++- module/program/model.php | 31 +++++++++++++++++++------- module/program/view/pgmcreate.html.php | 7 +++--- module/program/view/pgmedit.html.php | 7 +++--- module/program/view/prjcreate.html.php | 7 +++--- module/program/view/prjedit.html.php | 7 +++--- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/module/custom/config.php b/module/custom/config.php index f2efb71885..3afd1d0b25 100644 --- a/module/custom/config.php +++ b/module/custom/config.php @@ -12,6 +12,7 @@ $config->custom->canAdd['program'] = 'unitList'; $config->custom->noModuleMenu = array(); +$config->custom->requiredModules[10] = 'program'; $config->custom->requiredModules[15] = 'product'; $config->custom->requiredModules[20] = 'story'; $config->custom->requiredModules[25] = 'productplan'; @@ -32,8 +33,12 @@ $config->custom->requiredModules[80] = 'doc'; $config->custom->requiredModules[85] = 'user'; -$config->custom->fieldList['product']['create'] = 'line,PO,QD,RD,type,desc'; -$config->custom->fieldList['product']['edit'] = 'line,PO,QD,RD,type,desc,status'; +$config->custom->fieldList['program']['PGMCreate'] = 'budget,PM,desc'; +$config->custom->fieldList['program']['PGMEdit'] = 'budget,PM,desc'; +$config->custom->fieldList['program']['PRJCreate'] = 'budget,PM,desc'; +$config->custom->fieldList['program']['PRJEdit'] = 'budget,PM,desc'; +$config->custom->fieldList['product']['create'] = 'PO,QD,RD,type,desc'; +$config->custom->fieldList['product']['edit'] = 'PO,QD,RD,type,desc,status'; $config->custom->fieldList['story']['create'] = 'module,plan,source,pri,estimate,keywords'; $config->custom->fieldList['story']['change'] = 'comment'; $config->custom->fieldList['story']['close'] = 'comment'; diff --git a/module/custom/model.php b/module/custom/model.php index 377264e00a..5eabf7e608 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -476,6 +476,12 @@ class customModel extends model if($moduleName == 'user' and $method == 'edit' and strpos($this->config->user->contactField, $fieldName) === false) continue; if($fieldName == 'comment') $fields[$fieldName] = $this->lang->comment; if(isset($moduleLang->$fieldName) and is_string($moduleLang->$fieldName)) $fields[$fieldName] = $moduleLang->$fieldName; + + if($moduleName == 'program') + { + $fieldKey = substr($method, 0, 3) . ucfirst($fieldName); + if(isset($moduleLang->$fieldKey) and is_string($moduleLang->$fieldKey)) $fields[$fieldName] = $moduleLang->$fieldKey; + } } } return $fields; @@ -502,7 +508,6 @@ class customModel extends model { foreach($data->requiredFields as $method => $fields) { - $method = strtolower($method); $systemField = $this->config->$moduleName->$method->requiredFields; $fields = join(',', $fields); diff --git a/module/program/model.php b/module/program/model.php index d15a18c4e1..ec84affc81 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -145,8 +145,11 @@ class programModel extends model } /* Redefines the language entries for the fields in the project table. */ - $this->lang->project->code = $this->lang->program->PGMCode; - $this->lang->project->name = $this->lang->program->PGMName; + foreach(explode(',', $this->config->program->PGMCreate->requiredFields) as $fieldName) + { + $fieldKey = 'PGM' . ucfirst($fieldName); + if(isset($this->lang->program->$fieldKey)) $this->lang->project->$fieldName = $this->lang->program->$fieldKey; + } $program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->pgmcreate['id'], $this->post->uid); $this->dao->insert(TABLE_PROGRAM)->data($program) @@ -246,8 +249,12 @@ class programModel extends model if(dao::isError()) return false; /* Redefines the language entries for the fields in the project table. */ - $this->lang->project->code = $this->lang->program->PGMCode; - $this->lang->project->name = $this->lang->program->PGMName; + foreach(explode(',', $this->config->program->PGMCreate->requiredFields) as $fieldName) + { + $fieldKey = 'PGM' . ucfirst($fieldName); + if(isset($this->lang->program->$fieldKey)) $this->lang->project->$fieldName = $this->lang->program->$fieldKey; + } + $this->dao->update(TABLE_PROGRAM)->data($program) ->autoCheck($skipFields = 'begin,end') ->batchcheck($this->config->program->PGMEdit->requiredFields, 'notempty') @@ -1226,8 +1233,12 @@ class programModel extends model if($this->post->delta == 999) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ','); /* Redefines the language entries for the fields in the project table. */ - $this->lang->project->name = $this->lang->program->PRJName; - $this->lang->project->code = $this->lang->program->PRJCode; + foreach(explode(',', $requiredFields) as $fieldName) + { + $fieldKey = 'PRJ' . ucfirst($fieldName); + if(isset($this->lang->program->$fieldKey)) $this->lang->project->$fieldName = $this->lang->program->$fieldKey; + } + $project = $this->loadModel('file')->processImgURL($project, $this->config->program->editor->prjcreate['id'], $this->post->uid); $this->dao->insert(TABLE_PROJECT)->data($project) ->autoCheck() @@ -1361,8 +1372,12 @@ class programModel extends model if($this->post->delta == 999) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ','); /* Redefines the language entries for the fields in the project table. */ - $this->lang->project->name = $this->lang->program->PRJName; - $this->lang->project->code = $this->lang->program->PRJCode; + foreach(explode(',', $requiredFields) as $fieldName) + { + $fieldKey = 'PRJ' . ucfirst($fieldName); + if(isset($this->lang->program->$fieldKey)) $this->lang->project->$fieldName = $this->lang->program->$fieldKey; + } + $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck($skipFields = 'begin,end') ->batchcheck($requiredFields, 'notempty') diff --git a/module/program/view/pgmcreate.html.php b/module/program/view/pgmcreate.html.php index 286243ba69..c7e8126b5b 100644 --- a/module/program/view/pgmcreate.html.php +++ b/module/program/view/pgmcreate.html.php @@ -34,6 +34,7 @@ project->weekend);?> project->placeholder);?> project->errorSameProducts);?> +program->PGMCreate->requiredFields;?>
@@ -57,7 +58,7 @@ program->PGMPM;?> - + program->PO;?> @@ -67,7 +68,7 @@ program->PGMBudget;?>
- + program->unitList, empty($parentProgram->budgetUnit) ? 'yuan' : $parentProgram->budgetUnit, "class='form-control'");?>
@@ -97,7 +98,7 @@ program->PGMDesc;?> fetch('user', 'ajaxPrintTemplates', 'type=project&link=desc');?> - + diff --git a/module/program/view/pgmedit.html.php b/module/program/view/pgmedit.html.php index af6fda1c73..6eb00316c2 100644 --- a/module/program/view/pgmedit.html.php +++ b/module/program/view/pgmedit.html.php @@ -14,6 +14,7 @@ project->weekend);?> parent ? $lang->program->subPGMAclList : $lang->program->PGMAclList;?> +program->PGMEdit->requiredFields;?>
@@ -36,7 +37,7 @@ program->PGMPM;?> - PM, "class='form-control chosen'");?> + PM, "class='form-control chosen'" . (strpos($requiredFields, 'PM') !== false ? ' required' : ''));?> program->PO;?> @@ -44,7 +45,7 @@ program->PGMBudget;?> - budget, "class='form-control'");?> + budget, "class='form-control'" . (strpos($requiredFields, 'budget') !== false ? ' required' : ''));?> program->unitList, $program->budgetUnit, "class='form-control'");?> @@ -68,7 +69,7 @@ program->PGMDesc;?> fetch('user', 'ajaxPrintTemplates', 'type=program&link=desc');?> - desc, "rows='6' class='form-control kindeditor' hidefocus='true'");?> + desc, "rows='6' class='form-control kindeditor' hidefocus='true'" . (strpos($requiredFields, 'desc') !== false ? ' required' : ''));?> diff --git a/module/program/view/prjcreate.html.php b/module/program/view/prjcreate.html.php index 2764b130a0..b21d68e427 100644 --- a/module/program/view/prjcreate.html.php +++ b/module/program/view/prjcreate.html.php @@ -45,6 +45,7 @@ else project->weekend);?> program->errorSameProducts);?> +program->PRJCreate->requiredFields;?>
@@ -120,13 +121,13 @@ else program->PRJPM;?> - + program->PRJBudget;?>
- + program->unitList, empty($parentProgram->budgetUnit) ? 'yuan' : $parentProgram->budgetUnit, "class='form-control'");?>
@@ -160,7 +161,7 @@ else program->PRJDesc;?> fetch('user', 'ajaxPrintTemplates', 'type=project&link=desc');?> - + diff --git a/module/program/view/prjedit.html.php b/module/program/view/prjedit.html.php index edfa69b101..0af9033e3f 100644 --- a/module/program/view/prjedit.html.php +++ b/module/program/view/prjedit.html.php @@ -19,6 +19,7 @@ id);?> program->PGMChangeTips);?> parent ? $lang->program->PGMPRJAclList : $lang->program->PRJAclList;?> +program->PRJEdit->requiredFields;?>
@@ -91,13 +92,13 @@ program->PRJPM;?> - PM, "class='form-control chosen'");?> + PM, "class='form-control chosen'" . (strpos($requiredFields, 'PM') !== false ? ' required' : ''));?> program->PRJBudget;?>
- budget, "class='form-control'");?> + budget, "class='form-control'" . (strpos($requiredFields, 'budget') !== false ? ' required' : ''));?> program->unitList, $project->budgetUnit, "class='form-control'");?>
@@ -136,7 +137,7 @@ program->PRJDesc;?> fetch('user', 'ajaxPrintTemplates', 'type=project&link=desc');?> - desc, "rows='6' class='form-control kindeditor' hidefocus='true'");?> + desc, "rows='6' class='form-control kindeditor' hidefocus='true'" . (strpos($requiredFields, 'desc') !== false ? ' required' : ''));?>