X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill_pkg.cgi;h=6a9f8775e3e7bbd26b34e39e12008ab01cf15dc0;hb=e55892bdf6dc95710a19876087690a9664421215;hp=5f02588e97a62f195e38df22ded83ab46b93d4f9;hpb=94ff30dbfd8bcdd47170b3a93f8112dd2da68aa9;p=freeside.git diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 5f02588e9..6a9f8775e 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -5,6 +5,8 @@ 'count_query' => $count_query, 'count_addl' => \@total_desc, 'header' => [ + @pkgnum_header, + emt('Pkg Def'), emt('Description'), @post_desc_header, @peritem_desc, @@ -15,9 +17,16 @@ 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 @@ -30,6 +39,8 @@ \&FS::UI::Web::cust_fields, ], 'sort_fields' => [ + @pkgnum_null, + '', '', @post_desc_null, @peritem, @@ -39,7 +50,8 @@ #'credit_amount', ], 'links' => [ - #'', + @pkgnum_null, + '', '', @post_desc_null, @peritem_null, @@ -52,13 +64,15 @@ ), ], #'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, @@ -69,7 +83,8 @@ FS::UI::Web::cust_colors(), ], 'style' => [ - #'', + @pkgnum_null, + '', '', @post_desc_null, @peritem_null, @@ -105,6 +120,8 @@ Filtering parameters: - refnum: Filter on customer reference source. +- cust_classnum: Filter on customer class. + - classnum: Filter on package class. - use_override: Apply "classnum" and "taxclass" filtering based on the @@ -165,19 +182,32 @@ Filtering parameters: <%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 = (); @@ -192,9 +222,9 @@ if ( $conf->exists('enable_taxclasses') ) { # valid in both the tax and non-tax cases my $join_cust = - " LEFT JOIN cust_bill USING (invnum) - LEFT JOIN cust_main USING (custnum) - "; + " LEFT JOIN cust_bill USING (invnum)". + # use cust_pkg.locationnum if it exists + FS::UI::Web::join_cust_main('cust_bill', 'cust_pkg'); #agent virtualization my $agentnums_sql = @@ -230,6 +260,13 @@ if ( $cgi->param('refnum') =~ /^(\d+)$/ ) { push @where, "cust_main.refnum = $1"; } +# cust_classnum +if ( $cgi->param('cust_classnum') ) { + my @classnums = grep /^\d+$/, $cgi->param('cust_classnum'); + push @where, 'cust_main.classnum IN('.join(',',@classnums).')' + if @classnums; +} + # custnum if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { push @where, "cust_main.custnum = $1"; @@ -249,7 +286,7 @@ if ( $cgi->param('use_override') ) { )"; $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') ) { @@ -415,7 +452,7 @@ 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' ) { @@ -425,7 +462,7 @@ if ( $cgi->param('nottax') ) { $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') ) { @@ -610,7 +647,7 @@ $where &&= "WHERE $where"; my $query = { 'table' => 'cust_bill_pkg', - 'addl_from' => "$join_cust $join_pkg", + 'addl_from' => "$join_pkg $join_cust", 'hashref' => {}, 'select' => join(",\n", @select ), 'extra_sql' => $where, @@ -619,11 +656,9 @@ my $query = { my $count_query = 'SELECT ' . join(',', @total) . - " FROM cust_bill_pkg $join_cust $join_pkg + " FROM cust_bill_pkg $join_pkg $join_cust $where"; -shift @total_desc; #the first one is implicit - @peritem_desc = map {emt($_)} @peritem_desc; my @peritem_sub = map { my $field = $_; @@ -644,4 +679,5 @@ my $credit_link = [ "${p}search/cust_credit_bill_pkg.html?billpkgnum=", 'billpkg warn "\n\nQUERY:\n".Dumper($query)."\n\nCOUNT_QUERY:\n$count_query\n\n" if $cgi->param('debug'); +