From b9229d6233a5ecaa894c5ed7035cf2743ee6c295 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Mon, 3 Oct 2016 21:25:42 -0500 Subject: [PATCH] 72157: Monthly recurring field is missing [ajax only for cust with many packages] --- FS/FS/cust_main/Packages.pm | 24 ++++++++++++++++++++++++ httemplate/view/cust_main/billing.html | 20 ++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm index 4d0eee7ed..a4900508c 100644 --- a/FS/FS/cust_main/Packages.pm +++ b/FS/FS/cust_main/Packages.pm @@ -659,10 +659,34 @@ sub num_cancelled_pkgs { shift->num_pkgs("cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0"); } +=item num_ncancelled_pkgs + +Returns the number of packages that have not been cancelled (see L) for this +customer. + +=cut + sub num_ncancelled_pkgs { shift->num_pkgs("( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )"); } +=item num_billing_pkgs + +Returns the number of packages that have not been cancelled +and have a non-zero billing frequency (see L) +for this customer. + +=cut + +sub num_billing_pkgs { + my $self = shift; + my $opt = shift || {}; + $opt->{addl_from} .= ' LEFT JOIN part_pkg USING (pkgpart)'; + $opt->{extra_sql} .= ' AND ' if $opt->{extra_sql}; + $opt->{extra_sql} .= "freq IS NOT NULL AND freq != '0'"; + $self->num_ncancelled_pkgs($opt); +} + sub num_suspended_pkgs { shift->num_pkgs(" ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 ) AND cust_pkg.susp IS NOT NULL AND cust_pkg.susp != 0 "); diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 6c4524476..aeebc5ab2 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -33,8 +33,7 @@ 'subs' => [ 'get_display_recurring'] &> +% # 10 is an arbitrary number, use ajax for customers with many packages +% if ( $cust_main->num_billing_pkgs > 10 ) { +<& '/elements/xmlhttp.html', + 'url' => $fsurl.'misc/xmlhttp-cust_main-display_recurring.html', + 'subs' => [ 'get_display_recurring'] &> + +% } else { + +% } + % if ( $conf->exists('cust_main-select-prorate_day') ) { <% mt('Prorate day of month') |h %> -- 2.11.0