diff options
author | Mark Wells <mark@freeside.biz> | 2016-09-08 11:05:38 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2016-09-08 11:05:38 -0700 |
commit | 0929e7aec153632691a64ae8755c082090fd1de5 (patch) | |
tree | ab72a786d31797d681572100edd58e2fe5b03d3d /httemplate | |
parent | 1768c2039b6ff3d68bd3b711621d82dcbf5eab75 (diff) | |
parent | 6df492990ea195513430f3a56d537e57e50b6913 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/elements/change_history_common.html | 7 | ||||
-rw-r--r-- | httemplate/misc/xmlhttp-cust_main-display_recurring.html | 29 | ||||
-rw-r--r-- | httemplate/view/cust_main/billing.html | 57 | ||||
-rw-r--r-- | httemplate/view/cust_main/change_history.html | 1 |
4 files changed, 82 insertions, 12 deletions
diff --git a/httemplate/elements/change_history_common.html b/httemplate/elements/change_history_common.html index e228e65..5aaf6e6 100644 --- a/httemplate/elements/change_history_common.html +++ b/httemplate/elements/change_history_common.html @@ -197,6 +197,12 @@ my $svc_labelsub = sub { $label. ': <b>'. encode_entities($item->label($item->history_date)). '</b>'; }; +my $tag_labelsub = sub { + my($item, $label) = @_; + my $part_tag = qsearchs('part_tag',{ tagnum => $item->tagnum }); + $label. ': <SPAN STYLE="background-color: #'.$part_tag->tagcolor.'">'. encode_entities($part_tag->tagname). '</SPAN>'; +}; + my %h_table_labelsub = ( 'h_cust_pkg' => $pkg_labelsub, 'h_svc_acct' => $svc_labelsub, @@ -208,6 +214,7 @@ my %h_table_labelsub = ( 'h_svc_external' => $svc_labelsub, 'h_svc_phone' => $svc_labelsub, #'h_phone_device' + 'h_cust_tag' => $tag_labelsub, ); my $discounts = {}; diff --git a/httemplate/misc/xmlhttp-cust_main-display_recurring.html b/httemplate/misc/xmlhttp-cust_main-display_recurring.html new file mode 100644 index 0000000..dd9ed3b --- /dev/null +++ b/httemplate/misc/xmlhttp-cust_main-display_recurring.html @@ -0,0 +1,29 @@ +<% encode_json($return) %>\ +<%init> + +my %arg = $cgi->param('arg'); +my $custnum = delete($arg{'custnum'}); + +my $error; +my $return; + +$error = "No customer specified" unless $custnum =~ /^\d+$/; + +my $curuser = $FS::CurrentUser::CurrentUser; + +$error = "access denied" + unless $error or $curuser->access_right('View customer'); + +my $cust_main; +$cust_main = qsearchs( { + 'table' => 'cust_main', + 'hashref' => { 'custnum' => $custnum }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, +}) unless $error; +$error = "Customer not found!" unless $error or $cust_main; + +$return = $error + ? { 'error' => $error } + : { 'display_recurring' => [ $cust_main->display_recurring ] }; + +</%init> diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 894b2df..a94b5c1 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -21,18 +21,51 @@ <TD><B><% $balance %></B></TD> </TR> -% #54: just an arbitrary number i pulled out of my goober. ideally we'd like -% # to consider e.g. a histogram of num_ncancelled_packages for the entire -% # customer base, and compare it to a graph of the overhead for generating this -% # information. (and optimize it better, we could get it more from SQL) -% if ( $cust_main->num_ncancelled_pkgs < 54 ) { -% foreach my $freq_info ($cust_main->display_recurring) { - <TR> - <TH ALIGN="right"><% emt( ucfirst($freq_info->{'freq_pretty'}). ' recurring' ) %></TH> - <TD><% $money_char. sprintf('%.2f', $freq_info->{'amount'}) %></TD> - </TR> -% } -% } +<TR ID="recurring_row"> + <TH ID="recurring_label" ALIGN="right"><% emt( 'Recurring' ) %></TH> + <TD ID="recurring_value"><IMG SRC="<% $fsurl %>images/wait-orange.gif"></TD> +</TR> + +<& '/elements/xmlhttp.html', + 'url' => $fsurl.'misc/xmlhttp-cust_main-display_recurring.html', + 'subs' => [ 'get_display_recurring'] &> + +<SCRIPT> +<&| /elements/onload.js &> +get_display_recurring('custnum',<% $cust_main->custnum %>, function (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> % if ( $conf->exists('cust_main-select-prorate_day') ) { <TR> diff --git a/httemplate/view/cust_main/change_history.html b/httemplate/view/cust_main/change_history.html index d46a4ff..a781c73 100644 --- a/httemplate/view/cust_main/change_history.html +++ b/httemplate/view/cust_main/change_history.html @@ -46,6 +46,7 @@ tie my %tables, 'Tie::IxHash', 'phone_device' => 'Phone device', 'cust_pkg_discount' => 'Discount', #? it gets provisioned anyway 'phone_avail' => 'Phone', + 'cust_tag' => 'Tag', ; my $pkg_join = "JOIN cust_pkg USING ( pkgnum )"; |