Plugged in the summary data in the sidebar. Kicked off the nls file
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 17 Nov 2009 15:45:13 +0000 (15:45 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 17 Nov 2009 15:45:13 +0000 (15:45 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14940 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
Open-ILS/web/templates/default/circ/selfcheck/circ_page.tt2
Open-ILS/web/templates/default/circ/selfcheck/main.tt2

diff --git a/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js b/Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
new file mode 100644 (file)
index 0000000..53aab38
--- /dev/null
@@ -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>."
+}
+
index 0921dcd..2405c55 100644 (file)
@@ -3,6 +3,10 @@ dojo.require('openils.Util');
 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 @@ SelfCheckManager.prototype.drawLoginPage = function() {
  * Login the patron.  
  */
 SelfCheckManager.prototype.loginPatron = function(barcode, passwd) {
-    console.log('loginPatron: ' + barcode);
 
     if(this.orgSettings[SET_PATRON_PASSWORD_REQUIRED]) {
 
@@ -168,13 +171,10 @@ SelfCheckManager.prototype.updateScanBox = function(args) {
         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,6 +205,121 @@ SelfCheckManager.prototype.drawCircPage = function() {
     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();
+                }
+            }
+        );
+    }
 }
 
 
index 6461b1a..8c9c3ba 100644 (file)
@@ -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>
 <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>
 
index 1fd3596..abda7c2 100644 (file)
@@ -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>