This commit was manufactured by cvs2svn to create tag 'freeside_2_1_0'.
[freeside.git] / httemplate / misc / upload-batch.cgi
1 % if ( $error ) {
2 %   errorpage($error);
3 % } else {
4     <% include('/elements/header.html','Batch results upload successful') %> 
5     <% include('/elements/footer.html') %> 
6 % }
7 <%init>
8
9 die "access denied"
10   unless $FS::CurrentUser::CurrentUser->access_right('Process batches');
11
12 my $error;
13
14 my $fh = $cgi->upload('batch_results');
15 $error = 'No file uploaded' unless defined($fh);
16
17 unless ( $error ) {
18
19   $cgi->param('batchnum') =~ /^(\d+)$/;
20   my $batchnum = $1;
21
22   my $pay_batch = qsearchs( 'pay_batch', { 'batchnum' => $batchnum } );
23   if ( ! $pay_batch ) {
24     $error = "batchnum $batchnum not found";
25   } elsif ( $pay_batch->status ne 'I' ) {
26     $error = "batch $batchnum is not in transit";
27   } else {
28     $error = $pay_batch->import_results(
29                                          'filehandle' => $fh,
30                                          'format'     => $cgi->param('format'),
31                                        );
32   }
33
34 }
35
36 </%init>