diff options
Diffstat (limited to 'httemplate/browse/part_pkg.cgi')
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 7b9436cee..180f18263 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; } @@ -63,8 +78,10 @@ print <<END; <TH><FONT SIZE=-1>Data</FONT></TH> <TH>Service</TH> <TH><FONT SIZE=-1>Quan.</FONT></TH> - </TR> END +print '<TH><FONT SIZE=-1>Primary</FONT></TH>' + if dbdef->table('pkg_svc')->column('primary_svc'); +print '</TR>'; foreach my $part_pkg ( sort $sortby @part_pkg ) { my($hashref)=$part_pkg->hashref; @@ -100,8 +117,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; @@ -117,7 +145,13 @@ END my($part_svc) = qsearchs('part_svc',{'svcpart'=> $svcpart }); print $n,qq!<TD><A HREF="${p}edit/part_svc.cgi?$svcpart">!, $part_svc->getfield('svc'),"</A></TD><TD>", - $pkg_svc->getfield('quantity'),"</TD></TR>\n"; + $pkg_svc->getfield('quantity'),"</TD>"; + if ( dbdef->table('pkg_svc')->column('primary_svc') ) { + print '<TD>'; + print 'PRIMARY' if $pkg_svc->primary_svc =~ /^Y/i; + print '</TD>'; + } + print "</TR>\n"; $n="<TR>"; } @@ -132,13 +166,8 @@ print <<END; </HTML> 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}; -} - %> |