From f675734f1eda5b39f891a6fc8f2f29cbd2e36c35 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Mon, 24 Oct 2016 03:51:26 -0500 Subject: [PATCH] 72901: OFM Freeside Note Classes [conf update, jquery refactor] --- FS/FS/Conf.pm | 17 ++++-- FS/FS/Upgrade.pm | 8 --- FS/FS/cust_main_note.pm | 3 +- httemplate/edit/cust_main_note.cgi | 12 ++--- httemplate/elements/menu.html | 3 +- httemplate/view/cust_main/notes/notes.html | 87 +++++++++++++----------------- 6 files changed, 59 insertions(+), 71 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 6bfe047b9..e4f581961 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -3931,6 +3931,13 @@ and customer address. Include units.', }, { + 'key' => 'cust_main_note-require_class', + 'section' => 'customer_fields', + 'description' => 'Require customer note classes for customer notes', + 'type' => 'checkbox', + }, + + { 'key' => 'cust_main-ticket_statuses', 'section' => 'ticketing', 'description' => 'Show tickets with these statuses on the customer view page.', @@ -5417,10 +5424,14 @@ and customer address. Include units.', { 'key' => 'note-classes', - 'section' => 'customer_fields', - 'description' => 'Use customer note classes', + 'section' => 'deprecated', + 'description' => 'Use customer note classes (now automatically used if classes are defined)', 'type' => 'select', - 'select_enum' => [ '', 'Enabled', 'Required' ], + 'select_hash' => [ + 0 => 'Disabled', + 1 => 'Enabled', + 2 => 'Enabled, with tabs', + ], }, { diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm index 845208688..fce46335b 100644 --- a/FS/FS/Upgrade.pm +++ b/FS/FS/Upgrade.pm @@ -178,14 +178,6 @@ 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 4c48eb609..2288d7c4e 100644 --- a/FS/FS/cust_main_note.pm +++ b/FS/FS/cust_main_note.pm @@ -120,8 +120,7 @@ sub check { 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'; + if $conf->exists('cust_main_note-require_class'); } $self->SUPER::check; diff --git a/httemplate/edit/cust_main_note.cgi b/httemplate/edit/cust_main_note.cgi index cc93f2498..18d59e951 100755 --- a/httemplate/edit/cust_main_note.cgi +++ b/httemplate/edit/cust_main_note.cgi @@ -6,17 +6,17 @@ -% 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' +% if (my @noteclasses = qsearch('cust_note_class',{ 'disabled' => '' })) { +% my %noteclassopts = $conf->exists('cust_main_note-require_class') +% ? ('disable_empty' => 1) +% : ('empty_label' => '(unclassified)'); Class   <% include( '/elements/select-table.html', 'table' => 'cust_note_class', + 'records' => \@noteclasses, 'name_col' => 'classname', 'curr_value' => $classnum, - 'hashref' => { 'disabled' => '' }, - %includeopts, + %noteclassopts, ) %>
% } diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index eb34e4946..c4ea9cd7c 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -684,8 +684,7 @@ tie my %config_cust, 'Tie::IxHash', 'Contact types' => [ $fsurl.'browse/contact_class.html', ''], #XXX useful description ; -$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')); +$config_cust{'Note classes'} = [ $fsurl.'browse/cust_note_class.html', 'Note classes define groups of customer notes for reporting.' ]; 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 f36d7d878..f998ba4c0 100644 --- a/httemplate/view/cust_main/notes/notes.html +++ b/httemplate/view/cust_main/notes/notes.html @@ -2,60 +2,44 @@ <& /elements/init_overlib.html &> -% if ( $note_classes_conf ) { +% if ( $use_class_tabs ) { <% mt('Show notes of class:') |h %>   % # list unclassified last -% foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) { - $b } (keys %classes)), '0' ) { + <% $classes{$classnum} %> -% } +% }
-% } +% } <& /elements/table-grid.html &> @@ -64,7 +48,7 @@ function display_notes_classnum (classnum) { <% mt('Time') |h %> % } <% mt('Employee') |h %> -% if ($note_classes_conf) { +% if ($use_classes) { <% mt('Class') |h %> % } <% mt('Note') |h %> @@ -100,15 +84,14 @@ function display_notes_classnum (classnum) { % '('.emt('delete').')'; % } % - > + > <% note_datestr($note,$conf) %>  <% $note->usernum ? $note->access_user->name : $note->otaker %> -% if ($note_classes_conf) { +% if ($use_classes) { <% $note->classname %> @@ -122,9 +105,13 @@ function display_notes_classnum (classnum) { % } #end foreach note +% if (@notes) { +% } else { +

<% emt('No notes for this customer') %>

+% } <%init> @@ -138,11 +125,11 @@ my(%opt) = @_; my $cust_main = $opt{'cust_main'}; my $custnum = $cust_main->custnum; -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; +my $use_classes = grep { $_ > 0 } keys %classes; # show class column +my $use_class_tabs = (keys %classes > 1) ? 1 : 0; # use class tabs $classes{'-1'} = 'All'; #subroutines -- 2.11.0