summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-torrus_serviceid.html
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements/select-torrus_serviceid.html')
-rw-r--r--httemplate/elements/select-torrus_serviceid.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/httemplate/elements/select-torrus_serviceid.html b/httemplate/elements/select-torrus_serviceid.html
new file mode 100644
index 000000000..34e8e930f
--- /dev/null
+++ b/httemplate/elements/select-torrus_serviceid.html
@@ -0,0 +1,32 @@
+<SELECT NAME="<% $opt{'field'} || 'serviceid' %>">
+
+% unless ( $opt{'multiple'} || $opt{'disable_empty'} ) {
+ <OPTION VALUE="">Select serviceid</OPTION>
+% }
+
+% foreach my $serviceid ( keys %serviceid ) {
+ <OPTION VALUE="<%$serviceid%>"
+ <% $serviceid eq $value ? 'SELECTED' : '' %>
+ ><% $serviceid %></OPTION>
+% }
+
+</SELECT>
+
+<%init>
+
+my %opt = @_;
+
+my $value = $opt{'curr_value'} || $opt{'value'};
+
+#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;
+}
+
+</%init>