X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=180f18263c6e793a3bcfa6a5f1ad1bcce286d473;hp=7b9436cee46abdf3ee558d15faf60186c2caf86e;hb=a800fde5d31fb9b9cfe46b1ce2f68ea8e56bff53;hpb=7c319f1608fd3459c992eda7743696fc745fccf1 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 <Data Service Quan. - END +print 'Primary' + if dbdef->table('pkg_svc')->column('primary_svc'); +print ''; foreach my $part_pkg ( sort $sortby @part_pkg ) { my($hashref)=$part_pkg->hashref; @@ -100,8 +117,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 < $svcpart }); print $n,qq!!, $part_svc->getfield('svc'),"", - $pkg_svc->getfield('quantity'),"\n"; + $pkg_svc->getfield('quantity'),""; + if ( dbdef->table('pkg_svc')->column('primary_svc') ) { + print ''; + print 'PRIMARY' if $pkg_svc->primary_svc =~ /^Y/i; + print ''; + } + print "\n"; $n=""; } @@ -132,13 +166,8 @@ 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}; -} - %>