X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Ftr-part_pkg-taxproducts.html;h=50dace729887349e0c05b0edc2f1cb03aa7188f9;hp=ad464ca77b12ff62962729052157b518a1e83ac5;hb=7a33cb6e4c3e33b7399d6574cbd3ee38ddcba5e0;hpb=0ed195595b5c7ea404c8848d9d1881ada4214489 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', }), -;