X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fsearch%2Freport_cdr.html;h=10ab21841f8cd1110aca0fb9de0c5a7e9f5b1105;hb=e168ca3db2702bd9a540316cd9bd840238dd19ce;hp=c5f728c8772dd41427bea6737159c8a091b198f4;hpb=0ce1ba66efbd074aca5182bb3e42bd99ff55472a;p=freeside.git
diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html
index c5f728c87..10ab21841 100644
--- a/httemplate/search/report_cdr.html
+++ b/httemplate/search/report_cdr.html
@@ -5,7 +5,7 @@
-
+ |
Search options
|
@@ -65,7 +65,28 @@
Charged Party #: |
-
+
+ |
+
+
+
+ Charged Party or Source #: |
+
+
+ |
+
+
+
+ Last Application: |
+
+
+ |
+
+
+
+ Freeside service #: |
+
+
|
@@ -84,11 +105,16 @@
<% include( '/elements/tr-select-cdrbatch.html' ) %>
- |
+ Acct ID (one per-line): |
+ |
- Display options |
+ |
+
+
+
+ Display options |
@@ -110,6 +136,8 @@
+
+
<% include('/elements/footer.html') %>
<%init>
@@ -125,7 +153,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;
@@ -138,4 +166,72 @@ my $names_list = [ map {
@fields
];
+my @charged_party = ();
+my @charged_party_or_src = ();
+my @svcnum = ();
+if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+ my $custnum = $1;
+
+ my $cust_main = qsearchs( {
+ 'table' => 'cust_main',
+ 'hashref' => { 'custnum' => $custnum },
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+ });
+ die "Customer not found!" unless $cust_main;
+
+ #historical?
+ foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
+
+ my @voip_pkgs =
+ grep { $_->plan eq 'voip_cdr' } $cust_pkg->part_pkg->self_and_bill_linked;
+ if ( scalar(@voip_pkgs) > 1 ) {
+ die "multiple voip_cdr packages bundled\n";
+ } elsif ( !@voip_pkgs ) {
+ next;
+ }
+ my $voip_pkg = @voip_pkgs[0];
+
+ my $cdr_svc_method = $voip_pkg->option('cdr_svc_method')
+ || 'svc_phone.phonenum';
+
+ my @cust_svc = $cust_pkg->cust_svc; #historical?
+
+ if ( $cdr_svc_method eq 'svc_phone.phonenum' ) {
+
+ my @svc_phone = map $_->svc_x,
+ grep { $_->part_svc->svcdb eq 'svc_phone' } @cust_svc;
+
+ my @numbers = map {
+ my $number = $_->phonenum;
+ $number = $_->countrycode. $number
+ unless $_->countrycode eq '1';
+ $number;
+ }
+ @svc_phone;
+
+ if ( $voip_pkg->option('disable_src') ) {
+ push @charged_party, @numbers;
+ } else {
+ push @charged_party_or_src, @numbers;
+ }
+
+ } elsif ( $cdr_svc_method eq 'svc_pbx.title' ) {
+ my @svc_pbx = map $_->svc_x,
+ grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
+ push @charged_party, map $_->title, @svc_pbx;
+ } elsif ( $cdr_svc_method eq 'svc_pbx.svcnum' ) {
+ my @cust_svc_pbx = grep { $_->part_svc->svcdb eq 'svc_pbx' } @cust_svc;
+ push @svcnum, map $_->svcnum, @cust_svc_pbx;
+ }
+
+ }
+
+ die "No CDR packages for customer $custnum\n"
+ unless @charged_party || @charged_party_or_src || @svcnum;
+
+ #die "Multiple matching metods for customer $custnum\n"
+ # if #there's more than one
+
+}
+
%init>