--- /dev/null
+<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>
--- /dev/null
+<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>
$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' ) {
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';
</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',