c295e0d7a620652467e9a0ac9f03a87b8898c3a1
[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 ($conf->exists('note-classes') && $conf->config('note-classes') > 0) {
10     Class &nbsp;
11         <% include( '/elements/select-table.html',
12                  'table'       => 'cust_note_class',
13                  'name_col'    => 'classname',
14                  'curr_value'  => $classnum,
15                  'empty_label' => '(none)',
16                  'hashref'     => { 'disabled' => '' },
17          ) %>
18     <BR>
19 % }
20
21 % if ( $FS::CurrentUser::CurrentUser->option('disable_html_editor') ) {
22     <TEXTAREA NAME="comment_plain" ROWS="12" COLS="60"><% 
23     join '', split /<br \/>|&nbsp;/, $comment 
24     %></TEXTAREA>
25 % } else {
26     <& /elements/htmlarea.html,
27          'field'      => 'comment_html',
28          'curr_value' => $comment,
29          'config'     => { toolbarStartupExpanded => Cpanel::JSON::XS::false,
30                            height                 => 315,
31                          },
32     &>
33 % }
34
35 <BR>
36
37 <& /elements/checkbox.html, 'field'      => 'sticky',
38                             'value'      => 1,
39                             'curr_value' => $sticky,
40 &>
41 Sticky note<BR><BR>
42
43 <INPUT TYPE="submit" VALUE="<% $notenum ? emt("Apply changes") : emt("Add Note") %>">
44
45 </FORM>
46 </BODY>
47 </HTML>
48
49 <%init>
50
51 my $conf = new FS::Conf;
52
53 my $comment;
54 my $notenum = '';
55 my $classnum;
56 my $sticky = 0;
57 if ( $cgi->param('error') ) {
58   $comment     = $cgi->param('comment');
59   $classnum = $cgi->param('classnum');
60 } elsif ( $cgi->param('notenum') =~ /^(\d+)$/ ) {
61   $notenum = $1;
62   die "illegal query ". $cgi->keywords unless $notenum;
63   my $note = qsearchs('cust_main_note', { 'notenum' => $notenum });
64   die "no such note: ". $notenum unless $note;
65   $comment = $note->comments;
66   $classnum = $note->classnum;
67   $sticky = $note->sticky;
68 }
69
70 $comment =~ s/\r//g; # remove weird line breaks to protect FCKeditor
71
72 $cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
73 my $custnum = $1;
74
75 my $action = $notenum ? 'Edit' : 'Add';
76
77 die "access denied"
78   unless $FS::CurrentUser::CurrentUser->access_right("$action customer note");
79
80 </%init>
81