} else {
$cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/;
- $count_query = 'SELECT 1';
+ $count_query = "SELECT COUNT(*) FROM cust_bill WHERE invnum = $2";
$sql_query = {
'table' => 'cust_bill',
'hashref' => { 'invnum' => $2 },
}
my $link = [ "${p}view/cust_bill.cgi?", 'invnum', ];
- my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
+ my $clink = sub {
+ my $cust_bill = shift;
+ my $cust_main = $cust_bill->cust_main;
+ $cust_main
+ ? [ "${p}view/cust_main.cgi?", 'custnum' ]
+ : '';
+ };
-%>
-<%= include( 'elements/search.html',
- 'title' => 'Invoice Search Results',
- 'name' => 'invoices',
- 'query' => $sql_query,
- 'count_query' => $count_query,
- 'count_addl' => [ '$%.2f total invoiced',
- '$%.2f total outstanding balance',
- ],
- 'redirect' => $link,
- 'header' =>
- [ 'Invoice #', qw(Balance Amount Date), 'Contact name',
- 'Company' ],
- 'fields' => [
- 'invnum',
- sub { sprintf('$%.2f', shift->get('owed') ) },
- sub { sprintf('$%.2f', shift->charged ) },
- sub { time2str('%b %d %Y', shift->_date ) },
- sub { my $cust_bill = shift;
- my $cust_main = $cust_bill->cust_main;
- $cust_main
- ? $cust_main->get('last'). ', '. $cust_main->first
- : "WARNING: can't find cust_main.custnum ".
- $cust_bill->custnum. ' (cust_bill.invnum '.
- $cust_bill->invnum. ')';
- },
- sub { my $cust_main = shift->cust_main;
- $cust_main ? $cust_main->company : '';
- },
- ],
- 'links' => [
- $link,
- $link,
- $link,
- $link,
- $clink,
- $clink,
- ],
+ my $conf = new FS::Conf;
+ my $money_char = $conf->config('money_char') || '$';
- )
+%><%= include( 'elements/search.html',
+ 'title' => 'Invoice Search Results',
+ 'name' => 'invoices',
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'count_addl' => [ '$%.2f total invoiced',
+ '$%.2f total outstanding balance',
+ ],
+ 'redirect' => $link,
+ 'header' =>
+ [ 'Invoice #', qw(Balance Amount Date), 'Contact name',
+ 'Company' ],
+ 'fields' => [
+ 'invnum',
+ sub { sprintf($money_char.'%.2f', shift->get('owed') ) },
+ sub { sprintf($money_char.'%.2f', shift->charged ) },
+ sub { time2str('%b %d %Y', shift->_date ) },
+ sub { my $cust_bill = shift;
+ my $cust_main = $cust_bill->cust_main;
+ $cust_main
+ ? $cust_main->get('last'). ', '. $cust_main->first
+ : "WARNING: can't find cust_main.custnum ".
+ $cust_bill->custnum. ' (cust_bill.invnum '.
+ $cust_bill->invnum. ')';
+ },
+ sub { my $cust_main = shift->cust_main;
+ $cust_main ? $cust_main->company : '';
+ },
+ ],
+ 'align' => 'rrrrll',
+ 'links' => [
+ $link,
+ $link,
+ $link,
+ $link,
+ $clink,
+ $clink,
+ ],
+
+ )
%>