[freeside-commits] branch FREESIDE_3_BRANCH updated. ba6079dc54bdec02fd3a83396a8430ad095ee2d3

Jonathan Prykop jonathan at 420.am
Mon Oct 24 21:55:36 PDT 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  ba6079dc54bdec02fd3a83396a8430ad095ee2d3 (commit)
       via  d11723f9d8addadcd2aea0dd39fd4d8778dc68ee (commit)
       via  e3feefe68971ffc16a759b76577723fffcc265f2 (commit)
       via  932a41248987b59d271994a209545280ef38498e (commit)
      from  bec799dce8edac137ad9b124629132afa94ef07c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ba6079dc54bdec02fd3a83396a8430ad095ee2d3
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Oct 24 23:52:56 2016 -0500

    72901: OFM Freeside Note Classes [additional v3 tweaks]

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index c31a1e1..0808c38 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4180,7 +4180,7 @@ and customer address. Include units.',
 
   {
     'key'         => 'cust_main_note-require_class',
-    'section'     => 'customer_fields',
+    'section'     => 'UI',
     'description' => 'Require customer note classes for customer notes',
     'type'        => 'checkbox',
   },
diff --git a/httemplate/view/cust_main/notes.html b/httemplate/view/cust_main/notes.html
index deba956..1692519 100755
--- a/httemplate/view/cust_main/notes.html
+++ b/httemplate/view/cust_main/notes.html
@@ -27,6 +27,7 @@
 %        ! $conf->exists('cust_main-disable_notes')
 %      ) {
 
+<P>
   <& /elements/popup_link-cust_main.html,
                 'label'       => emt('Add customer note'),
                 'action'      => $p. 'edit/cust_main_note.cgi',
@@ -35,9 +36,9 @@
                 'width'       => 616,
                 'height'      => 538, #575
   &>
+</P>
 
 %   }
-<BR>
 
 % # actually display notes
 <& notes/notes.html, 'cust_main' => $cust_main &>
diff --git a/httemplate/view/cust_main/notes/notes.html b/httemplate/view/cust_main/notes/notes.html
index 18a75f7..1da0b3c 100644
--- a/httemplate/view/cust_main/notes/notes.html
+++ b/httemplate/view/cust_main/notes/notes.html
@@ -1,4 +1,5 @@
 % if ( scalar(@notes) ) {
+<SCRIPT SRC="<% $fsurl %>elements/jquery.js"></SCRIPT>
 <SCRIPT TYPE="text/javascript">
 
 function display_notes_classnum (classnum) {

commit d11723f9d8addadcd2aea0dd39fd4d8778dc68ee
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Oct 24 03:51:26 2016 -0500

    72901: OFM Freeside Note Classes [v3 merge jquery/conf refactor]

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 8e07c72..c31a1e1 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4179,6 +4179,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'     => 'UI',
     'description' => 'Show tickets with these statuses on the customer view page.',
@@ -5744,10 +5751,14 @@ and customer address. Include units.',
 
   {
     'key'         => 'note-classes',
-    'section'     => 'UI',
-    '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/cust_main_note.pm b/FS/FS/cust_main_note.pm
index 1723951..f637c35 100644
--- a/FS/FS/cust_main_note.pm
+++ b/FS/FS/cust_main_note.pm
@@ -121,8 +121,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 4cf5024..55bd97c 100755
--- a/httemplate/edit/cust_main_note.cgi
+++ b/httemplate/edit/cust_main_note.cgi
@@ -6,17 +6,17 @@
 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
 <INPUT TYPE="hidden" NAME="notenum" VALUE="<% $notenum %>">
 
-% 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,
          ) %>
     <BR>
 % }
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index f8d727e..bd2464a 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -659,8 +659,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 ee2dcc6..18a75f7 100644
--- a/httemplate/view/cust_main/notes/notes.html
+++ b/httemplate/view/cust_main/notes/notes.html
@@ -2,60 +2,44 @@
 <SCRIPT TYPE="text/javascript">
 
 function display_notes_classnum (classnum) {
-
-  var bgcolor1 = '#eeeeee';
-  var bgcolor2 = '#ffffff';
-  var sticky_color = { '#eeeeee' : '#ffff66',
-                       '#ffffff' : '#ffffb8' };
-  var notes_bgcolor = '';
-
-  var trs = document.getElementsByTagName("TR");
-  for (var i=0; i < trs.length; i++) {
-    if (trs[i].id.length > 6 && trs[i].id.substring(0,6) == 'notes_') {
-      if (( classnum == '-1' ) || ( trs[i].getAttribute('data-classnum') == classnum )) {
-        trs[i].style.display = 'table-row';
-        if ( notes_bgcolor == bgcolor1 ) {
-          notes_bgcolor = bgcolor2;
-        } else {
-          notes_bgcolor = bgcolor1;
-        }
-        trs[i].style.backgroundColor = (trs[i].getAttribute('data-sticky') == '1') ? sticky_color[notes_bgcolor] : notes_bgcolor;
-      } else {
-        trs[i].style.display = 'none';
-      }
-    }
-  }
-%   if ($note_classes_conf) {
-
-  var as = document.getElementsByTagName("a");
-  for (var i=0; i < as.length; i++) {
-    if(as[i].id.length > 14 && as[i].id.substring(0,14) == 'notes_tablink_') {
-      if(as[i].id == 'notes_tablink_'+classnum) {
-        as[i].style.fontWeight = 'bold';
-      } else {
-        as[i].style.fontWeight = 'normal';
-      }
-    }
+  // hide/show
+  var $custnote = $('.custnote');
+  if (classnum >= 0) {
+    $custnote.hide();
+    $('tr[data-classnum=' + classnum + ']').show();
+  } else {
+    $custnote.show();
   }
-%   } # if note_classes_conf
-
+  // restripe
+  var $shownote = $custnote.filter(':visible');
+  var $shownote_even = $shownote.filter(':even');
+  var $shownote_odd = $shownote.filter(':odd');
+  $shownote_even.css('background-color','#eeeeee');
+  $shownote_even.filter('.stickynote').css('background-color','#ffff66');
+  $shownote_odd.css('background-color','#ffffff');
+  $shownote_odd.filter('.stickynote').css('background-color','#ffffb8');
+%   if ($use_class_tabs) {
+  // update links
+  var $tablink = $('.notes_tablink');
+  $tablink.css('font-weight','normal');
+  $tablink.filter('a[data-classnum=' + classnum + ']').css('font-weight','bold');
+%   }
 }
-
 </SCRIPT>
 
   <& /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' ) {
-	    <A	id="notes_tablink_<% $classnum %>"
+% 	  foreach my $classnum ( (grep { $_ != 0} sort { $a <=> $b } (keys %classes)), '0' ) {
+	    <A CLASS="notes_tablink"
+        data-classnum="<% $classnum %>"
 		HREF="javascript:display_notes_classnum(<% $classnum %>)"
-		style="font-weight: <% $classnum == -1 ? 'bold' : 'normal' %>"
 	    ><% $classes{$classnum} %></A>
-% 	}
+% 	  }
     <BR>
-% }
+%   }
 
 <& /elements/table-grid.html &>
   <TR>
@@ -64,7 +48,7 @@ function display_notes_classnum (classnum) {
     <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Time') |h %></TH>
 %   }
     <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Person') |h %></TH>
-%   if ($note_classes_conf) {
+%   if ($use_classes) {
     <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Class') |h %></TH>
 %   }
     <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Note') |h %></TH>
@@ -100,15 +84,14 @@ function display_notes_classnum (classnum) {
 %             '('.emt('delete').')</A>';
 %   }
 %
-    <TR ID="notes_<% $note->notenum %>"
-        data-sticky="<% $note->sticky ? 1 : 0 %>"
-        <% $note_classes_conf ? ' data-classnum="'.($note->classnum || 0).'"' : '' %>>
+    <TR CLASS="grid custnote<% $note->sticky ? ' stickynote' : '' %>"
+        <% $use_class_tabs ? ' data-classnum="'.($note->classnum || 0).'"' : '' %>>
 
       <% note_datestr($note,$conf) %>
       <TD CLASS="grid">
          <% $note->usernum ? $note->access_user->name : $note->otaker %>
       </TD>
-%   if ($note_classes_conf) {
+%   if ($use_classes) {
       <TD CLASS="grid">
 	<% $note->classname %>   
       </TD>
@@ -122,9 +105,13 @@ function display_notes_classnum (classnum) {
     </TR>
 % } #end foreach note
 
+% if (@notes) {
 </TABLE>
 
 <SCRIPT>display_notes_classnum('-1')</SCRIPT>
+% } else {
+<P><I><% emt('No notes for this customer') %></I></P>
+% }
 
 <%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

commit e3feefe68971ffc16a759b76577723fffcc265f2
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Oct 24 23:25:51 2016 -0500

    72901: OFM Freeside Note Classes [v3 merge tweak]

diff --git a/httemplate/view/cust_main/notes/notes.html b/httemplate/view/cust_main/notes/notes.html
index f36d7d8..ee2dcc6 100644
--- a/httemplate/view/cust_main/notes/notes.html
+++ b/httemplate/view/cust_main/notes/notes.html
@@ -63,7 +63,7 @@ function display_notes_classnum (classnum) {
 %   if ( $conf->exists('cust_main_note-display_times') ) {
     <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Time') |h %></TH>
 %   }
-    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Employee') |h %></TH>
+    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Person') |h %></TH>
 %   if ($note_classes_conf) {
     <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Class') |h %></TH>
 %   }

commit 932a41248987b59d271994a209545280ef38498e
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Oct 14 20:49:38 2016 -0500

    72901: OFM Freeside Note Classes [v3 merge]

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index d3d437d..8e07c72 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5747,11 +5747,7 @@ and customer address. Include units.',
     'section'     => 'UI',
     '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/cust_main_note.pm b/FS/FS/cust_main_note.pm
index 44d99d8..1723951 100644
--- a/FS/FS/cust_main_note.pm
+++ b/FS/FS/cust_main_note.pm
@@ -5,6 +5,7 @@ use base qw( FS::otaker_Mixin FS::Record );
 use Carp;
 use FS::Record qw( qsearch qsearchs );
 use FS::cust_note_class;
+use FS::Conf;
 
 =head1 NAME
 
@@ -117,6 +118,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 a089db2..4cf5024 100755
--- a/httemplate/edit/cust_main_note.cgi
+++ b/httemplate/edit/cust_main_note.cgi
@@ -6,14 +6,17 @@
 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
 <INPUT TYPE="hidden" NAME="notenum" VALUE="<% $notenum %>">
 
-% 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,
          ) %>
     <BR>
 % }
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 621165d..f8d727e 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -660,7 +660,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 fa45a68..f36d7d8 100644
--- a/httemplate/view/cust_main/notes/notes.html
+++ b/httemplate/view/cust_main/notes/notes.html
@@ -1,55 +1,81 @@
 % if ( scalar(@notes) ) {
-
 <SCRIPT TYPE="text/javascript">
 
-    function display_notes_classnum(classnum){
-	document.getElementById('notes_'+classnum).style.display = 'block';
-	document.getElementById('notes_tablink_'+classnum).style.fontWeight = 'bold';
-
-	var divs = document.getElementsByTagName("div");
-	var i;
-	for(i=0; i < divs.length; i++){
-	    var d = divs[i];
-	    if(d.id.length > 6 && d.id.substring(0,6) == 'notes_') {
-		if(divs[i].id != 'notes_'+classnum) {
-		    divs[i].style.display = 'none';
-		}
-	    }
-	}
-	
-	var as = document.getElementsByTagName("a");
-	for(i=0; i < as.length; i++){
-	    var a = as[i];
-	    if(a.id.length > 14 && a.id.substring(0,14) == 'notes_tablink_') {
-		if(as[i].id != 'notes_tablink_'+classnum) {
-		    as[i].style.fontWeight = 'normal';
-		}
-	    }
-	}
+function display_notes_classnum (classnum) {
+
+  var bgcolor1 = '#eeeeee';
+  var bgcolor2 = '#ffffff';
+  var sticky_color = { '#eeeeee' : '#ffff66',
+                       '#ffffff' : '#ffffb8' };
+  var notes_bgcolor = '';
+
+  var trs = document.getElementsByTagName("TR");
+  for (var i=0; i < trs.length; i++) {
+    if (trs[i].id.length > 6 && trs[i].id.substring(0,6) == 'notes_') {
+      if (( classnum == '-1' ) || ( trs[i].getAttribute('data-classnum') == classnum )) {
+        trs[i].style.display = 'table-row';
+        if ( notes_bgcolor == bgcolor1 ) {
+          notes_bgcolor = bgcolor2;
+        } else {
+          notes_bgcolor = bgcolor1;
+        }
+        trs[i].style.backgroundColor = (trs[i].getAttribute('data-sticky') == '1') ? sticky_color[notes_bgcolor] : notes_bgcolor;
+      } else {
+        trs[i].style.display = 'none';
+      }
+    }
+  }
+%   if ($note_classes_conf) {
+
+  var as = document.getElementsByTagName("a");
+  for (var i=0; i < as.length; i++) {
+    if(as[i].id.length > 14 && as[i].id.substring(0,14) == 'notes_tablink_') {
+      if(as[i].id == 'notes_tablink_'+classnum) {
+        as[i].style.fontWeight = 'bold';
+      } else {
+        as[i].style.fontWeight = 'normal';
+      }
     }
+  }
+%   } # if note_classes_conf
+
+}
 
 </SCRIPT>
 
   <& /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' ) {
+	    <A	id="notes_tablink_<% $classnum %>"
+		HREF="javascript:display_notes_classnum(<% $classnum %>)"
+		style="font-weight: <% $classnum == -1 ? 'bold' : 'normal' %>"
+	    ><% $classes{$classnum} %></A>
+% 	}
+    <BR>
+% }
+
+<& /elements/table-grid.html &>
+  <TR>
+    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Date') |h %></TH>
+%   if ( $conf->exists('cust_main_note-display_times') ) {
+    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Time') |h %></TH>
+%   }
+    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Employee') |h %></TH>
+%   if ($note_classes_conf) {
+    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Class') |h %></TH>
 %   }
+    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"><% mt('Note') |h %></TH>
+%   if ($curuser->access_right('Edit customer note') ) {
+    <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="padding: 0 1em"> </TH>
+%   }
+  </TR>
+
+% } # end if @notes
+
+% foreach my $note (@notes) {
 %
 %   my $pop = popurl(3);
 %   my $notenum = $note->notenum;
@@ -74,77 +100,32 @@
 %             '('.emt('delete').')</A>';
 %   }
 %
-% 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 ) {
-    </TABLE>
-  </DIV>
-% }
-% my $display = ($tmp_classnum == 0 || !$conf->exists('note-classes') 
-%				    || $conf->config('note-classes') < 2) 
-%							    ? 'block' : 'none';
-	<DIV 	id="notes_<% $tmp_classnum %>"
-		style="display:<% $display %>"
-	>
-	<& /elements/table-grid.html &>
-	<TR>
-	    <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
-%   if ( $conf->exists('cust_main_note-display_times') ) {
-	    <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Time') |h %></TH>
-%   }
-	    <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Person') |h %></TH>
-%   if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) {
-	    <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Class') |h %></TH>
-%   }
-	    <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Note') |h %></TH>
-%   if ($curuser->access_right('Edit customer note') ) {
-	    <TH CLASS="grid" BGCOLOR="#cccccc"> </TH>
-%   }
-	</TR>
-% $skipheader = (!$conf->exists('note-classes') || $conf->config('note-classes') < 2);
-% $last_classnum = $note->classnum;
-% }
-
-% my $color = $note->sticky ? $sticky_color{$bgcolor} : $bgcolor;
+    <TR ID="notes_<% $note->notenum %>"
+        data-sticky="<% $note->sticky ? 1 : 0 %>"
+        <% $note_classes_conf ? ' data-classnum="'.($note->classnum || 0).'"' : '' %>>
 
-    <TR>
-      <% note_datestr($note,$conf,$color) %>
-      <TD CLASS="grid" BGCOLOR="<% $color %>">
+      <% note_datestr($note,$conf) %>
+      <TD CLASS="grid">
          <% $note->usernum ? $note->access_user->name : $note->otaker %>
       </TD>
-% if ($conf->exists('note-classes') && $conf->config('note-classes') == 1) {
-      <TD CLASS="grid" BGCOLOR="<% $color %>">
+%   if ($note_classes_conf) {
+      <TD CLASS="grid">
 	<% $note->classname %>   
       </TD>
-% }
-      <TD CLASS="grid" BGCOLOR="<% $color %>">
+%   }
+      <TD CLASS="grid">
         <% $note->comments | defang %>
       </TD>
-% if($edit) {
-      <TD CLASS="grid" BGCOLOR="<% $color %>"><% $edit %></TD>
-% }
+%   if ($edit) {
+      <TD CLASS="grid"><% $edit %></TD>
+%   }
     </TR>
-
-% } #end display notes
+% } #end foreach note
 
 </TABLE>
-</DIV>
 
-% 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) ) {
-	    <A	id="notes_tablink_<% $classnum %>"
-		HREF="javascript:display_notes_classnum(<% $classnum %>)"
-		style="font-weight: <% $classnum == 0 ? 'bold' : 'normal' %>"
-	    ><% $classes{$classnum} %></A>
-% 	}
-    <BR>
-% }
+<SCRIPT>display_notes_classnum('-1')</SCRIPT>
 
-% }
 <%init>
 
 use HTML::Defang;
@@ -157,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{<TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">};
+  my($note, $conf) = @_ or return '';
+  my $td = qq{<TD CLASS="grid" ALIGN="right">};
   my $format = "$td%b %o, %Y</TD>";
   $format .= "$td%l:%M%P</TD>"
     if $conf->exists('cust_main_note-display_times');

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                              |   11 +-
 FS/FS/cust_main_note.pm                    |    7 ++
 httemplate/edit/cust_main_note.cgi         |    9 +-
 httemplate/elements/menu.html              |    3 +-
 httemplate/view/cust_main/notes.html       |    3 +-
 httemplate/view/cust_main/notes/notes.html |  184 ++++++++++++----------------
 6 files changed, 104 insertions(+), 113 deletions(-)




More information about the freeside-commits mailing list