[freeside-commits] branch master updated. 82b49ace9ca58b1c5508b0b4a705fd1a5890974e

Mark Wells mark at 420.am
Tue Jan 12 12:13:38 PST 2016


The branch, master has been updated
       via  82b49ace9ca58b1c5508b0b4a705fd1a5890974e (commit)
      from  b9ca052cf1e7c58e09833371273672b7c854a98a (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 82b49ace9ca58b1c5508b0b4a705fd1a5890974e
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Jan 12 11:55:35 2016 -0800

    make customer and location fields available in broadband_snmp export, #39341

diff --git a/FS/FS/part_export/broadband_snmp.pm b/FS/FS/part_export/broadband_snmp.pm
index 0ba2756..56d7816 100644
--- a/FS/FS/part_export/broadband_snmp.pm
+++ b/FS/FS/part_export/broadband_snmp.pm
@@ -55,8 +55,10 @@ tie my %options, 'Tie::IxHash',
   'weight'  => 10,
   'notes'   => <<'END'
 Send one or more SNMP SET requests to the IP address registered to the service.
-The value may interpolate fields from svc_broadband by prefixing the field 
-name with <b>$</b>, or <b>$new_</b> and <b>$old_</b> for replace operations.
+The value may interpolate fields from svc_broadband, cust_location, or
+cust_main by prefixing the field name with <b>$</b>. For replace operations,
+svc_broadband fields may be prefixed with <b>$new_</b> and <b>$old_</b>
+(e.g. "$old_mac_addr").
 END
 );
 
@@ -159,6 +161,10 @@ sub substitute {
   # accepts old_ and new_ for replace actions, like shellcommands
   my $self = shift;
   my ($value, $svc_new, $svc_old) = @_;
+
+  my $location = $svc_new->cust_svc->cust_pkg->cust_location;
+  my $cust_main = $location->cust_main;
+
   foreach my $field ( $svc_new->fields ) {
     my $new_val = $svc_new->$field;
     $value =~ s/\$(new_)?$field/$new_val/g;
@@ -167,6 +173,21 @@ sub substitute {
       $value =~ s/\$old_$field/$old_val/g;
     }
   }
+
+  # we don't yet have export_relocate hooks in here, so there's no old/new
+  # cust_location. do cust_location before cust_main, since cust_main has
+  # a bunch of empty fields with the same names.
+  
+  foreach my $field ( $location->fields ) {
+    my $curr_val = $location->get($field);
+    $value =~ s/\$$field/$curr_val/g;
+  }
+
+  foreach my $field ( $cust_main->fields ) {
+    my $curr_val = $cust_main->get($field);
+    $value =~ s/\$$field/$curr_val/g;
+  }
+
   $value;
 }
 
diff --git a/httemplate/edit/elements/part_export/broadband_snmp.html b/httemplate/edit/elements/part_export/broadband_snmp.html
index 63b61e2..44b80f4 100644
--- a/httemplate/edit/elements/part_export/broadband_snmp.html
+++ b/httemplate/edit/elements/part_export/broadband_snmp.html
@@ -75,7 +75,7 @@ function receive_mib(obj, rownum) {
     <INPUT TYPE="text" NAME="datatype" ID="datatype">
   </TD>
   <TD>
-    <INPUT NAME="value" ID="value">
+    <INPUT NAME="value" ID="value" SIZE="30">
   </TD>
 </TR>
 <& /elements/auto-table.html,

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

Summary of changes:
 FS/FS/part_export/broadband_snmp.pm                |   25 ++++++++++++++++++--
 .../edit/elements/part_export/broadband_snmp.html  |    2 +-
 2 files changed, 24 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list