% if ( $error ) { Census tract error % } % else { Confirm census tract % }
% my $querystring = "census_year=$year&latitude=".$cache->get('latitude').'&longitude='.$cache->get('longitude'); Map service module location
% $querystring = "census_year=$year&zip_code=".$cache->get('zip'); Map zip code center

% if ( $error ) { % } else { % }
Entered census tract Calculated census tract
<% $old_tract %><% $error %><% $new_tract %>
<%init> local $SIG{__DIE__}; #disable Mason error trap my $DEBUG = 0; my $conf = new FS::Conf; warn $cgi->param('q') if $DEBUG; my $q = decode_json($cgi->param('q')) or die "bad argument '".$cgi->param('q')."'"; my $pre = $q->{'same'} ? 'bill_' : 'ship_'; my %location = ( map { $_ => $q->{$pre.$_} } qw( company address1 address2 city state zip country latitude longitude ) ); 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 $new_tract = $cache->get('censustract'); my $error = $cache->get('censustract_error'); warn Dumper($cache) if $DEBUG;