+<!-- mason kludge -->
<%
-#<!-- $Id: part_pkg.cgi,v 1.6 2001-10-20 12:17:59 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);
+%>
+<%= 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>
+<A HREF="<%= $p %>edit/part_pkg.cgi"><I>Add a new package definition</I></A>
+<BR><BR>
-$p = popurl(2);
+<%= $total %> packages
+<%
+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( '-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",
- " 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 COLSPAN=$colspan>Package</TH>
<TH>Comment</TH>
<TH><FONT SIZE=-1>Freq.</FONT></TH>
<TH><FONT SIZE=-1>Plan</FONT></TH>
</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} });
}
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>
print "</TR>";
}
+$colspan = $cgi->param('showdisabled') ? 8 : 9;
print <<END;
- <TR><TD COLSPAN=8><I><A HREF="${p}edit/part_pkg.cgi">Add a new package definition</A></I></TD></TR>
+
</TABLE>
</BODY>
</HTML>