X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=48b0ab2b3c80a6ed6f1e76d4d4005586c03ecb5a;hp=7b9436cee46abdf3ee558d15faf60186c2caf86e;hb=6fe8172b11d0369d0b1274d6825ec0c57afe8001;hpb=0ebeec96313dd7edfca340f01f8fbbbac1f4aa1d diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 7b9436cee..48b0ab2b3 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,11 +25,28 @@ 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; + $sortby = sub { $a->pkgpart <=> $b->pkgpart; }; } +my $conf = new FS::Conf; +my $taxclasses = $conf->exists('enable_taxclasses'); + %> <%= header("Package Definition Listing",menubar( 'Main Menu' => $p )) %> <% unless ( $cgi->param('active') ) { %> @@ -40,76 +58,93 @@ if ( $cgi->param('active') ) { <% } %> <%= $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 )!; -} +<% 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; -print &table(), <param('showdisabled') ? 2 : 3; %> + +<%= &table() %> - Package + >Package Comment -END -print ' Customer
packages
' - if $cgi->param('active'); -print <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 $sortby @part_pkg ) { - my($hashref)=$part_pkg->hashref; my(@pkg_svc)=grep $_->getfield('quantity'), - qsearch('pkg_svc',{'pkgpart'=> $hashref->{pkgpart} }); + qsearch( 'pkg_svc', { 'pkgpart' => $part_pkg->pkgpart } ); my($rowspan)=scalar(@pkg_svc); my $plandata; - if ( $hashref->{plan} ) { - $plandata = $hashref->{plandata}; + if ( $part_pkg->plan ) { + $plandata = $part_pkg->plandata; $plandata =~ s/^(\w+)=/$1 /mg; $plandata =~ s/\n/
/g; } else { - $hashref->{plan} = "(legacy)"; - $plandata = "Setup ". $hashref->{setup}. - "
Recur ". $hashref->{recur}; + $part_pkg->plan('(legacy)'); + $plandata = "Setup ". $part_pkg->setup. + "
Recur ". $part_pkg->recur; } - print < - $hashref->{pkgpart} -END + ><%= $part_pkg->pkgpart %> + +<% unless ( $cgi->param('showdisabled') ) { %> + > + <% if ( $part_pkg->disabled ) { %> + DISABLED + <% } %> + +<% } %> - unless ( $cgi->param('showdisabled') ) { - print ""; - print "DISABLED" if $hashref->{disabled}; - print ''; - } + ><%= $part_pkg->pkg %> + ><%= $part_pkg->comment %> + +<% if ( $cgi->param('active') ) { %> + > + <%= $num_active_cust_pkg{$part_pkg->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 + +<% } %> - 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 -END + ><%= $part_pkg->freq_pretty %> + +<% if ( $taxclasses ) { %> + ><%= $part_pkg->taxclass || ' ' %> +<% } %> + + ><%= $part_pkg->plan %> + ><%= $plandata %> +<% my($pkg_svc); my($n)=""; foreach $pkg_svc ( @pkg_svc ) { @@ -117,28 +152,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 ""; -} - -$colspan = $cgi->param('showdisabled') ? 8 : 9; -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}; -} - -%>