2 % $cgi->param('reasonnum', $reasonnum);
3 % $cgi->param('error', $error);
4 % $dbh->rollback if $oldAutoCommit;
6 <% $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ) %>
10 % if ( $cgi->param('apply') eq 'yes' ) {
11 % my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum })
12 % or die "unknown custnum $custnum";
13 % $cust_main->apply_credits;
15 % #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
17 % $dbh->commit or die $dbh->errstr if $oldAutoCommit;
19 <% header('Credit sucessful') %>
20 <SCRIPT TYPE="text/javascript">
21 window.top.location.reload();
29 unless $FS::CurrentUser::CurrentUser->access_right('Post credit');
31 $cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!";
34 $cgi->param('reasonnum') =~ /^(-?\d+)$/ or die "Illegal reasonnum";
37 my $oldAutoCommit = $FS::UID::AutoCommit;
38 local $FS::UID::AutoCommit = 0;
42 if ($reasonnum == -1) {
44 $error = 'Enter a new reason (or select an existing one)'
45 unless $cgi->param('newreasonnum') !~ /^\s*$/;
46 my $reason = new FS::reason({ 'reason_type' => $cgi->param('newreasonnumT'),
47 'reason' => $cgi->param('newreasonnum'),
49 $error ||= $reason->insert;
50 $cgi->param('reasonnum', $reason->reasonnum)
55 my $new = new FS::cust_credit ( {
57 $_, scalar($cgi->param($_));
58 } fields('cust_credit')
60 $error = $new->insert;