diff options
author | ivan <ivan> | 2007-02-05 09:44:38 +0000 |
---|---|---|
committer | ivan <ivan> | 2007-02-05 09:44:38 +0000 |
commit | a014f2e125028a5a80c0587f36df5e865b70b47f (patch) | |
tree | d4f4c93cf9a033aca956dccbb10e9e81a45a54c5 /httemplate/misc/upload-batch.cgi | |
parent | 5d9a5e54a74950b0e62264abcd53e77607f04b48 (diff) |
move cust_pay_batch::upload results subroutine to an FS::pay_batch method. upon first download, have batches auto-reset their amounts to the customer balance upon if it is smaller.
Diffstat (limited to 'httemplate/misc/upload-batch.cgi')
-rw-r--r-- | httemplate/misc/upload-batch.cgi | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/httemplate/misc/upload-batch.cgi b/httemplate/misc/upload-batch.cgi index 5b4961be3..ccaf6f046 100644 --- a/httemplate/misc/upload-batch.cgi +++ b/httemplate/misc/upload-batch.cgi @@ -1,32 +1,37 @@ -% -% -% my $fh = $cgi->upload('batch_results'); -% $cgi->param('batchnum') =~ /^(\d+)$/; -% my $paybatch = $1; -% -% my $error = defined($fh) -% ? FS::cust_pay_batch::import_results( { -% 'filehandle' => $fh, -% 'format' => $cgi->param('format'), -% 'paybatch' => $paybatch, -% } ) -% : 'No file'; -% % if ( $error ) { -% <!-- mason kludge --> -% + % eidiot($error); %# $cgi->param('error', $error); %# print $cgi->redirect( "${p}cust_main-import.cgi % } else { -% - <!-- mason kludge --> <% 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 $paybatch is not in transit"; + } else { + $error = $pay_batch->import_results( + 'filehandle' => $fh, + 'format' => $cgi->param('format'), + ); + } +<%/init> |