RT#8224: allow user to disable HTML editor
[freeside.git] / httemplate / edit / cust_main_note.cgi
1 <% include('/elements/header-popup.html', "$action Customer Note") %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM ACTION="<% popurl(1) %>process/cust_main_note.cgi" METHOD=POST>
6 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
7 <INPUT TYPE="hidden" NAME="notenum" VALUE="<% $notenum %>">
8
9 % if( $FS::CurrentUser::CurrentUser->option('disable_html_editor') ) {
10   <TEXTAREA NAME="comment_plain" ROWS="12" COLS="60"><% 
11   join '', split /<br \/>|&nbsp;/, $comment 
12   %></TEXTAREA>
13 % }
14 % else {
15 <% include('/elements/htmlarea.html', 'field' => 'comment_html',
16                                       'curr_value' => $comment) %>
17 % }
18
19 <BR><BR>
20 <INPUT TYPE="submit" VALUE="<% $notenum ? "Apply Changes" : "Add Note" %>">
21
22 </FORM>
23 </BODY>
24 </HTML>
25
26 <%init>
27
28 my $comment;
29 my $notenum = '';
30 if ( $cgi->param('error') ) {
31   $comment     = $cgi->param('comment');
32 } elsif ( $cgi->param('notenum') =~ /^(\d+)$/ ) {
33   $notenum = $1;
34   die "illegal query ". $cgi->keywords unless $notenum;
35   my $note = qsearchs('cust_main_note', { 'notenum' => $notenum });
36   die "no such note: ". $notenum unless $note;
37   $comment = $note->comments;
38 }
39
40 $comment =~ s/\r//g; # remove weird line breaks to protect FCKeditor
41
42 $cgi->param('custnum') =~ /^(\d+)$/ or die "illeagl custnum";
43 my $custnum = $1;
44
45 my $action = $notenum ? 'Edit' : 'Add';
46
47 die "access denied"
48   unless $FS::CurrentUser::CurrentUser->access_right("$action customer note");
49
50 </%init>
51