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 | |
parent | 8efd6f2dd2b81f42fdd573c3a194dd0eb6e28206 (diff) |
proper cdr_batch table, RT#6386
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/elements/select-cdrbatch.html | 42 | ||||
-rw-r--r-- | httemplate/elements/tr-select-cdrbatch.html | 18 | ||||
-rw-r--r-- | httemplate/search/cdr.html | 26 | ||||
-rw-r--r-- | httemplate/search/report_cdr.html | 2 | ||||
-rw-r--r-- | httemplate/view/svc_phone.cgi | 4 |
5 files changed, 39 insertions, 53 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> 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</A>"; #} keys(%what); my @links = map { - qq(<A HREF="${p}search/cdr.html?cdrbatch=__ALL__;charged_party=$number;freesidestatus=$what{$_}">). + qq(<A HREF="${p}search/cdr.html?cdrbatchnum=__ALL__;charged_party=$number;freesidestatus=$what{$_}">). "View $_ CDRs</A>"; } keys(%what); - my @ilinks = ( qq(<A HREF="${p}search/cdr.html?cdrbatch=__ALL__;dst=$number">). + my @ilinks = ( qq(<A HREF="${p}search/cdr.html?cdrbatchnum=__ALL__;dst=$number">). 'View incoming CDRs</A>' ); ### |