diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-01-19 14:05:44 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-01-19 14:05:44 -0800 |
commit | 17ca8b897e82cffb3731a63ccae1fb12494a7246 (patch) | |
tree | 3b8ef21a07f7827308cbeada19d499f657444c07 /httemplate/elements/select-paybatch.html | |
parent | bbf3f6d6af46d522a395e4c31ed8818059517b75 (diff) |
select quick payment entry batch in payment report, RT#26343
Diffstat (limited to 'httemplate/elements/select-paybatch.html')
-rw-r--r-- | httemplate/elements/select-paybatch.html | 46 |
1 files changed, 46 insertions, 0 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> |