2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "cust_credit_bill.cgi?". $cgi->query_string ) %>
5 <% header('Credit application sucessful') %>
6 <SCRIPT TYPE="text/javascript">
7 window.top.location.reload();
15 unless $FS::CurrentUser::CurrentUser->access_right('Apply credit');
17 $cgi->param('crednum') =~ /^(\d*)$/ or die "Illegal crednum!";
20 my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } )
21 or die "No such crednum";
23 my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_credit->custnum } )
24 or die "Bogus credit: not attached to customer";
26 my $custnum = $cust_main->custnum;
29 if ($cgi->param('invnum') =~ /^Refund$/) {
30 $new = new FS::cust_refund ( {
31 'reason' => ( $cust_credit->reason || 'refund from credit' ),
32 'refund' => $cgi->param('amount'),
34 #'_date' => $cgi->param('_date'),
36 'payinfo' => 'Refund',
37 'crednum' => $crednum,
40 $new = new FS::cust_credit_bill ( {
42 $_, scalar($cgi->param($_));
43 #} qw(custnum _date amount invnum)
44 } fields('cust_credit_bill')
48 my $error = $new->insert;