summaryrefslogtreecommitdiff
path: root/FS/FS/pay_batch.pm
diff options
context:
space:
mode:
authormark <mark>2010-06-16 02:19:13 +0000
committermark <mark>2010-06-16 02:19:13 +0000
commite37126c4d8a3eea4d27c855733a77cba026565c4 (patch)
tree7157385b2dc65a6dd2aa70149711fc29b53315f8 /FS/FS/pay_batch.pm
parent50de3921a10ae2ecc890c8661aa772dce72f0c53 (diff)
RT#5683: payment batch upload uses job queue and progressbar
Diffstat (limited to 'FS/FS/pay_batch.pm')
-rw-r--r--FS/FS/pay_batch.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm
index 6a27554..d73c052 100644
--- a/FS/FS/pay_batch.pm
+++ b/FS/FS/pay_batch.pm
@@ -195,6 +195,9 @@ sub import_results {
my $info = $import_info{$format}
or die "unknown format $format";
+ my $job = $param->{'job'};
+ $job->update_statustext(0) if $job;
+
my $filetype = $info->{'filetype'}; # CSV or fixed
my @fields = @{ $info->{'fields'}};
my $formatre = $info->{'formatre'}; # for fixed
@@ -286,7 +289,12 @@ sub import_results {
}
}
+ my $num = 0;
foreach (@all_values) {
+ if($job) {
+ $num++;
+ $job->update_statustext(int(100 * $num/scalar(@all_values)));
+ }
my @values = @$_;
my %hash;
@@ -404,6 +412,29 @@ sub import_results {
}
+use MIME::Base64;
+use Storable 'thaw';
+use Data::Dumper;
+sub process_import_results {
+ my $job = shift;
+ my $param = thaw(decode_base64(shift));
+ $param->{'job'} = $job;
+ warn Dumper($param) if $DEBUG;
+ my $batchnum = delete $param->{'batchnum'} or die "no batchnum specified\n";
+ my $batch = FS::pay_batch->by_key($batchnum) or die "batchnum '$batchnum' not found\n";
+
+ my $file = $param->{'uploaded_files'} or die "no files provided\n";
+ $file =~ s/^(\w+):([\.\w]+)$/$2/;
+ my $dir = '%%%FREESIDE_CACHE%%%/cache.' . $FS::UID::datasrc;
+ open( $param->{'filehandle'},
+ '<',
+ "$dir/$file" )
+ or die "unable to open '$file'.\n";
+ my $error = $batch->import_results($param);
+ unlink $file;
+ die $error if $error;
+}
+
# Formerly httemplate/misc/download-batch.cgi
sub export_batch {
my $self = shift;