summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-04-14 15:33:39 -0700
committerMark Wells <mark@freeside.biz>2012-04-14 15:33:39 -0700
commit5abe1300f16cf01a6311203deee29373162491c7 (patch)
tree13a8b474966c5697ec2dc3003bd7b3389e9afefc
parent3fd1a0086512ada7b04e211161ac699d932ae1d0 (diff)
rename geocode_cache; minor coord_auto bugfix
-rw-r--r--FS/FS/Mason.pm2
-rw-r--r--FS/FS/Misc/Geo.pm5
-rw-r--r--FS/FS/geocode_cache.pm212
-rw-r--r--FS/MANIFEST4
-rw-r--r--FS/t/geocode_cache.t5
-rw-r--r--httemplate/elements/order_pkg.js3
-rw-r--r--httemplate/elements/standardize_locations.js7
-rw-r--r--httemplate/misc/xmlhttp-address_standardize.html2
8 files changed, 11 insertions, 229 deletions
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 62568eb78..a45be3fb6 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -304,7 +304,7 @@ if ( -e $addl_handler_use_file ) {
use FS::tower;
use FS::tower_sector;
use FS::contact_class;
- use FS::geocode_cache;
+ use FS::GeocodeCache;
# Sammath Naur
if ( $FS::Mason::addl_handler_use ) {
diff --git a/FS/FS/Misc/Geo.pm b/FS/FS/Misc/Geo.pm
index 174357c77..c8290e7ed 100644
--- a/FS/FS/Misc/Geo.pm
+++ b/FS/FS/Misc/Geo.pm
@@ -354,8 +354,9 @@ sub standardize_teleatlas {
return $location;
}
- my $path = $conf->config('teleatlas-path')
- or die "no teleatlas-path configured";
+ if ( my $path = $conf->config('teleatlas-path') ) {
+ local @INC = (@INC, $path);
+ }
my $userid = $conf->config('teleatlas-userid')
or die "no teleatlas-userid configured";
my $password = $conf->config('teleatlas-password')
diff --git a/FS/FS/geocode_cache.pm b/FS/FS/geocode_cache.pm
deleted file mode 100644
index 0041e3772..000000000
--- a/FS/FS/geocode_cache.pm
+++ /dev/null
@@ -1,212 +0,0 @@
-package FS::geocode_cache;
-
-use strict;
-use vars qw($conf $DEBUG);
-use base qw( FS::geocode_Mixin );
-use FS::Record qw( qsearch qsearchs );
-use FS::Conf;
-use FS::Misc::Geo;
-
-use Data::Dumper;
-
-FS::UID->install_callback( sub { $conf = new FS::Conf; } );
-
-$DEBUG = 0;
-
-=head1 NAME
-
-FS::geocode_cache - An address undergoing the geocode process.
-
-=head1 SYNOPSIS
-
- use FS::geocode_cache;
-
- $record = FS::geocode_cache->standardize(%location_hash);
-
-=head1 DESCRIPTION
-
-An FS::geocode_cache object represents a street address in the process of
-being geocoded. FS::geocode_cache inherits from FS::geocode_Mixin.
-
-Most methods on this object throw an exception on error.
-
-FS::geocode_cache has the following fields, with the same meaning as in
-L<FS::cust_location>:
-
-=over 4
-
-All other fields have the same meaning as in L<FS::cust_main> and
-L<FS::cust_location>:
-
-=item address1
-
-=item address2
-
-=item city
-
-=item county
-
-=item state
-
-=item zip
-
-=item latitude
-
-=item longitude
-
-=item addr_clean
-
-=item country
-
-=item censustract
-
-=item geocode
-
-=item district
-
-=back
-
-=head1 METHODS
-
-=over 4
-
-=item new HASHREF
-
-Creates a new cache object. For internal use. See C<standardize>.
-
-=cut
-
-# minimalist constructor
-sub new {
- my $class = shift;
- my $self = {
- company => '',
- address1 => '',
- address2 => '',
- city => '',
- state => '',
- zip => '',
- country => '',
- latitude => '',
- longitude => '',
- addr_clean => '',
- censustract => '',
- @_
- };
- bless $self, $class;
-}
-
-# minimalist accessor, for compatibility with geocode_Mixin
-sub get {
- $_[0]->{$_[1]}
-}
-
-sub set {
- $_[0]->{$_[1]} = $_[2];
-}
-
-sub location_hash { %{$_[0]} };
-
-=item set_censustract
-
-Look up the censustract, if it's not already filled in, and return it.
-On error, sets 'error' and returns nothing.
-
-This uses the "get_censustract_*" methods in L<FS::Misc::Geo>; currently
-the only one is 'ffiec'.
-
-=cut
-
-sub set_censustract {
- my $self = shift;
-
- if ( $self->get('censustract') =~ /^\d{9}\.\d{2}$/ ) {
- return $self->get('censustract');
- }
- my $censusyear = $conf->config('census_year');
- return if !$censusyear;
-
- my $method = 'ffiec';
- # configurable censustract-only lookup goes here if it's ever needed.
- $method = "get_censustract_$method";
- my $censustract = eval { FS::Misc::Geo->$method($self, $censusyear) };
- $self->set("censustract_error", $@);
- $self->set("censustract", $censustract);
-}
-
-=item set_coord
-
-Set the latitude and longitude fields if they're not already set. Returns
-those values, in order.
-
-=cut
-
-sub set_coord { # the one in geocode_Mixin will suffice
- my $self = shift;
- if ( !$self->get('latitude') || !$self->get('longitude') ) {
- $self->SUPER::set_coord;
- $self->set('coord_error', $@);
- }
- return $self->get('latitude'), $self->get('longitude');
-}
-
-=head1 CLASS METHODS
-
-=over 4
-
-=item standardize LOCATION
-
-Given a location hash or L<FS::geocode_Mixin> object, standardize the
-address using the configured method and return an L<FS::geocode_cache>
-object.
-
-The methods are the "standardize_*" functions in L<FS::Geo::Misc>.
-
-=cut
-
-sub standardize {
- my $class = shift;
- my $location = shift;
- $location = { $location->location_hash }
- if UNIVERSAL::can($location, 'location_hash');
-
- local $Data::Dumper::Terse = 1;
- warn "standardizing location:\n".Dumper($location) if $DEBUG;
-
- my $method = $conf->config('address_standardize_method');
-
- if ( $method ) {
- $method = "standardize_$method";
- my $new_location = eval { FS::Misc::Geo->$method( $location ) };
- if ( $new_location ) {
- $location = {
- addr_clean => 'Y',
- %$new_location
- # standardize_* can return an address with addr_clean => '' if
- # the address is somehow questionable
- }
- }
- else {
- # XXX need an option to decide what to do on error
- $location->{'addr_clean'} = '';
- $location->{'error'} = $@;
- }
- warn "result:\n".Dumper($location) if $DEBUG;
- }
- # else $location = $location
- my $cache = $class->new(%$location);
- return $cache;
-}
-
-=back
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::Record>, schema.html from the base documentation.
-
-=cut
-
-1;
-
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 76741ad60..e97f8702a 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -632,5 +632,5 @@ FS/h_svc_cert.pm
t/h_svc_cert.t
FS/contact_class.pm
t/contact_class.t
-FS/geocode_cache.pm
-t/geocode_cache.t
+FS/GeocodeCache.pm
+t/GeocodeCache.t
diff --git a/FS/t/geocode_cache.t b/FS/t/geocode_cache.t
deleted file mode 100644
index 7cbc58d6d..000000000
--- a/FS/t/geocode_cache.t
+++ /dev/null
@@ -1,5 +0,0 @@
-BEGIN { $| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless $loaded;}
-use FS::geocode_cache;
-$loaded=1;
-print "ok 1\n";
diff --git a/httemplate/elements/order_pkg.js b/httemplate/elements/order_pkg.js
index 84c7a820b..8c1efd93a 100644
--- a/httemplate/elements/order_pkg.js
+++ b/httemplate/elements/order_pkg.js
@@ -19,13 +19,10 @@ function pkg_changed () {
form.start_date_text.disabled = false;
form.start_date.style.backgroundColor = '#ffffff';
form.start_date_button.style.display = '';
- //form.start_date_button_disabled.style.display = 'none';
- //form.invoice_terms.disabled = true;
} else {
form.start_date_text.disabled = true;
form.start_date.style.backgroundColor = '#dddddd';
form.start_date_button.style.display = 'none';
- //form.start_date_button_disabled.style.display = '';
}
} else {
diff --git a/httemplate/elements/standardize_locations.js b/httemplate/elements/standardize_locations.js
index 8bec87e1d..77683b9d3 100644
--- a/httemplate/elements/standardize_locations.js
+++ b/httemplate/elements/standardize_locations.js
@@ -45,9 +45,10 @@ function standardize_locations() {
}
% }
-// unless they're both empty
- if ( cf.elements['<% $pre %>latitude'] == '' &&
- cf.elements['<% $pre %>longitude'] == '' ) {
+ // but if the coordinates have been set to null, turn coord_auto on
+ // and standardize
+ if ( cf.elements['<% $pre %>latitude'].value == '' &&
+ cf.elements['<% $pre %>longitude'].value == '' ) {
cf.elements['<% $pre %>coord_auto'].value = 'Y';
changed = true;
}
diff --git a/httemplate/misc/xmlhttp-address_standardize.html b/httemplate/misc/xmlhttp-address_standardize.html
index f305a2410..c2d6d7a80 100644
--- a/httemplate/misc/xmlhttp-address_standardize.html
+++ b/httemplate/misc/xmlhttp-address_standardize.html
@@ -24,7 +24,7 @@ foreach my $pre ( '', 'ship_' ) {
qw( company address1 address2 city state zip country )
};
- my $cache = eval { FS::geocode_cache->standardize($location) };
+ my $cache = eval { FS::GeocodeCache->standardize($location) };
$cache->set_censustract if $pre;
$cache->set_coord;