[freeside-commits] branch FREESIDE_3_BRANCH updated. 8caec1039528538d542a941d58374d6045415527

Mark Wells mark at 420.am
Tue Dec 31 17:35:28 PST 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  8caec1039528538d542a941d58374d6045415527 (commit)
       via  20e5319c0f11a51b36c7badf577ddeb4484d678d (commit)
      from  357154e4844983731281c30a666893c60c45748e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8caec1039528538d542a941d58374d6045415527
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Dec 31 17:33:05 2013 -0800

    enable census tract lookup in package order/change and location edit, #26722

diff --git a/httemplate/edit/cust_location.cgi b/httemplate/edit/cust_location.cgi
index 93ce323..774b667 100755
--- a/httemplate/edit/cust_location.cgi
+++ b/httemplate/edit/cust_location.cgi
@@ -19,6 +19,7 @@ ACTION="<% $p %>edit/process/cust_location.cgi" METHOD=POST>
             'form'          => 'EditLocationForm',
             'callback'      => 'document.EditLocationForm.submit();',
             'with_census'   => 1,
+            'with_census_functions' => 1,
 &>
 </TABLE>
 
diff --git a/httemplate/edit/process/change-cust_pkg.html b/httemplate/edit/process/change-cust_pkg.html
index 0d571de..96175e1 100644
--- a/httemplate/edit/process/change-cust_pkg.html
+++ b/httemplate/edit/process/change-cust_pkg.html
@@ -35,7 +35,7 @@ if ( $cgi->param('locationnum') == -1 ) {
   my $cust_location = FS::cust_location->new({
     'custnum' => $cust_pkg->custnum,
     map { $_ => scalar($cgi->param($_)) }
-        qw( address1 address2 city county state zip country )
+        FS::cust_main->location_fields
   });
   $change{'cust_location'} = $cust_location;
 }
diff --git a/httemplate/elements/standardize_locations.js b/httemplate/elements/standardize_locations.js
index 6b06cb4..cea59b8 100644
--- a/httemplate/elements/standardize_locations.js
+++ b/httemplate/elements/standardize_locations.js
@@ -161,14 +161,6 @@ function replace_address() {
     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'];
@@ -304,6 +296,45 @@ function setselect(el, value) {
   }
 
 }
+
+% 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 %>;
+  // this is the existing/confirmed censustract, not the manually entered one
+  if ( form.elements['censustract'].value == '' ||
+       form.elements['censustract'].value != 
+          form.elements['enter_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() {
+          overlib( OLresponseAJAX, CAPTION, 'Confirm censustract', STICKY,
+            AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH,
+            576, HEIGHT, 268, BGCOLOR, '#333399', CGCOLOR, '#333399',
+            TEXTSIZE, 3 );
+        },
+        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 = @_;
@@ -323,5 +354,12 @@ if ($billship) {
 
 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>
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi
index ce83480..5b4a3de 100755
--- a/httemplate/misc/change_pkg.cgi
+++ b/httemplate/misc/change_pkg.cgi
@@ -80,8 +80,10 @@
 
 
 <& /elements/standardize_locations.html,
-            'form'       => "OrderPkgForm",
-            'callback'   => 'document.OrderPkgForm.submit();',
+            'form'        => "OrderPkgForm",
+            'with_census' => 1,
+            'with_census_functions' => 1,
+            'callback'   => 'document.OrderPkgForm.submit()',
 &>
 
 <INPUT NAME    = "submitButton"
diff --git a/httemplate/misc/confirm-censustract.html b/httemplate/misc/confirm-censustract.html
index 6a11617..9e0af49 100644
--- a/httemplate/misc/confirm-censustract.html
+++ b/httemplate/misc/confirm-censustract.html
@@ -61,7 +61,11 @@ warn $cgi->param('q') if $DEBUG;
 my $q = decode_json($cgi->param('q'))
   or die "bad argument '".$cgi->param('q')."'";
 
-my $pre = $q->{'same'} ? 'bill_' : 'ship_';
+my $pre = '';
+if ($q->{billship}) {
+  # this still isn't quite correct
+  $pre = $q->{'same'} ? 'bill_' : 'ship_';
+}
 my %location = (
   map { $_ => $q->{$pre.$_} }
     qw( company address1 address2 city state zip country latitude longitude )
diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html
index 03531bf..b06f962 100644
--- a/httemplate/misc/order_pkg.html
+++ b/httemplate/misc/order_pkg.html
@@ -176,8 +176,9 @@
 
   <& /elements/standardize_locations.html,
                 'form'        => "OrderPkgForm",
-                'callback'    => 'document.OrderPkgForm.submit();',
+                'callback'    => 'document.OrderPkgForm.submit()',
                 'with_census' => 1,
+                'with_census_functions' => 1,
   &>
 
 % }

commit 20e5319c0f11a51b36c7badf577ddeb4484d678d
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Dec 30 16:47:47 2013 -0800

    allow censustract to be entered manually when standardization doesn't provide one, #23497

diff --git a/httemplate/elements/standardize_locations.js b/httemplate/elements/standardize_locations.js
index debd9e7..6b06cb4 100644
--- a/httemplate/elements/standardize_locations.js
+++ b/httemplate/elements/standardize_locations.js
@@ -157,10 +157,18 @@ function replace_address() {
   var clean = newaddr['<% $pre %>addr_clean'] == 'Y';
   var error = newaddr['<% $pre %>error'];
   if ( clean ) {
-%   foreach my $field (qw(address1 address2 city state zip addr_clean censustract)) {
+%   foreach my $field (qw(address1 address2 city state zip addr_clean )) {
     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'];

-----------------------------------------------------------------------

Summary of changes:
 httemplate/edit/cust_location.cgi            |    1 +
 httemplate/edit/process/change-cust_pkg.html |    2 +-
 httemplate/elements/standardize_locations.js |   48 +++++++++++++++++++++++++-
 httemplate/misc/change_pkg.cgi               |    6 ++-
 httemplate/misc/confirm-censustract.html     |    6 +++-
 httemplate/misc/order_pkg.html               |    3 +-
 6 files changed, 60 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list