From f82ca09e99a297d72a74f01387f0aaef5d208563 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Wed, 31 Aug 2022 11:15:59 +0800 Subject: [PATCH 1/3] * Compatible workflow fields for import|export. --- module/common/view/noticeimport.html.php | 5 ++ module/port/control.php | 1 - module/port/model.php | 89 ++++++++++++++++++------ module/port/view/thead.html.php | 13 ---- 4 files changed, 73 insertions(+), 35 deletions(-) diff --git a/module/common/view/noticeimport.html.php b/module/common/view/noticeimport.html.php index 5f87dd9b43..a3a5b3a8b5 100644 --- a/module/common/view/noticeimport.html.php +++ b/module/common/view/noticeimport.html.php @@ -28,4 +28,9 @@ function submitForm(type) $('#importNoticeModal .form-actions .btn').addClass('disabled'); $("button[data-target='#importNoticeModal']").closest('form').submit(); } + +$('#importNoticeModal .close').click(function() +{ + $('#importNoticeModal .form-actions .btn').removeClass('disabled'); +}) diff --git a/module/port/control.php b/module/port/control.php index 39257735fb..7d465cf754 100644 --- a/module/port/control.php +++ b/module/port/control.php @@ -159,7 +159,6 @@ class port extends control $datas = $this->port->getPageDatas($formatDatas, $pagerID); if($model == 'task') $datas = $this->task->processDatas4Task($datas); - $html = $this->port->buildNextList($datas->datas, $lastID, $fields, $pagerID, $model); die($html); } diff --git a/module/port/model.php b/module/port/model.php index f93951a470..11a4d61249 100644 --- a/module/port/model.php +++ b/module/port/model.php @@ -198,8 +198,12 @@ class portModel extends model /* Get export rows and fields datas */ $exportDatas = $this->getExportDatas($fieldList, $rows); - $this->post->set('rows', $exportDatas['rows']); - $this->post->set('fields', $exportDatas['fields']); + $fields = $exportDatas['fields']; + $rows = $exportDatas['rows']; + if($this->config->edition != 'open') list($fields, $rows) = $this->loadModel('workflowfield')->appendDataFromFlow($fields, $rows, $model); + + $this->post->set('rows', $rows); + $this->post->set('fields', $fields); $this->post->set('kind', $model); } @@ -249,6 +253,7 @@ class portModel extends model if(empty($fields)) return false; if(!is_array($fields)) $fields = explode(',', $fields); + $fieldList = array(); /* build module fieldList. */ foreach ($fields as $key => $field) @@ -275,6 +280,32 @@ class portModel extends model $fieldList['mailto']['control'] = 'multiple'; $fieldList['mailto']['values'] = $this->portConfig->sysDataList['user']; } + + /* Set workflow fields .*/ + $workflowFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD) + ->where('module')->eq($model) + ->andWhere('buildin')->eq(0) + ->fetchAll('id'); + + foreach($workflowFields as $field) + { + if(!in_array($field->control, array('select', 'radio', 'multi-select'))) continue; + if(!isset($fields[$field->field]) and !array_search($field->field, $fields)) continue; + if(empty($field->options)) continue; + + $field = $this->loadModel('workflowfield')->processFieldOptions($field); + $options = $this->workflowfield->getFieldOptions($field, true); + if($options) + { + $control = $field->control == 'multi-select' ? 'multiple' : 'select'; + $fieldList[$field->field]['title'] = $field->name; + $fieldList[$field->field]['control'] = $control; + $fieldList[$field->field]['values'] = $options; + $fieldList[$field->field]['from'] = 'workflow'; + $this->config->$model->listFields .= ',' . $field->field; + } + } + return $fieldList; } @@ -441,7 +472,7 @@ class portModel extends model $modelData = $this->processRows4Fields($rows, $fields); - $modelData = $this->getNatureDatas($model, $modelData, $filter); + $modelData = $this->getNatureDatas($model, $modelData, $filter, $fields); $this->createTmpFile($modelData); } @@ -449,7 +480,8 @@ class portModel extends model { $modelData = $this->getDatasByFile($tmpFile); } - + if(isset($fields['id'])) unset($fields['id']); + $this->session->set($model . 'TemplateFields', array_keys($fields)); return $modelData; } @@ -648,7 +680,6 @@ class portModel extends model { $lists = array(); $this->commonActions($model); - if(!empty($this->modelListFields)) { $listFields = $this->modelListFields; @@ -661,6 +692,7 @@ class portModel extends model $lists[$listName] = $fieldList[$field]['values']; if(strpos($this->config->$model->sysLangFields, $field)) $lists[$listName] = join(',', $fieldList[$field]['values']); } + $this->config->excel->sysDataField[] = $field; } $lists['listStyle'] = $listFields; @@ -829,17 +861,35 @@ class portModel extends model * @access public * @return void */ - public function getNatureDatas($model, $datas, $filter = '') + public function getNatureDatas($model, $datas, $filter = '', $fields = '') { + $fieldList = $this->initFieldList($model, array_keys($fields), false); $lang = $this->lang->$model; + foreach($datas as $key => $data) { foreach($data as $field => $cellValue) { + if(empty($cellValue)) continue; if(strpos($this->portConfig->dateFeilds, $field) !== false and helper::isZeroDate($cellValue)) $datas[$key]->$field = ''; - if(strpos($filter, $field) !== false) continue; + //if(strpos($filter, $field) !== false) continue; if(is_array($cellValue)) continue; - if(strrpos($cellValue, '(#') === false) + + if(!empty($fieldList[$field]['from']) and in_array($fieldList[$field]['control'], array('select', 'multiple'))) + { + $control = $fieldList[$field]['control']; + if($control == 'multiple') + { + $cellValue = explode("\n", $cellValue); + foreach($cellValue as &$value) $value = array_search($value, $fieldList[$field]['values'], true); + $datas[$key]->$field = join(',', $cellValue); + } + else + { + $datas[$key]->$field = array_search($cellValue, $fieldList[$field]['values']); + } + } + elseif(strrpos($cellValue, '(#') === false) { if(!isset($lang->{$field . 'List'}) or !is_array($lang->{$field . 'List'})) continue; @@ -942,6 +992,7 @@ class portModel extends model $this->commonActions($model); $modelLang = $this->lang->$model; $fields = explode(',', $this->modelConfig->templateFields); + array_unshift($fields, 'id'); foreach($fields as $key => $fieldName) { @@ -950,6 +1001,15 @@ class portModel extends model unset($fields[$key]); } + if($this->config->edition != 'open') + { + $appendFields = $this->loadModel('workflowaction')->getFields($model, 'showimport', false); + foreach($appendFields as $appendField) + { + if(!$appendField->buildin and $appendField->show) $fields[$appendField->field] = $appendField->name; + } + } + return $fields; } @@ -1224,8 +1284,6 @@ class portModel extends model $importFields = !empty($_SESSION[$model . 'TemplateFields']) ? $_SESSION[$model . 'TemplateFields'] : $this->config->$model->templateFields; - $this->getWorkFlowFields($model); - $datas->requiredFields = $this->config->$model->create->requiredFields; $datas->allPager = isset($datas->allPager) ? $datas->allPager : 1; $datas->pagerID = $pagerID; @@ -1257,7 +1315,6 @@ class portModel extends model $addID = 1; if($model == 'task') $members = $this->loadModel('user')->getTeamMemberPairs($this->session->taskPortParams['executionID'], 'execution'); - $appendFields = $this->session->appendFields; $showImportCount = $this->config->port->lazyLoading ? $this->config->port->showImportCount : $this->maxImport; $lastRow = $lastID + $key + $showImportCount; @@ -1344,16 +1401,6 @@ class portModel extends model else $html .= '' . html::input("$name", $selected, "class='form-control autocomplete='off'") . ''; } - if(!empty($appendFields)) - { - $this->loadModel('flow'); - foreach($appendFields as $field) - { - if(!$field->show) continue; - $value = $field->defaultValue ? $field->defaultValue : zget($object, $field->field, ''); - $html .='' . $this->flow->buildControl($field, $value, "$field->field[$key]", true) . ''; - } - } $html .= '' . "\n"; } diff --git a/module/port/view/thead.html.php b/module/port/view/thead.html.php index 1099ef1652..94c3161658 100644 --- a/module/port/view/thead.html.php +++ b/module/port/view/thead.html.php @@ -4,16 +4,3 @@ -show) continue; - - $width = ($field->width && $field->width != 'auto' ? $field->width . 'px' : 'auto'); - $required = strpos(",$field->rules,", ",$notEmptyRule->id,") !== false ? 'required' : ''; - echo "$field->name"; - } -} -?> From 7ceeee8ae72396ea3ad83b1556a671001fa37d89 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Tue, 6 Sep 2022 10:42:20 +0800 Subject: [PATCH 2/3] * Add judge edition for port. --- module/port/model.php | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/module/port/model.php b/module/port/model.php index 11a4d61249..16f72d1fc0 100644 --- a/module/port/model.php +++ b/module/port/model.php @@ -281,28 +281,31 @@ class portModel extends model $fieldList['mailto']['values'] = $this->portConfig->sysDataList['user']; } - /* Set workflow fields .*/ - $workflowFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD) - ->where('module')->eq($model) - ->andWhere('buildin')->eq(0) - ->fetchAll('id'); - - foreach($workflowFields as $field) + if($this->config->edition != 'open') { - if(!in_array($field->control, array('select', 'radio', 'multi-select'))) continue; - if(!isset($fields[$field->field]) and !array_search($field->field, $fields)) continue; - if(empty($field->options)) continue; + /* Set workflow fields .*/ + $workflowFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD) + ->where('module')->eq($model) + ->andWhere('buildin')->eq(0) + ->fetchAll('id'); - $field = $this->loadModel('workflowfield')->processFieldOptions($field); - $options = $this->workflowfield->getFieldOptions($field, true); - if($options) + foreach($workflowFields as $field) { - $control = $field->control == 'multi-select' ? 'multiple' : 'select'; - $fieldList[$field->field]['title'] = $field->name; - $fieldList[$field->field]['control'] = $control; - $fieldList[$field->field]['values'] = $options; - $fieldList[$field->field]['from'] = 'workflow'; - $this->config->$model->listFields .= ',' . $field->field; + if(!in_array($field->control, array('select', 'radio', 'multi-select'))) continue; + if(!isset($fields[$field->field]) and !array_search($field->field, $fields)) continue; + if(empty($field->options)) continue; + + $field = $this->loadModel('workflowfield')->processFieldOptions($field); + $options = $this->workflowfield->getFieldOptions($field, true); + if($options) + { + $control = $field->control == 'multi-select' ? 'multiple' : 'select'; + $fieldList[$field->field]['title'] = $field->name; + $fieldList[$field->field]['control'] = $control; + $fieldList[$field->field]['values'] = $options; + $fieldList[$field->field]['from'] = 'workflow'; + $this->config->$model->listFields .= ',' . $field->field; + } } } From 25613fe0c6341038e25e6779a7bf890f760c2a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E8=83=A1=E6=88=90?= Date: Tue, 6 Sep 2022 09:05:22 +0000 Subject: [PATCH 3/3] Update model.php --- module/port/model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/port/model.php b/module/port/model.php index 16f72d1fc0..c03c16c6ab 100644 --- a/module/port/model.php +++ b/module/port/model.php @@ -861,6 +861,7 @@ class portModel extends model * @param int $model * @param int $datas * @param string $filter + * @param string $fields * @access public * @return void */