From 006f36a6d2ee10664c3207b47ff046de447ea8bb Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Tue, 11 Dec 2018 18:01:30 -0500 Subject: [PATCH] RT# 74693 - Added Bulk edit of rates only --- httemplate/browse/cust_main_county.cgi | 59 +++++++++++++++++++++- httemplate/edit/bulk-cust_main_county.html | 30 +++++++---- httemplate/edit/process/bulk-cust_main_county.html | 11 +++- 3 files changed, 87 insertions(+), 13 deletions(-) diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi index 552327836..722c699a2 100755 --- a/httemplate/browse/cust_main_county.cgi +++ b/httemplate/browse/cust_main_county.cgi @@ -260,6 +260,21 @@ if ( $country && $state && } $cgi->delete('county'); +my $city = ''; +if ( $country && $state && $county && + $cgi->param('city') =~ + /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)$/ + ) +{ + $city = $1; + if ( $city eq '__NONE__' ) { + $title = "No city, $title"; + } else { + $title = "$city city, $title"; + } +} +$cgi->delete('city'); + $title = " for $title" if $title; my $taxclass = ''; @@ -279,12 +294,18 @@ my $filter_change = "window.location = '". $cgi->self_url. ";country=' + encodeURIComponent( document.getElementById('country').options[document.getElementById('country').selectedIndex].value ) + ". "';state=' + encodeURIComponent( document.getElementById('state').options[document.getElementById('state').selectedIndex].value ) +". - "';county=' + encodeURIComponent( document.getElementById('county').options[document.getElementById('county').selectedIndex].value );"; + "';county=' + encodeURIComponent( document.getElementById('county').options[document.getElementById('county').selectedIndex].value )"; + +$filter_change .= " +';city=' + encodeURIComponent( document.getElementById('city').options[document.getElementById('city').selectedIndex].value )" + if $conf->exists('enable_taxclasses'); + +$filter_change .= ";"; #restore this so pagination works $cgi->param('country', $country) if $country; $cgi->param('state', $state ) if $state; $cgi->param('county', $county ) if $county; +$cgi->param('city', $city ) if $city; $cgi->param('taxclass', $county ) if $taxclass; my $html_posttotal = @@ -338,6 +359,31 @@ if ( scalar(@counties) > 1 ) { ''; } +if ( $conf->exists('enable_taxclasses') ) { + my @cities = ( $country && $state && $county ) ? cities($county, $state, $country) : (); + if ( scalar(@cities) > 1 ) { + $html_posttotal .= + ' show city: '. + include('/elements/select-city.html', + 'country' => $country, + 'state' => $state, + 'county' => $county, + 'city' => $city, + 'onchange' => $filter_change, + 'empty_label' => '(all)', + 'empty_data_label' => '(none)', + 'empty_data_value' => '__NONE__', + 'disable_empty' => 0, + 'disable_cityupdate' => 1, + ); + } else { + $html_posttotal .= + ''; + } +} + $html_posttotal .= ' )'; my $bulk_popup_link = @@ -412,6 +458,8 @@ my $html_foot = <Bulk edit selected | +Bulk edit rate only selected +| bulk edit with excel file END @@ -434,6 +482,15 @@ if ( $county ) { $count_query .= ' AND county = '. dbh->quote($county); } } +if ( $city ) { + if ( $city eq '__NONE__' ) { + $hashref->{'city'} = ''; + $count_query .= " AND ( city = '' OR city IS NULL ) "; + } else { + $hashref->{'city'} = $city; + $count_query .= ' AND city = '. dbh->quote($city); + } +} if ( $taxclass ) { $hashref->{'taxclass'} = $taxclass; $count_query .= ( $count_query =~ /WHERE/i ? ' AND ' : ' WHERE ' ). diff --git a/httemplate/edit/bulk-cust_main_county.html b/httemplate/edit/bulk-cust_main_county.html index 8b1234825..650fa7857 100644 --- a/httemplate/edit/bulk-cust_main_county.html +++ b/httemplate/edit/bulk-cust_main_county.html @@ -3,6 +3,7 @@
" METHOD="POST"> + @@ -45,11 +46,13 @@ % } -<% include('/elements/tr-input-text.html', +% unless ($rate_only) { + <% include('/elements/tr-input-text.html', 'field' => 'taxname', 'label' => 'Tax name' ) -%> + %> +% } <% include('/elements/tr-input-percentage.html', 'field' => 'tax', @@ -57,27 +60,29 @@ ) %> -<% include('/elements/tablebreak-tr-title.html', value=>'Exemptions' ) %> +% unless ($rate_only) { + <% include('/elements/tablebreak-tr-title.html', value=>'Exemptions' ) %> -<% include('/elements/tr-checkbox.html', + <% include('/elements/tr-checkbox.html', 'field' => 'setuptax', 'value' => 'Y', 'label' => 'This tax not applicable to setup fees', ) -%> + %> -<% include('/elements/tr-checkbox.html', + <% include('/elements/tr-checkbox.html', 'field' => 'recurtax', 'value' => 'Y', 'label' => 'This tax not applicable to recurring fees', ) -%> + %> -<% include('/elements/tr-input-money.html', + <% include('/elements/tr-input-money.html', 'field' => 'exempt_amount', 'label' => 'Monthly exemption per customer ($25 "Texas tax")', ) -%> + %> +% }
@@ -97,8 +102,13 @@ $cgi->param('taxnum') =~ /^([\d,]+)$/ or $m->comp('/elements/errorpage-popup.html', $cgi->param('error') || 'Nothing selected'); my @taxnum = split(',', $1); -$cgi->param('action') =~ /^(add|edit)$/ or die "unknown action"; +$cgi->param('action') =~ /^(add|edit|edit_rate_only)$/ or die "unknown action"; my $action = $1; +my $rate_only; +if ($action eq "edit_rate_only") { + $action = "edit"; + $rate_only = 1; +} my $title = "Bulk $action tax rate"; my @cust_main_county = diff --git a/httemplate/edit/process/bulk-cust_main_county.html b/httemplate/edit/process/bulk-cust_main_county.html index b5a0258b1..55832e9c5 100644 --- a/httemplate/edit/process/bulk-cust_main_county.html +++ b/httemplate/edit/process/bulk-cust_main_county.html @@ -27,6 +27,8 @@ my @taxnum = split(',', $1); $cgi->param('action') =~ /^(add|edit)$/ or die "unknown action"; my $action = $1; +my $rate_only = $cgi->param('rate_only') if $cgi->param('rate_only'); + my $error = ''; foreach my $taxnum ( @taxnum ) { @@ -35,8 +37,13 @@ foreach my $taxnum ( @taxnum ) { if ( $action eq 'edit' || $cust_main_county->tax == 0 ) { #let's replace - foreach (qw( taxname tax exempt_amount setuptax recurtax )) { - $cust_main_county->set( $_ => scalar($cgi->param($_)) ) + if ($rate_only) { + $cust_main_county->set( tax => scalar($cgi->param('tax')) ); + } + else { + foreach (qw( taxname tax exempt_amount setuptax recurtax )) { + $cust_main_county->set( $_ => scalar($cgi->param($_)) ) + } } $error = $cust_main_county->replace and last; -- 2.11.0