LP#1452950 patron reg post code lookup
authorBill Erickson <berickxx@gmail.com>
Mon, 31 Aug 2015 01:34:52 +0000 (21:34 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:31:55 +0000 (17:31 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 4bf4792..2aa6d57 100644 (file)
@@ -61,6 +61,9 @@
 
     [% IF field == 'alert_message' %]
       <textarea class="form-control" ng-model="[% model %]"/>
+    [% ELSIF field == 'post_code' %]
+      <input type="text" ng-blur="post_code_changed(patron.[% path %])"
+        class="form-control" ng-model="[% model %]"/>
     [% ELSE %]
       <input type="[% input_type %]" 
         class="form-control" ng-model="[% model %]"/>
index b676963..09a4e57 100644 (file)
@@ -492,6 +492,19 @@ function PatronRegCtrl($scope, $routeParams,
             }
         });
         $scope.patron.addresses = addresses;
+    } 
+
+    $scope.post_code_changed = function(addr) { 
+        console.log('post code ' + addr.post_code);
+        egCore.net.request(
+            'open-ils.search', 'open-ils.search.zip', addr.post_code)
+        .then(function(resp) {
+            if (!resp) return;
+            if (resp.city) addr.city = resp.city;
+            if (resp.state) addr.state = resp.state;
+            if (resp.county) addr.county = resp.county;
+            if (resp.alert) alert(resp.alert);
+        });
     }
 }