summaryrefslogtreecommitdiff
path: root/httemplate/misc/xmlhttp-address_standardize.html
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-03-14 13:27:33 -0700
committerMark Wells <mark@freeside.biz>2012-03-30 15:13:44 -0700
commit3fd1a0086512ada7b04e211161ac699d932ae1d0 (patch)
tree3705b1d7c4b16d185723af6890ae4eca2b8df211 /httemplate/misc/xmlhttp-address_standardize.html
parentfadc3d69d6a6bceac54fcb52b456222f28c42645 (diff)
alternate address standardization method (TeleAtlas), #13763
Diffstat (limited to 'httemplate/misc/xmlhttp-address_standardize.html')
-rw-r--r--httemplate/misc/xmlhttp-address_standardize.html38
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..f305a2410
--- /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::geocode_cache->standardize($location) };
+ $cache->set_censustract if $pre;
+ $cache->set_coord;
+
+ foreach ( keys(%$cache) ) {
+ $new{$pre.$_} = $cache->get($_);
+ }
+}
+
+my $return = { old => \%old, new => \%new };
+warn "result:\n".encode_json($return) if $DEBUG;
+</%init>