diff options
author | Mark Wells <mark@freeside.biz> | 2012-11-06 12:48:41 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-11-06 12:49:11 -0800 |
commit | 468c9e660eb0edb2033f0f8dbb4458f20280082c (patch) | |
tree | 9a87abfbfad9c820598c3a8d773f35c421c2bb38 /httemplate/misc/xmlhttp-address_standardize.html | |
parent | 2b2aa5664742a134da11862a7cedb37d25524423 (diff) |
improved address standardization, #13763
Diffstat (limited to 'httemplate/misc/xmlhttp-address_standardize.html')
-rw-r--r-- | httemplate/misc/xmlhttp-address_standardize.html | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/httemplate/misc/xmlhttp-address_standardize.html b/httemplate/misc/xmlhttp-address_standardize.html new file mode 100644 index 000000000..f53c35fca --- /dev/null +++ b/httemplate/misc/xmlhttp-address_standardize.html @@ -0,0 +1,38 @@ +<% encode_json($return) %> +<%init> + +local $SIG{__DIE__}; #disable Mason error trap + +my $DEBUG = 0; + +my $conf = new FS::Conf; + +my $sub = $cgi->param('sub'); + +warn $cgi->param('arg') if $DEBUG; + +my %old = %{ decode_json($cgi->param('arg')) } + or die "bad argument '".$cgi->param('arg')."'"; + +my %new; + +foreach my $pre ( '', 'ship_' ) { + next unless ($pre || !$old{onlyship}); + + my $location = { + map { $_ => $old{$pre.$_} } + qw( company address1 address2 city state zip country ) + }; + + my $cache = eval { FS::GeocodeCache->standardize($location) }; + $cache->set_coord; + # don't do set_censustract here, though censustract may be set by now + + foreach ( keys(%$cache) ) { + $new{$pre.$_} = $cache->get($_); + } +} + +my $return = { old => \%old, new => \%new }; +warn "result:\n".encode_json($return) if $DEBUG; +</%init> |