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 <& /elements/header-popup.html, emt('Payment entered') &>
16 <SCRIPT TYPE="text/javascript">
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 ( {
53 no_auto_apply => ($cgi->param('apply') eq 'never') ? 'Y' : '',
55 $_, scalar($cgi->param($_));
56 } qw( paid payby payinfo paybatch
58 bank depositor account teller
61 # gatewaynum, processor, auth, order_number
62 # are for realtime payments only, and can't be entered manually
65 my @rights = ('Post payment');
66 push @rights, 'Post check payment' if $new->payby eq 'BILL';
67 push @rights, 'Post cash payment' if $new->payby eq 'CASH';
70 unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
72 my $error = $new->insert( 'manual' => 1 );