X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=2a167e8d6eb057263ec647003dd4193c053114e8;hp=e20ba24048b2239eb361490cfedee878b5e33e95;hb=83178acdc79de25f98c3e7eee9a4de1a17eaf9f4;hpb=a6d3e4dc73803cffad96fd4b6270b2fb5f4b0568 diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index e20ba2404..2a167e8d6 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -1,32 +1,65 @@ + <% -# -use strict; -use vars qw( $cgi $p $part_pkg ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs); -use FS::CGI qw(header menubar popurl table); -use FS::part_pkg; -use FS::pkg_svc; -use FS::part_svc; +my %search; +if ( $cgi->param('showdisabled') ) { + %search = (); +} else { + %search = ( 'disabled' => '' ); +} -$cgi = new CGI; +my @part_pkg = qsearch('part_pkg', \%search ); +my $total = scalar(@part_pkg); -&cgisuidsetup($cgi); +my $sortby; +my %num_active_cust_pkg; +if ( $cgi->param('active') ) { + my $active_sth = dbh->prepare( + 'SELECT COUNT(*) FROM cust_pkg WHERE pkgpart = ?'. + ' AND ( cancel IS NULL OR cancel = 0 )'. + ' AND ( susp IS NULL OR susp = 0 )' + ) or die dbh->errstr; + foreach my $part_pkg ( @part_pkg ) { + $active_sth->execute($part_pkg->pkgpart) or die $active_sth->errstr; + $num_active_cust_pkg{$part_pkg->pkgpart} = + $active_sth->fetchrow_arrayref->[0]; + } + $sortby = sub { + $num_active_cust_pkg{$b->pkgpart} <=> $num_active_cust_pkg{$a->pkgpart}; + }; +} else { + $sortby = \*pkgpart_sort; +} -$p = popurl(2); +%> +<%= header("Package Definition Listing",menubar( 'Main Menu' => $p )) %> +<% unless ( $cgi->param('active') ) { %> + One or more service definitions are grouped together into a package + definition and given pricing information. Customers purchase packages + rather than purchase services directly.

+ Add a new package definition +

+<% } %> -print $cgi->header( '-expires' => 'now' ), header("Package Definition Listing",menubar( - 'Main Menu' => $p, -)), "One or more services are grouped together into a package and given", - " pricing information. Customers purchase packages, not services.

", - &table(), < +<%= $total %> package definitions +<% +if ( $cgi->param('showdisabled') ) { + $cgi->param('showdisabled', 0); + print qq!( hide disabled packages )!; +} else { + $cgi->param('showdisabled', 1); + print qq!( show disabled packages )!; +} + +my $colspan = $cgi->param('showdisabled') ? 2 : 3; +print &table(), < - Package + Package Comment +END +print ' Customer
packages
' + if $cgi->param('active'); +print <Freq. Plan Data @@ -35,9 +68,7 @@ print $cgi->header( '-expires' => 'now' ), header("Package Definition Listing",m END -foreach $part_pkg ( sort { - $a->getfield('pkgpart') <=> $b->getfield('pkgpart') -} qsearch('part_pkg',{}) ) { +foreach my $part_pkg ( sort $sortby @part_pkg ) { my($hashref)=$part_pkg->hashref; my(@pkg_svc)=grep $_->getfield('quantity'), qsearch('pkg_svc',{'pkgpart'=> $hashref->{pkgpart} }); @@ -54,11 +85,28 @@ foreach $part_pkg ( sort { } print < - - $hashref->{pkgpart} - + $hashref->{pkgpart} +END + + unless ( $cgi->param('showdisabled') ) { + print ""; + print "DISABLED" if $hashref->{disabled}; + print ''; + } + + print <$hashref->{pkg} $hashref->{comment} +END + if ( $cgi->param('active') ) { + print " "; + print ''. + $num_active_cust_pkg{$hashref->{'pkgpart'}}. + qq! active!; + # suspended/cancelled + print ''; + } + print <$hashref->{freq} $hashref->{plan} $plandata @@ -78,10 +126,16 @@ END print ""; } +$colspan = $cgi->param('showdisabled') ? 8 : 9; print <Add a new package definition + END + +sub pkgpart_sort { + $a->pkgpart <=> $b->pkgpart; +} + %>