From: ivan Date: Sun, 23 Jul 2006 14:07:33 +0000 (+0000) Subject: more work towards adding an "inactive" status - add it to the A/R report X-Git-Tag: BEFORE_FINAL_MASONIZE~75 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=e75070ffcf15e537036e4685d2aabb0415eec6d3 more work towards adding an "inactive" status - add it to the A/R report --- diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index cbcf6cc51..2b9564442 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -3670,18 +3670,17 @@ Returns a hex triplet color string for this customer's status. =cut +use vars qw(%statuscolor); +%statuscolor = ( + 'prospect' => '7e0079', #'000000', #black? naw, purple + 'active' => '00CC00', #green + 'inactive' => '0000CC', #blue + 'suspended' => 'FF9900', #yellow + 'cancelled' => 'FF0000', #red +); sub statuscolor { my $self = shift; - - my %statuscolor = ( - 'prospect' => '7e0079', #'000000', #black? naw, purple - 'active' => '00CC00', #green - 'inactive' => '0000CC', #blue - 'suspended' => 'FF9900', #yellow - 'cancelled' => 'FF0000', #red - ); - $statuscolor{$self->status}; } @@ -3703,6 +3702,10 @@ $select_count_pkgs = "SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.custnum = cust_main.custnum"; +sub select_count_pkgs_sql { + $select_count_pkgs; +} + sub prospect_sql { " 0 = ( $select_count_pkgs ) "; } diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index c1a239fd2..f42d8af7f 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -62,26 +62,19 @@ END my $owed_cols = join(',', map owed( @$_, 'cust'=>1 ), @ranges ); - my $recurring = <select_count_pkgs_sql; - ( select count(*) from cust_pkg - where cust_main.custnum = cust_pkg.custnum - and $recurring - and ( cancel = 0 or cancel is null ) - ) as uncancelled_pkgs, - - ( select count(*) from cust_pkg - where cust_main.custnum = cust_pkg.custnum - and $recurring - and ( cancel = 0 or cancel is null ) - and ( susp = 0 or susp is null ) - ) as active_pkgs + my $active_sql = FS::cust_pkg->active_sql; + my $inactive_sql = FS::cust_pkg->inactive_sql; + my $suspended_sql = FS::cust_pkg->inactive_sql; + my $cancelled_sql = FS::cust_pkg->inactive_sql; + my $packages_cols = <1, 'noas'=>1). " > 0"; @@ -119,6 +112,27 @@ END my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; + my $status_statuscol = sub { + #conceptual false laziness with cust_main::status... + my $row = shift; + + my $status = 'unknown'; + if ( $self->num_pkgs == 0 ) { + $status = 'prospect'; + } elsif ( $self->active_pkgs) > 0 ) { + $status = 'active'; + } elsif ( $self->inactive_pkgs > 0 ) { + $status = 'inactive'; + } elsif ( $self->suspended_pkgs > 0 ) { + $status = 'suspended'; + } elsif ( $self->cancelled_pkgs > 0 ) { + $status = 'cancelled' + } + + ( ucfirst($status), $FS::cust_main::statuscolor{$status} ); + }; + + %><%= include( 'elements/search.html', 'title' => 'Accounts Receivable Aging Summary', 'name' => 'customers', @@ -156,20 +170,7 @@ END ], 'fields' => [ \&FS::UI::Web::cust_fields, - sub { - my $row = shift; - my $status = 'Cancelled'; - my $statuscol = 'FF0000'; - if ( $row->uncancelled_pkgs ) { - $status = 'Suspended'; - $statuscol = 'FF9900'; - if ( $row->active_pkgs ) { - $status = 'Active'; - $statuscol = '00CC00'; - } - } - $status; - }, + sub { (shift->status_statuscol)[0] }, #sub { ucfirst(shift->status) }, sub { sprintf( $money_char.'%.2f', shift->get('owed_0_30') ) }, @@ -202,20 +203,7 @@ END 'b', '', '', '', '', 'b', ], 'color' => [ ( map '', FS::UI::Web::cust_header() ), - sub { - my $row = shift; - my $status = 'Cancelled'; - my $statuscol = 'FF0000'; - if ( $row->uncancelled_pkgs ) { - $status = 'Suspended'; - $statuscol = 'FF9900'; - if ( $row->active_pkgs ) { - $status = 'Active'; - $statuscol = '00CC00'; - } - } - $statuscol; - }, + sub { (shift->status_statuscol)[1] }, #sub { shift->statuscolor; }, '', '',