faf179acc8fa33b39f446594446b0e64fd6d113d
[freeside.git] / httemplate / edit / elements / part_export / broadband_snmp_get.html
1 <%doc>
2 Quite a bit of false laziness with edit/elements/part_export/broadband_snmp.html
3 </%doc>
4 <& head.html, %opt &>
5 <INPUT TYPE="hidden" NAME="options" VALUE="snmp_community,snmp_version,snmp_timeout">
6 <& /elements/tr-select.html,
7   label   => 'SNMP version',
8   field   => 'snmp_version',
9   options => [ '1', '2c' ],
10   curr_value => $curr_value->{'snmp_version'} 
11 &>
12 <& /elements/tr-input-text.html,
13   label   => 'Community',
14   field   => 'snmp_community',
15   curr_value  => $curr_value->{'snmp_community'},
16 &>
17 <& /elements/tr-input-text.html,
18   label   => 'Timeout (seconds)',
19   field   => 'snmp_timeout',
20   curr_value  => $curr_value->{'snmp_timeout'},
21 &>
22 </TABLE>
23 <script type="text/javascript">
24 function open_select_mib_get(obj) {
25   nd(1); // if there's already one open, close it
26   var rownum = obj.rownum;
27   var curr_oid = obj.form.elements['snmp_oid' + rownum].value || '';
28   var url = '<%$fsurl%>misc/select-mib-popup.html?' +
29             'callback=receive_mib_get;' +
30             'arg=' + rownum +
31             ';curr_value=' + curr_oid;
32   overlib(
33     OLiframeContent(url, 550, 450, '<% $popup_name %>', 0, 'auto'),
34     CAPTION, 'Select MIB object', STICKY, AUTOSTATUSCAP,
35     MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK,
36     BGCOLOR, '#333399', CGCOLOR, '#333399',
37     CLOSETEXT, 'Close'
38   );
39 }
40 function receive_mib_get(obj, rownum) {
41   var oidfield = document.getElementById('snmp_oid'+rownum);
42   oidfield.value = obj.fullname;
43   oidfield.onchange();
44 }
45 </script>
46
47 <table bgcolor="#cccccc" border=0 cellspacing=3>
48 <TR><TH>Object ID</TH></TR>
49 <TR id="broadband_snmp_get_template">
50   <TD>
51     <INPUT NAME="oid" ID="oid" SIZE="54">
52     <INPUT TYPE="button" VALUE="..." ID="openselector" onclick="open_select_mib_get(this)">
53   </TD>
54 </TR>
55 <& /elements/auto-table.html,
56   template_row  => 'broadband_snmp_get_template',
57   fieldorder    => ['oid'],
58   data          => \@data,
59   table         => 'snmp',
60 &>
61 <INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid">
62 <& foot.html, %opt &>
63 <%init>
64 my %opt = @_;
65
66 my $part_export = $opt{part_export} || FS::part_export->new;
67
68 my $curr_value = {};
69 foreach my $field ( qw(snmp_version snmp_community snmp_timeout) ) {
70   $curr_value->{$field} = ($opt{'part_export'} && $opt{'part_export'}->exportnum)
71                           ? $part_export->option($field) 
72                           : $opt{'export_info'}->{'options'}->{$field}->{'default'};
73 }
74
75 my @oids    = split("\n", $part_export->option('snmp_oid'));
76
77 my @data;
78 while (@oids) {
79   my @thisrow = (shift(@oids));
80   push @data, \@thisrow if grep length($_), @thisrow;
81 }
82
83 my $popup_name = 'popup-'.time."-$$-".rand() * 2**32;
84 </%init>