summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2009-07-02 11:22:48 +0000
committerivan <ivan>2009-07-02 11:22:48 +0000
commit69678d308805f5ca4b171ea0c5ac1da957811aa0 (patch)
treedf846cada38cb49897906248d36db5e68b5efd3b /httemplate
parent8db53bcb53bbb32855c38f62afa4d1b39777cb7d (diff)
settlement cdr processing, RT#5495
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/cust_main/billing.html13
-rw-r--r--httemplate/search/cdr.html79
-rw-r--r--httemplate/search/report_cdr.html18
3 files changed, 87 insertions, 23 deletions
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index 4c4be23..3f3d801 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -477,10 +477,13 @@ my @payby = grep /\w/, $conf->config('payby');
@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
unless @payby;
-#false laziness w/view/cust_main/billing.html
-my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
-my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
-$term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
-my $show_term = $term_sth->fetchrow_arrayref->[0];
+my $show_term = '';
+if ( $cust_main->custnum ) {
+ #false laziness w/view/cust_main/billing.html
+ my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
+ my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
+ $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
+ $show_term = $term_sth->fetchrow_arrayref->[0];
+}
</%init>
diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html
index cef8ec0..26eac75 100644
--- a/httemplate/search/cdr.html
+++ b/httemplate/search/cdr.html
@@ -65,46 +65,87 @@ my $hashref = {};
my @search = ();
###
+# dates
+###
+
+my $str2time_sql = str2time_sql;
+
+my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
+push @search, "$str2time_sql calldate) >= $beginning ",
+ "$str2time_sql calldate) <= $ending";
+
+###
+# duration / billsec
+###
+
+push @search, FS::UI::Web::parse_lt_gt($cgi, 'duration');
+push @search, FS::UI::Web::parse_lt_gt($cgi, 'billsec');
+
+#above here things just push @search
+#below here things also have to define $hashref->{} or push @qsearch
+my @qsearch = @search;
+
+###
# freesidestatus
###
if ( $cgi->param('freesidestatus') eq 'NULL' ) {
- my $title = "Unprocessed $title";
+ $title = "Unprocessed $title";
$hashref->{'freesidestatus'} = ''; # Record.pm will take care of it
push @search, "( freesidestatus IS NULL OR freesidestatus = '' )";
} elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) {
- my $title = "Processed $title";
+ $title = "Processed $title";
$hashref->{'freesidestatus'} = $1;
push @search, "freesidestatus = '$1'";
}
###
-# dates
+# termpartNstatus
###
-my $str2time_sql = str2time_sql;
+foreach my $param ( grep /^termpart\d+status$/, $cgi->param ) {
-my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
-push @search, "$str2time_sql calldate) >= $beginning ",
- "$str2time_sql calldate) <= $ending";
+ my $status = $cgi->param($param);
-###
-# duration / billsec
-###
+ $param =~ /^termpart(\d+)status$/ or die 'guru meditation 54something';
+ my $termpart = $1;
-push @search, FS::UI::Web::parse_lt_gt($cgi, 'duration');
-push @search, FS::UI::Web::parse_lt_gt($cgi, 'billsec');
+ my $search = '';
+ if ( $status eq 'NULL' ) {
+
+ #false lazienss w/cdr_termination.pm (i should be a part_termination method)
+ my $where_term =
+ "( cdr.acctid = cdr_termination.acctid AND termpart = $termpart ) ";
+ #my $join_term = "LEFT JOIN cdr_termination ON ( $where_term )";
+ $search =
+ "NOT EXISTS ( SELECT 1 FROM cdr_termination WHERE $where_term )";
+
+ } elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) {
+
+ #false lazienss w/cdr_termination.pm (i should be a part_termination method)
+ my $where_term =
+ "( cdr.acctid = cdr_termination.acctid AND termpart = $termpart AND status = '$1' ) ";
+ #my $join_term = "LEFT JOIN cdr_termination ON ( $where_term )";
+ $search =
+ "EXISTS ( SELECT 1 FROM cdr_termination WHERE $where_term )";
+
+ }
+
+ if ( $search ) {
+ push @search, $search;
+ push @qsearch, $search;
+ }
+
+}
###
# src/dest/charged_party
###
-my @qsearch = @search;
-
if ( $cgi->param('src') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) {
( my $src = $1 ) =~ s/\D//g;
$hashref->{'src'} = $src;
@@ -122,10 +163,12 @@ if ( $cgi->param('charged_party') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) {
#$hashref->{'charged_party'} = $charged_party;
#push @search, "charged_party = '$charged_party'";
#XXX countrycode
- push @search, " ( charged_party = '$charged_party'
- OR charged_party = '1$charged_party' ) ";
- push @qsearch, " ( charged_party = '$charged_party'
- OR charged_party = '1$charged_party' ) ";
+
+ my $search = " ( charged_party = '$charged_party'
+ OR charged_party = '1$charged_party' ) ";
+
+ push @search, $search;
+ push @qsearch, $search;
}
###
diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html
index 2851631..6a0b89b 100644
--- a/httemplate/search/report_cdr.html
+++ b/httemplate/search/report_cdr.html
@@ -3,6 +3,7 @@
<FORM ACTION="cdr.html" METHOD="GET">
<TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+
<TR>
<TD ALIGN="right">Status: </TD>
<TD>
@@ -14,6 +15,23 @@
</TD>
</TR>
+% #if ( ) { # disable for everyone not using termination billing...
+% foreach my $termpart ( 1..1 ) { #qsearch('part_termination
+
+ <TR>
+ <TD ALIGN="right">Termination Status: </TD>
+ <TD>
+ <SELECT NAME="termpart<%$termpart%>status">
+ <OPTION VALUE="">(all)
+ <OPTION VALUE="NULL">unprocessed
+ <OPTION VALUE="done">processed
+ </SELECT>
+ </TD>
+ </TR>
+
+% }
+% #}
+
<% include ( '/elements/tr-input-beginning_ending.html' ) %>
<TR>