replace FS::CGI::header function with header-popup component, related to #71249
[freeside.git] / httemplate / edit / process / cust_main_note.cgi
index 5127c72..2428689 100755 (executable)
@@ -2,9 +2,9 @@
 %  $cgi->param('error', $error);
 <% $cgi->redirect(popurl(2). 'cust_main_note.cgi?'. $cgi->query_string ) %>
 %} else {
-<% header('Note ' . ($notenum ? 'updated' : 'added') ) %>
+<& /elements/header-popup.html, 'Note ' . ($notenum ? 'updated' : 'added')  &>
     <SCRIPT TYPE="text/javascript">
-      window.top.location.reload();
+      topreload();
     </SCRIPT>
     </BODY></HTML>
 % }
@@ -18,16 +18,22 @@ $cgi->param('notenum') =~ /^(\d*)$/
   or die "Illegal notenum: ". $cgi->param('notenum');
 my $notenum = $1;
 
-my $otaker = $FS::CurrentUser::CurrentUser->name;
-$otaker = $FS::CurrentUser::CurrentUser->username
-  if ($otaker eq "User, Legacy");
+$cgi->param('classnum') =~ /^(\d*)$/;
+my $classnum = $1;
+
+my $comment = $cgi->param('comment_html') || 
+              join("<br />\n", 
+                split "(?:\r|\n)+", $cgi->param('comment_plain')
+              );
 
 my $new = new FS::cust_main_note ( {
   notenum  => $notenum,
   custnum  => $custnum,
+  classnum => $classnum ? $classnum : undef,
   _date    => time,
-  otaker   => $otaker,
-  comments =>  $cgi->param('comment'),
+  usernum  => $FS::CurrentUser::CurrentUser->usernum,
+  comments => $comment,
+  sticky   => scalar( $cgi->param('sticky') ),
 } );
 
 my $error;