[freeside-commits] freeside/httemplate/search cdr.html, 1.23, 1.24 report_cdr.html, 1.14, 1.15
Ivan,,,
ivan at wavetail.420.am
Sun Oct 24 17:28:43 PDT 2010
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv11412/httemplate/search
Modified Files:
cdr.html report_cdr.html
Log Message:
svc_pbx and whole-customer links to CDRs, RT#10315
Index: report_cdr.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_cdr.html,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -d -r1.14 -r1.15
--- report_cdr.html 20 May 2010 08:48:51 -0000 1.14
+++ report_cdr.html 25 Oct 2010 00:28:41 -0000 1.15
@@ -65,7 +65,21 @@
<TR>
<TD ALIGN="right">Charged Party #: </TD>
<TD>
- <INPUT TYPE="text" NAME="charged_party">
+ <INPUT TYPE="text" NAME="charged_party" VALUE="<% join(',', @charged_party) |h %>">
+ </TD>
+ </TR>
+
+ <TR>
+ <TD ALIGN="right">Charged Party or Source #: </TD>
+ <TD>
+ <INPUT TYPE="text" NAME="charged_party_or_src" VALUE="<% join(',', @charged_party_or_src ) |h %>" >
+ </TD>
+ </TR>
+
+ <TR>
+ <TD ALIGN="right">Freeside service #: </TD>
+ <TD>
+ <INPUT TYPE="text" NAME="svcnum" VALUE="<% join(',', @svcnum ) %>" >
</TD>
</TR>
@@ -145,4 +159,72 @@
@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>
Index: cdr.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cdr.html,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -w -d -r1.23 -r1.24
--- cdr.html 22 Sep 2010 19:35:18 -0000 1.23
+++ cdr.html 25 Oct 2010 00:28:41 -0000 1.24
@@ -147,7 +147,7 @@
}
###
-# src/dest/charged_party
+# src/dest/charged_party/svcnum
###
my $phonenum = qr/^\s*([\d\-\+\ ]+)\s*$/;
@@ -175,27 +175,32 @@
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 $search = " ( charged_party IN ('$charged_party', '1$charged_party')
- OR src IN ('$charged_party', '1$charged_party') )";
+ 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) )";
+
+ 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;
}
More information about the freeside-commits
mailing list