summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-01-19 14:05:44 -0800
committerIvan Kohler <ivan@freeside.biz>2014-01-19 14:05:44 -0800
commit17ca8b897e82cffb3731a63ccae1fb12494a7246 (patch)
tree3b8ef21a07f7827308cbeada19d499f657444c07
parentbbf3f6d6af46d522a395e4c31ed8818059517b75 (diff)
select quick payment entry batch in payment report, RT#26343
-rw-r--r--httemplate/elements/select-paybatch.html46
-rw-r--r--httemplate/elements/tr-select-paybatch.html13
-rwxr-xr-xhttemplate/search/elements/cust_pay_or_refund.html6
-rw-r--r--httemplate/search/elements/report_cust_pay_or_refund.html10
4 files changed, 73 insertions, 2 deletions
diff --git a/httemplate/elements/select-paybatch.html b/httemplate/elements/select-paybatch.html
new file mode 100644
index 000000000..1dba452b5
--- /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 000000000..aedf893db
--- /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 234121fa3..c272a1614 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 b39c7c088..25f7cdadd 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',