summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/cust_credit.cgi
blob: ac92631f872693ba4cd38c5e6a01dad3c70a67dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<%

$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!";
my $custnum = $1;

$cgi->param('otaker',getotaker);

my $new = new FS::cust_credit ( {
  map {
    $_, scalar($cgi->param($_));
  #} qw(custnum _date amount otaker reason)
  } fields('cust_credit')
} );

my $error = $new->insert;

if ( $error ) {
  $cgi->param('error', $error);
  print $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string );
} else {
  if ( $cgi->param('apply') eq 'yes' ) {
    my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum })
      or die "unknown custnum $custnum";
    $cust_main->apply_credits;
  }
  print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
}


%>