2 % my $param = $cgi->Vars;
4 % #my $paybatch = $param->{'paybatch'};
5 % my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
9 % #while ( exists($param->{"custnum$row"}) ) {
10 % for ( my $row = 0; exists($param->{"custnum$row"}); $row++ ) {
11 % push @cust_pay, new FS::cust_pay {
12 % 'custnum' => $param->{"custnum$row"},
13 % 'paid' => $param->{"paid$row"},
15 % 'payinfo' => $param->{"payinfo$row"},
16 % 'paybatch' => $paybatch,
18 % if $param->{"custnum$row"}
19 % || $param->{"paid$row"}
20 % || $param->{"payinfo$row"};
24 % my @errors = FS::cust_pay->batch_insert(@cust_pay);
25 % my $num_errors = scalar(grep $_, @errors);
27 % if ( $num_errors ) {
29 % $cgi->param('error', "$num_errors error". ($num_errors>1 ? 's' : '').
30 % ' - Batch not processed, correct and resubmit'
34 % $cgi->param('error'. $erow++, shift @errors) while @errors;
37 <% $cgi->redirect($p.'batch-cust_pay.html?'. $cgi->query_string)
43 <% $cgi->redirect(popurl(3). "search/cust_pay.cgi?magic=paybatch;paybatch=$paybatch") %>