return;
}
- my $invnum = delete $options{invnum};
+ #my $invnum = delete $options{invnum};
+ my $invnum = $options{invnum};
#pay fields should all come from either cust_payby or options, not both
# in theory, could just pass payby, and use it to select cust_payby,
'_date' => $new->_date,
'usernum' => $new->usernum,
'batchnum' => $new->batchnum,
+ 'invnum' => $old->invnum,
'gatewaynum' => $opt{'gatewaynum'},
'processor' => $opt{'processor'},
'auth' => $opt{'auth'},
<OPTION VALUE="select">Select an invoice to pay</OPTION>
% foreach my $record (@invoices) {
% my $read_date = time2str("%b %o, %Y", $record->_date);
- <OPTION VALUE="<% $record->charged %>"><% $record->invnum %> (<% $read_date %>) - <% $record->charged %></OPTION>
+% $hidden .= '<INPUT TYPE="hidden" ID="inv'.$record->invnum.'" NAME="inv'.$record->invnum.'" VALUE="'.$record->owed.'">';
+ <OPTION VALUE="<% $record->invnum %>"><% $record->invnum %> (<% $read_date %>) - <% $record->owed %></OPTION>
% }
- </SELECT>
+ </SELECT>
+
+ <% $hidden %>
+
</TD>
</TR>
my %opt = @_;
my $status = $opt{'status'} ? $opt{'status'} : 'all';
+my $hidden;
my @invoices;
if ($status eq "all") { @invoices = $opt{'cust_main'}->cust_bill; }
function <% $opt{prefix} %>invoice_select_changed(what) {
var surcharge;
+ var invdue = document.getElementById("<% $opt{prefix} %>inv" + what.value);
if (document.getElementById('surcharge_percentage') || document.getElementById('surcharge_flatfee')) {
- surcharge = (+what.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value;
+ surcharge = (+invdue.value * +document.getElementById('surcharge_percentage').value) + +document.getElementById('surcharge_flatfee').value;
}
else { surcharge = 0; }
- var amount = +what.value + +surcharge;
+ var amount = +invdue.value + +surcharge;
if ( what.value == 'select' ) {
$('#payment_amount_row').hide();
'extra_sql' => ' AND '. $curuser->agentnums_sql,
}) or die "unknown custnum $custnum";
+my $invoice = ($cgi->param('invoice') =~ /^(\d+)$/) ? $cgi->param('invoice') : '';
+
$cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/
or errorpage("illegal amount ". $cgi->param('amount'));
my $amount = $1;
'payinfo' => $payinfo,
'paydate' => $paydate,
'payname' => $payname,
+ 'invnum' => $invoice,
map { $_ => scalar($cgi->param($_)) }
@{$payby2fields{$payby}}
);
'discount_term' => $discount_term,
'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '',
'no_invnum' => 1,
+ 'invnum' => $invoice,
map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}}
);
errorpage($error) if $error;