summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-torrus_serviceid.html
blob: 34e8e930f08c23e16c22b3319aebeb4b0cb5840f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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>