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