1 % if ( !$error and !$new_tract ) {
2 % # then set_censustract returned nothing
3 % # because it's not relevant for this address
4 % # so output nothing (forces confirm_censustract() to continue)
16 <% $location{address1} |h %> <% $location{address2} |h %><BR>
17 <% $location{city} |h %>, <% $location{state} |h %> <% $location{zip} |h %><BR>
19 % my $address1 = $location{address1};
20 % $address1 =~ s/(apt|ste|suite|unit)[\s\d]\w*\s*$//i;
21 % my $querystring = "census_year=$year&address=$address1, $location{address2}, $location{city}, $location{state}";
22 <A HREF="<%$p%>misc/openmap.html?<% $querystring %>"
25 >Map service location</A><BR>
26 % $querystring = "census_year=$year&pre=$pre&zip_code=" . $cache->get('zip');
27 <A HREF="<%$p%>misc/openmap.html?<% $querystring %>"
30 >Map zip code center</A><BR>
32 <input type="hidden" id="new_tract" name="new_tract" value="<%$new_tract%>">
35 <TH style="width:50%">Entered census tract</TH>
36 <TH style="width:50%">Calculated census tract</TH>
39 <TD><% $old_tract %></TD>
41 <TD><div id='newcensustract'><FONT COLOR="#ff0000"><% $error %></FONT></div></TD>
43 <TD><div id='newcensustract'><% $new_tract %></div></TD>
49 onclick="set_censustract('<% $old_tract %>', '<% $year %>', '<% $pre %>')">
50 <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered census tract
54 <div id="setnewtractdiv"
55 % if ( $error ) { ## do not display this block if error finding track.
59 <BUTTON TYPE="button" id="setnewtract"
60 onclick="set_censustract(getElementById('new_tract').value, '<% $year %>', '<% $pre %>')">
61 <IMG SRC="<%$p%>images/tick.png" ALT=""> Use calculated census tract
64 <div id='cancelsubmissiontop'
65 % if ( !$error ) { ## do not display this block if there is no error finding a track.
69 <BUTTON TYPE="button" onclick="submit_abort()">
70 <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
76 <TD COLSPAN=2 ALIGN="center">
77 <div id='cancelsubmissionbottom'
78 % if ( $error ) { ## do not display this block if error finding track.
82 <BUTTON TYPE="button" onclick="submit_abort()">
83 <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
92 local $SIG{__DIE__}; #disable Mason error trap
96 my $conf = new FS::Conf;
98 warn $cgi->param('q') if $DEBUG;
100 my $q = decode_json($cgi->param('q'))
101 or die "bad argument '".$cgi->param('q')."'";
103 my $pre = $q->{prefix} || '';
105 map { $_ => $q->{$pre.$_} }
106 qw( company address1 address2 city state zip country latitude longitude )
109 my $old_tract = $q->{$pre.'censustract'};
110 my $cache = eval { FS::GeocodeCache->new(%location) };
111 $cache->set_censustract;
112 my $year = FS::Conf->new->config('census_legacy') || '2020';
113 my $new_tract = $cache->get('censustract');
114 my $error = $cache->get('censustract_error');
116 warn Dumper($cache) if $DEBUG;