X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fconfirm-address_standardize.html;h=8bd43ca547e8bdba38bf620f07461cc6dac911f1;hp=a6f4b06e830c2a1a13b496d92e3376222cb577a9;hb=HEAD;hpb=84fa358b56b89205fff99927080d5c28c01d57ff diff --git a/httemplate/misc/confirm-address_standardize.html b/httemplate/misc/confirm-address_standardize.html index a6f4b06e8..8bd43ca54 100644 --- a/httemplate/misc/confirm-address_standardize.html +++ b/httemplate/misc/confirm-address_standardize.html @@ -1,8 +1,18 @@

-% if ( $new{error} or $new{ship_error} ) { +% if ( $is_error ) { Address standardization error % } % else { @@ -10,113 +20,155 @@ Confirm address standardization % }

+
-% my @prefixes; -% if ( $old{onlyship} ) { -% @prefixes = ('ship_'); -% } elsif ( $old{same} ) { -% @prefixes = (''); -% } else { -% @prefixes = ('', 'ship_'); -% } -% for my $pre ('', 'ship_') { -% my $name = $pre eq 'ship_' ? 'service' : 'billing'; -% if ( $new{$pre.'addr_clean'} ) { +% for my $pre (@prefixes) { +% 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". - - + + + + % if ( $old{$pre.'company'} ) { - - - - + % } + - - + + - - + - - + - -% } # if addr_clean -% elsif ( $new{$pre.'error'} ) { +% } else { # not an error +% $rows++ if !$new{$pre.'addr_clean'}; + + + +% if ( !$new{$pre.'addr_clean'} ) { # we incremented $rows to fit this in + + + + +% } + % if ( $old{$pre.'company'} ) { - + + % } - - + + - + + - + + -% } #if error + +% } # if error % } # for $pre -%# only do this part if address standardization provided a censustract -% if ( $new{'ship_censustract'} ) { +% # the prefix for the censustract +% my $pre = $old{billship} ? +% ( $old{same} ? 'bill_' : 'ship_' ) : +% ''; +% my $censustract = $new{$pre.'censustract'}; +% if ( $censustract ) { + + - + % } #if censustract -% if ( $new{error} or $new{ship_error} ) { +% 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 - + + + % } -% else { + +% # always provide a cancel button - - + -
Entered <%$name%> addressStandardized <%$name%> address CLASS="td_radio"> +% if ( $show_radio ) { + +% } # else confirm_manual_address will be called + Entered <%$name%> address +
<% $old{$pre.'company'} %><% $new{$pre.'company'} %>
<% $old{$pre.'company'} |h %>
<% $old{$pre.'address1'} %><% $new{$pre.'address1'} %><% $old{$pre.'address1'} |h %><% $new{$pre.'error'} %>
<% $old{$pre.'address2'} %><% $new{$pre.'address2'} %><% $old{$pre.'address2'} |h %>
<% $old{$pre.'city'} %>, <% $old{$pre.'state'} %> <% $old{$pre.'zip'} %><% $new{$pre.'city'} %>, <% $new{$pre.'state'} %> <% $new{$pre.'zip'} %><% $old{$pre.'city'} |h %>, <% $old{$pre.'state'} |h %> <% $old{$pre.'zip'} |h %>
CLASS="td_radio"> +% if ( $show_radio ) { + +% } + Entered <%$name%> addressStandardized <%$name%> address CLASS="td_radio"> +% if ( $show_radio ) { + +% } +
(unverified)
<% $old{$pre.'company'} %><% $old{$pre.'company'} |h %><% $new{$pre.'company'} |h %>
<% $old{$pre.'address1'} %><% $new{$pre.'error'} %><% $old{$pre.'address1'} |h %><% $new{$pre.'address1'} |h %>
<% $old{$pre.'address2'} %><% $old{$pre.'address2'} |h %><% $new{$pre.'address2'} |h %>
<% $old{$pre.'city'} %>, <% $old{$pre.'state'} %> <% $old{$pre.'zip'} %><% $old{$pre.'city'} |h %>, <% $old{$pre.'state'} |h %> <% $old{$pre.'zip'} |h %><% $new{$pre.'city'} |h %>, <% $new{$pre.'state'} |h %> <% $new{$pre.'zip'} |h %>
+% if ( $show_radio ) { + > +% } + Entered census tract Calculated census tract +% if ( $show_radio ) { + > +% } +
<% $old{'ship_censustract'} %><% $old{$pre.'censustract'} %> -% if ( $new{'ship_census_error'} ) { - <% $new{'ship_census_error'} %> +% if ( $census_error ) { + <% $census_error %> % } else { - <% $new{'ship_censustract'} %> + <% $censustract %> % }
+ + - -
- - + +
- -
-% } # !error +
<%init> # slightly weird interface... @@ -125,6 +177,44 @@ 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'; +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'}; # seems to be unused +my $is_error = $census_error || grep { $new{$_.'error'} } @prefixes;