add CDR batch TFTP feature, RT#3113
[freeside.git] / httemplate / elements / select-cdrbatch.html
1 % if ( scalar(@{ $opt{'cdrbatches'} }) ) {
2
3     <SELECT NAME="<% $opt{'name'} || 'cdrbatch' %>">
4
5     <OPTION VALUE="__ALL__">All
6     <OPTION VALUE="">(blank)
7
8 %   foreach my $cdrbatch ( @{ $opt{'cdrbatches'} } ) { 
9         <OPTION VALUE="<% $cdrbatch %>"<% $cdrbatch eq $selected_cdrbatch ? ' SELECTED' : '' %>><% $cdrbatch %>
10 %   } 
11
12     </SELECT>
13
14 % } else {
15
16   <INPUT TYPE="hidden" NAME="cdrbatch" VALUE="__ALL__">
17
18 % }
19
20 <%init>
21
22 my %opt = @_;
23 my $selected_cdrbatch = $opt{'curr_value'}; # || $opt{'value'} necessary?
24
25 my $conf = new FS::Conf;
26
27 unless ( $opt{'cdrbatches'} ) {
28
29   my $sth = dbh->prepare('SELECT DISTINCT cdrbatch FROM cdr')
30      or die dbh->errstr;
31   $sth->execute or die $sth->errstr;
32   my %cdrbatches = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
33   @{ $opt{'cdrbatches'} } = grep $_, keys %cdrbatches;
34
35 }
36
37 </%init>
38