diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-01-24 18:13:02 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-02-10 07:51:11 -0800 |
commit | 3be3e98fde6ea3d19e843551e960f77c41e2fba2 (patch) | |
tree | 2d31a15b404a5bf0734a07ff645b9847a4473dc1 | |
parent | 216b4b41bc9393568cc6737c4efe94960ed1d0d0 (diff) |
select a date when importing payments, RT#27087
Conflicts:
FS/FS/cust_pay.pm
-rw-r--r-- | FS/FS/cust_pay.pm | 9 | ||||
-rw-r--r-- | httemplate/elements/tr-input-date-field.html | 19 | ||||
-rw-r--r-- | httemplate/misc/cust_pay-import.cgi | 22 | ||||
-rw-r--r-- | httemplate/misc/process/cust_pay-import.cgi | 4 |
4 files changed, 43 insertions, 11 deletions
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index a1286e36f..046b7c7b5 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -11,6 +11,7 @@ use Business::CreditCard; use Text::Template; use FS::UID qw( getotaker ); use FS::Misc qw( send_email ); +use FS::Misc::DateTime qw( parse_datetime ); #for batch_import use FS::Record qw( dbh qsearch qsearchs ); use FS::CurrentUser; use FS::payby; @@ -1125,9 +1126,12 @@ Inserts new payments. sub batch_import { my $param = shift; - my $fh = $param->{filehandle}; + my $fh = $param->{filehandle}; + my $format = $param->{'format'}; + my $agentnum = $param->{agentnum}; - my $format = $param->{'format'}; + my $_date = $param->{_date}; + $_date = parse_datetime($_date) if $_date && $_date =~ /\D/; my $paybatch = $param->{'paybatch'}; my $custnum_prefix = $conf->config('cust_main-custnum-display_prefix'); @@ -1181,6 +1185,7 @@ sub batch_import { payby => $payby, paybatch => $paybatch, ); + $cust_pay{_date} = $_date if $_date; my $cust_main; foreach my $field ( @fields ) { diff --git a/httemplate/elements/tr-input-date-field.html b/httemplate/elements/tr-input-date-field.html index 37a22e5df..40162f0fd 100644 --- a/httemplate/elements/tr-input-date-field.html +++ b/httemplate/elements/tr-input-date-field.html @@ -1,3 +1,22 @@ +<%doc> + +Example: + + <& /elements/tr-input_date-field, + { + 'name' => 'field_name', + 'value' => $current_value, + 'label' => 'Label', + + #optional + 'format' => '%m/%d/%Y', #overrides date_format config + 'usedatetime' => 1, #use DateTime->strftime to format the date + # instead of Date::Format->time2str + 'noinit' => 1, #first one on the page is enough + }, + &> + +</%doc> % unless ( $noinit ) { <LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2"> <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT> diff --git a/httemplate/misc/cust_pay-import.cgi b/httemplate/misc/cust_pay-import.cgi index 849a25bea..28ad6e7df 100644 --- a/httemplate/misc/cust_pay-import.cgi +++ b/httemplate/misc/cust_pay-import.cgi @@ -1,4 +1,4 @@ -<% include("/elements/header.html",'Batch Payment Import') %> +<& /elements/header.html, 'Batch Payment Import' &> Import a CSV file containing customer payments. <BR><BR> @@ -7,12 +7,18 @@ Import a CSV file containing customer payments. <% &ntable("#cccccc", 2) %> -<% include('/elements/tr-select-agent.html', - #'curr_value' => '', #$agentnum, - 'label' => "<B>Agent</B>", - 'empty_label' => 'Select agent', - ) -%> +<& /elements/tr-select-agent.html, + #'curr_value' => '', #$agentnum, + 'label' => "<B>Agent</B>", + 'empty_label' => 'Select agent', +&> + +<& /elements/tr-input-date-field.html, { + 'name' => '_date', + #'value' => '', + 'label' => 'Date', + } +&> <TR> <TH ALIGN="right">Format</TH> @@ -59,4 +65,4 @@ Field information: <BR> -<% include('/elements/footer.html') %> +<& /elements/footer.html &> diff --git a/httemplate/misc/process/cust_pay-import.cgi b/httemplate/misc/process/cust_pay-import.cgi index 92b6e5a36..7711773d8 100644 --- a/httemplate/misc/process/cust_pay-import.cgi +++ b/httemplate/misc/process/cust_pay-import.cgi @@ -9,8 +9,10 @@ my $paybatch = time2str('webbatch-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); my $error = defined($fh) ? FS::cust_pay::batch_import( { 'filehandle' => $fh, - 'agentnum' => scalar($cgi->param('agentnum')), 'format' => scalar($cgi->param('format')), + + 'agentnum' => scalar($cgi->param('agentnum')), + '_date' => scalar($cgi->param('_date')), 'paybatch' => $paybatch, } ) : 'No file'; |