default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / misc / confirm-censustract.html
index 880cade..02847f8 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,16 +13,23 @@ Census tract error
 Confirm census tract
 % }
 </B><BR>
-<% $location{address1} %> <% $location{address2} %><BR>
-<% $location{city} %>, <% $location{state} %> <% $location{zip} %><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>
-% $querystring = "census_year=$year&zip_code=".$cache->get('zip');
-<A HREF="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?<% $querystring %>"
-   TARGET="_blank">Map zip code center</A><BR>
+% my $address1 = $location{address1};
+% $address1 =~ s/(apt|ste|suite|unit)[\s\d]\w*\s*$//i;
+% my $querystring = "census_year=$year&address=$address1, $location{address2}, $location{city}, $location{state}";
+<A HREF="<%$p%>misc/openmap.html?<% $querystring %>"
+   REL="opener"
+   TARGET="_blank"
+>Map service location</A><BR>
+% $querystring = "census_year=$year&pre=$pre&zip_code=" . $cache->get('zip');
+<A HREF="<%$p%>misc/openmap.html?<% $querystring %>"
+   REL="opener"
+   TARGET="_blank"
+>Map zip code center</A><BR>
 <BR>
+<input type="hidden" id="new_tract" name="new_tract" value="<%$new_tract%>">
 <TABLE>
   <TR>
     <TH style="width:50%">Entered census tract</TH>
@@ -24,9 +38,9 @@ Confirm census tract
   <TR>
     <TD><% $old_tract %></TD>
 % if ( $error ) {
-    <TD><FONT COLOR="#ff0000"><% $error %></FONT></TD>
+    <TD><div id='newcensustract'><FONT COLOR="#ff0000"><% $error %></FONT></div></TD>
 % } else {
-    <TD><% $new_tract %></TD>
+    <TD><div id='newcensustract'><% $new_tract %></div></TD>
 % }
   </TR>
   <TR>
@@ -36,30 +50,43 @@ Confirm census tract
       <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 %>', '<% $pre %>')">
+     <div id="setnewtractdiv"
+% if ( $error ) { ## do not display this block if error finding track.
+      style="display:none"
+% }
+     >
+      <BUTTON TYPE="button" id="setnewtract"
+              onclick="set_censustract(getElementById('new_tract').value, '<% $year %>', '<% $pre %>')">
       <IMG SRC="<%$p%>images/tick.png" ALT=""> Use calculated census tract
       </BUTTON>
-    </TD>
-  </TR>
-  <TR>
-    <TD COLSPAN=2 ALIGN="center">
+     </div>
+     <div id='cancelsubmissiontop'
+% if ( !$error ) { ## do not display this block if there is no error finding a track.
+      style="display:none"
+% }
+     >
       <BUTTON TYPE="button" onclick="submit_abort()">
-      <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
+        <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
       </BUTTON>
+     </div>
     </TD>
   </TR>
-%   } else { # don't show a button to use the calculated value
-    <TD COLSPAN=1 ALIGN="center">
+  <TR>
+    <TD COLSPAN=2 ALIGN="center">
+     <div id='cancelsubmissionbottom'
+% if ( $error ) { ## do not display this block if error finding track.
+      style="display:none"
+% }
+     >
       <BUTTON TYPE="button" onclick="submit_abort()">
-      <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
+        <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
       </BUTTON>
+     </div>
     </TD>
   </TR>
-%   }
 </TABLE></CENTER>
+
 <%init>
 
 local $SIG{__DIE__}; #disable Mason error trap
@@ -82,7 +109,7 @@ my %location = (
 my $old_tract = $q->{$pre.'censustract'};
 my $cache = eval { FS::GeocodeCache->new(%location) };
 $cache->set_censustract;
-my $year = FS::Conf->new->config('census_year');
+my $year = FS::Conf->new->config('census_legacy') || '2020';
 my $new_tract = $cache->get('censustract');
 my $error = $cache->get('censustract_error');