+my $money_char = FS::Conf->new->config('money_char') || '$';
+
+my $title = emt('Credit Search Results');
+
+my $unapplied = $cgi->param('unapplied');
+$title = emt("Unapplied $title") if $unapplied;
+my $clink = sub {
+ my $cust_bill = shift;
+ $cust_bill->cust_main_custnum
+ ? [ "${p}view/cust_main.cgi?", 'custnum' ]
+ : '';
+};
+
+my (@header, @fields, @sort_fields, $align, @links, @color, @style);
+$align = '';
+
+#amount
+push @header, emt('Amount');
+push @fields, sub { $money_char .sprintf('%.2f', shift->amount) };
+push @sort_fields, 'amount';
+$align .= 'r';
+push @links, '';
+push @color, '';
+push @style, '';
+
+# unapplied amount
+if ($unapplied) {
+ push @header, emt('Unapplied');
+ push @fields, sub { $money_char .sprintf('%.2f', shift->unapplied_amount) };
+ push @sort_fields, '';
+ $align .= 'r';
+ push @links, '';
+ push @color, '';
+ push @style, '';
+}
+
+push @header, emt('Date'),
+ emt('By'),
+ emt('Reason'),
+ FS::UI::Web::cust_header(),
+ ;
+push @fields, sub { time2str('%b %d %Y', shift->_date ) },
+ 'otaker',
+ 'reason',
+ \&FS::UI::Web::cust_fields,
+ ;
+push @sort_fields, '_date', 'otaker', 'reason', FS::UI::Web::cust_sort_fields();
+$align .= 'rll'.FS::UI::Web::cust_aligns();
+push @links, '',
+ '',
+ '',
+ ( map { $_ ne 'Cust. Status' ? $clink : '' }
+ FS::UI::Web::cust_header()
+ ),
+ ;
+push @color, '',
+ '',
+ '',
+ FS::UI::Web::cust_colors(),
+ ;
+push @style, '',
+ '',
+ '',
+ FS::UI::Web::cust_styles(),
+ ;