From: Mark Wells Date: Tue, 28 Jun 2016 23:39:05 +0000 (-0700) Subject: Merge branch 'master' of git.freeside.biz:/home/git/freeside X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=c663e377fd2c5089e7364b1144248edbaab76fe4;hp=1c6bfeb43ab4a75417bb0cb69b22b77d034ec799 Merge branch 'master' of git.freeside.biz:/home/git/freeside --- diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ecd30702f..3fb0a87fb 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -4769,15 +4769,10 @@ Returns an SQL expression identifying un-cancelled cust_main records. =cut sub uncancelled_sql { uncancel_sql(@_); } -sub uncancel_sql { " - ( 0 < ( $select_count_pkgs - AND ( cust_pkg.cancel IS NULL - OR cust_pkg.cancel = 0 - ) - ) - OR 0 = ( $select_count_pkgs ) - ) -"; } +sub uncancel_sql { + my $self = shift; + "( NOT (".$self->cancelled_sql.") )"; #sensitive to cust_main-status_module +} =item balance_sql diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index 9fc66e059..adf8c7194 100644 --- a/FS/FS/cust_main_Mixin.pm +++ b/FS/FS/cust_main_Mixin.pm @@ -210,19 +210,9 @@ a customer. sub cust_status { my $self = shift; return $self->cust_unlinked_msg unless $self->cust_linked; - - #FS::cust_main::status($self) - #false laziness w/actual cust_main::status - # (make sure FS::cust_main methods are called) - for my $status (qw( prospect active inactive suspended cancelled )) { - my $method = $status.'_sql'; - my $sql = FS::cust_main->$method();; - my $numnum = ( $sql =~ s/cust_main\.custnum/?/g ); - my $sth = dbh->prepare("SELECT $sql") or die dbh->errstr; - $sth->execute( ($self->custnum) x $numnum ) - or die "Error executing 'SELECT $sql': ". $sth->errstr; - return $status if $sth->fetchrow_arrayref->[0]; - } + my $cust_main = $self->cust_main; + return $self->cust_unlinked_msg unless $cust_main; + return $cust_main->cust_status; } =item ucfirst_cust_status diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index 62231a120..da6c89d44 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -501,7 +501,7 @@ if ( $cgi->param('browse') ); } - @cust_main = grep { $_->num_ncancelled_pkgs || ! $_->num_pkgs } @cust_main + @cust_main = grep { $_->status ne 'cancelled' } @cust_main if ! $cgi->param('cancelled') && ( $cgi->param('showcancelledcustomers') eq '0' #see if it was set by me