X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-part_pkg-taxproducts.html;h=50dace729887349e0c05b0edc2f1cb03aa7188f9;hb=e803d5f00368e951f7a4b82d5d390b53c4a6c827;hp=274dc3b48eb67b2de4f723e8332daf312095f47a;hpb=817c1ce0e1cbcfd1f684222c66f46dd13b2d6dd7;p=freeside.git
diff --git a/httemplate/elements/tr-part_pkg-taxproducts.html b/httemplate/elements/tr-part_pkg-taxproducts.html
index 274dc3b48..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,15 +41,31 @@
<%init>
my %opt = @_;
my $field = delete($opt{field}) || 'taxproductnum';
-my $pkgpart = delete($opt{pkgpart});
-my $part_pkg = FS::part_pkg->by_key($pkgpart);
-my %pkg_options = $part_pkg->options;
-$pkg_options{'usage_taxproductnum_'} = $part_pkg->taxproductnum;
-
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', }),
;
+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);
+ %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) );
+}
+
%init>