external taxes support package locations RT10093
[freeside.git] / httemplate / edit / cust_main / bottomfixup.js
1 function bottomfixup(what) {
2
3 %# ../cust_main.cgi
4   var layervars = new Array(
5     'payauto',
6     'payinfo', 'payinfo1', 'payinfo2', 'paytype',
7     'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
8     'paystart_month', 'paystart_year', 'payissue',
9     'payip',
10     'paid'
11   );
12
13   var cf = document.CustomerForm;
14   var payby = cf.payby.options[cf.payby.selectedIndex].value;
15   for ( f=0; f < layervars.length; f++ ) {
16     var field = layervars[f];
17     copyelement( cf.elements[payby + '_' + field],
18                  cf.elements[field]
19                );
20   }
21
22   //this part does USPS address correction
23   standardize_locations();
24
25 }
26
27 <% include( '/elements/standardize_locations.js',
28             'callback', 'post_geocode();'
29           )
30 %>
31
32 function post_geocode() {
33
34 % if ( $conf->exists('cust_main-require_censustract') ) {
35
36   //alert('fetch census tract data');
37   var cf = document.CustomerForm;
38   var state_el = cf.elements['ship_state'];
39   var census_data = new Array(
40     'year',   <% $conf->config('census_year') || '2009' %>,
41     'address', cf.elements['ship_address1'].value,
42     'city',    cf.elements['ship_city'].value,
43     'state',   state_el.options[ state_el.selectedIndex ].value,
44     'zip',     cf.elements['ship_zip'].value
45   );
46
47   censustract( census_data, update_censustract );
48
49 % }else{
50
51   document.CustomerForm.submit();
52
53 % }
54
55 }
56
57 function copyelement(from, to) {
58   if ( from == undefined ) {
59     to.value = '';
60   } else if ( from.type == 'select-one' ) {
61     to.value = from.options[from.selectedIndex].value;
62     //alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
63   } else if ( from.type == 'checkbox' ) {
64     if ( from.checked ) {
65       to.value = from.value;
66     } else {
67       to.value = '';
68     }
69   } else {
70     if ( from.value == undefined ) {
71       to.value = '';
72     } else {
73       to.value = from.value;
74     }
75   }
76   //alert(from + " (" + from.type + "): " + to.name + " => " + to.value);
77 }
78
79 <%init>
80
81 my $conf = new FS::Conf;
82
83 </%init>