dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dd_import.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxAdmin;
3
4class dd_import extends \dbxObj {
5
6public $oTPL;
7
8
9public function __construct() {
10 $this->oTPL = dbx()->get_system_obj('dbxTPL');
11}
12
13public function import() {
14 $content = '';
15 $status = 'run';
16 $timer = 100;
17 $percent = 100;
18 $section = $this->_section;
19 dbx()->debug("run import dd_import section=($section)");
20
21
22 $dd =$this->get_property('dd' ,0 ,$section) ; // #todo $section
23 $path_file=$this->get_property('path_file','' ,$section) ;
24 $seperator=$this->get_property('seperator',';',$section);
25 $where =$this->get_property('dd_where' ,'' ,$section) ;
26 $remap =$this->get_property('dd_remap' ,0 ,$section);
27
28 if (!$path_file) $path_file = dbx()->get_file_dir().'sys/csv/'.$dd.'.csv';
29
30
31
32 $file = basename($path_file);
33 $data['file'] = dbx()->os_path($path_file);
34
35 dbx()->debug("### IMPORT CSV dd=($dd) file=($path_file)");
36
37 $oForm = dbx()->get_system_obj('dbxForm');
38 $oForm->init($section, 'form-csv-reader');
39 $oForm->_action = "?dbx_modul=dbxAdmin&dbx_run1=datadic&dbx_run2=import_csv&dd=$dd";
40 $oForm->_data = $data;
41 $oForm->_msg_info = '';
42 $oForm->_try_max = 99999999;
43 $oForm->_fld_change_state = 'all';
44
45 $bdata['id'] = 'button_{i}';
46 $bdata['label'] = "CSV einlesen ($file)";
47 $bdata['sec'] = $timer;
48
49 $oImporter = dbx()->get_system_obj('dbxCSVreader');
50 $oImporter->_section=$section;
51
52
53
54 $date_time = date('d-m-Y H:i:s');
55
56 $msg = "CSV Datei ($path_file) einlesen.";
57
58 $submit=0;
59 if ($oForm->submit()) $submit=1;
60
61 dbx()->debug("### IMPORT CSV submit=($submit) dd=($dd) file=($path_file)");
62 $submit=1;
63
64 if ($submit) {
65
66 $status = $oImporter->init($dd.'_import_csv');
67 dbx()->debug("############# A-Status=($status)");
68
69 if ($status == 'init') {
70 $percent = 100;
71 $msg = "CSV Datei ($path_file) einlesen.";
72 $oImporter->set_property('path_file' , $path_file);
73 $oImporter->set_property('dd' , $dd);
74 $oImporter->set_property('where' , '');
75 $oImporter->set_property('pass' , 0);
76 $oImporter->set_property('owner' , -1);
77 $oImporter->set_property('utf8' , 1);
78 $oImporter->set_property('run_bytes' , 9600);
79 $oImporter->set_property('seperator' , $seperator);
80 $oImporter->set_property('remap' , $remap);
81 $oImporter->set_property('where' , $where);
82 dbx()->debug("##init remap Importer ($path_file) sep=($seperator)");
83 }
84
85 if ($status == 'run') {
86 $status = $oImporter->run();
87 $path_file= $oImporter->get_property('path_file');
88 $filesize = $oImporter->get_property('filesize');
89 $filepos = $oImporter->get_property('filepos');
90 $percent = $oImporter->get_property('percent');
91 $querys = $oImporter->get_property('querys');
92 $errors = $oImporter->get_property('errors');
93 $lines = $oImporter->get_property('lines');
94 $msg = "Datensätze=($querys) ($percent %) status=($status)";
95 dbx()->debug("File=($path_file) filesize=($filesize) FilePos=($filepos) Querys=($querys) errors=($errors) lines=($lines)");
96
97 }
98 if ($status == 'end') {
99 dbx()->debug("END CSV ($dd)");
100 $msg = "Es wurden ($querys) Datensätze eingelesen ($date_time)";
101 if ($errors) $msg .= " Es sind ($errors) Fehler aufgetreten.";
102 }
103
104 $pdata['msg'] = $msg;
105 $pdata['value'] = $percent;
106 $pdata['width'] = $percent;
107 $progress = $this->oTPL->get_tpl('dbx', 'progressbar-1', $pdata);
108 $oForm->add_obj('progress', 'obj-value', $progress);
109 }
110
111
112 $bdata['sec'] = $timer;
113 $bdata['class'] = 'hidden';
114 $button = $this->oTPL->get_tpl('dbx', 'button-submit', $bdata);
115
116 $oForm->add_obj('button' , 'obj-value', $button);
117
118 if ($status != 'end') $oForm->add_js_autosubmit('#dbx_form_{i}', $timer);
119
120 return $oForm->run();
121}
122
123public function run() {
124
125 dbx()->debug("#X# run dd_import");
126 return $this->import();
127}
128
129}
get_property($name, $default='', $section='', $modul='modul')
Liest eine Objekt- oder Session-Property.
Public $_section
Definition dbxKernel.php:66
Class dbxServer extends dbxObj
DBX schema administration.