X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcdr.html;h=bf59ff625bcac6eb831001ca86db49c527fb7676;hb=636dd1f25af52d35efe7a323a5765ff5adeadf83;hp=702dc1bccb7c6f8c0c0aa64d64c34491213c0d56;hpb=343befcb41d5ab76173645ceb8ac235ca7b92d35;p=freeside.git diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html index 702dc1bcc..bf59ff625 100644 --- a/httemplate/search/cdr.html +++ b/httemplate/search/cdr.html @@ -8,6 +8,7 @@ 'order_by' => 'ORDER BY calldate', }, 'count_query' => $count_query, + 'count_addl' => [ $totalminutes_sub ], 'header' => [ '', # checkbox column @header, @@ -45,7 +46,6 @@ ''; } }, - ) %> <%init> @@ -55,6 +55,11 @@ die "access denied" my $edit_data = $FS::CurrentUser::CurrentUser->access_right('Edit rating data'); +my $totalminutes_sub = sub { + my $billsec = shift; + sprintf("%.2f",$billsec/60) . ' total minutes'; +}; + my $conf = new FS::Conf; my $areboxes = 0; @@ -147,7 +152,7 @@ foreach my $param ( grep /^termpart\d+status$/, $cgi->param ) { } ### -# src/dest/charged_party +# src/dest/charged_party/svcnum ### my $phonenum = qr/^\s*([\d\-\+\ ]+)\s*$/; @@ -163,10 +168,15 @@ if ( $cgi->param('src') =~ $phonenum ) { push @search, "src = '$src'"; } -if ( $cgi->param('dst') =~ $phonenum ) { - ( my $dst = $1 ) =~ s/$x//g; - $hashref->{'dst'} = $dst; - push @search, "dst = '$dst'"; +if ( $cgi->param('dst') ) { + + my @d = map { $_, "1$_" } split(/\s*,\s*/, $cgi->param('dst') ); + + my $search = 'dst IN ('. join(',', map dbh->quote($_), @d). ')'; + + push @search, $search; + push @qsearch, $search; + } if ( $cgi->param('dcontext') =~ /^\s*(.+)\s*$/ ) { @@ -175,27 +185,32 @@ if ( $cgi->param('dcontext') =~ /^\s*(.+)\s*$/ ) { push @search, "dcontext = '$dcontext'"; } -if ( $cgi->param('charged_party') =~ $phonenum ) { - ( my $charged_party = $1 ) =~ s/$x//g; - #$hashref->{'charged_party'} = $charged_party; - #push @search, "charged_party = '$charged_party'"; - #XXX countrycode +if ( $cgi->param('charged_party') ) { - my $search = " ( charged_party IN ('$charged_party', '1$charged_party') )"; + my @cp = map { $_, "1$_" } + split(/\s*,\s*/, $cgi->param('charged_party') ); + + my $search = 'charged_party IN ('. join(',', map dbh->quote($_), @cp). ')'; push @search, $search; push @qsearch, $search; } -if ( $cgi->param('charged_party_or_src') =~ $phonenum ) { - ( my $charged_party = $1 ) =~ s/$x//g; - #$hashref->{'charged_party'} = $charged_party; - #push @search, "charged_party = '$charged_party'"; - #XXX countrycode +if ( $cgi->param('charged_party_or_src') ) { + + my @cp = map { $_, "1$_" } + split(/\s*,\s*/, $cgi->param('charged_party_or_src') ); + my $in = join(',', map dbh->quote($_), @cp); + + my $search = "( charged_party IN ($in) OR src IN ($in) )"; - my $search = " ( charged_party IN ('$charged_party', '1$charged_party') - OR src IN ('$charged_party', '1$charged_party') )"; + push @search, $search; + push @qsearch, $search; +} +if ( $cgi->param('svcnum') =~ /^([\d, ]+)$/ ) { + my $svcnum = $1; + my $search = "svcnum IN ($svcnum)"; push @search, $search; push @qsearch, $search; } @@ -252,7 +267,7 @@ if ( $cgi->param('acctid') =~ /\d/ ) { my $search = join(' AND ', @search); $search = "WHERE $search" if $search; -my $count_query = "SELECT COUNT(*) FROM cdr $search"; +my $count_query = "SELECT COUNT(*), sum(billsec) FROM cdr $search"; my $qsearch = join(' AND ', @qsearch); $qsearch = ( scalar(keys %$hashref) ? ' AND ' : ' WHERE ' ) . $qsearch