1 <STYLE type="text/css">
2 th { line-height: 150%;
7 vertical-align: middle;
16 Address standardization error
19 Confirm address standardization
23 <FORM ID="confirm_replace_form">
25 % for my $pre (@prefixes) {
26 % my $name = $pre eq 'bill_' ? 'billing' : 'service';
28 % if ( $new{$pre.'error'} ) {
29 % # Standardization returned an error, so the user can either "continue
30 % # without replacing" (replace = "") or "abort".
32 <TD ROWSPAN=<% $rows %> CLASS="td_radio">
33 % if ( $show_radio ) {
34 <INPUT TYPE="radio" NAME="<% $pre %>replace" VALUE="" CHECKED="Y">
35 % } # else confirm_manual_address will be called
37 <TH>Entered <%$name%> address
40 <TD CLASS="td_radio"></TD>
43 % if ( $old{$pre.'company'} ) {
44 <TD><% $old{$pre.'company'} |h %></TD>
48 <TD><% $old{$pre.'address1'} |h %></TD>
49 <TD ROWSPAN=3><FONT COLOR="#ff0000"><B><% $new{$pre.'error'} %></B></FONT></TD>
52 <TD><% $old{$pre.'address2'} |h %></TD>
55 <TD><% $old{$pre.'city'} |h %>, <% $old{$pre.'state'} |h %> <% $old{$pre.'zip'} |h %></TD>
57 % } else { # not an error
58 % $rows++ if !$new{$pre.'addr_clean'};
60 <TD ROWSPAN=<% $rows %> CLASS="td_radio">
61 % if ( $show_radio ) {
62 <INPUT TYPE="radio" NAME="<% $pre %>replace" VALUE="">
65 <TH>Entered <%$name%> address</TH>
66 <TH>Standardized <%$name%> address</TH>
67 <TD ROWSPAN=<% $rows %> CLASS="td_radio">
68 % if ( $show_radio ) {
69 <INPUT TYPE="radio" NAME="<% $pre %>replace" VALUE="Y" CHECKED="Y">
73 % if ( !$new{$pre.'addr_clean'} ) { # we incremented $rows to fit this in
76 <TH STYLE="font-size:smaller;color:#ff0000">(unverified)</TH>
80 % if ( $old{$pre.'company'} ) {
82 <TD><% $old{$pre.'company'} |h %></TD>
83 <TD><% $new{$pre.'company'} |h %></TD>
87 <TD><% $old{$pre.'address1'} |h %></TD>
88 <TD><% $new{$pre.'address1'} |h %></TD>
91 <TD><% $old{$pre.'address2'} |h %></TD>
92 <TD><% $new{$pre.'address2'} |h %></TD>
95 <TD><% $old{$pre.'city'} |h %>, <% $old{$pre.'state'} |h %> <% $old{$pre.'zip'} |h %></TD>
96 <TD><% $new{$pre.'city'} |h %>, <% $new{$pre.'state'} |h %> <% $new{$pre.'zip'} |h %></TD>
102 % # the prefix for the censustract
103 % my $pre = $old{billship} ?
104 % ( $old{same} ? 'bill_' : 'ship_' ) :
106 % my $censustract = $new{$pre.'censustract'};
107 % if ( $censustract ) {
109 <TD ROWSPAN=2 CLASS="td_radio">
110 % if ( $show_radio ) {
111 <INPUT TYPE="radio" NAME="census_replace" VALUE="" <% $census_error ? 'CHECKED="Y"' : '' %>>
114 <TH>Entered census tract</TH>
115 <TH>Calculated census tract</TH>
116 <TD ROWSPAN=2 CLASS="td_radio">
117 % if ( $show_radio ) {
118 <INPUT TYPE="radio" NAME="census_replace" VALUE="Y" <% $census_error ? '' : 'CHECKED="Y"' %>>
123 <TD><% $old{$pre.'censustract'} %></TD>
125 % if ( $census_error ) {
126 <FONT COLOR="#ff0000"><% $census_error %></FONT>
135 % if ( $show_radio ) {
136 % # One button: "use selected address(es)".
137 <TD ALIGN="center" COLSPAN=4>
138 <BUTTON TYPE="button" onclick="replace_address();">
139 <IMG SRC="<%$p%>images/<% $is_error ? 'error.png' : 'tick.png' %>"
141 Use selected <%$addresses%>
145 % # Two buttons: "use entered address", and "use selected address"
146 % # and empty columns before and after
149 <BUTTON TYPE="button" onclick="confirm_manual_address();">
150 <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered <%$addresses%>
153 % # disable the button if standardization completely failed
155 <BUTTON TYPE="button" onclick="replace_address();" <% $failed ? 'DISABLED' : '' %>>
156 <IMG SRC="<%$p%>images/tick.png" ALT=""> Use standardized <%$addresses%>
162 % # always provide a cancel button
164 <TD ALIGN="center" COLSPAN=4>
165 <BUTTON TYPE="button" onclick="submit_abort();">
166 <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
174 # slightly weird interface...
175 my $q = decode_json($cgi->param('q'));
177 my %old = %{ $q->{old} };
178 my %new = %{ $q->{new} };
180 my $addresses = $old{billship} ? 'addresses' : 'address';
182 my $failed = 0; # true if standardization returned no addresses
188 # Then there are bill and ship addresses and they're the same. Treat
189 # bill_error as a failure, and let the user accept or reject the whole
192 @prefixes = ('bill_');
193 $failed = 1 if $new{'bill_error'};
195 } elsif ( $old{billship} ) {
197 # There are separate bill and ship addresses. Treat error in both as a
198 # failure. Otherwise, at least one of them has a choice between entered
199 # and standardized address, so let the user choose.
201 @prefixes = ('bill_', 'ship_');
202 if ( $new{'bill_error'} and $new{'ship_error'} ) {
210 # There are no bill/ship addresses (this is used for package locations).
211 # Treat like the first case but without the bill_ prefix.
213 $failed = 1 if $new{'error'};
217 my $census_error = $new{'census_error'}; # seems to be unused
218 my $is_error = $census_error || grep { $new{$_.'error'} } @prefixes;