X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcust_main_note.cgi;h=2428689c617cfc69e150b9c74546ad177d8ac743;hp=d9251f042ffe1ea175b2fb882ff949549c351564;hb=4d5e45b24200386a7fc47f2cd69949e82e4bc9c3;hpb=30c3ff2acf90e1386fae00759078899c859faf36 diff --git a/httemplate/edit/process/cust_main_note.cgi b/httemplate/edit/process/cust_main_note.cgi index d9251f042..2428689c6 100755 --- a/httemplate/edit/process/cust_main_note.cgi +++ b/httemplate/edit/process/cust_main_note.cgi @@ -1,34 +1,60 @@ -% -% -%$cgi->param('custnum') =~ /^(\d+)$/ -% or die "Illegal custnum: ". $cgi->param('custnum'); -%my $custnum = $1; -% -%my $otaker = $FS::CurrentUser::CurrentUser->name; -%$otaker = $FS::CurrentUser::CurrentUser->username -% if ($otaker eq "User, Legacy"); -% -%my $new = new FS::cust_main_note ( { -% custnum => $custnum, -% _date => time, -% otaker => $otaker, -% comments => $cgi->param('comment'), -%} ); -% -%my $error = $new->insert; -% %if ($error) { % $cgi->param('error', $error); -% print $cgi->redirect(popurl(2). 'cust_main_note.cgi?'. $cgi->query_string ); -%} -% -% -<% header('Note added') %> +<% $cgi->redirect(popurl(2). 'cust_main_note.cgi?'. $cgi->query_string ) %> +%} else { +<& /elements/header-popup.html, 'Note ' . ($notenum ? 'updated' : 'added') &> - -% -% +% } +<%init> + +$cgi->param('custnum') =~ /^(\d+)$/ + or die "Illegal custnum: ". $cgi->param('custnum'); +my $custnum = $1; + +$cgi->param('notenum') =~ /^(\d*)$/ + or die "Illegal notenum: ". $cgi->param('notenum'); +my $notenum = $1; + +$cgi->param('classnum') =~ /^(\d*)$/; +my $classnum = $1; + +my $comment = $cgi->param('comment_html') || + join("
\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, + usernum => $FS::CurrentUser::CurrentUser->usernum, + comments => $comment, + sticky => scalar( $cgi->param('sticky') ), +} ); + +my $error; +if ($notenum) { + + die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Edit customer note'); + + my $old = qsearchs('cust_main_note', { 'notenum' => $notenum }); + $error = "No such note: $notenum" unless $old; + unless ($error) { + map { $new->$_($old->$_) } ('_date', 'otaker'); + $error = $new->replace($old); + } + +} else { + + die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Add customer note'); + + $error = $new->insert; +} +