From 91a6e5e58df70ffad1234cb80ab76eaeaf8359b9 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 6 Sep 2016 12:42:34 -0700 Subject: UI improvements for selecting taxproducts, #71555 and #71556 --- httemplate/elements/select-taxproduct.html | 90 ++++++++++++++++++++---- httemplate/elements/tr-part_pkg-taxproducts.html | 62 ++++++++++++---- 2 files changed, 125 insertions(+), 27 deletions(-) (limited to 'httemplate/elements') diff --git a/httemplate/elements/select-taxproduct.html b/httemplate/elements/select-taxproduct.html index 5feb71d80..d08ac22d1 100644 --- a/httemplate/elements/select-taxproduct.html +++ b/httemplate/elements/select-taxproduct.html @@ -1,14 +1,79 @@ -<% $opt{'prefix'} %> - <% $opt{'postfix'} %> +% if (!$init) { +% $init = 1; + + +% } +<% $opt{'prefix'} %> + + + +<% $opt{'postfix'} %> +<%shared> +my $init = 0; + <%init> my %opt = @_; @@ -19,7 +84,8 @@ my $description = $opt{'taxproduct_description'}; unless ( $description || ! $value ) { my $part_pkg_taxproduct = qsearchs( 'part_pkg_taxproduct', { 'taxproductnum'=> $value } ); - $description = $part_pkg_taxproduct->description + $description = $part_pkg_taxproduct->taxproduct . ' ' . + $part_pkg_taxproduct->description if $part_pkg_taxproduct; } diff --git a/httemplate/elements/tr-part_pkg-taxproducts.html b/httemplate/elements/tr-part_pkg-taxproducts.html index c57232c08..5dcea09f1 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,29 @@ <%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); %pkg_options = $part_pkg->options; - $pkg_options{'usage_taxproductnum_'} = $part_pkg->taxproductnum; + $curr_values{''} = $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', }), -; +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) ); +} -- cgit v1.2.1