summaryrefslogtreecommitdiff
path: root/FS/FS/svc_phone.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-02-25 17:10:46 -0800
committerMark Wells <mark@freeside.biz>2013-02-25 17:10:46 -0800
commitdb5e7f34b1e17ae6ce8909062537cc2fb98ca30d (patch)
treeab15f48e4be51356ec5625e55269ec1b68e37375 /FS/FS/svc_phone.pm
parent2fc12e6b5a376fef9b5f5bf0301aab8497c6a412 (diff)
display inbound CDRs in selfservice, #18316; Taqua caller ID, #18574
Diffstat (limited to 'FS/FS/svc_phone.pm')
-rw-r--r--FS/FS/svc_phone.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index bf610c6..f28002c 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -688,6 +688,8 @@ with the chosen prefix.
=item disable_src => 1: Only match on "charged_party", not "src".
+=item nonzero: Only return CDRs where duration > 0.
+
=item by_svcnum: not supported for svc_phone
=item billsec_sum: Instead of returning all of the CDRs, return a single
@@ -755,6 +757,9 @@ sub psearch_cdrs {
if ( $options{'end'} ) {
push @where, 'startdate < '. $options{'end'};
}
+ if ( $options{'nonzero'} ) {
+ push @where, 'duration > 0';
+ }
my $extra_sql = ( keys(%hash) ? ' AND ' : ' WHERE ' ). join(' AND ', @where );
@@ -781,6 +786,30 @@ sub get_cdrs {
qsearch ( $psearch->{query} )
}
+=item sum_cdrs
+
+Takes the same options as psearch_cdrs, but returns a single row containing
+"count" (the number of CDRs) and the sums of the following fields: duration,
+billsec, rated_price, rated_seconds, rated_minutes.
+
+Note that if any calls are not rated, their rated_* fields will be null.
+If you want to use those fields, pass the 'status' option to limit to
+calls that have been rated. This is intentional; please don't "fix" it.
+
+=cut
+
+sub sum_cdrs {
+ my $self = shift;
+ my $psearch = $self->psearch_cdrs(@_);
+ $psearch->{query}->{'select'} = join(',',
+ 'COUNT(*) AS count',
+ map { "SUM($_) AS $_" }
+ qw(duration billsec rated_price rated_seconds rated_minutes)
+ );
+ # hack
+ $psearch->{query}->{'extra_sql'} =~ s/ ORDER BY.*$//;
+ qsearchs ( $psearch->{query} );
+}
=back