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