[freeside-commits] branch master updated. 81ae0992cf8506c6a77485548ebde25eb946a9a9

Mark Wells mark at 420.am
Sat Oct 5 20:04:50 PDT 2013


The branch, master has been updated
       via  81ae0992cf8506c6a77485548ebde25eb946a9a9 (commit)
       via  913b38d717fc7f2fae32722e9f30462fc9344fb3 (commit)
      from  9f26e78e38c70af6d2de28808c119b0e2251fd41 (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 81ae0992cf8506c6a77485548ebde25eb946a9a9
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Oct 5 20:03:53 2013 -0700

    mark advertising source as a required field

diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html
index ebd9b92..e25506f 100644
--- a/httemplate/edit/cust_main/top_misc.html
+++ b/httemplate/edit/cust_main/top_misc.html
@@ -154,9 +154,10 @@
 
 % } else { 
 
-   <& /elements/tr-select-part_referral.html,
-                'curr_value' => $refnum
-   &>
+  <& /elements/tr-select-part_referral.html,
+                'curr_value' => $refnum,
+                'label'      => "<B>${r}".emt('Advertising source')."</B>"
+  &>
 % } 
 
 

commit 913b38d717fc7f2fae32722e9f30462fc9344fb3
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Oct 5 20:03:49 2013 -0700

    restore duplicate customer checking with 3.x locations, #16582

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index baca21d..16bbaad 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4044,7 +4044,7 @@ and customer address. Include units.',
     'type'        => 'select',
     'multiple'    => 1,
     'select_hash' => [ 
-      #'address1' => 'Billing address',
+      'address' => 'Billing or service address',
     ],
   },
 
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index f14f897..182527f 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -610,14 +610,24 @@ sub search {
   ##
   # address
   ##
-  if ( $params->{'address'} =~ /\S/ ) {
-    my $address = dbh->quote('%'. lc($params->{'address'}). '%');
-    push @where, "EXISTS(
-      SELECT 1 FROM cust_location 
-      WHERE cust_location.custnum = cust_main.custnum
-        AND (LOWER(cust_location.address1) LIKE $address OR
-             LOWER(cust_location.address2) LIKE $address)
-    )";
+  if ( $params->{'address'} ) {
+    # allow this to be an arrayref
+    my @values = ($params->{'address'});
+    @values = @{$values[0]} if ref($values[0]);
+    my @orwhere;
+    foreach (grep /\S/, @values) {
+      my $address = dbh->quote('%'. lc($_). '%');
+      push @orwhere,
+        "LOWER(cust_location.address1) LIKE $address",
+        "LOWER(cust_location.address2) LIKE $address";
+    }
+    if (@orwhere) {
+      push @where, "EXISTS(
+        SELECT 1 FROM cust_location 
+        WHERE cust_location.custnum = cust_main.custnum
+          AND (".join(' OR ', at orwhere).")
+        )";
+    }
   }
 
   ##
diff --git a/httemplate/edit/cust_main/bottomfixup.js b/httemplate/edit/cust_main/bottomfixup.js
index 9e18fa0..ecfcb3c 100644
--- a/httemplate/edit/cust_main/bottomfixup.js
+++ b/httemplate/edit/cust_main/bottomfixup.js
@@ -10,17 +10,20 @@ my @fixups = ('copy_payby_fields', 'standardize_locations');
 push @fixups, 'confirm_censustract'
     if $conf->exists('cust_main-require_censustract');
 
-# currently doesn't work; disable to avoid problems
-#push @fixups, 'check_unique'
-#    if $conf->exists('cust_main-check_unique') and !$opt{'custnum'};
+my $uniqueness = $conf->config('cust_main-check_unique');
+push @fixups, 'check_unique'
+    if $uniqueness and !$opt{'custnum'};
 
 push @fixups, 'do_submit'; # always last
 </%init>
-
 var fixups = <% encode_json(\@fixups) %>;
 var fixup_position;
 var running = false;
 
+<&| /elements/onload.js &>
+submit_abort();
+</&>
+
 %# state machine to deal with all the asynchronous stuff we're doing
 %# call this after each fixup on success:
 function submit_continue() {
@@ -132,10 +135,14 @@ function set_censustract(tract, year) {
 }
 
 function check_unique() {
-  var search_hash = new Object;
-% foreach ($conf->config('cust_main-check_unique')) {
-  search_hash['<% $_ %>'] = document.CustomerForm.elements['<% $_ %>'].value;
+  var search_hash = {};
+% if ($uniqueness eq 'address') {
+  search_hash['address'] = [
+    document.CustomerForm.elements['bill_address1'].value,
+    document.CustomerForm.elements['ship_address1'].value
+  ];
 % }
+%# no other options yet
 
 %# supported in IE8+, Firefox 3.5+, WebKit, Opera 10.5+
   duplicates_form(JSON.stringify(search_hash), confirm_unique);
diff --git a/httemplate/misc/xmlhttp-cust_main-duplicates.html b/httemplate/misc/xmlhttp-cust_main-duplicates.html
index 7ee00af..7cd4633 100644
--- a/httemplate/misc/xmlhttp-cust_main-duplicates.html
+++ b/httemplate/misc/xmlhttp-cust_main-duplicates.html
@@ -50,7 +50,9 @@ my $conf = new FS::Conf;
 
 my $sub = $cgi->param('sub');
 my $hashref = decode_json($cgi->param('arg'));
-my @cust_main = qsearch('cust_main', $hashref);
+my $search = FS::cust_main->search($hashref);
+#warn Dumper($search);
+my @cust_main = qsearch( $search );
 
 my $set_to_customer = <<EOF;
   var custnum_array = document.getElementsByName('dup_custnum');

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

Summary of changes:
 FS/FS/Conf.pm                                     |    2 +-
 FS/FS/cust_main/Search.pm                         |   26 ++++++++++++++------
 httemplate/edit/cust_main/bottomfixup.js          |   21 +++++++++++-----
 httemplate/edit/cust_main/top_misc.html           |    7 +++--
 httemplate/misc/xmlhttp-cust_main-duplicates.html |    4 ++-
 5 files changed, 40 insertions(+), 20 deletions(-)




More information about the freeside-commits mailing list