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