% next unless $amount > 0;
% if ( $cust_bill_pkg->invnum ne $old_invnum ) {
- <TR><TD COLSPAN=3 BGCOLOR="#f8f8f8"> </TD></TR>
- <TR><TH COLSPAN=3 BGCOLOR="#f8f8f8" ALIGN="left">Invoice #<% $cust_bill_pkg->invnum %> - <% time2str($date_format, $cust_bill_pkg->cust_bill->_date) %></TD></TR>
+ <TR><TD COLSPAN=4 BGCOLOR="#f8f8f8"> </TD></TR>
+ <TR><TH COLSPAN=4 BGCOLOR="#f8f8f8" ALIGN="left">Invoice #<% $cust_bill_pkg->invnum %> - <% time2str($date_format, $cust_bill_pkg->cust_bill->_date) %></TD></TR>
% $old_invnum = $cust_bill_pkg->invnum;
% }
+% my $el_name = 'billpkgnum'. $cust_bill_pkg->billpkgnum. '-'. $setuprecur;
<TR>
<TD>
<INPUT TYPE = "checkbox"
- NAME = "billpkgnum<% $cust_bill_pkg->billpkgnum.'-'. $setuprecur %>"
- VALUE = "<% $amount %>"
+ NAME = "<% $el_name %>"
+ ID = "<% $el_name %>"
onClick = "calc_total(this)"
- data-amount = "<% $amount %>"
data-billpkgnum = "<% $cust_bill_pkg->billpkgnum %>"
data-setuprecur = "<% $setuprecur %>"
>
<TD BGCOLOR="#ffffff"><% $cust_bill_pkg->desc |h %></TD>
%# show one-time/setup vs recur vs usage?
<TD BGCOLOR="#ffffff" ALIGN="right"><% $money_char. $amount %></TD>
+ <TD ALIGN="right">
+ <% $money_char %><INPUT TYPE = "text"
+ NAME = "<% $el_name %>-amount"
+ ID = "<% $el_name %>-amount"
+ VALUE = "<% $amount %>"
+ SIZE = 6
+ onChange = "calc_total(this)"
+ STYLE = "text-align:right;"
+ DISABLED
+ >
+ </TD>
</TR>
% }
-<TR><TD COLSPAN=3 BGCOLOR="#f8f8f8"> </TD></TR>
+<TR><TD COLSPAN=4 BGCOLOR="#f8f8f8"> </TD></TR>
<TR>
<TD></TD>
- <TD ALIGN="right">Subtotal: </TD>
+ <TD ALIGN="right" COLSPAN=2>Subtotal: </TD>
<TD ALIGN="right" ID="subtotal_td"><% $money_char %><% sprintf('%.2f', 0) %></TD>
</TR>
<TR>
<TD></TD>
- <TD ALIGN="right">Taxes: </TD>
+ <TD ALIGN="right" COLSPAN=2>Taxes: </TD>
<TD ALIGN="right" ID="taxtotal_td"><% $money_char %><% sprintf('%.2f', 0) %></TD>
</TR>
<TR>
<TD></TD>
- <TH ALIGN="right">Total credit amount: </TD>
+ <TH ALIGN="right" COLSPAN=2>Total credit amount: </TD>
<TH ALIGN="right" ID="total_td"><% $money_char %><% sprintf('%.2f', 0) %></TD>
</TR>
-<INPUT TYPE="hidden" NAME="amount" ID="total_el" VALUE="0.00">
</table>
+<INPUT TYPE="hidden" NAME="amount" ID="total_el" VALUE="0.00">
+
<table>
<& /elements/tr-select-reason.html,
'field' => 'reasonnum',
'reason_class' => 'R',
#XXX reconcile both this and show_taxes wanteding to enable this
+ 'id' => 'select_reason',
'control_button' => "document.getElementById('credit_button')",
'cgi' => $cgi,
&>
</TD>
</TR>
+% if ( $conf->exists('credits-auto-apply-disable') ) {
+ <INPUT TYPE="HIDDEN" NAME="apply" VALUE="no">
+% } else {
+ <TR>
+ <TD ALIGN="right"><% mt('Apply to selected line items') |h %></TD>
+ <TD><SELECT NAME="apply"><OPTION VALUE="yes" SELECTED><% mt('yes') |h %><OPTION><% mt('no') |h %></SELECT></TD>
+ </TR>
+% }
+
</table>
<BR>
%>
<SCRIPT TYPE="text/javascript">
+document.getElementById('select_reason').disabled = true;
+ // start it disabled because no line items are selected yet
function show_taxes(arg) {
var argsHash = eval('(' + arg + ')');
//XXX reconcile both this and the reason selector wanteding to enable this
if ( total > 0 ) {
- document.getElementById('credit_button').disabled = false;
+ //document.getElementById('credit_button').disabled = false;
+ document.getElementById('select_reason').disabled = false;
}
}
function calc_total(what) {
- document.getElementById('credit_button').disabled = true;
+ //document.getElementById('credit_button').disabled = true;
+ document.getElementById('select_reason').disabled = true;
var subtotal = 0;
// bah, a pain, just using an attribute var re = /^billpkgnum(\d+)$/;
var setuprecurs = [];
var amounts = [];
for (var i=0; i<el.length; i++) {
- if ( el[i].type == 'checkbox' && el[i].checked ) {
- subtotal += parseFloat( el[i].getAttribute('data-amount') );
- amounts.push( el[i].getAttribute('data-amount') );
- billpkgnums.push( el[i].getAttribute('data-billpkgnum') );
- setuprecurs.push( el[i].getAttribute('data-setuprecur') );
+
+ if ( el[i].type == 'checkbox' ) {
+ var amount_el = document.getElementById( el[i].id + '-amount' );
+ if ( el[i].checked ) {
+ amount_el.disabled = false;
+ var amount = amount_el.value;
+ subtotal += parseFloat( amount );
+ amounts.push( amount );
+ billpkgnums.push( el[i].getAttribute('data-billpkgnum') );
+ setuprecurs.push( el[i].getAttribute('data-setuprecur') );
+ } else {
+ amount_el.disabled = true;
+ }
}
+
}
document.getElementById('subtotal_td').innerHTML =
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
-die "access denied" unless $curuser->access_right('Post credit');
+die "access denied" unless $curuser->access_right('Credit line items');
#a tiny bit of false laziness w/search/cust_bill_pkg.cgi, but we're pretty
# specialized and a piece of UI, not a report