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