summaryrefslogtreecommitdiff
path: root/httemplate/misc/upload-batch.cgi
blob: d1a84fd0217a9a45b647521cc26aa8aa64d25d04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% if ( $error ) {
%   errorpage($error);
% } else {
    <% include('/elements/header.html','Batch results upload successful') %> 
    <% include('/elements/footer.html') %> 
% }
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Process batches');

my $error;

my $fh = $cgi->upload('batch_results');
$error = 'No file uploaded' unless defined($fh);

unless ( $error ) {

  $cgi->param('batchnum') =~ /^(\d+)$/;
  my $batchnum = $1;

  my $pay_batch = qsearchs( 'pay_batch', { 'batchnum' => $batchnum } );
  if ( ! $pay_batch ) {
    $error = "batchnum $batchnum not found";
  } elsif ( $pay_batch->status ne 'I' ) {
    $error = "batch $batchnum is not in transit";
  } else {
    $error = $pay_batch->import_results(
                                         'filehandle' => $fh,
                                         'format'     => $cgi->param('format'),
                                       );
  }

}

</%init>