diff options
author | ivan <ivan> | 2003-11-03 05:21:56 +0000 |
---|---|---|
committer | ivan <ivan> | 2003-11-03 05:21:56 +0000 |
commit | 49e3543ec27222e8fd7d6a53f716c7f2ad2eaccf (patch) | |
tree | 19b10f226f61ee57d6b21a2aefbbf4f6d16bab97 | |
parent | b7f711c134111ccd46e861497f2dc333044d3179 (diff) |
also show suspended and canceled counts on active package browse
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 2a167e8d6..044ba462e 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 = ?'. @@ -27,6 +28,18 @@ if ( $cgi->param('active') ) { $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; } @@ -102,8 +115,19 @@ END print " <TD ROWSPAN=$rowspan>"; print '<FONT COLOR="#00CC00"><B>'. $num_active_cust_pkg{$hashref->{'pkgpart'}}. - qq!</B></FONT> <A HREF="${p}search/cust_pkg.cgi?magic=active;pkgpart=$hashref->{pkgpart}">active</A>!; - # suspended/cancelled + qq!</B></FONT> <A HREF="${p}search/cust_pkg.cgi?magic=active;pkgpart=$hashref->{pkgpart}">active</A><BR>!; + + $suspended_sth->execute( $part_pkg->pkgpart ) or die $suspended_sth->errstr; + my $num_suspended = $suspended_sth->fetchrow_arrayref->[0]; + print '<FONT COLOR="#FF9900"<B>'. $num_suspended. + qq!</B></FONT> <A HREF="${p}search/cust_pkg.cgi?magic=suspended;pkgpart=$hashref->{pkgpart}">suspended</A><BR>!; + + $canceled_sth->execute( $part_pkg->pkgpart ) or die $canceled_sth->errstr; + my $num_canceled = $canceled_sth->fetchrow_arrayref->[0]; + print '<FONT COLOR="#FF0000"<B>'. $num_canceled. + qq!</B></FONT> <A HREF="${p}search/cust_pkg.cgi?magic=canceled;pkgpart=$hashref->{pkgpart}">canceled</A>!; + + print '</TD>'; } print <<END; |