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,
11 % 'backdate_application' => ($_date < time-86400) );
13 % if ( $link eq 'popup' ) {
15 <% header(emt('Payment entered')) %>
16 <SCRIPT TYPE="text/javascript">
17 window.top.location.reload();
22 % } elsif ( $link eq 'custnum' ) {
23 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum") %>
25 % die "unknown link $link";
31 my $conf = FS::Conf->new;
33 $cgi->param('linknum') =~ /^(\d+)$/
34 or die "Illegal linknum: ". $cgi->param('linknum');
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';
43 if ( $FS::CurrentUser::CurrentUser->access_right('Backdate payment') ) {
44 $_date = parse_datetime($cgi->param('_date'));
50 my $new = new FS::cust_pay ( {
54 $_, scalar($cgi->param($_));
55 } qw( paid payby payinfo paybatch
57 bank depositor account teller
60 # gatewaynum, processor, auth, order_number
61 # are for realtime payments only, and can't be entered manually
64 my @rights = ('Post payment');
65 push @rights, 'Post check payment' if $new->payby eq 'BILL';
66 push @rights, 'Post cash payment' if $new->payby eq 'CASH';
69 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
71 my $error ||= $new->insert( 'manual' => 1 );