From: Ivan Kohler Date: Sun, 19 Jan 2014 22:05:44 +0000 (-0800) Subject: select quick payment entry batch in payment report, RT#26343 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=17ca8b897e82cffb3731a63ccae1fb12494a7246 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 000000000..1dba452b5 --- /dev/null +++ b/httemplate/elements/select-paybatch.html @@ -0,0 +1,46 @@ + +<%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 }; + + 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 @@ + + <% $opt{'paybatch'} || 'Payment entry batch: ' %> + + <% include( '/elements/select-paybatch.html', 'curr_value' => $selected_paybatch, %opt ) %> + + +<%init> + +my( %opt ) = @_; +#my $conf = new FS::Conf; +my $selected_paybatch = $opt{'curr_value'}; # || $opt{'value'} necessary? + + 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: % } +% 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',