finish merge cleanup
authorMark Wells <mark@freeside.biz>
Thu, 11 Oct 2012 20:35:26 +0000 (13:35 -0700)
committerMark Wells <mark@freeside.biz>
Thu, 11 Oct 2012 20:35:26 +0000 (13:35 -0700)
FS/FS/cust_main/Location.pm
httemplate/edit/cust_main/bottomfixup.js
httemplate/elements/location.html
httemplate/elements/standardize_locations.js

index 8e30bb6..ba3513b 100644 (file)
@@ -18,7 +18,8 @@ BEGIN {
     no strict 'refs';
     @location_fields = 
       qw( address1 address2 city county state zip country district
-        latitude longitude coord_auto censustract censusyear geocode );
+        latitude longitude coord_auto censustract censusyear geocode
+        addr_clean );
 
     foreach my $f (@location_fields) {
       *{"FS::cust_main::Location::$f"} = sub {
index b64f6bd..3a8da23 100644 (file)
@@ -5,7 +5,12 @@ my $conf = new FS::Conf;
 my $company_latitude  = $conf->config('company_latitude');
 my $company_longitude = $conf->config('company_longitude');
 
-my @fixups = ('copy_payby_fields', 'standardize_locations');
+my @fixups = (
+    'copy_if_same',
+    'copy_payby_fields',
+    'standardize_locations',
+    'confirm_censustract'
+    );
 
 push @fixups, 'confirm_censustract';
 
@@ -46,6 +51,29 @@ function do_submit() {
   document.CustomerForm.submit();
 }
 
+%# if "same as billing" is checked, ensure that the invisible ship location
+%# fields are set to the values of the visible fields.
+function copy_if_same() {
+  var cf = document.CustomerForm;
+  if ( cf.same.checked ) {
+    var inputs = new Array(
+        'address1', 'address2', 'location_type', 'location_number', 'zip',
+        'latitude', 'longitude', 'coord_auto', 'geocode',
+        // these are selects, not inputs, but per the spec this still works
+        'city', 'county', 'state', 'country'
+    );
+    for ( var i = 0; i < inputs.length; i++ ) {
+      if ( cf['bill_' + inputs[i]] != undefined ) {
+        // because some of these fields don't always exist
+        cf['ship_' + inputs[i]].value = cf['bill_' + inputs[i]].value;
+      }
+    }
+    cf['ship_addr_clean'].checked = cf['bill_addr_clean'].checked;
+  }
+  // this can't really fail
+  submit_continue();
+}
+
 function copy_payby_fields() {
   var layervars = new Array(
     'payauto', 'billday',
index 4df218b..b91f964 100644 (file)
@@ -139,7 +139,7 @@ Example:
         >
 
 %    #XXX i don't work so well when the dropdown is changed :/  i probably need to be triggered by "default service address"
-%    $alt_err =~ s/(ship_)?address2/'<B>'.encode_entities($object->get($1.'address2')).'<\/B>'/e;
+%    $alt_err =~ s/(.*)?address2/'<B>'.encode_entities($object->get($1.'address2')).'<\/B>'/e;
      <% $alt_err %>
 
     </TD>
@@ -243,7 +243,6 @@ Example:
 <INPUT TYPE="hidden" NAME="old_<%$pre.$_%>" ID="old_<%$pre.$_%>" VALUE="<% $object->get($_) |h%>">
 % }
 %# Placeholders
-<INPUT TYPE="hidden" NAME="<%$pre%>cachenum" VALUE="">
 <INPUT TYPE="hidden" NAME="<%$pre%>addr_clean" VALUE="">
 <%init>
 
index f6564a5..f24eebb 100644 (file)
@@ -17,7 +17,7 @@ function form_address_info() {
     'country':  cf.elements['<% $main_prefix %>country'].value,
 % }
 % if ( $withcensus ) {
-    'ship_censustract': cf.elements['enter_censustract'].value,
+    'ship_censustract': cf.elements['<% $ship_prefix %>enter_censustract'].value,
 % }
     'ship_address1': cf.elements['<% $ship_prefix %>address1'].value,
     'ship_address2': cf.elements['<% $ship_prefix %>address2'].value,
@@ -86,9 +86,9 @@ function standardize_locations() {
     address_standardize(JSON.stringify(address_info), confirm_standardize);
   }
   else {
-    cf.elements['ship_addr_clean'].value = 'Y';
+    cf.elements['<% $ship_prefix %>addr_clean'].value = 'Y';
 %   if ( !$onlyship ) {
-    cf.elements['addr_clean'].value = 'Y';
+    cf.elements['<% $main_prefix %>addr_clean'].value = 'Y';
 %   }
     post_standardization();
   }
@@ -193,8 +193,8 @@ function confirm_manual_address() {
 %# not much to do in this case, just confirm the censustract
 % if ( $withcensus ) {
   var cf = document.<% $formname %>;
-  cf.elements['<% $main_prefix %>censustract'].value =
-  cf.elements['<% $main_prefix %>enter_censustract'].value;
+  cf.elements['<% $ship_prefix %>censustract'].value =
+  cf.elements['<% $ship_prefix %>enter_censustract'].value;
 % }
   post_standardization();
 }
@@ -292,6 +292,7 @@ my $withcensus = 1;
 
 my $formname =  $opt{form} || 'CustomerForm';
 my $onlyship =  $opt{onlyship} || '';
+# this whole "onlyship" thing is kind of backward...
 my $main_prefix =  $opt{main_prefix} || '';
 my $ship_prefix =  $opt{ship_prefix} || ($onlyship ? '' : 'ship_');
 my $taxpre = $main_prefix;