'count_query' => $count_query,
'count_addl' => \@total_desc,
'header' => [
+ @pkgnum_header,
+ emt('Pkg Def'),
emt('Description'),
@post_desc_header,
@peritem_desc,
FS::UI::Web::cust_header(),
],
'fields' => [
+ @pkgnum,
sub { $_[0]->pkgnum > 0
- ? $_[0]->get('pkg') # possibly use override.pkg
- : $_[0]->get('itemdesc') # but i think this correct
+ # possibly use override.pkg but i think this correct
+ ? $_[0]->get('pkgpart')
+ : ''
+ },
+ sub { $_[0]->pkgnum > 0
+ # possibly use override.pkg but i think this correct
+ ? $_[0]->get('pkg')
+ : $_[0]->get('itemdesc')
},
@post_desc,
#strikethrough or "N/A ($amount)" or something these when
\&FS::UI::Web::cust_fields,
],
'sort_fields' => [
+ @pkgnum_null,
+ '',
'',
@post_desc_null,
@peritem,
#'credit_amount',
],
'links' => [
- #'',
+ @pkgnum_null,
+ '',
'',
@post_desc_null,
@peritem_null,
),
],
#'align' => 'rlrrrc'.FS::UI::Web::cust_aligns(),
- 'align' => 'l'.
+ 'align' => $pkgnum_align.
+ 'rl'.
$post_desc_align.
$peritem_align.
'rcrr'.
FS::UI::Web::cust_aligns(),
'color' => [
- #'',
+ @pkgnum_null,
+ '',
'',
@post_desc_null,
@peritem_null,
FS::UI::Web::cust_colors(),
],
'style' => [
- #'',
+ @pkgnum_null,
+ '',
'',
@post_desc_null,
@peritem_null,
</%doc>
<%init>
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied" unless $curuser->access_right('Financial reports');
my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';
my @select = ( 'cust_bill_pkg.*', 'cust_bill._date' );
my @total = ( 'COUNT(*)', 'SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)');
-my @total_desc = ( '%d line items', $money_char.'%.2f total' ); # sprintf strings
+my @total_desc = ( $money_char.'%.2f total' ); # sprintf strings
my @peritem = ( 'setup', 'recur' );
my @peritem_desc = ( 'Setup charge', 'Recurring charge' );
+my @pkgnum_header = ();
+my @pkgnum = ();
+my @pkgnum_null;
+my $pkgnum_align = '';
+if ( $curuser->option('show_pkgnum') ) {
+ push @select, 'cust_bill_pkg.pkgnum';
+ push @pkgnum_header, 'Pkg Num';
+ push @pkgnum, sub { $_[0]->pkgnum > 0 ? $_[0]->pkgnum : '' };
+ push @pkgnum_null, '';
+ $pkgnum_align .= 'r';
+}
+
my @post_desc_header = ();
my @post_desc = ();
my @post_desc_null = ();
)";
$part_pkg = 'override';
}
-push @select, 'part_pkg.pkg'; # or should this use override?
+push @select, 'part_pkg.pkgpart', 'part_pkg.pkg'; # or should this use override?
# the non-tax case
if ( $cgi->param('nottax') ) {
push @select, "($recur_no_usage) AS recur_no_usage";
$peritem[1] = 'recur_no_usage';
$total[1] = "SUM(cust_bill_pkg.setup + $recur_no_usage)";
- $total_desc[1] .= ' (excluding usage)';
+ $total_desc[0] .= ' (excluding usage)';
} elsif ( $cgi->param('usage') eq 'usage' ) {
$peritem[1] = '_usage';
$peritem_desc[1] = 'Usage charge';
$total[1] = "SUM($usage)";
- $total_desc[1] .= ' usage charges';
+ $total_desc[0] .= ' usage charges';
}
} elsif ( $cgi->param('istax') ) {
} elsif ( $cgi->param('out') ) {
- $join_pkg = '
+ $join_pkg .= '
LEFT JOIN cust_bill_pkg_tax_location USING (billpkgnum)
';
push @where, 'cust_bill_pkg_tax_location.billpkgnum IS NULL';
} else { # not locationtaxid or 'out'--the normal case
- $join_pkg = '
+ $join_pkg .= '
LEFT JOIN cust_bill_pkg_tax_location USING (billpkgnum)
JOIN cust_main_county USING (taxnum)
';
" FROM cust_bill_pkg $join_cust $join_pkg
$where";
-shift @total_desc; #the first one is implicit
-
@peritem_desc = map {emt($_)} @peritem_desc;
my @peritem_sub = map {
my $field = $_;
warn "\n\nQUERY:\n".Dumper($query)."\n\nCOUNT_QUERY:\n$count_query\n\n"
if $cgi->param('debug');
+
</%init>