[freeside-commits] freeside/httemplate/misc/process
cust_main_note-import.cgi, NONE, 1.1
Jeff Finucane,420,,
jeff at wavetail.420.am
Tue Mar 20 10:03:45 PDT 2007
Update of /home/cvs/cvsroot/freeside/httemplate/misc/process
In directory wavetail:/tmp/cvs-serv9533/httemplate/misc/process
Added Files:
cust_main_note-import.cgi
Log Message:
ticket 1418, a tool for customer note importation
--- NEW FILE: cust_main_note-import.cgi ---
<% 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>
More information about the freeside-commits
mailing list