function bottomfixup(what) {
+%# ../cust_main.cgi
var layervars = new Array(
'payauto',
'payinfo', 'payinfo1', 'payinfo2', 'paytype',
var ship_changed = argsHash['ship_address_standardized'];
var error = argsHash['error'];
var ship_error = argsHash['ship_error'];
+
//yay closures
standardize_address = function () {
cf.elements['ship_zip'].value = argsHash['new_ship_zip'];
}
- }
-
- var cf = document.CustomerForm;
-
-% if ( $conf->exists('enable_taxproducts') ) {
-
- if ( <% $taxpre %>error ) {
-
- var country_el = cf.elements['<% $taxpre %>country'];
- var country = country_el.options[ country_el.selectedIndex ].value;
-
- if ( country == 'CA' || country == 'US' ) {
-
- var state_el = cf.elements['<% $taxpre %>state'];
- var state = state_el.options[ state_el.selectedIndex ].value;
-
- var url = "cust_main/choose_tax_location.html" +
- "?data_vendor=cch-zip" +
- ";city=" + cf.elements['<% $taxpre %>city'].value +
- ";state=" + state +
- ";zip=" + cf.elements['<% $taxpre %>zip'].value +
- ";country=" + country +
- ";";
+ post_standardization();
- // popup a chooser
- OLgetAJAX( url, update_geocode, 300 );
-
- } else {
-
- cf.elements['geocode'].value = 'DEFAULT';
- cf.submit();
-
- }
+ }
- } else
-% }
if ( changed || ship_changed ) {
% if ( $conf->exists('cust_main-auto_standardize_address') ) {
standardize_address();
- cf.submit();
% } else {
confirm_change = confirm_change +
'<TR><TD>' +
- '<BUTTON TYPE="button" onClick="document.CustomerForm.submit();"><IMG SRC="<%$p%>images/error.png" ALT=""> Use entered ' + addresses + '</BUTTON>' +
+ '<BUTTON TYPE="button" onClick="post_standardization();"><IMG SRC="<%$p%>images/error.png" ALT=""> Use entered ' + addresses + '</BUTTON>' +
'</TD><TD>' +
- '<BUTTON TYPE="button" onClick="standardize_address(); document.CustomerForm.submit();"><IMG SRC="<%$p%>images/tick.png" ALT=""> Use standardized ' + addresses + '</BUTTON>' +
+ '<BUTTON TYPE="button" onClick="standardize_address();"><IMG SRC="<%$p%>images/tick.png" ALT=""> Use standardized ' + addresses + '</BUTTON>' +
'</TD></TR>' +
'<TR><TD COLSPAN=2 ALIGN="center">' +
'<BUTTON TYPE="button" onClick="document.CustomerForm.submitButton.disabled=false; parent.cClick();"><IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission</BUTTON></TD></TR>' +
} else {
- cf.submit();
+ post_standardization();
+
+ }
+
+
+}
+
+function post_standardization() {
+
+ var cf = document.CustomerForm;
+
+% if ( $conf->exists('enable_taxproducts') ) {
+
+ if ( new String(cf.elements['<% $taxpre %>zip'].value).length < 10 )
+ {
+
+ var country_el = cf.elements['<% $taxpre %>country'];
+ var country = country_el.options[ country_el.selectedIndex ].value;
+ var geocode = cf.elements['geocode'].value;
+
+ if ( country == 'CA' || country == 'US' ) {
+
+ var state_el = cf.elements['<% $taxpre %>state'];
+ var state = state_el.options[ state_el.selectedIndex ].value;
+
+ var url = "cust_main/choose_tax_location.html" +
+ "?data_vendor=cch-zip" +
+ ";city=" + cf.elements['<% $taxpre %>city'].value +
+ ";state=" + state +
+ ";zip=" + cf.elements['<% $taxpre %>zip'].value +
+ ";country=" + country +
+ ";geocode=" + geocode +
+ ";";
+
+ // popup a chooser
+ OLgetAJAX( url, update_geocode, 300 );
+
+ } else {
+
+ cf.elements['geocode'].value = 'DEFAULT';
+ post_geocode();
+
+ }
+
+ } else {
+
+ cf.elements['geocode'].value = '';
+ post_geocode();
}
+% } else {
+
+ post_geocode();
+
+% }
+
+}
+
+function post_geocode() {
+
+% if ( $conf->exists('cust_main-require_censustract') ) {
+
+ //alert('fetch census tract data');
+ var cf = document.CustomerForm;
+ var state_el = cf.elements['ship_state'];
+ var census_data = new Array(
+ 'year', <% $conf->config('census_year') || '2009' %>,
+ 'address', cf.elements['ship_address1'].value,
+ 'city', cf.elements['ship_city'].value,
+ 'state', state_el.options[ state_el.selectedIndex ].value,
+ 'zip', cf.elements['ship_zip'].value
+ );
+
+ censustract( census_data, update_censustract );
+
+% }else{
+
+ document.CustomerForm.submit();
+
+% }
+
}
function update_geocode() {
setselect(cf.elements['<% $taxpre %>state'], argsHash['state']);
cf.elements['<% $taxpre %>zip'].value = argsHash['zip'];
cf.elements['geocode'].value = argsHash['geocode'];
+ post_geocode();
}
}
+var set_censustract;
+
+function update_censustract(arg) {
+
+ var argsHash = eval('(' + arg + ')');
+
+ var cf = document.CustomerForm;
+
+ var msacode = argsHash['msacode'];
+ var statecode = argsHash['statecode'];
+ var countycode = argsHash['countycode'];
+ var tractcode = argsHash['tractcode'];
+ var error = argsHash['error'];
+
+ var newcensus =
+ new String(statecode) +
+ new String(countycode) +
+ new String(tractcode).replace(/\s$/, ''); // JSON 1 workaround
+
+ set_censustract = function () {
+
+ cf.elements['censustract'].value = newcensus
+ cf.submit();
+
+ }
+
+ if (error || cf.elements['censustract'].value != newcensus) {
+ // popup an entry dialog
+
+ if (error) { newcensus = error; }
+ newcensus.replace(/.*ndefined.*/, 'Not found');
+
+ var choose_censustract =
+ '<CENTER><BR><B>Confirm censustract</B><BR>' +
+ '<A href="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?' +
+ 'census_year=<% $conf->config('census_year') || '2008' %>' +
+ '&latitude=' + cf.elements['latitude'].value +
+ '&longitude=' + cf.elements['longitude'].value +
+ '" target="_blank">Map service module location</A><BR>' +
+ '<A href="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?' +
+ 'census_year=<% $conf->config('census_year') || '2008' %>' +
+ '&zip_code=' + cf.elements['ship_zip'].value +
+ '" target="_blank">Map zip code center</A><BR><BR>' +
+ '<TABLE>';
+
+ choose_censustract = choose_censustract +
+ '<TR><TH style="width:50%">Entered census tract</TH>' +
+ '<TH style="width:50%">Calculated census tract</TH></TR>' +
+ '<TR><TD>' + cf.elements['censustract'].value +
+ '</TD><TD>' + newcensus + '</TD></TR>' +
+ '<TR><TD> </TD><TD> </TD></TR>';
+
+ choose_censustract = choose_censustract +
+ '<TR><TD ALIGN="center">' +
+ '<BUTTON TYPE="button" onClick="document.CustomerForm.submit();"><IMG SRC="<%$p%>images/error.png" ALT=""> Use entered census tract </BUTTON>' +
+ '</TD><TD ALIGN="center">' +
+ '<BUTTON TYPE="button" onClick="set_censustract();"><IMG SRC="<%$p%>images/tick.png" ALT=""> Use calculated census tract </BUTTON>' +
+ '</TD></TR>' +
+ '<TR><TD COLSPAN=2 ALIGN="center">' +
+ '<BUTTON TYPE="button" onClick="document.CustomerForm.submitButton.disabled=false; parent.cClick();"><IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission</BUTTON></TD></TR>' +
+
+ '</TABLE></CENTER>';
+
+ overlib( choose_censustract, CAPTION, 'Confirm censustract', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH, 576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399', TEXTSIZE, 3 );
+
+ } else {
+
+ cf.submit();
+
+ }
+
+}
+
function copyelement(from, to) {
if ( from == undefined ) {
to.value = '';