-));
-#), ' onLoad="visualize()"');
-
-print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
- "</FONT>"
- if $cgi->param('error');
-
-#print '<FORM ACTION="', popurl(1), 'process/part_pkg.cgi" METHOD=POST>';
-print '<FORM NAME="dummy">';
-
-#if ( $cgi->param('clone') ) {
-# print qq!<INPUT TYPE="hidden" NAME="clone" VALUE="!, $cgi->param('clone'), qq!">!;
-#}
-#if ( $cgi->param('pkgnum') ) {
-# print qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="!, $cgi->param('pkgnum'), qq!">!;
-#}
-#
-#print qq!<INPUT TYPE="hidden" NAME="pkgpart" VALUE="$hashref->{pkgpart}">!,
-print "Package Part #", $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)";
-
-print ntable("#cccccc",2), <<END;
-<TR><TD ALIGN="right">Package (customer-visable)</TD><TD><INPUT TYPE="text" NAME="pkg" SIZE=32 VALUE="$hashref->{pkg}"></TD></TR>
-<TR><TD ALIGN="right">Comment (customer-hidden)</TD><TD><INPUT TYPE="text" NAME="comment" SIZE=32 VALUE="$hashref->{comment}"></TD></TR>
-<TR><TD ALIGN="right">Frequency (months) of recurring fee</TD><TD><INPUT TYPE="text" NAME="freq" VALUE="$hashref->{freq}" SIZE=3></TD></TR>
-<TR><TD ALIGN="right">Setup fee tax exempt</TD><TD>
-END
-
-print '<INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y"';
-print ' CHECKED' if $hashref->{setuptax} eq "Y";
-print '>';
-
-print <<END;
-</TD></TR>
-<TR><TD ALIGN="right">Recurring fee tax exempt</TD><TD>
-END
-
-print '<INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y"';
-print ' CHECKED' if $hashref->{recurtax} eq "Y";
-print '>';
-
-print '</TD></TR>';
-
-print '<TR><TD ALIGN="right">Disable new orders</TD><TD>';
-print '<INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"';
-print ' CHECKED' if $hashref->{disabled} eq "Y";
-print '>';
-print '</TD></TR></TABLE>';
-
-my $thead = "\n\n". ntable('#cccccc', 2). <<END;
-<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH><TH BGCOLOR="#dcdcdc">Service</TH></TR>
-END
-
-#unless ( $cgi->param('clone') ) {
-#dunno why...
-unless ( 0 ) {
- #print <<END, $thead;
- print <<END, itable(), '<TR><TD VALIGN="top">', $thead;
-<BR><BR>Enter the quantity of each service this package includes.<BR><BR>
-END
+)) %>
+
+<% #), ' onLoad="visualize()"'); %>
+
+<% if ( $cgi->param('error') ) { %>
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
+<% } %>
+
+<FORM NAME="dummy">
+
+<%= itable('',8,1) %><TR><TD VALIGN="top">
+
+Package information
+
+<%= ntable("#cccccc",2) %>
+ <TR>
+ <TD ALIGN="right">Package Definition #</TD>
+ <TD BGCOLOR="#ffffff">
+ <%= $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)" %>
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">Package (customer-visible)</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="pkg" SIZE=32 VALUE="<%= $part_pkg->pkg %>">
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">Comment (customer-hidden)</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="comment" SIZE=32 VALUE="<%=$part_pkg->comment%>">
+ </TD>
+ </TR>
+ <%= include( '/elements/tr-select-pkg_class.html', $part_pkg->classnum ) %>
+ <TR>
+ <TD ALIGN="right">Promotional code</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="promo_code" SIZE=32 VALUE="<%=$part_pkg->promo_code%>">
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">Disable new orders</TD>
+ <TD>
+ <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>
+ </TD>
+ </TR>
+
+</TABLE>
+
+</TD><TD VALIGN="top">
+
+Tax information
+<%= ntable("#cccccc", 2) %>
+ <TR>
+ <TD ALIGN="right">Setup fee tax exempt</TD>
+ <TD>
+ <INPUT TYPE="checkbox" NAME="setuptax" VALUE="Y" <%= $hashref->{setuptax} eq 'Y' ? ' CHECKED' : '' %>>
+ </TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right">Recurring fee tax exempt</TD>
+ <TD>
+ <INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y" <%= $hashref->{recurtax} eq 'Y' ? ' CHECKED' : '' %>>
+ </TD>
+ </TR>
+
+<% my $conf = new FS::Conf; %>
+<% if ( $conf->exists('enable_taxclasses') ) { %>
+
+ <TR>
+ <TD align="right">Tax class</TD>
+ <TD>
+ <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %>
+ </TD>
+ </TR>
+
+<% } else { %>
+
+ <%= include('/elements/select-taxclass.html', $hashref->{taxclass} ) %>
+
+<% } %>
+
+</TABLE>
+
+</TD></TR></TABLE>
+
+<%
+
+my $thead = "\n\n". ntable('#cccccc', 2).
+ '<TR><TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Quan.</FONT></TH>';
+$thead .= '<TH BGCOLOR="#dcdcdc"><FONT SIZE=-1>Primary</FONT></TH>'
+ if dbdef->table('pkg_svc')->column('primary_svc');
+$thead .= '<TH BGCOLOR="#dcdcdc">Service</TH></TR>';
+
+%>
+
+<BR><BR>Services included
+<%= itable('', 4, 1) %><TR><TD VALIGN="top">
+<%= $thead %>
+
+<%
+
+my $where = "WHERE disabled IS NULL OR disabled = ''";
+if ( $pkgpart ) {
+ $where .= " OR 0 < ( SELECT quantity FROM pkg_svc
+ WHERE pkg_svc.svcpart = part_svc.svcpart
+ AND pkgpart = $pkgpart
+ )";