X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=65cf2431eb9716dc1f9ac1316d794b75d8a2a13a;hp=707972ed70678aa6908c45e12c89e223530f3a5c;hb=a01faeb3a6b823c97535782f072c455298a4ffc7;hpb=6caffaefb96e25c68866825e2211816355a656aa diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 707972ed7..65cf2431e 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -11,37 +11,84 @@ if ( $cgi->param('showdisabled') ) { my @part_pkg = qsearch('part_pkg', \%search ); my $total = scalar(@part_pkg); -print 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". - " rather than purchase services directly.

". - "$total packages "; +my $sortby; +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 = ?'. + ' 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}; + }; + + $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; -if ( $cgi->param('showdisabled') ) { - $cgi->param('showdisabled', 0); - print qq!( hide disabled packages )!; } else { - $cgi->param('showdisabled', 1); - print qq!( show disabled packages )!; + $sortby = sub { $a->pkgpart <=> $b->pkgpart; }; } -my $colspan = $cgi->param('showdisabled') ? 2 : 3; -print &table(), <exists('enable_taxclasses'); + +%> +<%= 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 +

+<% } %> + +<%= $total %> package definitions +<% if ( $cgi->param('showdisabled') ) { $cgi->param('showdisabled', 0); %> + ( hide disabled packages ) +<% } else { $cgi->param('showdisabled', 1); %> + ( show disabled packages )!; +<% } %> + +<% my $colspan = $cgi->param('showdisabled') ? 2 : 3; %> + +<%= &table() %> - Package + >Package Comment +<% if ( $cgi->param('active') ) { %> + Customer
packages
+<% } %> Freq. +<% if ( $taxclasses ) { %> + Taxclass +<% } %> Plan Data Service Quan. +<% if ( dbdef->table('pkg_svc')->column('primary_svc') ) { %> + Primary +<% } %> + -END -foreach my $part_pkg ( sort { - $a->getfield('pkgpart') <=> $b->getfield('pkgpart') -} @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} }); @@ -56,25 +103,49 @@ foreach my $part_pkg ( sort { $plandata = "Setup ". $hashref->{setup}. "
Recur ". $hashref->{recur}; } - print < - $hashref->{pkgpart} -END + ><%= $hashref->{pkgpart} %> - unless ( $cgi->param('showdisabled') ) { - print ""; - print "DISABLED" if $hashref->{disabled}; - print ''; - } +<% unless ( $cgi->param('showdisabled') ) { %> + > + <% if ( $hashref->{disabled} ) { %> + DISABLED + <% } %> + +<% } %> + + ><%= $hashref->{pkg} %> + ><%= $hashref->{comment} %> + +<% if ( $cgi->param('active') ) { %> + > + <%= $num_active_cust_pkg{$hashref->{'pkgpart'}} %> active
+ + <% $suspended_sth->execute( $part_pkg->pkgpart ) + or die $suspended_sth->errstr; + my $num_suspended = $suspended_sth->fetchrow_arrayref->[0]; + %> + <%= $num_suspended %> suspended
+ + <% $canceled_sth->execute( $part_pkg->pkgpart ) + or die $canceled_sth->errstr; + my $num_canceled = $canceled_sth->fetchrow_arrayref->[0]; + %> + <%= $num_canceled %> canceled + +<% } %> + + ><%= $hashref->{freq} %> - print <$hashref->{pkg} - $hashref->{comment} - $hashref->{freq} - $hashref->{plan} - $plandata -END +<% if ( $taxclasses ) { %> + ><%= $hashref->{taxclass} || ' ' %> +<% } %> + ><%= $hashref->{plan} %> + ><%= $plandata %> + +<% my($pkg_svc); my($n)=""; foreach $pkg_svc ( @pkg_svc ) { @@ -82,17 +153,20 @@ END my($part_svc) = qsearchs('part_svc',{'svcpart'=> $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=""; } +%> - print ""; -} + +<% } %> -print <param('showdisabled') ? 8 : 9 %>>Add a new package definition -END -%>