From c174642d32c139d1233597e3fa6a467586207023 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Mar 2003 11:36:51 +0000 Subject: [PATCH] minor meta import webUI updates --- httemplate/misc/meta-import.cgi | 24 +++++++--- httemplate/misc/process/meta-import.cgi | 82 +++++++++++++-------------------- 2 files changed, 50 insertions(+), 56 deletions(-) diff --git a/httemplate/misc/meta-import.cgi b/httemplate/misc/meta-import.cgi index ebd2a7e2f..2f3b7380d 100644 --- a/httemplate/misc/meta-import.cgi +++ b/httemplate/misc/meta-import.cgi @@ -1,9 +1,7 @@ <%= header('Import') %>
-Import a CSV file containing customer records (zip tar etc).

- -##no##Default file format is CSV, with the following field order: cust_pkg.setup, dayphone, first, last, address1, address2, city, state, zip, comments

+Import data from a DBI data source

<% #false laziness with edit/cust_main.cgi @@ -44,9 +42,23 @@ Import a CSV file containing customer records (zip tar etc).

<% } %>

- CSV (zip, tar etc) Filename:

- -
+ + + + + + + + + + + + + +
DBI data source:
DBI username:
DBI password:
+ + + diff --git a/httemplate/misc/process/meta-import.cgi b/httemplate/misc/process/meta-import.cgi index 4c3c7d665..9e374b508 100644 --- a/httemplate/misc/process/meta-import.cgi +++ b/httemplate/misc/process/meta-import.cgi @@ -1,5 +1,6 @@ <%= header('Map tables') %> + +
+ <% - #one - unless ( $cgi->param('magic') ) { - - #oops, silly - #my $fh = $cgi->upload('csvfile'); - ##warn $cgi; - ##warn $fh; - # - #use Archive::Tar; - #$tar = Archive::Tar->new(); - #$tar->create_archive($fh); #or die $tar->error; - - #haha for now - my @files = qw( -authserv credtype dunprev invoice pmtdet product taxplan -ccdet customer genlog ledger pops pubvars -cchist discplan glacct origco prodcat recur users -credcode dundet invline payment prodclas repforms webserv - ); + #use DBIx::DBSchema; + my $schema = new_native DBIx::DBSchema + map { $cgi->param($_) } qw( data_source username password ); + foreach my $field (qw( data_source username password )) { %> + VALUE="<%= $cgi->param($field) %>"> + <% } + + my %schema = (); + if ( $cgi->param('schema') ) { + my $schema_string = $cgi->param('schema'); + %> <% + %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ + or die "guru meditation #420: $_"; + ( $1 => $2 ); + } + split( /\n/, $schema_string ); + } + + #first page + unless ( $cgi->param('magic') ) { %> - %> - <%= hashmaker('schema', \@files, [ grep { ! /^h_/ } dbdef->tables ] ) %> + <%= hashmaker('schema', [ $schema->tables ], + [ grep !/^h_/, dbdef->tables ], ) %>
<% - } elsif ( $cgi->param('magic') eq 'process' ) { + #second page + } elsif ( $cgi->param('magic') eq 'process' ) { %> - %> <% - my $schema_string = $cgi->param('schema'); - %><% - my %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/ - or die "guru meditation #420: $_"; - ( $1 => $2 ); - } - split( /\n/, $schema_string ); - - #*** should be in global.asa/handler.pl like the rest - eval 'use Text::CSV_XS;'; - foreach my $table ( keys %schema ) { - my $csv = Text::CSV_XS->new({ 'binary'=>1 }); - open(FILE,"); - close FILE; - $csv->parse($header) or die; - my @from_columns = $csv->fields; - + my @from_columns = $schema->table($table)->columns; my @fs_columns = dbdef->table($schema{$table})->columns; %> - <%= hashmaker($table, \@from_columns, \@fs_columns, $table, $schema{$table} ) %> + <%= hashmaker($table, \@from_columns => \@fs_columns, + $table => $schema{$table}, ) %>


<% @@ -87,16 +74,11 @@ credcode dundet invline payment prodclas repforms webserv
<% + #third (results) } elsif ( $cgi->param('magic') eq 'process2' ) { print "
\n";
-    #false laziness with above
-    my $schema_string = $cgi->param('schema');
-    my %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
-                         or die "guru meditation #420: $_";
-                       ( $1 => $2 );
-                     }
-                 split( /\n/, $schema_string );
+
     foreach my $table ( keys %schema ) {
       ( my $spaces = $table ) =~ s/./ /g;
       print "'$table' => { 'table' => '$schema{$table}',\n".
-- 
2.11.0