*finally* seems to be working under Mason. sheesh.
[freeside.git] / httemplate / browse / part_pkg.cgi
index 9a699d5..0af64e7 100755 (executable)
@@ -1,29 +1,33 @@
+<!-- mason kludge -->
 <%
-#<!-- $Id: part_pkg.cgi,v 1.7 2001-10-26 10:24:56 ivan Exp $ -->
 
-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);
+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.<BR><BR>".
+  "$total packages ";
 
-$p = popurl(2);
+if ( $cgi->param('showdisabled') ) {
+  $cgi->param('showdisabled', 0);
+  print qq!( <a href="!. $cgi->self_url. qq!">hide disabled packages</a> )!;
+} else {
+  $cgi->param('showdisabled', 1);
+  print qq!( <a href="!. $cgi->self_url. qq!">show disabled packages</a> )!;
+}
 
-print $cgi->header( @FS::CGI::header ), 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.<BR><BR>", 
-  &table(), <<END;
+my $colspan = $cgi->param('showdisabled') ? 2 : 3;
+print &table(), <<END;
       <TR>
         <TH COLSPAN=2>Package</TH>
         <TH>Comment</TH>
@@ -35,9 +39,9 @@ print $cgi->header( @FS::CGI::header ), header("Package Definition Listing",menu
       </TR>
 END
 
-foreach $part_pkg ( sort { 
+foreach my $part_pkg ( sort { 
   $a->getfield('pkgpart') <=> $b->getfield('pkgpart')
-} qsearch('part_pkg',{}) ) {
+} @part_pkg ) {
   my($hashref)=$part_pkg->hashref;
   my(@pkg_svc)=grep $_->getfield('quantity'),
     qsearch('pkg_svc',{'pkgpart'=> $hashref->{pkgpart} });
@@ -54,9 +58,16 @@ foreach $part_pkg ( sort {
   }
   print <<END;
       <TR>
-        <TD ROWSPAN=$rowspan><A HREF="${p}edit/part_pkg.cgi?$hashref->{pkgpart}">
-          $hashref->{pkgpart}
-        </A></TD>
+        <TD ROWSPAN=$rowspan><A HREF="${p}edit/part_pkg.cgi?$hashref->{pkgpart}">$hashref->{pkgpart}</A></TD>
+END
+
+  unless ( $cgi->param('showdisabled') ) {
+    print "<TD ROWSPAN=$rowspan>";
+    print "DISABLED" if $hashref->{disabled};
+    print '</TD>';
+  }
+
+  print <<END;
         <TD ROWSPAN=$rowspan><A HREF="${p}edit/part_pkg.cgi?$hashref->{pkgpart}">$hashref->{pkg}</A></TD>
         <TD ROWSPAN=$rowspan>$hashref->{comment}</TD>
         <TD ROWSPAN=$rowspan>$hashref->{freq}</TD>