[open-ils-commits] r14940 - in trunk/Open-ILS/web: js/dojo/openils js/dojo/openils/circ js/dojo/openils/circ/nls js/ui/default/circ/selfcheck templates/default/circ/selfcheck (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 17 10:45:16 EST 2009


Author: erickson
Date: 2009-11-17 10:45:13 -0500 (Tue, 17 Nov 2009)
New Revision: 14940

Added:
   trunk/Open-ILS/web/js/dojo/openils/circ/
   trunk/Open-ILS/web/js/dojo/openils/circ/nls/
   trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
Modified:
   trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
   trunk/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2
   trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2
Log:

Plugged in the summary data in the sidebar.  Kicked off the nls file



Added: trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js	                        (rev 0)
+++ trunk/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js	2009-11-17 15:45:13 UTC (rev 14940)
@@ -0,0 +1,8 @@
+{
+    'TOTAL_ITEMS_SESSION' : "Total items this session: <b>${0}</b>.",
+    'TOTAL_ITEMS_ACCOUNT' : "Total items on account:  <b>${0}</b>.",
+    'HOLDS_READY_FOR_PICKUP' : "You have <b>${0}</b> item(s) ready for pickup.",
+    'TOTAL_HOLDS' : "You have <b>${0}</b> total holds.",
+    'TOTAL_FINES_ACCOUNT' : "Total fines on account: <b>$${0}</b>."
+}
+

Modified: trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2009-11-17 12:52:56 UTC (rev 14939)
+++ trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js	2009-11-17 15:45:13 UTC (rev 14940)
@@ -3,6 +3,10 @@
 dojo.require('openils.User');
 dojo.require('openils.Event');
 
+dojo.requireLocalization('openils.circ', 'selfcheck');
+var localeStrings = dojo.i18n.getLocalization('openils.circ', 'selfcheck');
+
+
 const SET_BARCODE_REGEX = 'opac.barcode_regex';
 const SET_PATRON_TIMEOUT = 'circ.selfcheck.patron_login_timeout';
 const SET_ALERT_ON_CHECKOUT_EVENT = 'circ.selfcheck.alert_on_checkout_event';
@@ -105,7 +109,6 @@
  * Login the patron.  
  */
 SelfCheckManager.prototype.loginPatron = function(barcode, passwd) {
-    console.log('loginPatron: ' + barcode);
 
     if(this.orgSettings[SET_PATRON_PASSWORD_REQUIRED]) {
 
@@ -168,13 +171,10 @@
         dojo.byId('oils-selfck-scan-text').innerHTML = args.msg;
 
     if(selfckScanBox._lastHandler && (args.handler || args.clearHandler)) {
-        console.log('disconnecting ' + selfckScanBox._lastHandler);
         dojo.disconnect(selfckScanBox._lastHandler);
     }
 
     if(args.handler) {
-        console.log('updating scan box with ['+args.msg+'] and handler ' + args.handler);
-
         selfckScanBox._lastHandler = dojo.connect(
             selfckScanBox, 
             'onKeyDown', 
@@ -205,10 +205,125 @@
     this.circTbody = dojo.byId('oils-selfck-circ-tbody');
     if(!this.circTemplate)
         this.circTemplate = this.circTbody.removeChild(dojo.byId('oils-selfck-circ-row'));
+
+    // items out, holds, and fines summaries
+
+    // fines summary
+    fieldmapper.standardRequest(
+        ['open-ils.actor', 'open-ils.actor.user.fines.summary'],
+        {   async : true,
+            params : [this.authtoken, this.patron.id()],
+            oncomplete : function(r) {
+                var summary = openils.Util.readResponse(r);
+                dojo.byId('oils-selfck-fines-total').innerHTML = 
+                    dojo.string.substitute(
+                        localeStrings.TOTAL_FINES_ACCOUNT, 
+                        [summary.balance_owed()]
+                    );
+            }
+        }
+    );
+
+    // items out summary
+
+    this.updateHoldsSummary();
+    this.updateCircSummary();
 }
 
+SelfCheckManager.prototype.updateHoldsSummary = function(decrement) {
 
 
+    var self = this;
+    var oncomplete = function() {
+        dojo.byId('oils-selfck-holds-total').innerHTML = 
+            dojo.string.substitute(
+                localeStrings.TOTAL_HOLDS, 
+                [self.holdsSummary.total]
+            );
+
+        dojo.byId('oils-selfck-holds-ready').innerHTML = 
+            dojo.string.substitute(
+                localeStrings.HOLDS_READY_FOR_PICKUP, 
+                [self.holdsSummary.ready]
+            );
+    };
+
+    if(!this.holdsSummary) {
+        fieldmapper.standardRequest(
+            ['open-ils.circ', 'open-ils.circ.holds.user_summary'],
+            {   async : true,
+                params : [this.authtoken, this.patron.id()],
+                oncomplete : function(r) {
+                    var summary = openils.Util.readResponse(r);
+                    self.holdsSummary = {};
+                    self.holdsSummary.ready = Number(summary['4']);
+                    self.holdsSummary.total = 0;
+                    for(var i in summary) 
+                        self.holdsSummary.total += Number(summary[i]);
+                    oncomplete();
+                }
+            }
+        );
+    } else {
+
+        if(this.decrement) 
+            this.holdsSummary.ready -= 1;
+    
+        oncomplete();
+    }
+}
+
+
+SelfCheckManager.prototype.updateCircSummary = function(increment) {
+
+    var self = this;
+    var oncomplete = function() {
+        dojo.byId('oils-selfck-circ-account-total').innerHTML = 
+            dojo.string.substitute(
+                localeStrings.TOTAL_ITEMS_ACCOUNT, 
+                [self.circSummary.total]
+            );
+
+        dojo.byId('oils-selfck-circ-session-total').innerHTML = 
+            dojo.string.substitute(
+                localeStrings.TOTAL_ITEMS_SESSION, 
+                [self.circSummary.session]
+            );
+    }
+
+    if(this.circSummary) {
+
+        if(increment) {
+            // local checkout occurred.  Add to the total and the session.
+            this.circSummary.total += 1;
+            this.circSummary.session += 1;
+        }
+
+        oncomplete();
+
+    } else {
+        // fetch the circ summary for the patron
+        var summary = fieldmapper.standardRequest(
+            ['open-ils.actor', 'open-ils.actor.user.checked_out.count'],
+            {
+                async : true,
+                params : [this.authtoken, this.patron.id()],
+                oncomplete : function(r) {
+                    var summary = openils.Util.readResponse(r);
+                    self.circSummary = {
+                        total : Number(summary.out) + Number(summary.overdue),
+                        overdue : Number(summary.overdue),
+                        session : 0
+                    }
+                    oncomplete();
+                }
+            }
+        );
+    }
+}
+
+
+
 /**
  * Check out a single item.  If the item is already checked 
  * out to the patron, redirect to renew()

Modified: trunk/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2	2009-11-17 12:52:56 UTC (rev 14939)
+++ trunk/Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2	2009-11-17 15:45:13 UTC (rev 14940)
@@ -7,7 +7,7 @@
                 <td>Title</td>
                 <td>Author</td>
                 <td>Due Date</td>
-                <td>Renewal Left</td>
+                <td>Renewals Left</td>
                 <td>Type</td>
             </tr>
         </thead>
@@ -31,20 +31,19 @@
 <div id='oils-selfck-circ-info-div'>
     <fieldset>
         <legend>Items Checked Out</legend>
-        <div>
-            <div>Total items this session: FOO</div>
-            <div>Total items on account: BAR</div>
-        </div>
+        <div id='oils-selfck-circ-session-total'></div>
+        <div id='oils-selfck-circ-account-total'></div>
     </fieldset>
     <fieldset>
-        <legend>Holds Ready for Pickup</legend>
-        <div>You have FOO items ready for pickup</div>
-        <div>For mor information, see <a href='foo'>Hold Details</a></div>
+        <legend>Holds</legend>
+        <div id='oils-selfck-holds-ready'></div>
+        <div id='oils-selfck-holds-total'></div>
+        <div><a href=='javascript:void(0);' id='oils-selfck-hold-details-link'>Hold Details</a></div>
     </fieldset>
     <fieldset>
         <legend>Fines</legend>
-        <div>Total fines on account: $FOO</div>
-        <div>Pay fines with <a href='foo'>Credit Card</a></div>
+        <div id='oils-selfck-fines-total'></div>
+        <div><a href='javascript:void(0);' id='oils-selfck-pay-fines-link'>Pay fines</a></div>
     </fieldset>
 </div>
 

Modified: trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2	2009-11-17 12:52:56 UTC (rev 14939)
+++ trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2	2009-11-17 15:45:13 UTC (rev 14940)
@@ -9,9 +9,7 @@
         <img src='[% ctx.media_prefix %]/images/eg_logo.jpg'/>
     </div>
     <div id='oils-selfck-scan-div'>
-        <div id='oils-selfck-scan-text'>
-            Please log in with your library barcode.
-        </div>
+        <div id='oils-selfck-scan-text'></div>
         <input jsId='selfckScanBox' dojoType='dijit.form.TextBox'></input>
     </div>
 </div>



More information about the open-ils-commits mailing list