don't look up or display census tracts for non-U.S. addresses, #32249
authorMark Wells <mark@freeside.biz>
Thu, 27 Nov 2014 00:55:41 +0000 (16:55 -0800)
committerMark Wells <mark@freeside.biz>
Thu, 27 Nov 2014 00:55:41 +0000 (16:55 -0800)
FS/FS/Misc/Geo.pm
httemplate/edit/cust_main/bottomfixup.js
httemplate/elements/standardize_locations.js
httemplate/elements/tr-censustract.html
httemplate/misc/confirm-censustract.html
httemplate/view/cust_main/locations.html
httemplate/view/cust_main/packages/location.html

index e41ba5d..a387aca 100644 (file)
@@ -42,6 +42,10 @@ sub get_censustract_ffiec {
   my $location = shift;
   my $year  = shift;
 
+  if ( length($location->{country}) and uc($location->{country}) ne 'US' ) {
+    return '';
+  }
+
   warn Dumper($location, $year) if $DEBUG;
 
   my $url = 'http://www.ffiec.gov/Geocode/default.aspx';
index 5a8835f..8aef1e7 100644 (file)
@@ -116,10 +116,13 @@ function confirm_censustract(pre) {
         '<%$p%>/misc/confirm-censustract.html',
         'q=' + encodeURIComponent(JSON.stringify(address_info)),
         function() {
-          overlib( OLresponseAJAX, CAPTION, 'Confirm censustract', STICKY,
-            AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH,
-            576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399',
-            TEXTSIZE, 3 );
+          if ( OLresponseAJAX ) {
+            overlib( OLresponseAJAX, CAPTION, 'Confirm censustract', STICKY,
+              AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH,
+              576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399',
+              TEXTSIZE, 3 );
+          } else
+            submit_continue();
         },
         0);
   } else submit_continue();
index 817a2e3..a4f13d7 100644 (file)
@@ -290,10 +290,15 @@ function confirm_censustract() {
         '<%$p%>/misc/confirm-censustract.html',
         'q=' + encodeURIComponent(JSON.stringify(address_info)),
         function() {
-          overlib( OLresponseAJAX, CAPTION, 'Confirm censustract', STICKY,
-            AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH,
-            576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399',
-            TEXTSIZE, 3 );
+          if ( OLresponseAJAX ) {
+            overlib( OLresponseAJAX, CAPTION, 'Confirm censustract', STICKY,
+              AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH,
+              576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399',
+              TEXTSIZE, 3 );
+          } else {
+            // no response
+            <% $post_censustract %>;
+          }
         },
         0);
   } else {
index bd014f1..7a4b349 100644 (file)
@@ -1,4 +1,4 @@
-% if ($censustract) {
+% if ($location->country eq 'US' and $censustract) {
 <TR>
   <TD ALIGN="right"><% mt('Census tract') |h %></TD>
   <TD COLSPAN=5>
index 880cade..024bc17 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
index fdbbc39..336c1aa 100755 (executable)
@@ -35,16 +35,18 @@ table.location {
 <TH COLSPAN=5>
 <DIV CLASS="<% $loc->disabled ? 'loclabel disabled' : 'loclabel' %>">
 <% $loc->location_label %>
-%   if ( $loc->censustract ) {
-        <BR>
-        <FONT SIZE=-1>
-        <% $loc->censustract %> (<% $loc->censusyear %> census)
-        </FONT>
-%   } elsif ( $conf->exists('cust_main-require_censustract') ) {
-        <BR>
-        <FONT SIZE=-1 COLOR="#ee3300">
-        <% emt('Census tract unknown') %>
-        </FONT>
+%   if ( $loc->country eq 'US' ) { # only U.S. census tracts for now
+%     if ( $loc->censustract ) {
+          <BR>
+          <FONT SIZE=-1>
+          <% $loc->censustract %> (<% $loc->censusyear %> census)
+          </FONT>
+%     } elsif ( $conf->exists('cust_main-require_censustract') ) {
+          <BR>
+          <FONT SIZE=-1 COLOR="#ee3300">
+          <% emt('Census tract unknown') %>
+          </FONT>
+%     }
 %   }
 </DIV>
 <DIV STYLE="display: inline; float:right;">
index c5ef10e..99d91e5 100644 (file)
           &>
           </FONT>
 %     }
-%     if ( $loc->censustract ) {
-         <BR>
-         <FONT SIZE=-1>
-         <% $loc->censustract %> (<% $loc->censusyear %> census)
-         </FONT>
-%     } elsif ( $opt{'cust_main-require_censustract'} ) {
-          <BR>
-          <FONT SIZE=-1 COLOR="#ee3300">
-          <% emt('Census tract unknown') %>
-          </FONT>
+%     if ( $loc->country eq 'US' ) {
+%       if ( $loc->censustract ) {
+           <BR>
+           <FONT SIZE=-1>
+           <% $loc->censustract %> (<% $loc->censusyear %> census)
+           </FONT>
+%       } elsif ( $opt{'cust_main-require_censustract'} ) {
+            <BR>
+            <FONT SIZE=-1 COLOR="#ee3300">
+            <% emt('Census tract unknown') %>
+            </FONT>
+%       }
 %     }
 
 %     if ( $default ) {