From 457cf05ffc31212de613249c95a8ab05aed34f47 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Nov 2009 09:47:02 +0000 Subject: proper cdr_batch table, RT#6386 --- httemplate/elements/select-cdrbatch.html | 42 +++++++---------------------- httemplate/elements/tr-select-cdrbatch.html | 18 ++++++------- httemplate/search/cdr.html | 26 +++++++++++++----- httemplate/search/report_cdr.html | 2 +- httemplate/view/svc_phone.cgi | 4 +-- 5 files changed, 39 insertions(+), 53 deletions(-) (limited to 'httemplate') 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'} }) ) { - - - -% } else { - - - -% } - +<% 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? - 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 ) { - + % } 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]; diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html index d1f68c5c6..cfbc5ed5d 100644 --- a/httemplate/search/cdr.html +++ b/httemplate/search/cdr.html @@ -179,18 +179,30 @@ if ( $cgi->param('charged_party') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) { } ### -# cdrbatch +# cdrbatchnum (or legacy cdrbatch) ### -if ( $cgi->param('cdrbatch') ne '__ALL__' ) { - if ( $cgi->param('cdrbatch') eq '' ) { - my $search = "( cdrbatch IS NULL OR cdrbatch = '' )"; +if ( $cgi->param('cdrbatch') ) { + + my $cdr_batch = + qsearchs('cdr_batch', { 'cdrbatch' => scalar($cgi->param('cdrbatch')) } ); + if ( $cdr_batch ) { + push @search, 'cdrbatchnum = '. $cdr_batch->cdrbatchnum; + } else { + die "unknown cdrbatch ". $cgi->param('cdrbatch'); + } + +} elsif ( $cgi->param('cdrbatchnum') ne '__ALL__' ) { + + if ( $cgi->param('cdrbatchnum') eq '' ) { + my $search = "( cdrbatchnum IS NULL )"; push @qsearch, $search; push @search, $search; - } else { - $hashref->{cdrbatch} = $cgi->param('cdrbatch'); - push @search, 'cdrbatch = '. dbh->quote($cgi->param('cdrbatch')); + } elsif ( $cgi->param('cdrbatchnum') =~ /^(\d+)$/ ) { + $hashref->{cdrbatchnum} = $1; + push @search, "cdrbatchnum = $1"; } + } ### diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html index c685198d9..744038d12 100644 --- a/httemplate/search/report_cdr.html +++ b/httemplate/search/report_cdr.html @@ -132,7 +132,7 @@ my @show_default = qw( startdate answerdate enddate duration billsec disposition amaflags accountcode userfield rated_price upstream_price carrierid - svcnum freesidestatus freesiderewritestatus cdrbatch + svcnum freesidestatus freesiderewritestatus ); my %show_default = map { $_=>1 } @show_default; diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi index 09d5be483..c5fce62d9 100644 --- a/httemplate/view/svc_phone.cgi +++ b/httemplate/view/svc_phone.cgi @@ -107,11 +107,11 @@ my $html_foot = sub { # "View $_ CDRs"; #} keys(%what); my @links = map { - qq(). + qq(). "View $_ CDRs"; } keys(%what); - my @ilinks = ( qq(). + my @ilinks = ( qq(). 'View incoming CDRs' ); ### -- cgit v1.2.1