% if ( $billship ) {
returnobj['same'] = cf.elements['same'].checked;
% }
-% if ( $withcensus ) {
-% # "entered" censustract always goes with the ship_ address if there is one
-% if ( $billship ) {
- returnobj['ship_censustract'] = cf.elements['enter_censustract'].value;
-% } else { # there's only a package address, so it's just "censustract"
- returnobj['censustract'] = cf.elements['enter_censustract'].value;
-% }
-% }
% for my $pre (@prefixes) {
- if ( <% $pre eq 'ship_' ? 1 : 0 %> && returnobj['same'] ) {
-% # special case: don't include any ship_ fields, and move the entered
-% # censustract over to bill_.
- returnobj['bill_censustract'] = returnobj['ship_censustract'];
- delete returnobj['ship_censustract'];
- } else {
% # normal case
-% for my $field (qw(address1 address2 city state zip country)) {
+% for my $field (qw(address1 address2 state zip country), ($conf->exists('cust_main-no_city_in_address') ? () : 'city')) {
returnobj['<% $pre %><% $field %>'] = cf.elements['<% $pre %><% $field %>'].value;
% } #for $field
- } // if returnobj['same']
+% if ( $withcensus ) {
+ returnobj['<% $pre %>censustract'] = cf.elements['<% $pre %>enter_censustract'].value;
+% }
% } #foreach $pre
return returnobj;
// then all entered address fields are correct
// but we still need to set the lat/long fields and addr_clean
- status_message('Verified');
+
+ if ( returned['all_clean'] ) {
+ status_message('Verified');
+ } else {
+ status_message('Unverified');
+ }
replace_address();
} else {
function() {
overlib( OLresponseAJAX, CAPTION, 'Address standardization', STICKY,
AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH,
- 576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399',
+ 650, HEIGHT, 368, BGCOLOR, '#333399', CGCOLOR, '#333399',
TEXTSIZE, 3 );
}, 0);
var newaddr = returned['new'];
var cf = document.<% $formname %>;
+ var crf = document.forms['confirm_replace_form'];
% foreach my $pre (@prefixes) {
var clean = newaddr['<% $pre %>addr_clean'] == 'Y';
+ var replace = true; // auto_standardize_address won't load the form, so just do it
+ if ( crf && crf['<% $pre %>replace'] ) {
+ replace = crf['<% $pre %>replace'].value == 'Y';
+ }
var error = newaddr['<% $pre %>error'];
- if ( clean ) {
-% foreach my $field (qw(address1 address2 city state zip addr_clean )) {
+ if ( clean && replace ) {
+% foreach my $field (qw(address1 address2 state zip addr_clean ),($conf->exists('cust_main-no_city_in_address') ? () : 'city')) {
cf.elements['<% $pre %><% $field %>'].value = newaddr['<% $pre %><% $field %>'];
% } #foreach $field
-% # special case: allow manually setting the census tract, whether
-% # standardization returned one or not
- if ( cf.elements['old_censustract'].value != cf.elements['enter_censustract'].value
- && cf.elements['enter_censustract'].value.length > 0 ) {
- cf.elements['<% $pre %>censustract'].value = cf.elements['enter_censustract'].value;
- }
-
-
if ( cf.elements['<% $pre %>coord_auto'].value ) {
cf.elements['<% $pre %>latitude'].value = newaddr['<% $pre %>latitude'];
cf.elements['<% $pre %>longitude'].value = newaddr['<% $pre %>longitude'];
}
% if ( $withcensus ) {
- if ( clean && newaddr['<% $pre %>censustract'] ) {
+ var census_replace = true;
+ if ( crf && crf['census_replace'] ) {
+ census_replace = crf['census_replace'].value == 'Y';
+ }
+
+ if ( clean && census_replace && newaddr['<% $pre %>censustract'] ) {
cf.elements['<% $pre %>censustract'].value = newaddr['<% $pre %>censustract'];
}
% } #if $withcensus
%# not much to do in this case, just confirm the censustract
% if ( $withcensus ) {
var cf = document.<% $formname %>;
-% if ( $billship ) {
- if ( cf.elements['same'] && cf.elements['same'].checked ) {
- cf.elements['bill_censustract'].value =
- cf.elements['enter_censustract'].value;
- } else {
- cf.elements['ship_censustract'].value =
- cf.elements['enter_censustract'].value;
- }
-% } else {
- cf.elements['censustract'].value = cf.elements['enter_censustract'].value;
+% foreach my $pre (@prefixes) {
+ cf.elements['<% $pre %>censustract'].value =
+ cf.elements['<% $pre %>enter_censustract'].value;
% }
-% }
+% } # $withcensus
post_standardization();
}
}
}
+
+% if ($census_functions) { # do not use this in cust_main
+function confirm_censustract() {
+% if ( FS::Conf->new->exists('cust_main-require_censustract') ) {
+ var form = document.<% $formname %>;
+ if ( form.elements['censustract'].value == '' ) {
+ var address_info = form_address_info();
+ address_info['latitude'] = form.elements['latitude'].value;
+ address_info['longitude'] = form.elements['longitude'].value;
+ OLpostAJAX(
+ '<%$p%>/misc/confirm-censustract.html',
+ 'q=' + encodeURIComponent(JSON.stringify(address_info)),
+ function() {
+ if ( OLresponseAJAX ) {
+ overlib( OLresponseAJAX, CAPTION, 'Confirm censustract', STICKY,
+ AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH,
+ 576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399',
+ TEXTSIZE, 3 );
+ } else {
+ // no response
+ <% $post_censustract %>;
+ }
+ },
+ 0);
+ } else {
+ <% $post_censustract %>;
+ }
+% } else { # skip this step
+ <% $post_censustract %>;
+% }
+}
+
+function set_censustract(tract, year) {
+ var form = document.<% $formname %>;
+ form.elements['censustract'].value = tract;
+ form.elements['censusyear'].value = year;
+ <% $post_censustract %>;
+}
+
+% } # $census_functions
+
<%init>
my %opt = @_;
my $formname = $opt{form} || 'CustomerForm';
my $post_geocode = $opt{callback} || 'post_geocode();';
+my $post_censustract;
+
+my $census_functions = $opt{'with_census_functions'} ? 1 : 0;
+if ( $census_functions ) {
+ $post_censustract = $post_geocode;
+ $post_geocode = 'confirm_censustract()';
+}
</%init>