use Date::Format;
use Business::CreditCard;
use Text::Template;
+use FS::Misc::DateTime qw( parse_datetime ); #for batch_import
use FS::Record qw( dbh qsearch qsearchs );
use FS::CurrentUser;
use FS::payby;
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'};
# here is the agent virtualization
payby => $payby,
paybatch => $paybatch,
);
+ $cust_pay{_date} = $_date if $_date;
my $cust_main;
foreach my $field ( @fields ) {
+<%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>
-<% include("/elements/header.html",'Batch Payment Import') %>
+<& /elements/header.html, 'Batch Payment Import' &>
Import a CSV file containing customer payments.
<BR><BR>
<% &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>
<BR>
-<% include('/elements/footer.html') %>
+<& /elements/footer.html &>
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';