diff --git a/README.md b/README.md index 405f75b..35acc02 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## import -## Модуль импорта v2.0.1 (Light версия) +## Модуль импорта v2.1 (Light версия) ## Автор: @MadDen @@ -13,6 +13,8 @@ ## Changelog: +13.04.2017 - версия 2.1 + 10.08.2016 - версия 2.0.1 08.08.2016 - версия 2.0 diff --git a/import/class.import.parsers.php b/import/class.import.parsers.php index 0db2d6d..3e604df 100644 --- a/import/class.import.parsers.php +++ b/import/class.import.parsers.php @@ -35,7 +35,7 @@ class ModuleImportParsers $ii = 0; - $items = []; + $items = array(); while ($item = fgetcsv($handle, 0, $sep, $protect)) { @@ -80,7 +80,7 @@ class ModuleImportParsers $tags = $Excel->sheets[0]['cells'][1]; // Определяем теги - $items = []; + $items = array(); $ii = 0; @@ -121,14 +121,14 @@ class ModuleImportParsers $a = array_values($xml); - $tags = []; // Определяем теги + $tags = array(); // Определяем теги foreach ($a[0][0] AS $key => $value) { $tags[] = $key; } - $items = []; + $items = array(); foreach ($a[0] AS $key => $row) { @@ -150,4 +150,43 @@ class ModuleImportParsers return $result; } + + /* !DBF */ + public static function DBF2Array($fname) + { + $db = dbase_open($fname, 0); + + $cols = dbase_get_header_info($db); + + $count = dbase_numrecords($db); + + $rows = array(); + + $tags = array(); + + foreach($cols AS $k => $v) + { + $tags[] = $v['name']; + } + + $ii = 1; + + for ($ii; $ii <= $count; $ii++) + { + $rows[] = dbase_get_record_with_names($db, $ii); + } + + $result = + [ + 'num' => $count - $parser_row, + 'tags' => $tags, + 'rows' => $rows + ]; + + dbase_close($db); + + unset($cols, $count, $tags, $rows); + + return $result; + } } diff --git a/import/class.import.php b/import/class.import.php index f054aa2..18191e8 100644 --- a/import/class.import.php +++ b/import/class.import.php @@ -338,7 +338,7 @@ class ModuleImport global $AVE_DB, $AVE_Template; // если новый - if (!$import_id) + if (! $import_id) { $AVE_DB->Query(" INSERT INTO @@ -416,13 +416,14 @@ class ModuleImport $message = $AVE_Template->get_config_vars('saved'); $header = $AVE_Template->get_config_vars('success'); $theme = 'accept'; + echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme)); exit; } else - { - return $import_id; - } + { + return $import_id; + } } /** @@ -584,12 +585,11 @@ class ModuleImport $i = 0; - $log = - [ + $log = array( 'updated' => array(), 'created' => array(), 'notfound' => array() - ]; + ); // Обрабатываем по очереди каждый объект foreach($import_data['rows'] as $item) @@ -601,6 +601,7 @@ class ModuleImport // парсим шаблоны $item_fields = $fields; + array_walk_recursive($item_fields, array($this, '_parse_tpl'), $replace); // чистим память @@ -618,7 +619,8 @@ class ModuleImport } } - if (! $pass) continue; + if (! $pass) + continue; // проверяем обязательные поля в теле документа foreach ($fields_oblig['body'] as $field_id) @@ -630,7 +632,8 @@ class ModuleImport } } - if (! $pass) continue; + if (! $pass) + continue; // находим документ по ключевым полям $docids = $this->_docs_find($fields_key, $fields_comp, $item_fields, $import->rub_id); diff --git a/import/module.php b/import/module.php index b287eb6..599b064 100644 --- a/import/module.php +++ b/import/module.php @@ -16,10 +16,10 @@ if (defined('ACP')) [ 'ModuleName' => "Импорт (Облегченная версия)", 'ModuleSysName' => "import", - 'ModuleVersion' => "2.0.1", + 'ModuleVersion' => "2.1", 'ModuleDescription' => "Осуществляет импорт документов из файлов различных типов", 'ModuleAutor' => "AVE.cms Team", - 'ModuleCopyright' => "© AVE.cms Team 2016", + 'ModuleCopyright' => "© AVE.cms Team 2017", 'ModuleStatus' => 1, 'ModuleIsFunction' => 0, 'ModuleTemplate' => 0,