Will things ever be the same again?
[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 %my $new = new FS::cust_credit ( {
7 %  map {
8 %    $_, scalar($cgi->param($_));
9 %  } fields('cust_credit')
10 %} );
11 %
12 %my $error = $new->insert;
13 %
14 %if ( $error ) {
15 %  $cgi->param('error', $error);
16 %
17 %  
18 <% $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ) %>
19 %
20 %
21 %} else {
22 %
23 %  if ( $cgi->param('apply') eq 'yes' ) {
24 %    my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum })
25 %      or die "unknown custnum $custnum";
26 %    $cust_main->apply_credits;
27 %  }
28 %  #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
29 %
30 %  
31 <% header('Credit sucessful') %>
32   <SCRIPT TYPE="text/javascript">
33     window.top.location.reload();
34   </SCRIPT>
35
36   </BODY></HTML>
37 % } 
38