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( 'manual' => 1 );
12 % if ( $link eq 'popup' ) {
14 <% header('Payment entered') %>
15 <SCRIPT TYPE="text/javascript">
16 window.top.location.reload();
21 % } elsif ( $link eq 'custnum' ) {
22 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum") %>
24 % die "unknown link $link";
30 $cgi->param('linknum') =~ /^(\d+)$/
31 or die "Illegal linknum: ". $cgi->param('linknum');
34 $cgi->param('link') =~ /^(custnum|invnum|popup)$/
35 or die "Illegal link: ". $cgi->param('link');
36 my $field = my $link = $1;
37 $field = 'custnum' if $field eq 'popup';
39 my $_date = parse_datetime($cgi->param('_date'));
41 my $new = new FS::cust_pay ( {
45 $_, scalar($cgi->param($_));
46 } qw( paid payby payinfo paybatch
52 my @rights = ('Post payment');
53 push @rights, 'Post check payment' if $new->payby eq 'BILL';
54 push @rights, 'Post cash payment' if $new->payby eq 'CASH';
57 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
59 my $error = $new->insert( 'manual' => 1 );