summaryrefslogtreecommitdiff
path: root/httemplate/misc/upload-batch.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/misc/upload-batch.cgi')
-rw-r--r--httemplate/misc/upload-batch.cgi61
1 files changed, 35 insertions, 26 deletions
diff --git a/httemplate/misc/upload-batch.cgi b/httemplate/misc/upload-batch.cgi
index 5d0150177..69d3ca6b1 100644
--- a/httemplate/misc/upload-batch.cgi
+++ b/httemplate/misc/upload-batch.cgi
@@ -1,30 +1,39 @@
-<%
-
- my $fh = $cgi->upload('batch_results');
- my $filename = $cgi->param('batch_results');
- $filename =~ /^(.*[\/\\])?([^\/\\]+)$/
- or die "unparsable filename: $filename\n";
- my $paybatch = $2;
-
- my $error = defined($fh)
- ? FS::cust_pay_batch::import_results( {
- 'filehandle' => $fh,
- 'format' => $cgi->param('format'),
- 'paybatch' => $paybatch,
- } )
- : 'No file';
-
- if ( $error ) {
- %>
+% if ( $error ) {
+
<!-- mason kludge -->
- <%
- eidiot($error);
-# $cgi->param('error', $error);
-# print $cgi->redirect( "${p}cust_main-import.cgi
+
+% 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 {
- %>
- <!-- mason kludge -->
- <%= header('Batch results upload sucessful') %> <%
+ $error = $pay_batch->import_results(
+ 'filehandle' => $fh,
+ 'format' => $cgi->param('format'),
+ );
}
-%>
+}
+
+</%init>