This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / httemplate / edit / process / cust_pay.cgi
1 <%
2
3 $cgi->param('linknum') =~ /^(\d+)$/
4   or die "Illegal linknum: ". $cgi->param('linknum');
5 my $linknum = $1;
6
7 $cgi->param('link') =~ /^(custnum|invnum)$/
8   or die "Illegal link: ". $cgi->param('link');
9 my $link = $1;
10
11 my $_date = str2time($cgi->param('_date'));
12
13 my $new = new FS::cust_pay ( {
14   $link => $linknum,
15   _date => $_date,
16   map {
17     $_, scalar($cgi->param($_));
18   } qw(paid payby payinfo paybatch)
19   #} fields('cust_pay')
20 } );
21
22 my $error = $new->insert;
23
24 if ($error) {
25   $cgi->param('error', $error);
26   print $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string );
27 } elsif ( $link eq 'invnum' ) {
28   print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum");
29 } elsif ( $link eq 'custnum' ) {
30   if ( $cgi->param('apply') eq 'yes' ) {
31     my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum })
32       or die "unknown custnum $linknum";
33     $cust_main->apply_payments;
34   }
35   if ( $cgi->param('quickpay') eq 'yes' ) {
36     print $cgi->redirect(popurl(3). "search/cust_main-quickpay.html");
37   } else {
38     print $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum");
39   }
40 }
41
42 %>