X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=efaa59e00c602e7062c2a2f921525237ca42de6d;hb=c58132f6a26349d09744ef2b3b235dfb7c3757f6;hp=7b9436cee46abdf3ee558d15faf60186c2caf86e;hpb=7c319f1608fd3459c992eda7743696fc745fccf1;p=freeside.git diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 7b9436cee..efaa59e00 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -12,7 +12,8 @@ my @part_pkg = qsearch('part_pkg', \%search ); my $total = scalar(@part_pkg); my $sortby; -my %num_active_cust_pkg; +my %num_active_cust_pkg = (); +my( $suspended_sth, $canceled_sth ) = ( '', '' ); if ( $cgi->param('active') ) { my $active_sth = dbh->prepare( 'SELECT COUNT(*) FROM cust_pkg WHERE pkgpart = ?'. @@ -24,7 +25,21 @@ if ( $cgi->param('active') ) { $num_active_cust_pkg{$part_pkg->pkgpart} = $active_sth->fetchrow_arrayref->[0]; } - $sortby = \*active_cust_pkg_sort; + $sortby = sub { + $num_active_cust_pkg{$b->pkgpart} <=> $num_active_cust_pkg{$a->pkgpart}; + }; + + $suspended_sth = dbh->prepare( + 'SELECT COUNT(*) FROM cust_pkg WHERE pkgpart = ?'. + ' AND ( cancel IS NULL OR cancel = 0 )'. + ' AND susp IS NOT NULL AND susp != 0' + ) or die dbh->errstr; + + $canceled_sth = dbh->prepare( + 'SELECT COUNT(*) FROM cust_pkg WHERE pkgpart = ?'. + ' AND cancel IS NOT NULL AND cancel != 0' + ) or die dbh->errstr; + } else { $sortby = \*pkgpart_sort; } @@ -100,8 +115,19 @@ END print " "; print ''. $num_active_cust_pkg{$hashref->{'pkgpart'}}. - qq! active!; - # suspended/cancelled + qq! active
!; + + $suspended_sth->execute( $part_pkg->pkgpart ) or die $suspended_sth->errstr; + my $num_suspended = $suspended_sth->fetchrow_arrayref->[0]; + print ''. $num_suspended. + qq! suspended
!; + + $canceled_sth->execute( $part_pkg->pkgpart ) or die $canceled_sth->errstr; + my $num_canceled = $canceled_sth->fetchrow_arrayref->[0]; + print ''. $num_canceled. + qq! canceled!; + + print ''; } print < END - sub pkgpart_sort { $a->pkgpart <=> $b->pkgpart; } -sub active_cust_pkg_sort { - $num_active_cust_pkg{$b->pkgpart} <=> $num_active_cust_pkg{$a->pkgpart}; -} - %>