[freeside-commits] branch FREESIDE_3_BRANCH updated. 2a5d3c4f83803a2ef0059b7e03bb6286efcbe900

Ivan ivan at 420.am
Sun Jan 19 14:05:52 PST 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  2a5d3c4f83803a2ef0059b7e03bb6286efcbe900 (commit)
      from  3503a3527328d16733369027ecbe5c17908fa223 (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 2a5d3c4f83803a2ef0059b7e03bb6286efcbe900
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Jan 19 14:05:51 2014 -0800

    select quick payment entry batch in payment report, RT#26343

diff --git a/httemplate/elements/select-paybatch.html b/httemplate/elements/select-paybatch.html
new file mode 100644
index 0000000..1dba452
--- /dev/null
+++ b/httemplate/elements/select-paybatch.html
@@ -0,0 +1,46 @@
+<SELECT NAME="<% $opt{field} || 'paybatch' %>">
+
+  <OPTION VALUE="">any/none</OPTION>
+
+% foreach my $p (@paybatch) {
+%   my( $paybatch, $date ) = @$p;
+%   #my @components = split('-', $paybatch);
+%   my $pretty_date = time2str($date_format, $date);
+%   my $pretty = "$pretty_date: $paybatch";
+
+    <OPTION VALUE="<% $paybatch |h %>"><% $pretty |h %></OPTION>
+
+% }
+
+</SELECT>
+<%init>
+
+use Date::Parse qw(str2time); #i should be in Mason.pm
+
+my %opt = @_;
+#my $paybatch = $opt{'curr_value'}; # || $opt{'value'} necessary?
+
+my $conf = new FS::Conf;
+my $date_format = $conf->config('date_format') || '%m/%d/%Y';
+
+my $sth = dbh->prepare('SELECT DISTINCT paybatch FROM cust_pay
+                          WHERE paybatch IS NOT NULL')
+  or die dbh->errstr;
+$sth->execute or die $sth->errstr;
+
+my @paybatch = #map $_->[0],
+                 sort { $a->[1] <=> $b->[1] }
+                   map { my $date = '';
+                         if ( /^\w+\-(\d+)\-/ ) {
+                           $date = $1;
+                         } elsif ( /^\w+\-([\d\/]+)\-([\d\:]+)\-/ ) {
+                           $date = str2time("$1 $2");
+                         #} else {
+                         #  warn "unparsable: $_\n";
+                         }
+                         [ $_, $date ];
+                       }
+                     grep ! /^webui-/, #don't actually want the single entries
+                       map $_->[0], @{ $sth->fetchall_arrayref };
+
+</%init>
diff --git a/httemplate/elements/tr-select-paybatch.html b/httemplate/elements/tr-select-paybatch.html
new file mode 100644
index 0000000..aedf893
--- /dev/null
+++ b/httemplate/elements/tr-select-paybatch.html
@@ -0,0 +1,13 @@
+<TR>
+  <TD ALIGN="right"><% $opt{'paybatch'} || 'Payment entry batch: ' %></TD>
+  <TD>
+    <% include( '/elements/select-paybatch.html', 'curr_value' => $selected_paybatch, %opt ) %>
+  </TD>
+</TR>
+<%init>
+
+my( %opt ) = @_;
+#my $conf = new FS::Conf;
+my $selected_paybatch = $opt{'curr_value'}; # || $opt{'value'} necessary?
+
+</%init>
diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html
index 234121f..c272a16 100755
--- a/httemplate/search/elements/cust_pay_or_refund.html
+++ b/httemplate/search/elements/cust_pay_or_refund.html
@@ -440,8 +440,6 @@ if ( $cgi->param('magic') ) {
     $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/
       or die "illegal paybatch: ". $cgi->param('paybatch');
 
-    push @search, "paybatch = '$1'";
-
     $orderby = "LOWER(company || ' ' || last || ' ' || first )";
 
   } elsif ( $cgi->param('magic') eq 'batchnum' ) {
@@ -457,6 +455,10 @@ if ( $cgi->param('magic') ) {
     die "unknown search magic: ". $cgi->param('magic');
   }
 
+  if ( $cgi->param('paybatch') =~ /^([\w\/\:\-\.]+)$/ ) {
+    push @search, "paybatch = '$1'";
+  }
+
   #unapplied payment/refund
   if ( $unapplied ) {
     push @select, '(' . "FS::$table"->unapplied_sql . ') AS unapplied_amount';
diff --git a/httemplate/search/elements/report_cust_pay_or_refund.html b/httemplate/search/elements/report_cust_pay_or_refund.html
index b39c7c0..25f7cda 100644
--- a/httemplate/search/elements/report_cust_pay_or_refund.html
+++ b/httemplate/search/elements/report_cust_pay_or_refund.html
@@ -89,6 +89,16 @@ Examples:
     </TR>
 % }
 
+% if ( $table eq 'cust_pay' ) {
+
+% # payment batch
+% #  <& /elements/tr-select-batchnum.html &>
+
+% #payment "entry" batch (should probably just all become the same thing)
+  <& /elements/tr-select-paybatch.html &>
+
+% }
+
   <& /elements/tr-input-lessthan_greaterthan.html,
                 'label' => emt('Amount'),
                 'field' => 'paid',

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

Summary of changes:
 httemplate/elements/select-paybatch.html           |   46 ++++++++++++++++++++
 httemplate/elements/tr-select-paybatch.html        |   13 ++++++
 httemplate/search/elements/cust_pay_or_refund.html |    6 ++-
 .../search/elements/report_cust_pay_or_refund.html |   10 ++++
 4 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 httemplate/elements/select-paybatch.html
 create mode 100644 httemplate/elements/tr-select-paybatch.html




More information about the freeside-commits mailing list