X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fprocess%2Fcust_main_note-import.cgi;h=945689f89f384468f7ecfdbda274e319b0e48c6c;hb=998b32d356338772484814a477d9efb159206b8d;hp=ec96f2349846d15e714db86e065f0bf87bcaa96c;hpb=1d0c67ac17b4b8d9256d7ed8192611d808d2be0f;p=freeside.git diff --git a/httemplate/misc/process/cust_main_note-import.cgi b/httemplate/misc/process/cust_main_note-import.cgi index ec96f2349..945689f89 100644 --- a/httemplate/misc/process/cust_main_note-import.cgi +++ b/httemplate/misc/process/cust_main_note-import.cgi @@ -39,25 +39,37 @@ 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 $cust_main = qsearchs('cust_main', - { 'custnum' => $param->{"custnum$row"} } - ); - my $error; - if ($cust_main) { - $cust_main->comments - ? $cust_main->comments($cust_main->comments. " ". $param->{"note$row"}) - : $cust_main->comments($param->{"note$row"}); - $error = $cust_main->replace; - }else{ - $error = "Can't find customer " . $param->{"custnum$row"}; + my $error = ''; + if ( $param->{use_comments} ) { # why? notes are sexier (i think this can + # come out now? UI doesn't let you set it + my $cust_main = qsearchs('cust_main', + { 'custnum' => $param->{"custnum$row"} } + ); + if ($cust_main) { + $cust_main->comments + ? $cust_main->comments($cust_main->comments. " ". $param->{"note$row"}) + : $cust_main->comments($param->{"note$row"}); + $error = $cust_main->replace; + }else{ + $error = "Can't find customer " . $param->{"custnum$row"}; + } + } else { + + my $comments = $param->{"note$row"}; + my $classnum = ''; + if ( $comments =~ /^\s*(\d+)\s*\|\s*(.+)$/ ) { + $classnum = $1; + $comments = $2; + } + + my $cust_main_note = new FS::cust_main_note { + 'custnum' => $param->{"custnum$row"}, + '_date' => $date, + 'otaker' => $otaker, + 'comments' => $comments, + 'classnum' => $classnum, + }; + $error = $cust_main_note->insert unless ($op eq "Preview"); } my $result = { 'custnum' => $param->{"custnum$row"}, 'last' => $param->{"last$row"},