summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-cdrbatch.html
blob: 866ba25161c6838b0155e3742a298cd9458b8797 (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
33
34
35
36
37
38
% if ( scalar(@{ $opt{'cdrbatches'} }) ) {

    <SELECT NAME="<% $opt{'name'} || 'cdrbatch' %>">

    <OPTION VALUE="__ALL__">All
    <OPTION VALUE="">(blank)

%   foreach my $cdrbatch ( @{ $opt{'cdrbatches'} } ) { 
        <OPTION VALUE="<% $cdrbatch %>"<% $cdrbatch eq $selected_cdrbatch ? ' SELECTED' : '' %>><% $cdrbatch %>
%   } 

    </SELECT>

% } else {

  <INPUT TYPE="hidden" NAME="cdrbatch" VALUE="__ALL__">

% }

<%init>

my %opt = @_;
my $selected_cdrbatch = $opt{'curr_value'}; # || $opt{'value'} necessary?

my $conf = new FS::Conf;

unless ( $opt{'cdrbatches'} ) {

  my $sth = dbh->prepare('SELECT DISTINCT cdrbatch FROM cdr')
     or die dbh->errstr;
  $sth->execute or die $sth->errstr;
  my %cdrbatches = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
  @{ $opt{'cdrbatches'} } = grep $_, keys %cdrbatches;

}

</%init>