From: Ivan Kohler Date: Wed, 28 Jan 2015 10:23:34 +0000 (-0800) Subject: sticky customer notes, RT#29311 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=8706262a6d18ef5103fb5972ca6443b73e700e6a sticky customer notes, RT#29311 --- diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index d01625a41..ef381e573 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1416,13 +1416,14 @@ sub tables_hashref { 'cust_main_note' => { 'columns' => [ - 'notenum', 'serial', '', '', '', '', - 'custnum', 'int', '', '', '', '', - 'classnum', 'int', 'NULL', '', '', '', - '_date', @date_type, '', '', - 'otaker', 'varchar', 'NULL', 32, '', '', - 'usernum', 'int', 'NULL', '', '', '', - 'comments', 'text', 'NULL', '', '', '', + 'notenum', 'serial', '', '', '', '', + 'custnum', 'int', '', '', '', '', + 'classnum', 'int', 'NULL', '', '', '', + '_date', @date_type, '', '', + 'otaker', 'varchar', 'NULL', 32, '', '', + 'usernum', 'int', 'NULL', '', '', '', + 'comments', 'text', 'NULL', '', '', '', + 'sticky', 'int', '', '', 0, '', ], 'primary_key' => 'notenum', 'unique' => [], diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 3ad7f99bb..b43d7e35c 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2346,8 +2346,8 @@ Returns all notes (see L) for this customer. sub notes { my($self,$orderby_classnum) = (shift,shift); - my $orderby = "_DATE DESC"; - $orderby = "CLASSNUM ASC, $orderby" if $orderby_classnum; + my $orderby = "sticky DESC, _date DESC"; + $orderby = "classnum ASC, $orderby" if $orderby_classnum; qsearch( 'cust_main_note', { 'custnum' => $self->custnum }, '', diff --git a/FS/FS/cust_main_note.pm b/FS/FS/cust_main_note.pm index 06da0965a..44d99d8c4 100644 --- a/FS/FS/cust_main_note.pm +++ b/FS/FS/cust_main_note.pm @@ -113,6 +113,7 @@ sub check { || $self->ut_numbern('_date') || $self->ut_textn('otaker') || $self->ut_anything('comments') + || $self->ut_numbern('sticky') ; return $error if $error; diff --git a/httemplate/edit/cust_main_note.cgi b/httemplate/edit/cust_main_note.cgi index 61590566c..a089db2d1 100755 --- a/httemplate/edit/cust_main_note.cgi +++ b/httemplate/edit/cust_main_note.cgi @@ -18,17 +18,24 @@
% } -% if( $FS::CurrentUser::CurrentUser->option('disable_html_editor') ) { - -% } -% else { -<% include('/elements/htmlarea.html', 'field' => 'comment_html', - 'curr_value' => $comment) %> +% if ( $FS::CurrentUser::CurrentUser->option('disable_html_editor') ) { + +% } else { + <& /elements/htmlarea.html, 'field' => 'comment_html', + 'curr_value' => $comment + &> % } -

+
+ +<& /elements/checkbox.html, 'field' => 'sticky', + 'value' => 1, + 'curr_value' => $sticky, +&> +Sticky note

+ "> @@ -42,6 +49,7 @@ my $conf = new FS::Conf; my $comment; my $notenum = ''; my $classnum; +my $sticky = 0; if ( $cgi->param('error') ) { $comment = $cgi->param('comment'); $classnum = $cgi->param('classnum'); @@ -52,6 +60,7 @@ if ( $cgi->param('error') ) { die "no such note: ". $notenum unless $note; $comment = $note->comments; $classnum = $note->classnum; + $sticky = $note->sticky; } $comment =~ s/\r//g; # remove weird line breaks to protect FCKeditor diff --git a/httemplate/edit/process/cust_main_note.cgi b/httemplate/edit/process/cust_main_note.cgi index 227297eef..53e616a43 100755 --- a/httemplate/edit/process/cust_main_note.cgi +++ b/httemplate/edit/process/cust_main_note.cgi @@ -33,6 +33,7 @@ my $new = new FS::cust_main_note ( { _date => time, usernum => $FS::CurrentUser::CurrentUser->usernum, comments => $comment, + sticky => scalar( $cgi->param('sticky') ), } ); my $error; diff --git a/httemplate/view/cust_main/notes/notes.html b/httemplate/view/cust_main/notes/notes.html old mode 100755 new mode 100644 index 6a7a06a02..fa45a68f2 --- a/httemplate/view/cust_main/notes/notes.html +++ b/httemplate/view/cust_main/notes/notes.html @@ -34,6 +34,10 @@ % my $bgcolor1 = '#eeeeee'; % my $bgcolor2 = '#ffffff'; +% my %sticky_color = ( '#eeeeee' => '#ffff66', +% '#ffffff' => '#ffffb8', +% ); +% % my $bgcolor = ''; % my $last_classnum = -1; % my $skipheader = 0; @@ -56,7 +60,7 @@ % ";notenum=$notenum", % 'actionlabel' => emt('Edit customer note'), % 'width' => 616, -% 'height' => 538, #575 +% 'height' => 575, % 'frame' => 'top', % ); % my $clickjs = qq!onclick="$onclick"!; @@ -103,21 +107,23 @@ % $last_classnum = $note->classnum; % } +% my $color = $note->sticky ? $sticky_color{$bgcolor} : $bgcolor; + - <% note_datestr($note,$conf,$bgcolor) %> - + <% note_datestr($note,$conf,$color) %> +  <% $note->usernum ? $note->access_user->name : $note->otaker %> % if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) { - + <% $note->classname %> % } - + <% $note->comments | defang %> % if($edit) { - <% $edit %> + <% $edit %> % }