summaryrefslogtreecommitdiff
path: root/httemplate/misc/upload-batch.cgi
blob: 69d3ca6b1bfce82c2004fc88f9c6d524bbd5bf2e (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
37
38
39
%  if ( $error ) {

    <!-- mason kludge -->

%    eidiot($error);
%#    $cgi->param('error', $error);
%#    print $cgi->redirect( "${p}cust_main-import.cgi
%  } else {

    <% include("/elements/header.html",'Batch results upload successful') %> 

%  }
<%init>

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>