stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / misc / confirm-censustract.html
index ae0ae3a..10ae918 100644 (file)
@@ -1,3 +1,10 @@
+% if ( !$error and !$new_tract ) {
+%   # then set_censustract returned nothing
+%   # because it's not relevant for this address
+%   # so output nothing (forces confirm_censustract() to continue)
+% $m->clear_buffer;
+% $m->abort;
+% }
 <CENTER><BR><B>
 % if ( $error ) {
 Census tract error
@@ -6,6 +13,9 @@ Census tract error
 Confirm census tract
 % }
 </B><BR>
+<% $location{address1} |h %> <% $location{address2} |h %><BR>
+<% $location{city} |h %>, <% $location{state} |h %> <% $location{zip} |h %><BR>
+<BR>
 % my $querystring = "census_year=$year&latitude=".$cache->get('latitude').'&longitude='.$cache->get('longitude');
 <A HREF="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?<% $querystring %>"
    TARGET="_blank">Map service module location</A><BR>
@@ -29,13 +39,14 @@ Confirm census tract
   <TR>
     <TD ALIGN="center">
       <BUTTON TYPE="button"
-              onclick="set_censustract('<% $old_tract %>', '<% $year %>')">
+              onclick="set_censustract('<% $old_tract %>', '<% $year %>', '<% $pre %>')">
       <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered census tract
       </BUTTON>
     </TD>
+%   if ( !$error ) {
     <TD ALIGN="center">
       <BUTTON TYPE="button"
-              onclick="set_censustract('<% $new_tract %>', '<% $year %>')">
+              onclick="set_censustract('<% $new_tract %>', '<% $year %>', '<% $pre %>')">
       <IMG SRC="<%$p%>images/tick.png" ALT=""> Use calculated census tract
       </BUTTON>
     </TD>
@@ -47,6 +58,14 @@ Confirm census tract
       </BUTTON>
     </TD>
   </TR>
+%   } else { # don't show a button to use the calculated value
+    <TD COLSPAN=1 ALIGN="center">
+      <BUTTON TYPE="button" onclick="submit_abort()">
+      <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
+      </BUTTON>
+    </TD>
+  </TR>
+%   }
 </TABLE></CENTER>
 <%init>
 
@@ -61,12 +80,13 @@ warn $cgi->param('q') if $DEBUG;
 my $q = decode_json($cgi->param('q'))
   or die "bad argument '".$cgi->param('q')."'";
 
+my $pre = $q->{prefix} || '';
 my %location = (
-  map { $_ => $q->{'ship_'.$_} }
+  map { $_ => $q->{$pre.$_} }
     qw( company address1 address2 city state zip country latitude longitude )
 );
 
-my $old_tract = $q->{'ship_censustract'};
+my $old_tract = $q->{$pre.'censustract'};
 my $cache = eval { FS::GeocodeCache->new(%location) };
 $cache->set_censustract;
 my $year = FS::Conf->new->config('census_year');