RT#39115 - added a optional display name for oid
[freeside.git] / httemplate / edit / elements / part_export / broadband_snmp_get.html
index 8b8717c..a426e61 100644 (file)
@@ -7,17 +7,17 @@ Quite a bit of false laziness with edit/elements/part_export/broadband_snmp.html
   label   => 'SNMP version',
   field   => 'snmp_version',
   options => [ '1', '2c' ],
-  curr_value => $part_export->option('version') 
+  curr_value => $curr_value->{'snmp_version'} 
 &>
 <& /elements/tr-input-text.html,
   label   => 'Community',
   field   => 'snmp_community',
-  curr_value  => $part_export->option('community') || $opt{'export_info'}->{'options'}->{'snmp_community'}->{'default'},
+  curr_value  => $curr_value->{'snmp_community'},
 &>
 <& /elements/tr-input-text.html,
   label   => 'Timeout (seconds)',
   field   => 'snmp_timeout',
-  curr_value  => $part_export->option('timeout') || $opt{'export_info'}->{'options'}->{'snmp_timeout'}->{'default'},
+  curr_value  => $curr_value->{'snmp_timeout'},
 &>
 </TABLE>
 <script type="text/javascript">
@@ -45,32 +45,44 @@ function receive_mib_get(obj, rownum) {
 </script>
 
 <table bgcolor="#cccccc" border=0 cellspacing=3>
-<TR><TH>Object ID</TH></TR>
+<TR><TH>Object Name</TH><TH>Object ID</TH></TR>
 <TR id="broadband_snmp_get_template">
   <TD>
+    <INPUT NAME="oid_name" ID="oid_name" SIZE="25">
+  </TD>
+  <TD>
     <INPUT NAME="oid" ID="oid" SIZE="54">
     <INPUT TYPE="button" VALUE="..." ID="openselector" onclick="open_select_mib_get(this)">
   </TD>
 </TR>
 <& /elements/auto-table.html,
   template_row  => 'broadband_snmp_get_template',
-  fieldorder    => ['oid'],
+  fieldorder    => ['oid_name','oid'],
   data          => \@data,
   table         => 'snmp',
 &>
-<INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid">
+<INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid,snmp_oid_name">
 <& foot.html, %opt &>
 <%init>
 my %opt = @_;
 
 my $part_export = $opt{part_export} || FS::part_export->new;
 
+my $curr_value = {};
+foreach my $field ( qw(snmp_version snmp_community snmp_timeout) ) {
+  $curr_value->{$field} = ($opt{'part_export'} && $opt{'part_export'}->exportnum)
+                          ? $part_export->option($field) 
+                          : $opt{'export_info'}->{'options'}->{$field}->{'default'};
+}
+
 my @oids    = split("\n", $part_export->option('snmp_oid'));
+my @oid_names    = split("\n", $part_export->option('snmp_oid_name'));
 
 my @data;
 while (@oids) {
   my @thisrow = (shift(@oids));
-  push @data, \@thisrow if grep length($_), @thisrow;
+  my $name = shift(@oid_names);
+  push @data, [$name, \@thisrow] if grep length($_), @thisrow;
 }
 
 my $popup_name = 'popup-'.time."-$$-".rand() * 2**32;