From a6211a623e3f7d8f6af8363693e722fd63e8459e Mon Sep 17 00:00:00 2001 From: mark Date: Wed, 16 Jun 2010 02:19:25 +0000 Subject: RT#5683: payment batch upload uses job queue and progressbar --- httemplate/elements/file-upload.html | 5 +++++ httemplate/misc/upload-batch.cgi | 32 +++--------------------------- httemplate/search/cust_pay_batch.cgi | 38 +++++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 40 deletions(-) (limited to 'httemplate') diff --git a/httemplate/elements/file-upload.html b/httemplate/elements/file-upload.html index 7e2eeefcd..034eaec38 100644 --- a/httemplate/elements/file-upload.html +++ b/httemplate/elements/file-upload.html @@ -54,10 +54,15 @@ % foreach (@field) { +% if($param{'no_table'}) { + <% shift @label %> +% } +% else { <% shift @label %> +% } % }
diff --git a/httemplate/misc/upload-batch.cgi b/httemplate/misc/upload-batch.cgi index d1a84fd02..be80b1ff7 100644 --- a/httemplate/misc/upload-batch.cgi +++ b/httemplate/misc/upload-batch.cgi @@ -1,36 +1,10 @@ -% if ( $error ) { -% errorpage($error); -% } else { - <% include('/elements/header.html','Batch results upload successful') %> - <% include('/elements/footer.html') %> -% } +<% $server->process %> <%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'), - ); - } - -} +my $server = + new FS::UI::Web::JSRPC 'FS::pay_batch::process_import_results', $cgi; diff --git a/httemplate/search/cust_pay_batch.cgi b/httemplate/search/cust_pay_batch.cgi index 169094435..e8a749035 100755 --- a/httemplate/search/cust_pay_batch.cgi +++ b/httemplate/search/cust_pay_batch.cgi @@ -124,7 +124,7 @@ $sql_query = "SELECT paybatchnum,invnum,custnum,cpb.last,cpb.first," . 'LEFT JOIN pay_batch USING ( batchnum ) ' . "$search ORDER BY $orderby"; -my $html_init = ''; +my $html_init = ''; if ( $pay_batch ) { my $fixed = $conf->config('batch-fixed_format-'. $pay_batch->payby); if ( @@ -136,11 +136,12 @@ if ( $pay_batch ) { && $FS::CurrentUser::CurrentUser->access_right('Redownload resolved batches') ) ) { - $html_init .= qq!!; + $html_init .= qq!!; if ( $fixed ) { $html_init .= qq!!; } else { - $html_init .= qq!Download batch in format !. qq!!. qq!!. qq!!. @@ -151,7 +152,7 @@ if ( $pay_batch ) { qq!!. qq!!; } - $html_init .= qq!
!; + $html_init .= qq!

!; } if ( @@ -160,13 +161,28 @@ if ( $pay_batch ) { && $FS::CurrentUser::CurrentUser->access_right('Reprocess batches') ) ) { - $html_init .= qq!!. - qq!Upload results
!. - qq!Filename
!; + $html_init .= ''. + include('/elements/form-file_upload.html', + 'name' => 'FileUpload', + 'action' => "$p/misc/upload-batch.cgi", + 'num_files' => 1, + 'fields' => [ 'batchnum', 'format' ], + 'message' => 'Batch results uploaded.', + ) . + 'Upload results
'. + include('/elements/file-upload.html', + 'field' => 'file', + 'label' => 'Filename', + 'no_table'=> 1 + ). + '
' + ; if ( $fixed ) { $html_init .= qq!!; } else { - $html_init .= qq!Format Format !. + qq!
!; + qq!
!; } $html_init .= qq!!; - $html_init .= '
'; + $html_init .= '
'; } - + $html_init .= '
' } if ($pay_batch) { -- cgit v1.2.1