From: ivan Date: Wed, 4 Nov 2009 00:53:12 +0000 (+0000) Subject: fix customer package search (fallout from customer classes) & add "not yet billed... X-Git-Tag: freeside_1_9_2~245 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=a5351dba7b097a440e60b5cb71b6382d8e5f61ab;p=freeside.git fix customer package search (fallout from customer classes) & add "not yet billed" status to customer package report --- diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index e4846ec34..e195ed87d 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -2221,6 +2221,7 @@ Returns an SQL expression identifying active packages. sub active_sql { " ". $_[0]->recurring_sql(). " + AND cust_pkg.setup IS NOT NULL AND cust_pkg.setup != 0 AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 ) AND ( cust_pkg.susp IS NULL OR cust_pkg.susp = 0 ) "; } @@ -2384,8 +2385,8 @@ sub search_sql { push @where, FS::cust_pkg->active_sql(); - } elsif ( $params->{'magic'} eq 'not yet billed' - || $params->{'status'} eq 'not yet billed' ) { + } elsif ( $params->{'magic'} =~ /^not[ _]yet[ _]billed$/ + || $params->{'status'} =~ /^not[ _]yet[ _]billed$/ ) { push @where, FS::cust_pkg->not_yet_billed_sql(); @@ -2419,7 +2420,7 @@ sub search_sql { { $classnum = $1; if ( $classnum ) { #a specific class - push @where, "classnum = $classnum"; + push @where, "part_pkg.classnum = $classnum"; #@pkg_class = ( qsearchs('pkg_class', { 'classnum' => $classnum } ) ); #die "classnum $classnum not found!" unless $pkg_class[0]; @@ -2427,7 +2428,7 @@ sub search_sql { } elsif ( $classnum eq '' ) { #the empty class - push @where, "classnum IS NULL"; + push @where, "part_pkg.classnum IS NULL"; #$title .= 'Empty class '; #@pkg_class = ( '(empty class)' ); } elsif ( $classnum eq '0' ) { @@ -2591,9 +2592,9 @@ sub search_sql { my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : ''; - my $addl_from = 'LEFT JOIN cust_main USING ( custnum ) '. - 'LEFT JOIN part_pkg USING ( pkgpart ) '. - 'LEFT JOIN pkg_class USING ( classnum ) '; + my $addl_from = 'LEFT JOIN part_pkg USING ( pkgpart ) '. + 'LEFT JOIN pkg_class USING ( classnum ) '. + 'LEFT JOIN cust_main USING ( custnum ) '; my $count_query = "SELECT COUNT(*) FROM cust_pkg $addl_from $extra_sql"; diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index c6cbb81a3..d9b90cf84 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -96,8 +96,15 @@ $select = " *, ( $count_cust_pkg + AND ( setup IS NULL OR cancel = 0 ) AND ( cancel IS NULL OR cancel = 0 ) - AND ( susp IS NULL OR susp = 0 ) + AND ( susp IS NULL OR susp = 0 ) + ) AS num_not_yet_billed, + + ( $count_cust_pkg + AND setup IS NOT NULL AND setup != 0 + AND ( cancel IS NULL OR cancel = 0 ) + AND ( susp IS NULL OR susp = 0 ) ) AS num_active, ( $count_cust_pkg @@ -283,6 +290,8 @@ if ( $acl_edit_global ) { 'cancelled' => 'FF0000', #'one-time charge' => '000000', 'charge' => '000000', + #'not yet billed' => '000000', + 'not yet billed' => '000000', ); my $cust_pkg_link = $p. 'search/cust_pkg.cgi?pkgpart='; push @fields, sub { my $part_pkg = shift; @@ -294,6 +303,8 @@ if ( $acl_edit_global ) { $magic = 'inactive'; #$label = 'one-time charge', $label = 'charge', + } else { + $label =~ s/_/ /g; } [ @@ -319,7 +330,7 @@ if ( $acl_edit_global ) { ), }, ], - } (qw( active suspended cancelled )) + } qw(not_yet_billed active suspended cancelled) ]; }; $align .= 'r'; #}