2 % unless $FS::CurrentUser::CurrentUser->access_right('Post payment batch');
4 % my $param = $cgi->Vars;
6 % #my $paybatch = $param->{'paybatch'};
7 % my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
11 % #while ( exists($param->{"custnum$row"}) ) {
12 % for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) {
13 % push @cust_pay, new FS::cust_pay {
14 % 'custnum' => $param->{"custnum$row"},
15 % 'paid' => $param->{"paid$row"},
17 % 'payinfo' => $param->{"payinfo$row"},
18 % 'paybatch' => $paybatch,
20 % if $param->{"custnum$row"}
21 % || $param->{"paid$row"}
22 % || $param->{"payinfo$row"};
26 % my @errors = FS::cust_pay->batch_insert(@cust_pay);
27 % my $num_errors = scalar(grep $_, @errors);
29 % if ( $num_errors ) {
31 % $cgi->param('error', "$num_errors error". ($num_errors>1 ? 's' : '').
32 % ' - Batch not processed, correct and resubmit'
36 % $cgi->param('error'. $erow++, shift @errors) while @errors;
39 <% $cgi->redirect($p.'batch-cust_pay.html?'. $cgi->query_string)
45 <% $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %>