<& elements/search.html,
- 'title' => emt('Invoice Search Results'),
- 'html_init' => $html_init,
- 'menubar' => $menubar,
- 'name' => 'invoices',
- 'query' => $sql_query,
- 'count_query' => $count_query,
- 'count_addl' => $count_addl,
- 'redirect' => $link,
- 'header' => [ emt('Invoice #'),
- emt('Balance'),
- emt('Net Amount'),
- emt('Gross Amount'),
- emt('Date'),
- FS::UI::Web::cust_header(),
- ],
- 'fields' => [
- 'display_invnum',
- sub { sprintf($money_char.'%.2f', shift->get('owed') ) },
- sub { sprintf($money_char.'%.2f', shift->get('net') ) },
- sub { sprintf($money_char.'%.2f', shift->charged ) },
- sub { time2str('%b %d %Y', shift->_date ) },
- \&FS::UI::Web::cust_fields,
- ],
- 'sort_fields' => [
- 'COALESCE( agent_invid, invnum )',
- FS::cust_bill->owed_sql,
- FS::cust_bill->net_sql,
- 'charged',
- '_date',
- ],
- 'align' => 'rrrrl'.FS::UI::Web::cust_aligns(),
- 'links' => [
- $link,
- $link,
- $link,
- $link,
- $link,
- ( map { $_ ne 'Cust. Status' ? $clink : '' }
- FS::UI::Web::cust_header()
- ),
- ],
- 'color' => [
- '',
- '',
- '',
- '',
- '',
- FS::UI::Web::cust_colors(),
- ],
- 'style' => [
- '',
- '',
- '',
- '',
- '',
- FS::UI::Web::cust_styles(),
- ],
+ 'title' => emt('Invoice Search Results'),
+ 'html_init' => $html_init,
+ 'menubar' => $menubar,
+ 'name' => 'invoices',
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'count_addl' => $count_addl,
+ 'redirect' => $link,
+ 'header' => [ emt('Invoice #'),
+ emt($invoiced ? 'Charged' : 'Gross Amount'),
+ emt('Discount'),
+ emt('Credits'),
+ emt('Net Amount'),
+ emt('Balance'),
+ emt('Date'),
+ FS::UI::Web::cust_header(),
+ ],
+ 'fields' => [
+ 'display_invnum',
+ $invoiced ? 'charged' : 'gross',
+ 'discounted',
+ 'credited',
+ 'net',
+ 'owed',
+ sub { time2str('%b %d %Y', shift->_date ) },
+ \&FS::UI::Web::cust_fields,
+ ],
+ 'sort_fields' => [
+ 'COALESCE( agent_invid, invnum )',
+ $invoiced ? 'charged' : 'gross',
+ 'discounted',
+ 'credited',
+ 'net',
+ 'owed',
+ '_date',
+ ],
+ 'format' => [
+ '',
+ $money_char.'%.2f',
+ $money_char.'%.2f',
+ $money_char.'%.2f',
+ $money_char.'%.2f',
+ $money_char.'%.2f',
+ '',
+ ],
+ 'align' => 'rrrrrrl'.FS::UI::Web::cust_aligns(),
+ 'links' => [
+ $link,
+ $link,
+ $link,
+ $link,
+ $link,
+ $link,
+ $link,
+ ( map { $_ ne 'Cust. Status' ? $clink : '' }
+ FS::UI::Web::cust_header()
+ ),
+ ],
+ 'color' => [
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ FS::UI::Web::cust_colors(),
+ ],
+ 'style' => [
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ FS::UI::Web::cust_styles(),
+ ],
&>
<%init>
my $count_addl = '';
my %search = ();
+# show invoiced amount (charged) instead of gross sales
+my $invoiced = $cgi->param('invoiced') ? 1 : 0;
+
if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) {
my $join_cust_main = FS::UI::Web::join_cust_main('cust_bill');
($search{'days'}, my $field) = ($2, $3);
$field = "_date" if $field eq 'date';
$search{'order_by'} = "cust_bill.$field";
+ $search{'invoiced'} = 1; # preserve old behavior under 3.x
}
#scalars
for (qw( agentnum custnum cust_status refnum invnum_min invnum_max
- open net newest_percust
+ open net newest_percust invoiced
))
{
( my $action = $_ ) =~ s/_$//;
include('/elements/progress-init.html',
$_.'form',
- [ keys %search ],
+ [ sort keys %search ],
"../misc/${_}invoices.cgi",
{ 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but...
$_, #key
my @values = ref($search{$f}) ? @{ $search{$f} } : $search{$f};
map qq!<INPUT TYPE="hidden" NAME="$f" VALUE="$_">!, @values;
}
- keys %search
+ sort keys %search
),
qq!</FORM>!
} qw( print_ email_ fax_ ftp_ spool_ ) ).