From: Mark Wells Date: Sun, 16 Oct 2016 04:06:04 +0000 (-0700) Subject: Merge branch 'master' of git.freeside.biz:/home/git/freeside X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=6a509099343ed155525c4304f1ad742cc6e4ce59;hp=fbfd9445bb00c2a1c7f4386878edead9b50c482f Merge branch 'master' of git.freeside.biz:/home/git/freeside --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index f4f7d2602..a48125d09 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -5419,11 +5419,7 @@ and customer address. Include units.', 'section' => 'customer_fields', 'description' => 'Use customer note classes', 'type' => 'select', - 'select_hash' => [ - 0 => 'Disabled', - 1 => 'Enabled', - 2 => 'Enabled, with tabs', - ], + 'select_enum' => [ '', 'Enabled', 'Required' ], }, { diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm index c959ba947..1c1095e37 100644 --- a/FS/FS/Upgrade.pm +++ b/FS/FS/Upgrade.pm @@ -178,6 +178,14 @@ If you need to continue using the old Form 477 report, turn on the $conf->set('cust-fields',$cust_fields); } + #repurposed + $conf->set('note-classes','Enabled') + if $conf->exists('note-classes') + and grep {$_ eq $conf->config('note-classes')} ('1','2'); + $conf->set('note-classes','') + if $conf->exists('note-classes') + and '0' eq $conf->config('note-classes'); + enable_banned_pay_pad() unless length($conf->config('banned_pay-pad')); # if translate-auto-insert is enabled for a locale, ensure that invoice diff --git a/FS/FS/cust_main_note.pm b/FS/FS/cust_main_note.pm index ee63883d2..4c48eb609 100644 --- a/FS/FS/cust_main_note.pm +++ b/FS/FS/cust_main_note.pm @@ -4,6 +4,7 @@ use base qw( FS::otaker_Mixin FS::Record ); use strict; use Carp; use FS::Record qw( qsearchs ); #qw( qsearch qsearchs ); +use FS::Conf; =head1 NAME @@ -116,6 +117,13 @@ sub check { ; return $error if $error; + if (!$self->classnum) { + my $conf = new FS::Conf; + return 'Note class is required' + if $conf->exists('note-classes') + and $conf->config('note-classes') eq 'Required'; + } + $self->SUPER::check; } diff --git a/httemplate/edit/cust_main_note.cgi b/httemplate/edit/cust_main_note.cgi index c295e0d7a..cc93f2498 100755 --- a/httemplate/edit/cust_main_note.cgi +++ b/httemplate/edit/cust_main_note.cgi @@ -6,14 +6,17 @@ -% if ($conf->exists('note-classes') && $conf->config('note-classes') > 0) { +% if ($conf->exists('note-classes') && $conf->config('note-classes')) { +% my %includeopts = $conf->config('note-classes') eq 'Enabled' +% ? ('empty_label' => '(unclassified)') +% : ('disable_empty' => 1); # eq 'Required' Class   <% include( '/elements/select-table.html', 'table' => 'cust_note_class', 'name_col' => 'classname', 'curr_value' => $classnum, - 'empty_label' => '(none)', 'hashref' => { 'disabled' => '' }, + %includeopts, ) %>
% } diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index d6ea06891..eb34e4946 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -685,7 +685,7 @@ tie my %config_cust, 'Tie::IxHash', ; $config_cust{'Note classes'} = [ $fsurl.'browse/cust_note_class.html', 'Note classes define groups of customer notes for reporting.' ] - if ($conf->exists('note-classes') && $conf->config('note-classes') > 0); + if ($conf->exists('note-classes') && $conf->config('note-classes')); tie my %config_agent, 'Tie::IxHash', 'Agent types' => [ $fsurl.'browse/agent_type.cgi', 'Agent types define groups of package definitions that you can then assign to particular agents' ], diff --git a/httemplate/view/cust_main/notes/notes.html b/httemplate/view/cust_main/notes/notes.html index eb421eb37..f36d7d878 100644 --- a/httemplate/view/cust_main/notes/notes.html +++ b/httemplate/view/cust_main/notes/notes.html @@ -1,55 +1,81 @@ % if ( scalar(@notes) ) { - <& /elements/init_overlib.html &> -% my $bgcolor1 = '#eeeeee'; -% my $bgcolor2 = '#ffffff'; -% my %sticky_color = ( '#eeeeee' => '#ffff66', -% '#ffffff' => '#ffffb8', -% ); -% -% my $bgcolor = ''; -% my $last_classnum = -1; -% my $skipheader = 0; -% my %classes = (); -% -% foreach my $note (@notes) { -% -% if ( $bgcolor eq $bgcolor1 ) { -% $bgcolor = $bgcolor2; -% } else { -% $bgcolor = $bgcolor1; +% if ( $note_classes_conf ) { +<% mt('Show notes of class:') |h %>   +% # list unclassified last +% foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) { + <% $classes{$classnum} %> +% } +
+% } + +<& /elements/table-grid.html &> + + <% mt('Date') |h %> +% if ( $conf->exists('cust_main_note-display_times') ) { + <% mt('Time') |h %> +% } + <% mt('Employee') |h %> +% if ($note_classes_conf) { + <% mt('Class') |h %> % } + <% mt('Note') |h %> +% if ($curuser->access_right('Edit customer note') ) { +   +% } + + +% } # end if @notes + +% foreach my $note (@notes) { % % my $pop = popurl(3); % my $notenum = $note->notenum; @@ -74,79 +100,32 @@ % '('.emt('delete').')'; % } % -% if ( $last_classnum != $note->classnum && !$skipheader ) { -% my $tmp_classnum = $note->classnum ? $note->classnum : 0; -% $classes{$tmp_classnum} = $note->classname ne '' ? $note->classname -% : emt('Other'); -% if ( $last_classnum != -1 ) { - - -% } -% my $display = ($tmp_classnum == 0 || !$conf->exists('note-classes') -% || $conf->config('note-classes') < 2) -% ? 'block' : 'none'; -
- <& /elements/table-grid.html &> - - - <% mt('Date') |h %> -% if ( $conf->exists('cust_main_note-display_times') ) { - <% mt('Time') |h %> -% } - <% mt('Employee') |h %> -% if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) { - <% mt('Class') |h %> -% } - <% mt('Note') |h %> -% if ($curuser->access_right('Edit customer note') ) { -   -% } - - -% $skipheader = (!$conf->exists('note-classes') || $conf->config('note-classes') < 2); -% $last_classnum = $note->classnum; -% } - -% my $color = $note->sticky ? $sticky_color{$bgcolor} : $bgcolor; + > - - <% note_datestr($note,$conf,$color) %> - + <% note_datestr($note,$conf) %> +  <% $note->usernum ? $note->access_user->name : $note->otaker %> -% if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) { - +% if ($note_classes_conf) { + <% $note->classname %> -% } - +% } + <% $note->comments | defang %> -% if($edit) { - <% $edit %> -% } +% if ($edit) { + <% $edit %> +% } - -% } #end display notes +% } #end foreach note -
-% if ( $conf->exists('note-classes') && $conf->config('note-classes') == 2 ) { -% my($classnum,$classname); -<% mt('Show notes of class:') |h %>   -% foreach my $classnum ( sort { $b <=> $a } (keys %classes) ) { - <% $classes{$classnum} %> -% } -
-% } + -% } <%init> use HTML::Defang; @@ -159,13 +138,18 @@ my(%opt) = @_; my $cust_main = $opt{'cust_main'}; my $custnum = $cust_main->custnum; -my (@notes) = $cust_main->notes($conf->exists('note-classes') && $conf->config('note-classes') == 2); +my $note_classes_conf = $conf->exists('note-classes') ? $conf->config('note-classes') : ''; + +my (@notes) = $cust_main->notes(); + +my %classes = map { ($_->classnum || 0) => ( $_->classname ne '' ? $_->classname : '('.emt('unclassified').')' ) } @notes; +$classes{'-1'} = 'All'; #subroutines sub note_datestr { - my($note, $conf, $bgcolor) = @_ or return ''; - my $td = qq{}; + my($note, $conf) = @_ or return ''; + my $td = qq{}; my $format = "$td%b %o, %Y"; $format .= "$td%l:%M%P" if $conf->exists('cust_main_note-display_times');