added duplicate phone / address searching. added and started using locale strings...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 13 Jul 2009 19:12:33 +0000 (19:12 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 13 Jul 2009 19:12:33 +0000 (19:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13579 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/actor/nls/register.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/actor/user/register.js
Open-ILS/web/templates/default/actor/user/register.tt2

diff --git a/Open-ILS/web/js/dojo/openils/actor/nls/register.js b/Open-ILS/web/js/dojo/openils/actor/nls/register.js
new file mode 100644 (file)
index 0000000..250c12d
--- /dev/null
@@ -0,0 +1,7 @@
+{
+    DUPE_PATRON_NAME : 'Found ${0} patron(s) with the same name',
+    DUPE_PATRON_EMAIL : 'Found ${0} patron(s) with the same email address',
+    DUPE_PATRON_IDENT : 'Found ${0} patron(s) with the same identification',
+    DUPE_PATRON_PHONE : 'Found ${0} patron(s) with the same phone number',
+    DUPE_PATRON_ADDR : 'Found ${0} patron(s) with the same address'
+}
index bffd23e..f018dac 100644 (file)
@@ -12,6 +12,10 @@ dojo.require('dojo.date');
 dojo.require('openils.CGI');
 dojo.require('openils.XUL');
 
+dojo.requireLocalization('openils.actor', 'register');
+var localeStrings = dojo.i18n.getLocalization('openils.actor', 'register');
+
+
 var pcrud;
 var fmClasses = ['au', 'ac', 'aua', 'actsc', 'asv', 'asvq', 'asva'];
 var fieldDoc = {};
@@ -333,6 +337,13 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
                     function(newVal) { uEditDupeSearch('ident', newVal); });
                 return;
 
+            case 'day_phone':
+            case 'evening_phone':
+            case 'other_phone':
+                dojo.connect(widget.widget, 'onChange',
+                    function(newVal) { uEditDupeSearch('phone', newVal); });
+                return;
+
         }
     }
 
@@ -347,6 +358,7 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
                                 params: [e],
                                 oncomplete : function(r) {
                                     var res = openils.Util.readResponse(r);
+                                    if(!res) return;
                                     var callback = function(w) { return w._addr == widget._addr; };
                                     if(res.city) findWidget('aua', 'city', callback).widget.attr('value', res.city);
                                     if(res.state) findWidget('aua', 'state', callback).widget.attr('value', res.state);
@@ -358,6 +370,24 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
                     }
                 );
                 return;
+
+            case 'street1':
+            case 'street2':
+            case 'city':
+                dojo.connect(widget.widget, 'onChange',
+                    function(e) {
+                        var callback = function(w) { return w._addr == widget._addr; };
+                        var args = {
+                            street1 : findWidget('aua', 'street1', callback).widget.attr('value'),
+                            street2 : findWidget('aua', 'street2', callback).widget.attr('value'),
+                            city : findWidget('aua', 'city', callback).widget.attr('value'),
+                            post_code : findWidget('aua', 'post_code', callback).widget.attr('value')
+                        };
+                        if(args.street1 && args.city && args.post_code)
+                            uEditDupeSearch('address', args); 
+                    }
+                );
+                return;
         }
     }
 }
@@ -386,31 +416,59 @@ function uEditDupeSearch(type, value) {
             openils.Util.hide('uedit-dupe-ident-link');
             search = {ident : {value : value, group : 2}};
             break;
+
+        case 'phone':
+            openils.Util.hide('uedit-dupe-phone-link');
+            search = {phone : {value : value, group : 2}};
+            break;
+
+        case 'address':
+            openils.Util.hide('uedit-dupe-address-link');
+            search = {};
+            dojo.forEach(['street1', 'street2', 'city', 'post_code'],
+                function(field) {
+                    if(value[field])
+                        search[field] = {value : value[field], group: 1};
+                }
+            );
+            break;
     }
 
+    // find possible duplicate patrons
     fieldmapper.standardRequest(
         ['open-ils.actor', 'open-ils.actor.patron.search.advanced'],
         {   async: true,
             params: [openils.User.authtoken, search],
             oncomplete : function(r) {
                 var resp = openils.Util.readResponse(r);
+                resp = resp.filter(function(id) { return (id != patron.id()); });
 
                 if(resp && resp.length > 0) {
+
                     openils.Util.hide('uedit-help-div');
                     openils.Util.show('uedit-dupe-div');
                     var link;
+
                     switch(type) {
                         case 'name':
                             link = dojo.byId('uedit-dupe-names-link');
-                            link.innerHTML = 'Found ' + resp.length + ' patrons with the same name';
+                            link.innerHTML = dojo.string.substitute(localeStrings.DUPE_PATRON_NAME, [resp.length]);
                             break;
                         case 'email':
                             link = dojo.byId('uedit-dupe-email-link');
-                            link.innerHTML = 'Found ' + resp.length + ' patrons with the same email';
+                            link.innerHTML = dojo.string.substitute(localeStrings.DUPE_PATRON_EMAIL, [resp.length]);
                             break;
                         case 'ident':
                             link = dojo.byId('uedit-dupe-ident-link');
-                            link.innerHTML = 'Found ' + resp.length + ' patrosn with the same identification';
+                            link.innerHTML = dojo.string.substitute(localeStrings.DUPE_PATRON_IDENT, [resp.length]);
+                            break;
+                        case 'phone':
+                            link = dojo.byId('uedit-dupe-phone-link');
+                            link.innerHTML = dojo.string.substitute(localeStrings.DUPE_PATRON_PHONE, [resp.length]);
+                            break;
+                        case 'address':
+                            link = dojo.byId('uedit-dupe-address-link');
+                            link.innerHTML = dojo.string.substitute(localeStrings.DUPE_PATRON_ADDR, [resp.length]);
                             break;
                     }
 
index 101cdde..9a1012d 100644 (file)
     <div><a href='javascript:void(0);' id='uedit-dupe-names-link'></a></div>
     <div><a href='javascript:void(0);' id='uedit-dupe-email-link'></a></div>
     <div><a href='javascript:void(0);' id='uedit-dupe-ident-link'></a></div>
+    <div><a href='javascript:void(0);' id='uedit-dupe-phone-link'></a></div>
+    <div><a href='javascript:void(0);' id='uedit-dupe-address-link'></a></div>
 </div>
 
 [% END %]