selfcheck checkin: profile, home org, address
authorBill Erickson <berick@esilibrary.com>
Mon, 4 Feb 2013 16:56:53 +0000 (11:56 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 4 Feb 2013 16:56:53 +0000 (11:56 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/circ/selfcheck/banner.tt2
Open-ILS/web/css/skin/default/selfcheck.css
Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js

index cda4866..77a7104 100644 (file)
@@ -1,4 +1,12 @@
-<div id='oils-selfck-user-banner'></div>
+<div id='oils-selfck-user-info'>
+    <div id='oils-selfck-user-banner'></div>
+    <div id='oils-selfck-user-details' class='hidden'>
+        <div id='oils-selfck-user-name'></div>
+        <div id='oils-selfck-user-home-ou'></div>
+        <div id='oils-selfck-user-profile'></div>
+        <div id='oils-selfck-user-address'></div>
+    </div>
+</div>
 <div id='oils-selfck-logo-div'>
     <img src='[% ctx.media_prefix %]/images/eg_logo.jpg'/>
 </div>
index 54185ed..8c0e5d5 100644 (file)
@@ -12,12 +12,16 @@ body {
     font-weight:bold;
 }
 
-#oils-selfck-user-banner {
+#oils-selfck-user-info {
     position:fixed;
     top:30px;
     right:30px;
 }
 
+#oils-selfck-user-details {
+    text-align: left;
+}
+
 #oils-selfck-logo-div {
     margin: 20px;
 }
index 766fcbc..7102c65 100644 (file)
@@ -40,6 +40,7 @@
     "FAIL_PART_no_matchpoint": "System rules do not define how to handle this item",
     "FAIL_PART_no_user": "The system could not find this patron",
     "FAIL_PART_transit_range": "The item cannot transit this far",
-    "PAYMENT_INVALID_USER_XACT_ID" : "We cannot proceed with the payment, because your account was updated from another location.  Please refresh the interface or log out and back in to retrieve the latest account information"
+    "PAYMENT_INVALID_USER_XACT_ID" : "We cannot proceed with the payment, because your account was updated from another location.  Please refresh the interface or log out and back in to retrieve the latest account information",
+    "ADDRESS": "${0} ${1}<br/>${2}, ${3} ${4}",
 }
 
index e0aa9b1..8bb0240 100644 (file)
@@ -97,8 +97,14 @@ SelfCheckManager.prototype.logoutStaff = function() {
     location.href = location.href;
 }
 
-SelfCheckManager.prototype.activateStaffMode = function() {
+SelfCheckManager.prototype.activateStaffMode = function(permorgs) {
+    var self = this;
+
+    // make sure this staff account has the needed permission here
+    if (permorgs.indexOf(Number(this.staff.ws_ou())) == -1) return;
+
     this.staffMode = true;
+
     openils.Util.show(
         dojo.byId('oils-selfck-nav-checkin').parentNode, 
         'inline'
@@ -106,10 +112,9 @@ SelfCheckManager.prototype.activateStaffMode = function() {
 
     openils.Util.show(dojo.byId('oils-selfchk-staff-actions'));
 
-    var self = this;
     dojo.byId('oils-selfchk-staff-logout').onclick = function() {
         self.logoutStaff();
-    }
+    };
 }
 
 
@@ -124,7 +129,8 @@ SelfCheckManager.prototype.init = function() {
 
     // are we in staff mode?
     new openils.User().getPermOrgList(['SELFCHECK_STAFF_MODE'], 
-        function(orglist) { if (orglist.length) self.activateStaffMode() }
+        function(orglist) { self.activateStaffMode(orglist) },
+        true, true
     );
 
     this.circTbody = dojo.byId('oils-selfck-circ-tbody');
@@ -398,7 +404,15 @@ SelfCheckManager.prototype.fetchPatron = function(barcode, usrname) {
     // retrieve the fleshed user by id
     this.patron = fieldmapper.standardRequest(
         ['open-ils.actor', 'open-ils.actor.user.fleshed.retrieve.authoritative'],
-        {params : [this.authtoken, patron_id]}
+        {params : [this.authtoken, patron_id,
+            [   'card',                                                                
+                'cards',
+                'addresses',                                                           
+                'billing_address',                                                     
+                'mailing_address',  
+                'profile'
+            ]
+        ]}
     );
 
     var evt = openils.Event.parse(this.patron);
@@ -426,13 +440,57 @@ SelfCheckManager.prototype.fetchPatron = function(barcode, usrname) {
     } else {
 
         this.handleAlert('', false, 'login-success');
-        dojo.byId('oils-selfck-user-banner').innerHTML = 
-            dojo.string.substitute(localeStrings.WELCOME_BANNER, [this.patron.first_given_name()]);
+
+        if (this.staffMode) {
+            this.drawPatronInfo();
+
+        } else {
+            dojo.byId('oils-selfck-user-banner').innerHTML = 
+                dojo.string.substitute(localeStrings.WELCOME_BANNER, 
+                    [this.patron.first_given_name()]);
+        }
+
+
         this.drawCircPage();
     }
 }
 
 
+SelfCheckManager.prototype.drawPatronInfo = function() {
+
+    openils.Util.show('oils-selfck-user-details');
+
+    var patron = this.patron;
+
+    dojo.byId('oils-selfck-user-name').innerHTML = 
+        openils.User.formalName(patron);
+
+    dojo.byId('oils-selfck-user-home-ou').innerHTML = 
+        fieldmapper.aou.findOrgUnit(patron.home_ou()).shortname();
+
+    dojo.byId('oils-selfck-user-profile').innerHTML = 
+        patron.profile().name();
+
+    var addr = patron.mailing_address() || 
+               patron.billing_address() || 
+               patron.addresses()[0];
+
+    if (addr) {
+
+        dojo.byId('oils-selfck-user-address').innerHTML = 
+            dojo.string.substitute(localeStrings.ADDRESS, [
+                addr.street1(),
+                addr.street2() || '',
+                addr.city(),
+                addr.state(),
+                addr.post_code()
+            ]);
+
+    } else {
+        dojo.byId('oils-selfck-user-address').innerHTML = '';
+    }
+}
+
 SelfCheckManager.prototype.handleAlert = function(message, shouldPopup, sound) {
 
     console.log("Handling alert " + message);