selfcheck checkin
authorBill Erickson <berick@esilibrary.com>
Fri, 1 Feb 2013 21:47:10 +0000 (16:47 -0500)
committerBill Erickson <berick@esilibrary.com>
Fri, 1 Feb 2013 21:47:10 +0000 (16:47 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/circ/selfcheck/checkin_page.tt2
Open-ILS/web/js/dojo/openils/Event.js
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js

index ade3d0a..3851b11 100644 (file)
@@ -8,6 +8,7 @@
                 <td>[% l('Author') %]</td>
                 <td>[% l('Due Date') %]</td>
                 <td>[% l('Renewals Left') %]</td>
+                <td>[% l('Status') %]</td>
             </tr>
         </thead>
         <tbody id='oils-selfck-checkin-tbody'>
@@ -18,6 +19,7 @@
                 <td name='author'></td>
                 <td name='due_date'></td>
                 <td name='remaining'></td>
+                <td name='status'></td>
             </tr>
         </tbody>
         <tbody id='oils-selfck-checkin-out-tbody' class='oils-selfck-item-table'></tbody>
index b2bf745..9d518ad 100644 (file)
@@ -30,6 +30,7 @@ if(!dojo._hasResource["openils.Event"]) {
             this.ilsperm = kwargs.ilsperm;
             this.ilspermloc = kwargs.ilspermloc;
             this.note = kwargs.note;
+            this.source = kwargs; // capture anything unexpected
         },
 
         toString : function() {
index 54c4aec..2ce93b4 100644 (file)
@@ -548,6 +548,10 @@ SelfCheckManager.prototype.drawCheckinPage = function() {
 
 SelfCheckManager.prototype.checkin = function(barcode) {
     var self = this;
+
+    // clear the box now so checkins can continue
+    this.updateScanBox();
+
     this.checkinCopy({
         barcode : barcode, 
         onload : function(evts) {
@@ -732,7 +736,7 @@ SelfCheckManager.prototype.updateCircSummary = function(increment) {
 
     if(increment) {
         // local checkout occurred.  Add to the total and the session.
-        this.circSummary.total += 1;
+        this.circSummary.total += 1; // TODO += increment for checkins
         this.circSummary.session += 1;
     }
 
@@ -1053,8 +1057,36 @@ SelfCheckManager.prototype.failPartMessage = function(result) {
     }
 }
 
-SelfCheckManager.prototype.displayCheckin = function(result) {
+SelfCheckManager.prototype.displayCheckin = function(result, statText) {
     console.log('display checkin results ' + result);
+
+    var copy = result.payload.copy;
+    var record = result.payload.record;
+    var circ = result.payload.circ;
+    var row = this.checkinTemplate.cloneNode(true);
+
+    if(record.isbn()) {
+        this.byName(row, 'jacket').setAttribute('src', 
+            '/opac/extras/ac/jacket/small/' + record.isbn());
+    }
+
+    this.byName(row, 'barcode').innerHTML = copy.barcode();
+    this.byName(row, 'title').innerHTML = record.title();
+    this.byName(row, 'author').innerHTML = record.author();
+    this.byName(row, 'status').innerHTML = statText || result.textcode;
+
+    if (circ) {
+        this.byName(row, 'remaining').innerHTML = circ.renewal_remaining();
+        var date = dojo.date.stamp.fromISOString(circ.due_date());
+        this.byName(row, 'due_date').innerHTML = 
+            dojo.date.locale.format(date, {selector : 'date'});
+    }
+
+
+    // put new circs at the top of the list
+    var tbody = this.checkinTbody;
+    tbody.insertBefore(row, tbody.getElementsByTagName('tr')[0]);
+
     this.updateCircSummary();
 }
 
@@ -1065,6 +1097,8 @@ SelfCheckManager.prototype.handleCheckinResult = function(item, result) {
     var payload = result.payload || {};
     var tc = result.textcode;
 
+    console.log('checkin resulted in ' + tc);
+
     if (tc == 'NO_SESSION') {
 
         return this.logoutStaff();
@@ -1080,6 +1114,18 @@ SelfCheckManager.prototype.handleCheckinResult = function(item, result) {
         displayText = 'No change ' + item; // TODO i18n
         this.displayCheckin(result);
 
+    } else if (tc == 'ROUTE_ITEM') {
+
+        var statText;
+        if (result.source.org) {
+            var sn = fieldmapper.aou.findOrgUnit(result.source.org).shortname();
+            displayText = 'Item needs routing to ' + sn; // TODO i18n
+            statText = tc + ' => ' + sn;
+
+        }
+
+        this.displayCheckin(result, statText);
+
     } else if (tc == 'ASSET_COPY_NOT_FOUND') {
 
         displayText = dojo.string.substitute(