fix A/R report
[freeside.git] / httemplate / elements / select-torrus_serviceid.html
index a8cfca8..e13a6e8 100644 (file)
@@ -4,8 +4,10 @@
   <OPTION VALUE="">Select serviceid</OPTION>
 % }
 
-% foreach my $serviceid ( keys %serviceid ) {
-    <OPTION VALUE="<%$serviceid%>"><% $serviceid %></OPTION>
+% foreach my $serviceid ( @serviceids ) {
+    <OPTION VALUE="<%$serviceid%>"
+            <% $serviceid eq $value ? 'SELECTED' : '' %>
+    ><% $serviceid %></OPTION>
 % } 
 
 </SELECT>
 
 my %opt = @_;
 
-#is this going to get too slow or will the index make it okay?
-my $sth = dbh->prepare("SELECT DISTINCT(serviceid) FROM srvexport")
-  or die dbh->errstr;
-$sth->execute or die $sth->errstr;
-my %serviceid = ();
-while ( my $row = $sth->fetchrow_arrayref ) {
-  my $serviceid = $row->[0];
-  $serviceid =~ s/_(IN|OUT)$//;
-  $serviceid{$serviceid}=1;
-}
+my $value = $opt{'curr_value'} || $opt{'value'};
+
+my $nms = new FS::NetworkMonitoringSystem;
+my @serviceids = $nms->torrus_serviceids;
 
 </%init>