removed <!-- $Id$ --> from all files to fix any redirects, whew
[freeside.git] / httemplate / edit / process / cust_credit.cgi
1 <%
2
3 $cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!";
4 my $custnum = $1;
5
6 $cgi->param('otaker',getotaker);
7
8 my $new = new FS::cust_credit ( {
9   map {
10     $_, scalar($cgi->param($_));
11   #} qw(custnum _date amount otaker reason)
12   } fields('cust_credit')
13 } );
14
15 my $error = $new->insert;
16
17 if ( $error ) {
18   $cgi->param('error', $error);
19   print $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string );
20 } else {
21   if ( $cgi->param('apply') eq 'yes' ) {
22     my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum })
23       or die "unknown custnum $custnum";
24     $cust_main->apply_credits;
25   }
26   print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
27 }
28
29
30 %>