From f88dda7fe57054bd030491a5b9363a1aff601bf2 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Sun, 13 Jan 2013 14:22:21 -0800 Subject: [PATCH] fix address standardization when changing package locations, #13763 --- httemplate/edit/cust_main/bottomfixup.js | 4 +-- httemplate/elements/order_pkg.js | 1 + httemplate/elements/standardize_locations.js | 39 ++++++++++-------------- httemplate/misc/change_pkg.cgi | 3 -- httemplate/misc/confirm-address_standardize.html | 12 +++----- httemplate/misc/order_pkg.html | 3 -- httemplate/misc/xmlhttp-address_standardize.html | 10 +++--- 7 files changed, 29 insertions(+), 43 deletions(-) diff --git a/httemplate/edit/cust_main/bottomfixup.js b/httemplate/edit/cust_main/bottomfixup.js index 1cfa52d8f..0de6d9dab 100644 --- a/httemplate/edit/cust_main/bottomfixup.js +++ b/httemplate/edit/cust_main/bottomfixup.js @@ -70,8 +70,8 @@ function copy_payby_fields() { <& /elements/standardize_locations.js, 'callback' => 'submit_continue();', - 'main_prefix' => 'bill_', - 'no_company' => 1, + 'billship' => 1, + 'with_census' => 1, # no with_firm, apparently &> function copyelement(from, to) { diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js index 8c1efd93a..1069a0ee4 100644 --- a/httemplate/elements/order_pkg.js +++ b/httemplate/elements/order_pkg.js @@ -44,4 +44,5 @@ function standardize_new_location() { function submit_abort() { document.OrderPkgForm.submitButton.disabled = false; + nd(1); } diff --git a/httemplate/elements/standardize_locations.js b/httemplate/elements/standardize_locations.js index 15c5761a0..88c87c154 100644 --- a/httemplate/elements/standardize_locations.js +++ b/httemplate/elements/standardize_locations.js @@ -7,8 +7,8 @@ function status_message(text, caption) { function form_address_info() { var cf = document.<% $formname %>; - var returnobj = { onlyship: <% $onlyship ? 1 : 0 %> }; -% if ( !$onlyship ) { + var returnobj = { billship: <% $billship %> }; +% if ( $billship ) { returnobj['same'] = cf.elements['same'].checked; % } % if ( $withfirm ) { @@ -59,16 +59,12 @@ function standardize_locations() { cf.elements['<% $pre %>coord_auto'].value = 'Y'; changed = true; } - -% } #foreach $pre - // standardize if the old address wasn't clean - if ( cf.elements['old_ship_addr_clean'].value == '' || - cf.elements['old_bill_addr_clean'].value == '' ) { - + if ( cf.elements['<% $pre %>addr_clean'].value == '' ) { changed = true; - } +% } #foreach $pre + // or if it was clean but has been changed for (var key in address_info) { var old_el = cf.elements['old_'+key]; @@ -81,7 +77,7 @@ function standardize_locations() { % # If address hasn't been changed, auto-confirm the existing value of % # censustract so that we don't ask the user to confirm it again. - if ( !changed ) { + if ( !changed && <% $withcensus %> ) { if ( address_info['same'] ) { cf.elements['bill_censustract'].value = address_info['bill_censustract']; @@ -279,21 +275,18 @@ function setselect(el, value) { my %opt = @_; my $conf = new FS::Conf; -my $withfirm = 1; -my $withcensus = 1; +my $withfirm = $opt{'with_firm'} ? 1 : 0; +my $withcensus = $opt{'with_census'} ? 1 : 0; + +my @prefixes = ''; +my $billship = $opt{'billship'} ? 1 : 0; # whether to have bill_ and ship_ prefixes +my $taxpre = ''; +if ($billship) { + @prefixes = qw(bill_ ship_); + $taxpre = $conf->exists('tax-ship_address') ? 'ship_' : 'bill_'; +} my $formname = $opt{form} || 'CustomerForm'; -my $onlyship = $opt{onlyship} || ''; -#my $main_prefix = $opt{main_prefix} || ''; -#my $ship_prefix = $opt{ship_prefix} || ($onlyship ? '' : 'ship_'); -# The prefixes are now 'ship_' and 'bill_'. -my $taxpre = 'bill_'; -$taxpre = 'ship_' if ( $conf->exists('tax-ship_address') || $onlyship ); my $post_geocode = $opt{callback} || 'post_geocode();'; -$withfirm = 0 if $opt{no_company}; -$withcensus = 0 if $opt{no_census}; - -my @prefixes = ('ship_'); -unshift @prefixes, 'bill_' unless $onlyship; diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi index 7b08f7b10..03e336cba 100755 --- a/httemplate/misc/change_pkg.cgi +++ b/httemplate/misc/change_pkg.cgi @@ -32,9 +32,6 @@ <& /elements/standardize_locations.html, 'form' => "OrderPkgForm", - 'onlyship' => 1, - 'no_company' => 1, - 'no_census' => 1, 'callback' => 'document.OrderPkgForm.submit();', &> diff --git a/httemplate/misc/confirm-address_standardize.html b/httemplate/misc/confirm-address_standardize.html index 57201ea5a..420e8ea1d 100644 --- a/httemplate/misc/confirm-address_standardize.html +++ b/httemplate/misc/confirm-address_standardize.html @@ -11,16 +11,14 @@ Confirm address standardization

-% my @prefixes; -% if ( $old{onlyship} ) { -% @prefixes = ('ship_'); -% } elsif ( $old{same} ) { +% my @prefixes = (''); +% if ( $old{same} ) { % @prefixes = ('bill_'); -% } else { +% } elsif ( $old{billship} ) { % @prefixes = ('bill_', 'ship_'); % } % for my $pre (@prefixes) { -% my $name = $pre eq 'ship_' ? 'service' : 'billing'; +% my $name = $pre eq 'bill_' ? 'billing' : 'service'; % if ( $new{$pre.'addr_clean'} ) { @@ -128,6 +126,6 @@ my $q = decode_json($cgi->param('q')); my %old = %{ $q->{old} }; my %new = %{ $q->{new} }; -my $addresses = $old{onlyship} ? 'address' : 'addresses'; +my $addresses = $old{billship} ? 'addresses' : 'address'; diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index bfc7b6903..993ea366c 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -129,9 +129,6 @@ <& /elements/standardize_locations.html, 'form' => "OrderPkgForm", - 'onlyship' => 1, - 'no_company' => 1, - 'no_census' => 1, 'callback' => 'document.OrderPkgForm.submit();', &> diff --git a/httemplate/misc/xmlhttp-address_standardize.html b/httemplate/misc/xmlhttp-address_standardize.html index 988057163..15f266ab0 100644 --- a/httemplate/misc/xmlhttp-address_standardize.html +++ b/httemplate/misc/xmlhttp-address_standardize.html @@ -16,12 +16,10 @@ my %old = %{ decode_json($cgi->param('arg')) } my %new; -my @prefixes; -if ($old{onlyship}) { - @prefixes = ('ship_'); -} elsif ( $old{same} ) { +my @prefixes = (''); +if ( $old{same} ) { @prefixes = ('bill_'); -} else { +} elsif ( $old{billship} ) { @prefixes = ('bill_', 'ship_'); } my $all_same = 1; @@ -44,6 +42,8 @@ foreach my $pre ( @prefixes ) { $all_same = 0 if ( $new{$pre.$_} ne $old{$pre.$_} ); last if !$all_same; } + + $all_same = 0 if $new{$pre.'error'}; } my $return = { old => \%old, new => \%new, all_same => $all_same }; -- 2.11.0
Entered <%$name%> address