first part of ACL and re-skinning work and some other small stuff
[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   %><%= $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ) %><%
18
19 } else {
20
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   %><%= header('Credit sucessful') %>
29   <SCRIPT TYPE="text/javascript">
30     window.top.location.reload();
31   </SCRIPT>
32
33   </BODY></HTML>
34
35 <% } %>