[freeside-commits] branch FREESIDE_4_BRANCH updated. 4075410bf6ab31746b0a49cc610a0a68059c0127

Jonathan Prykop jonathan at 420.am
Mon Oct 3 19:38:28 PDT 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  4075410bf6ab31746b0a49cc610a0a68059c0127 (commit)
      from  fbc50ae238365892b4890216a88ee976c8c47aed (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4075410bf6ab31746b0a49cc610a0a68059c0127
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Oct 3 21:25:42 2016 -0500

    72157: Monthly recurring field is missing [ajax only for cust with many packages]

diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm
index 83ad7db..3920376 100644
--- a/FS/FS/cust_main/Packages.pm
+++ b/FS/FS/cust_main/Packages.pm
@@ -717,6 +717,13 @@ sub num_cancelled_pkgs {
   $self->num_pkgs($opt);
 }
 
+=item num_ncancelled_pkgs
+
+Returns the number of packages that have not been cancelled (see L<FS::cust_pkg>) for this
+customer.
+
+=cut
+
 sub num_ncancelled_pkgs {
   my $self = shift;
   my $opt = shift || {};
@@ -725,6 +732,23 @@ sub num_ncancelled_pkgs {
   $self->num_pkgs($opt);
 }
 
+=item num_billing_pkgs
+
+Returns the number of packages that have not been cancelled 
+and have a non-zero billing frequency (see L<FS::cust_pkg>)
+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 {
   my $self = shift;
   my $opt = shift || {};
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index a94b5c1..7ee05a3 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -31,8 +31,7 @@
      'subs' => [ 'get_display_recurring'] &>
 
 <SCRIPT>
-<&| /elements/onload.js &>
-get_display_recurring('custnum',<% $cust_main->custnum %>, function (xmlresult) {
+function set_display_recurring (xmlresult) {
   var recurring = JSON.parse(xmlresult);
   var rlabel = document.getElementById('recurring_label');
   var rvalue = document.getElementById('recurring_value');
@@ -63,10 +62,23 @@ get_display_recurring('custnum',<% $cust_main->custnum %>, function (xmlresult)
   } else {
     rrow.parentNode.removeChild(rrow);
   }
-});
-</&>
+}
 </SCRIPT>
 
+% # 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'] &>
+<SCRIPT>
+get_display_recurring('custnum',<% $cust_main->custnum %>,set_display_recurring);
+</SCRIPT>
+% } else {
+<SCRIPT>
+set_display_recurring(<% encode_json({'display_recurring' => [ $cust_main->display_recurring ]}) |js_string %>);
+</SCRIPT>
+% }
+
 % if ( $conf->exists('cust_main-select-prorate_day') ) {
 <TR>
   <TH ALIGN="right"><% mt('Prorate day of month') |h %></TH>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_main/Packages.pm            |   24 ++++++++++++++++++++++++
 httemplate/view/cust_main/billing.html |   20 ++++++++++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list