diff options
author | ivan <ivan> | 2009-11-19 09:47:02 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-11-19 09:47:02 +0000 |
commit | 457cf05ffc31212de613249c95a8ab05aed34f47 (patch) | |
tree | 0ce85765bb021c52d3c3b572a68afc49879c1a57 /httemplate/elements | |
parent | 8efd6f2dd2b81f42fdd573c3a194dd0eb6e28206 (diff) |
proper cdr_batch table, RT#6386
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/select-cdrbatch.html | 42 | ||||
-rw-r--r-- | httemplate/elements/tr-select-cdrbatch.html | 18 |
2 files changed, 17 insertions, 43 deletions
diff --git a/httemplate/elements/select-cdrbatch.html b/httemplate/elements/select-cdrbatch.html index 866ba2516..034db3afd 100644 --- a/httemplate/elements/select-cdrbatch.html +++ b/httemplate/elements/select-cdrbatch.html @@ -1,38 +1,14 @@ -% 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__"> - -% } - +<% include( '/elements/select-table.html', + 'table' => 'cdr_batch', + 'name_col' => 'cdrbatch', + 'curr_value' => $cdrbatchnum, + 'empty_label' => '(none)', + 'pre_options' => [ '__ALL__' => '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; - -} +my $cdrbatchnum = $opt{'curr_value'}; # || $opt{'value'} necessary? </%init> - diff --git a/httemplate/elements/tr-select-cdrbatch.html b/httemplate/elements/tr-select-cdrbatch.html index 21cd00462..d080e2439 100644 --- a/httemplate/elements/tr-select-cdrbatch.html +++ b/httemplate/elements/tr-select-cdrbatch.html @@ -1,6 +1,6 @@ -% if ( ! scalar(@{ $opt{'cdrbatches'} }) ) { +% if ( ! $show ) { - <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'cdrbatch' %>" VALUE="<% $selected_cdrbatch %>"> + <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'cdrbatchnum' %>" VALUE="__ALL__"> % } else { @@ -18,15 +18,13 @@ my( %opt ) = @_; my $conf = new FS::Conf; my $selected_cdrbatch = $opt{'curr_value'}; # || $opt{'value'} necessary? -unless ( $opt{'cdrbatches'} ) { +$opt{'records'} = delete $opt{'cdr_batch'} + if $opt{'cdr_batch'}; - my $sth = dbh->prepare('SELECT 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; - -} +my $sth = dbh->prepare('SELECT COUNT(*) FROM cdr_batch LIMIT 1') + or die dbh->errstr; +$sth->execute or die $sth->errstr; +my $show = $sth->fetchrow_arrayref->[0]; </%init> |