[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 117e725f126180bc34e1c5d25d7cfca13edf2b02

Mark Wells mark at 420.am
Thu Mar 22 12:45:49 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  117e725f126180bc34e1c5d25d7cfca13edf2b02 (commit)
      from  9b2247c07534fa9408eed1ec034aaeca299dbed2 (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 117e725f126180bc34e1c5d25d7cfca13edf2b02
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Mar 22 12:45:08 2012 -0700

    show svc_hardware addresses as MAC addresses, #16266

diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm
index 22e6275..af6865f 100644
--- a/FS/FS/svc_hardware.pm
+++ b/FS/FS/svc_hardware.pm
@@ -2,9 +2,13 @@ package FS::svc_hardware;
 
 use strict;
 use base qw( FS::svc_Common );
+use vars qw( $conf );
 use FS::Record qw( qsearch qsearchs );
 use FS::hardware_type;
 use FS::hardware_status;
+use FS::Conf;
+
+FS::UID->install_callback(sub { $conf = FS::Conf->new; });
 
 =head1 NAME
 
@@ -125,7 +129,7 @@ sub search_sql {
 
 sub label {
   my $self = shift;
-  $self->serial || $self->hw_addr;
+  $self->serial || $self->display_hw_addr;
 }
 
 =item insert
@@ -213,6 +217,18 @@ sub status_label {
   $status->label;
 }
 
+=item display_hw_addr
+
+Returns the 'hw_addr' field, formatted as a MAC address if the
+'svc_hardware-check_mac_addr' option is enabled.
+
+=cut
+
+sub display_hw_addr {
+  my $self = shift;
+  ($conf->exists('svc_hardware-check_mac_addr') ? 
+    join(':', $self->hw_addr =~ /../g) : $self->hw_addr)
+}
 
 =back
 
diff --git a/httemplate/search/svc_hardware.cgi b/httemplate/search/svc_hardware.cgi
index 7dd0058..ec09be8 100644
--- a/httemplate/search/svc_hardware.cgi
+++ b/httemplate/search/svc_hardware.cgi
@@ -19,7 +19,7 @@
                                      'model',
                                      'revision',
                                      'serial',
-                                     'hw_addr',
+                                     'display_hw_addr',
                                      'ip_addr',
                                      'smartcard',
                                      \&FS::UI::Web::cust_fields,
diff --git a/httemplate/view/svc_hardware.cgi b/httemplate/view/svc_hardware.cgi
index 725358c..7f5e889 100644
--- a/httemplate/view/svc_hardware.cgi
+++ b/httemplate/view/svc_hardware.cgi
@@ -25,19 +25,11 @@ my $note =   { field => 'note',
                type  => 'text',
                value => sub { encode_entities($_[0]->note) }
              };
-my $hw_addr ={ field => 'hw_addr',
-               type  => 'text',
-               value => sub { 
-                my $hw_addr = $_[0]->hw_addr;
-                $conf->exists('svc_hardware-check_mac_addr') ?
-                  join(':', $hw_addr =~ /../g) : $hw_addr
-                },
-              };
 
 my @fields = (
   $model,
   'serial',
-  $hw_addr,
+  'display_hw_addr',
   'ip_addr',
   'smartcard',
   $status,

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

Summary of changes:
 FS/FS/svc_hardware.pm              |   18 +++++++++++++++++-
 httemplate/search/svc_hardware.cgi |    2 +-
 httemplate/view/svc_hardware.cgi   |   10 +---------
 3 files changed, 19 insertions(+), 11 deletions(-)




More information about the freeside-commits mailing list