X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-part_pkg-taxproducts.html;h=50dace729887349e0c05b0edc2f1cb03aa7188f9;hb=6ac44318c23b868404eeaf30b7fecef98271b7d8;hp=ad464ca77b12ff62962729052157b518a1e83ac5;hpb=0ed195595b5c7ea404c8848d9d1881ada4214489;p=freeside.git
diff --git a/httemplate/elements/tr-part_pkg-taxproducts.html b/httemplate/elements/tr-part_pkg-taxproducts.html
index ad464ca77..50dace729 100644
--- a/httemplate/elements/tr-part_pkg-taxproducts.html
+++ b/httemplate/elements/tr-part_pkg-taxproducts.html
@@ -1,18 +1,39 @@
+%# by default, only show default
- Tax products |
+ <% emt('Tax product') %> |
+ <& select-taxproduct.html,
+ %opt,
+ 'field' => $field.'_', # expected in edit/process/part_pkg
+ 'curr_value' => $curr_values{''},
+ &>
+ |
+
+% if ( !$separate ) {
+
+ |
+
+
+ |
+
+% }
% foreach my $usage_class (@classes) {
% my $classnum = $usage_class->classnum;
-% my $curr_value =
-% $cgi->param("usage_taxproductnum_$classnum")
-% || $pkg_options{"usage_taxproductnum_$classnum"}
-% || '';
-
- <% $usage_class->classname %> |
+
+ <% $usage_class->classname %> |
<& select-taxproduct.html,
%opt,
'field' => $field.'_'.$classnum,
- 'curr_value' => $curr_value
+ 'curr_value' => $curr_values{$classnum},
&>
|
@@ -20,18 +41,31 @@
<%init>
my %opt = @_;
my $field = delete($opt{field}) || 'taxproductnum';
+my @classes = qsearch('usage_class', { 'disabled' => '' });
+unshift @classes,
+ FS::usage_class->new({ 'classnum' => 'setup', 'classname' => 'Setup', }),
+ FS::usage_class->new({ 'classnum' => 'recur', 'classname' => 'Recur', }),
+;
+my $separate = 0; # will change to 1 if any non-default classes have values
+
my $pkgpart = delete($opt{pkgpart});
+my %curr_values;
my %pkg_options;
if ($pkgpart) {
my $part_pkg = FS::part_pkg->by_key($pkgpart);
- my %pkg_options = $part_pkg->options;
- $pkg_options{'usage_taxproductnum_'} = $part_pkg->taxproductnum;
+ %pkg_options = $part_pkg->options;
+ $curr_values{''} = $cgi->param('taxproductnum')
+ || $part_pkg->taxproductnum;
+}
+
+foreach my $usage_class (@classes) {
+ my $classnum = $usage_class->classnum;
+ my $curr_value =
+ $cgi->param("usage_taxproductnum_$classnum")
+ || $pkg_options{"usage_taxproductnum_$classnum"}
+ || '';
+ $curr_values{$classnum} = $curr_value;
+ $separate = 1 if ( length($classnum) and length($curr_value) );
}
-my @classes = qsearch('usage_class', { 'disabled' => '' });
-unshift @classes,
- FS::usage_class->new({ 'classnum' => '', 'classname' => '(default)', }),
- FS::usage_class->new({ 'classnum' => 'setup', 'classname' => 'Setup', }),
- FS::usage_class->new({ 'classnum' => 'recur', 'classname' => 'Recur', }),
-;
%init>