[freeside-commits] branch master updated. 761449917d3d1d7b3a2206785e702246b8b5625e

Ivan ivan at 420.am
Fri Jan 24 18:34:42 PST 2014


The branch, master has been updated
       via  761449917d3d1d7b3a2206785e702246b8b5625e (commit)
       via  a794f08248abbb8d2f0efb617d3e83babdfe0e09 (commit)
      from  5bd7552215c77573b07e9775d7d63f70b0a55fd1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 761449917d3d1d7b3a2206785e702246b8b5625e
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Jan 24 18:34:38 2014 -0800

    select a date when importing credits, RT#27087

diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index 3f8d57c..7ae6c97 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -1118,7 +1118,7 @@ sub process_batch_import {
   my $job = shift;
 
   my $opt = { 'table'   => 'cust_credit',
-              'params'  => [ 'credbatch' ],
+              'params'  => [ '_date', 'credbatch' ],
               'formats' => { 'simple' =>
                                [ 'custnum', 'amount', 'reasonnum', 'invnum' ],
                            },
diff --git a/httemplate/misc/cust_credit-import.html b/httemplate/misc/cust_credit-import.html
index 6de34e3..9a63a04 100644
--- a/httemplate/misc/cust_credit-import.html
+++ b/httemplate/misc/cust_credit-import.html
@@ -7,7 +7,7 @@ Import a file containing credits.
      'name'      => 'CreditImportForm',
      'action'    => 'process/cust_credit-import.cgi',
      'num_files' => 1,
-     'fields'    => [ 'format', 'credbatch' ],
+     'fields'    => [ 'format', '_date', 'credbatch' ],
      'message'   => 'Credit import successful',
      'url'       => $p."search/cust_credit.html?credbatch=$credbatch",
      'onsubmit'  => "document.CreditImportForm.submitButton.disabled=true;",
@@ -18,6 +18,13 @@ Import a file containing credits.
 
   <INPUT TYPE="hidden" NAME="credbatch" VALUE="<% $credbatch %>"%>
 
+  <& /elements/tr-input-date-field.html, {
+       'name'  => '_date',
+       #'value' => '',
+       'label' => 'Date',
+     }
+  &>
+
   <!--
   <TR>
     <TH ALIGN="right">Format</TH>
diff --git a/httemplate/misc/process/cust_credit-import.cgi b/httemplate/misc/process/cust_credit-import.cgi
index 5a5cfe2..4c4d42d 100644
--- a/httemplate/misc/process/cust_credit-import.cgi
+++ b/httemplate/misc/process/cust_credit-import.cgi
@@ -4,6 +4,11 @@
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Import');
 
+my %arg = $cgi->param('arg');
+$arg{_date} = parse_datetime( $arg{_date} )
+  if $arg{_date} && $arg{_date} =~ /\D/;
+$cgi->param('arg', %arg );
+
 my $server =
   new FS::UI::Web::JSRPC 'FS::cust_credit::process_batch_import', $cgi;
 

commit a794f08248abbb8d2f0efb617d3e83babdfe0e09
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Jan 24 18:13:02 2014 -0800

    select a date when importing payments, RT#27087

diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index ed76559..b7189a8 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -9,6 +9,7 @@ use vars qw( $DEBUG $me $conf @encrypted_fields
 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;
@@ -1091,9 +1092,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'};
 
   # here is the agent virtualization
@@ -1144,6 +1148,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 37a22e5..40162f0 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 849a25b..28ad6e7 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 92b6e5a..7711773 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';

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_credit.pm                           |    2 +-
 FS/FS/cust_pay.pm                              |    9 +++++++--
 httemplate/elements/tr-input-date-field.html   |   19 +++++++++++++++++++
 httemplate/misc/cust_credit-import.html        |    9 ++++++++-
 httemplate/misc/cust_pay-import.cgi            |   22 ++++++++++++++--------
 httemplate/misc/process/cust_credit-import.cgi |    5 +++++
 httemplate/misc/process/cust_pay-import.cgi    |    4 +++-
 7 files changed, 57 insertions(+), 13 deletions(-)




More information about the freeside-commits mailing list