summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-cdrbatch.html
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/elements/select-cdrbatch.html')
-rw-r--r--httemplate/elements/select-cdrbatch.html38
1 files changed, 38 insertions, 0 deletions
diff --git a/httemplate/elements/select-cdrbatch.html b/httemplate/elements/select-cdrbatch.html
new file mode 100644
index 0000000..866ba25
--- /dev/null
+++ b/httemplate/elements/select-cdrbatch.html
@@ -0,0 +1,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>
+