From 1ac4a177bd93ad7a97a45aacb66aa0bc9c23726b Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Sat, 28 Feb 2015 00:04:43 -0600 Subject: RT#30825: Modernize Bulk payment importing --- httemplate/misc/cust_pay-import.cgi | 52 ++++++++++++++++++++--------- httemplate/misc/process/cust_pay-import.cgi | 24 ++----------- 2 files changed, 40 insertions(+), 36 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/cust_pay-import.cgi b/httemplate/misc/cust_pay-import.cgi index 05a6c4fd8..ee0154db5 100644 --- a/httemplate/misc/cust_pay-import.cgi +++ b/httemplate/misc/cust_pay-import.cgi @@ -1,22 +1,31 @@ <& /elements/header.html, 'Batch Payment Import' &> -Import a CSV file containing customer payments. +Import a file containing customer payments.

-
+ +<% include( '/elements/form-file_upload.html', + 'name' => 'OneTrueForm', + 'action' => 'process/cust_pay-import.cgi', #progress-init target + 'fields' => [ 'agentnum', '_date', 'paybatch', 'format', 'payby' ], + 'num_files' => 1, + 'url' => popurl(2)."search/cust_pay.html?magic=paybatch;paybatch=$paybatch", + 'message' => 'Batch Payment Imported', + ) +%> <% &ntable("#cccccc", 2) %> + + <& /elements/tr-select-agent.html, - #'curr_value' => '', #$agentnum, 'label' => "Agent", 'empty_label' => 'Select agent', &> <& /elements/tr-input-date-field.html, { 'name' => '_date', - #'value' => '', - 'label' => 'Date', + 'label' => 'Date', } &> @@ -24,18 +33,26 @@ Import a CSV file containing customer payments. Format - - CSV filename - - +<% include( '/elements/tr-select-payby.html', + 'paybys' => \%paybys, + 'no_all' => 1, + 'label' => 'Payment type', + ) +%> + +<% include( '/elements/file-upload.html', + 'field' => 'file', + 'label' => 'Filename', + ) +%> - + @@ -43,11 +60,10 @@ Import a CSV file containing customer payments.
-Simple file format is CSV, with the following field order: custnum, agent_custid, amount, checknum +Simple file format is CSV or XLS, with the following field order: custnum, agent_custid, amount, checknum, invnum

- + Field information: @@ -68,3 +84,9 @@ Field information:
<& /elements/footer.html &> + +<%init> +my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); +my %paybys; +tie %paybys, 'Tie::IxHash', FS::payby->payment_payby2longname(); + diff --git a/httemplate/misc/process/cust_pay-import.cgi b/httemplate/misc/process/cust_pay-import.cgi index 7711773d8..2981da46d 100644 --- a/httemplate/misc/process/cust_pay-import.cgi +++ b/httemplate/misc/process/cust_pay-import.cgi @@ -1,23 +1,5 @@ -<% $cgi->redirect(popurl(3). "search/cust_pay.html?magic=paybatch;paybatch=$paybatch") %> +<% $server->process %> <%init> - -my $fh = $cgi->upload('csvfile'); - -# webbatch? I suppose -my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); - -my $error = defined($fh) - ? FS::cust_pay::batch_import( { - 'filehandle' => $fh, - 'format' => scalar($cgi->param('format')), - - 'agentnum' => scalar($cgi->param('agentnum')), - '_date' => scalar($cgi->param('_date')), - 'paybatch' => $paybatch, - } ) - : 'No file'; - -errorpage($error) - if ( $error ); - +my $server = new FS::UI::Web::JSRPC 'FS::cust_pay::process_batch_import', $cgi; + -- cgit v1.2.1