72901: OFM Freeside Note Classes [v3 merge]
[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, 'field'      => 'comment_html',
30                                 'curr_value' => $comment
31     &>
32 % }
33
34 <BR>
35
36 <& /elements/checkbox.html, 'field'      => 'sticky',
37                             'value'      => 1,
38                             'curr_value' => $sticky,
39 &>
40 Sticky note<BR><BR>
41
42 <INPUT TYPE="submit" VALUE="<% $notenum ? emt("Apply changes") : emt("Add Note") %>">
43
44 </FORM>
45 </BODY>
46 </HTML>
47
48 <%init>
49
50 my $conf = new FS::Conf;
51
52 my $comment;
53 my $notenum = '';
54 my $classnum;
55 my $sticky = 0;
56 if ( $cgi->param('error') ) {
57   $comment     = $cgi->param('comment');
58   $classnum = $cgi->param('classnum');
59 } elsif ( $cgi->param('notenum') =~ /^(\d+)$/ ) {
60   $notenum = $1;
61   die "illegal query ". $cgi->keywords unless $notenum;
62   my $note = qsearchs('cust_main_note', { 'notenum' => $notenum });
63   die "no such note: ". $notenum unless $note;
64   $comment = $note->comments;
65   $classnum = $note->classnum;
66   $sticky = $note->sticky;
67 }
68
69 $comment =~ s/\r//g; # remove weird line breaks to protect FCKeditor
70
71 $cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum";
72 my $custnum = $1;
73
74 my $action = $notenum ? 'Edit' : 'Add';
75
76 die "access denied"
77   unless $FS::CurrentUser::CurrentUser->access_right("$action customer note");
78
79 </%init>
80