From f18cbc5926a8595a03d9240650d51f2149db4e29 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Thu, 7 Jul 2022 12:35:58 +0800 Subject: [PATCH] * Fix bug . --- module/port/control.php | 48 +++++++++++++++++++++++------------------ module/port/model.php | 7 +++--- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/module/port/control.php b/module/port/control.php index cec9a9d9c2..922bebd697 100644 --- a/module/port/control.php +++ b/module/port/control.php @@ -30,36 +30,18 @@ class port extends control /* Init config fieldList */ $fieldList = $this->port->initFieldList($model, $fields); - $queryCondition = $this->session->{$model . 'QueryCondition'}; - $onlyCondition = $this->session->{$model . 'OnlyCondition'}; - - $modelDatas = array(); - if($onlyCondition and $queryCondition) - { - $table = zget($this->config->objectTables, $model);; - if(isset($this->config->$model->port->table)) $table = $this->config->$model->port->table; - $modelDatas = $this->dao->select('*')->from($table)->alias('t1') - ->where($queryCondition) - ->beginIF($this->post->exportType == 'selected')->andWhere('t1.id')->in($this->cookie->checkedItem)->fi() - ->fetchAll('id'); - } - elseif($queryCondition) - { - $stmt = $this->dbh->query($queryCondition . ($this->post->exportType == 'selected' ? " AND t1.id IN({$this->cookie->checkedItem})" : '') . " ORDER BY " . strtr($orderBy, '_', ' ')); - while($row = $stmt->fetch()) $modelDatas[$row->id] = $row; - } + $rows = $this->getRows($model); $list = $this->setListValue($model, $fieldList); if($list) foreach($list as $listName => $listValue) $this->post->set($listName, $listValue); /* Get export rows and fields datas */ - $exportDatas = $this->getExportDatas($fieldList, $modelDatas); + $exportDatas = $this->getExportDatas($fieldList, $rows); $this->post->set('rows', $exportDatas['rows']); $this->post->set('fields', $exportDatas['fields']); $this->post->set('kind', $model); - - $this->fetch('file', 'export2' . $_POST['fileType'], $POST); + $this->fetch('file', 'export2' . $_POST['fileType'], $_POST); } } @@ -137,6 +119,30 @@ class port extends control return $lists; } + public function getRows($model) + { + $queryCondition = $this->session->{$model . 'QueryCondition'}; + $onlyCondition = $this->session->{$model . 'OnlyCondition'}; + + $modelDatas = array(); + if($onlyCondition and $queryCondition) + { + $table = zget($this->config->objectTables, $model);; + if(isset($this->config->$model->port->table)) $table = $this->config->$model->port->table; + $modelDatas = $this->dao->select('*')->from($table)->alias('t1') + ->where($queryCondition) + ->beginIF($this->post->exportType == 'selected')->andWhere('t1.id')->in($this->cookie->checkedItem)->fi() + ->fetchAll('id'); + } + elseif($queryCondition) + { + $stmt = $this->dbh->query($queryCondition . ($this->post->exportType == 'selected' ? " AND t1.id IN({$this->cookie->checkedItem})" : '') . " ORDER BY " . strtr($orderBy, '_', ' ')); + while($row = $stmt->fetch()) $modelDatas[$row->id] = $row; + } + + return $modelDatas; + } + /** * Export Template. * diff --git a/module/port/model.php b/module/port/model.php index 8494b518c9..ee940387a6 100644 --- a/module/port/model.php +++ b/module/port/model.php @@ -49,6 +49,7 @@ class portModel extends model if(empty($fields)) return false; + $fieldList = array(); /* build module fieldList. */ foreach ($fields as $key => $field) { @@ -67,11 +68,10 @@ class portModel extends model $modelFieldList = $this->initForeignKey($model, $field, $modelFieldList); $modelFieldList['values'] = $this->initValues($model, $field, $modelFieldList); - - $this->modelConfig->fieldList[$field] = $modelFieldList; + $fieldList[$field] = $modelFieldList; } - return $this->modelConfig->fieldList; + return $fieldList; } /** @@ -129,6 +129,7 @@ class portModel extends model public function initValues($model, $field, $fieldValue = '') { $values = $fieldValue['values']; + if($values and (strpos($this->portConfig->sysDataFields, $values) !== false)) { return $this->portConfig->sysDataList[$values];