% if ( $is_error ) {
@@ -23,9 +26,13 @@ Confirm address standardization
% my $name = $pre eq 'bill_' ? 'billing' : 'service';
% my $rows = 5;
% if ( $new{$pre.'error'} ) {
+% # Standardization returned an error, so the user can either "continue
+% # without replacing" (replace = "") or "abort".
CLASS="td_radio">
+% if ( $show_radio ) {
+% } # else confirm_manual_address will be called
-% if ( !$new{$pre.'addr_clean'} ) {
+% if ( !$new{$pre.'addr_clean'} ) { # we incremented $rows to fit this in
(unverified)
@@ -88,18 +99,24 @@ Confirm address standardization
% } # if error
% } # for $pre
-%# only do this part if address standardization provided a censustract
-% my $pre = $old{same} ? 'bill_' : 'ship_';
+% # the prefix for the censustract
+% my $pre = $old{billship} ?
+% ( $old{same} ? 'bill_' : 'ship_' ) :
+% '';
% my $censustract = $new{$pre.'censustract'};
% if ( $censustract ) {
+% if ( $show_radio ) {
+% # One button: "use selected address(es)".
+
+
+
+% } else {
+% # Two buttons: "use entered address", and "use selected address"
+% # and empty columns before and after
-
+
+
+% # disable the button if standardization completely failed
-
+
+
+% }
+
+% # always provide a cancel button
+
+
+
+
@@ -138,15 +178,43 @@ my %old = %{ $q->{old} };
my %new = %{ $q->{new} };
my $addresses = $old{billship} ? 'addresses' : 'address';
+my $show_radio = 0;
+my $failed = 0; # true if standardization returned no addresses
my @prefixes = ('');
+
if ( $old{same} ) {
+
+ # Then there are bill and ship addresses and they're the same. Treat
+ # bill_error as a failure, and let the user accept or reject the whole
+ # standardization.
+
@prefixes = ('bill_');
+ $failed = 1 if $new{'bill_error'};
+
} elsif ( $old{billship} ) {
+
+ # There are separate bill and ship addresses. Treat error in both as a
+ # failure. Otherwise, at least one of them has a choice between entered
+ # and standardized address, so let the user choose.
+
@prefixes = ('bill_', 'ship_');
+ if ( $new{'bill_error'} and $new{'ship_error'} ) {
+ $failed = 1;
+ } else {
+ $show_radio = 1;
+ }
+
+} else {
+
+ # There are no bill/ship addresses (this is used for package locations).
+ # Treat like the first case but without the bill_ prefix.
+ @prefixes = ('');
+ $failed = 1 if $new{'error'};
+
}
-my $census_error = $new{'census_error'};
+my $census_error = $new{'census_error'}; # seems to be unused
my $is_error = $census_error || grep { $new{$_.'error'} } @prefixes;
%init>