diff options
author | jeff <jeff> | 2007-03-20 17:03:43 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-03-20 17:03:43 +0000 |
commit | 587f0384fb03179f6b504daeada93e193d2ea27f (patch) | |
tree | 0998d5d51ac6112bb80b24031fe7fdfdacc0d48d /httemplate/misc/process | |
parent | 7b3d074cbb694330334469510548d98eebe196ed (diff) |
ticket 1418, a tool for customer note importation
Diffstat (limited to 'httemplate/misc/process')
-rw-r--r-- | httemplate/misc/process/cust_main_note-import.cgi | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/httemplate/misc/process/cust_main_note-import.cgi b/httemplate/misc/process/cust_main_note-import.cgi new file mode 100644 index 000000000..af06ae95e --- /dev/null +++ b/httemplate/misc/process/cust_main_note-import.cgi @@ -0,0 +1,66 @@ +<% include("/elements/header.html", "Batch Customer Note Import $op") %> + +The following items <% $op eq 'Preview' ? 'would not be' : 'were not' %> imported. (See below for imported items) +<PRE> +% foreach my $row (@uninserted) { +% $csv->combine( (map{ $row->{$_} } qw(last first note) ), +% $row->{error} ? ('#!', $row->{error}) : (), +% ); +<% $csv->string %> +% } +</PRE> + +The following items <% $op eq 'Preview' ? 'would be' : 'were' %> imported. (See above for unimported items) + +<PRE> +% foreach my $row (@inserted) { +% $csv->combine( (map{ $row->{$_} } qw(custnum last first note) ), +% ('#!', $row->{name}), +% ); +<% $csv->string %> +% } +</PRE> + +<%init> +my $date = time; +my $otaker = $FS::CurrentUser::CurrentUser->username; +my $csv = new Text::CSV_XS; + +my $param = $cgi->Vars; + +my $op = $param->{preview} ? "Preview" : "Results"; + +my @inserted = (); +my @uninserted = (); +for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) { + if ( $param->{"custnum$row"} ) { + my $cust_main_note = new FS::cust_main_note { + 'custnum' => $param->{"custnum$row"}, + '_date' => $date, + 'otaker' => $otaker, + 'comments' => $param->{"note$row"}, + }; + my $error = ''; + $error = $cust_main_note->insert unless ($op eq "Preview"); + my $result = { 'custnum' => $param->{"custnum$row"}, + 'last' => $param->{"last$row"}, + 'first' => $param->{"first$row"}, + 'note' => $param->{"note$row"}, + 'name' => $param->{"name$row"}, + 'error' => $error, + }; + if ($error) { + push @uninserted, $result; + }else{ + push @inserted, $result; + } + }else{ + push @uninserted, { 'custnum' => '', + 'last' => $param->{"last$row"}, + 'first' => $param->{"first$row"}, + 'note' => $param->{"note$row"}, + 'error' => '', + }; + } +} +</%init> |