This commit was generated by cvs2svn to compensate for changes in r6252,
[freeside.git] / httemplate / edit / process / cust_pay.cgi
1 %if ($error) {
2 %  $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string ) %>
4 %} elsif ( $field eq 'invnum' ) {
5 <% $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum") %>
6 %} elsif ( $field eq 'custnum' ) {
7 %  if ( $cgi->param('apply') eq 'yes' ) {
8 %    my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum })
9 %      or die "unknown custnum $linknum";
10 %    $cust_main->apply_payments;
11 %  }
12 %  if ( $link eq 'popup' ) {
13 %    
14 <% header('Payment entered') %>
15     <SCRIPT TYPE="text/javascript">
16       window.top.location.reload();
17     </SCRIPT>
18
19     </BODY></HTML>
20 %
21 %  } elsif ( $link eq 'custnum' ) {
22 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum") %>
23 %  } else {
24 %    die "unknown link $link";
25 %  }
26 %
27 %}
28 <%init>
29
30 die "access denied"
31   unless $FS::CurrentUser::CurrentUser->access_right('Post payment');
32
33 $cgi->param('linknum') =~ /^(\d+)$/
34   or die "Illegal linknum: ". $cgi->param('linknum');
35 my $linknum = $1;
36
37 $cgi->param('link') =~ /^(custnum|invnum|popup)$/
38   or die "Illegal link: ". $cgi->param('link');
39 my $field = my $link = $1;
40 $field = 'custnum' if $field eq 'popup';
41
42 my $_date = str2time($cgi->param('_date'));
43
44 my $new = new FS::cust_pay ( {
45   $field => $linknum,
46   _date  => $_date,
47   map {
48     $_, scalar($cgi->param($_));
49   } qw(paid payby payinfo paybatch)
50   #} fields('cust_pay')
51 } );
52
53 my $error = $new->insert( 'manual' => 1 );
54
55 </%init>