-% #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
-% my $routing_label = $conf->config('echeck-country') eq 'US'
-% ? 'ABA/Routing number'
-% : 'Routing number';
-
-<TR>
- <TD ALIGN="right"><% mt($routing_label) |h %></TD>
- <TD BGCOLOR="#ffffff"><% $aba %></TD>
-</TR>
-
-% if ( $conf->config('echeck-country') eq 'CA' ) {
-<TR>
- <TD ALIGN="right"><% mt('Branch number') |h %></TD>
- <TD BGCOLOR="#ffffff"><% $branch %></TD>
-<TR>
+<& '/elements/xmlhttp.html',
+ 'url' => $fsurl.'misc/xmlhttp-cust_main-display_recurring.html',
+ 'subs' => [ 'get_display_recurring'] &>
+
+<SCRIPT>
+function set_display_recurring (xmlresult) {
+ var recurring = JSON.parse(xmlresult);
+ var rlabel = document.getElementById('recurring_label');
+ var rvalue = document.getElementById('recurring_value');
+ var rrow = document.getElementById('recurring_row');
+ if (recurring['error']) {
+ rvalue.innerHTML = '<SPAN STYLE="color: red">Error</SPAN>';
+ console.log('display_recurring error: ' + recurring['error']);
+ } else if (recurring['display_recurring'].length) {
+ for (var ri = 0; ri < recurring['display_recurring'].length; ri++) {
+ var robj = recurring['display_recurring'][ri];
+ var freq_pretty = robj['freq_pretty'].charAt(0).toUpperCase()+robj['freq_pretty'].slice(1)+' recurring';
+ var amount = '<% $money_char %>'+parseFloat(robj['amount']).toFixed(2);
+ if (ri + 1 < recurring['display_recurring'].length) {
+ var rr = document.createElement('TR');
+ var rl = document.createElement('TH');
+ rl.style.textAlign = 'right';
+ rl.innerHTML = freq_pretty;
+ rr.appendChild(rl);
+ var rv = document.createElement('TD');
+ rv.innerHTML = amount;
+ rr.appendChild(rv);
+ rrow.parentNode.insertBefore(rr,rrow);
+ } else {
+ rlabel.innerHTML = freq_pretty;
+ rvalue.innerHTML = amount;
+ }
+ }
+ } 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>