X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FStatus.pm;h=b0f6b4c37a78fd6762c1c6e91500086037fc8e10;hb=ee7e3cc614c860c8d0aa2fdc9b112c57fe548ff2;hp=e5803e0db69e01d55db7d9e7e3b115b862e256f3;hpb=6f1653f32e2d7bef2b31832a0289482bc40613e5;p=freeside.git diff --git a/FS/FS/cust_main/Status.pm b/FS/FS/cust_main/Status.pm index e5803e0db..b0f6b4c37 100644 --- a/FS/FS/cust_main/Status.pm +++ b/FS/FS/cust_main/Status.pm @@ -47,7 +47,7 @@ sub statuscolors { if ( $module eq 'Classic' ) { tie %statuscolors, 'Tie::IxHash', - 'prospect' => '7e0079', #'000000', #black? naw, purple + 'prospect' => 'FF00F5', #'000000', #black? naw, purple 'active' => '00CC00', #green 'ordered' => '009999', #teal? cyan? 'inactive' => '0000CC', #blue @@ -56,7 +56,7 @@ sub statuscolors { ; } elsif ( $module eq 'Recurring' ) { tie %statuscolors, 'Tie::IxHash', - 'prospect' => '7e0079', #'000000', #black? naw, purple + 'prospect' => 'FF00F5', #'000000', #black? naw, purple 'active' => '00CC00', #green 'ordered' => '009999', #teal? cyan? 'suspended' => 'FF9900', #yellow @@ -106,6 +106,42 @@ sub cancelled_sql { =back +=head1 CLASS METHODS + +=over 4 + +=item churn_sql START, END + +Returns an SQL statement for the customer churn status query. The columns +returned are the custnum and the number of active, suspended, and cancelled +packages (excluding one-time packages) at the start date ("s_active", +"s_suspended", and "s_cancelled") and the end date ("e_active", etc.). + +=cut + +# not sure this belongs here...FS::cust_main::Packages? + +sub churn_sql { + my $self = shift; + my ($speriod, $eperiod) = @_; + + my $s_sql = FS::h_cust_pkg->status_as_of_sql($speriod); + my $e_sql = FS::h_cust_pkg->status_as_of_sql($eperiod); + + my @select = ( + 'custnum', + 'COALESCE(SUM(s.is_active::int),0) as s_active', + 'COALESCE(SUM(s.is_suspended::int),0) as s_suspended', + 'COALESCE(SUM(s.is_cancelled::int),0) as s_cancelled', + 'COALESCE(SUM(e.is_active::int),0) as e_active', + 'COALESCE(SUM(e.is_suspended::int),0) as e_suspended', + 'COALESCE(SUM(e.is_cancelled::int),0) as e_cancelled', + ); + my $from = "($s_sql) AS s FULL JOIN ($e_sql) AS e USING (custnum)"; + + return "SELECT ".join(',', @select)." FROM $from GROUP BY custnum"; +} + =head1 BUGS =head1 SEE ALSO