CAT-119 Implement print Holds and Ready for Pick-up
authorVictoria Lewis <vlewis@catalystdevworks.com>
Thu, 30 Mar 2017 21:48:31 +0000 (14:48 -0700)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Implement 'Print List' actions under "Hold" and
"Items Ready For Pickup"

Signed-off-by: Victoria Lewis <vlewis@catalystdevworks.com>
modified:   KCLS/openils/var/templates_kcls/circ/selfcheck/main.tt2
modified:   Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
modified:   Open-ILS/web/js/ui/kcls/circ/selfcheck/selfcheck.js

KCLS/openils/var/templates_kcls/circ/selfcheck/main.tt2
Open-ILS/web/js/dojo/openils/circ/nls/selfcheck.js
Open-ILS/web/js/ui/kcls/circ/selfcheck/selfcheck.js

index 42a1f15..1eb82a1 100644 (file)
@@ -163,10 +163,9 @@ function switchTo(str,subpage) {
                   </tbody>
           </table>
         </div>
-        
-        <div id="step3e" style="display:none;">
+        <div id="step3f" style="display:none;">
           <table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td align="center" style="font-weight:bold;font-size:20px;">Items Ready for Pick-Up</td></tr></table><br />
-          <a href="javascript:;"><img src="[% ctx.media_prefix %]/images/selfcheck/printlist.jpg" alt='print' /></a><br /><br />
+          <a href="javascript:;"onclick="selfCheckMgr.printList('rdyHolds')"><img src="[% ctx.media_prefix %]/images/selfcheck/printlist.jpg" alt='print' /></a><br /><br />
           <table cellpadding="5" cellspacing="0" border="0" class="item_table" width="100%">
                   <tbody id='oils-selfck-rdy-tbody'>
                <tr id='oils-selfck-rdy-row'><td>
@@ -179,9 +178,7 @@ function switchTo(str,subpage) {
             </td></tr>
                   </tbody>
           </table>
-        </div>
-        
-        <div id="step3f" style="display:none;">
+          <br /br>
           <table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td align="center" style="font-weight:bold;font-size:20px;">Holds</td></tr></table><br />
           <a href="javascript:;" onclick="selfCheckMgr.printList('holds')"><img alt='print' src="[% ctx.media_prefix %]/images/selfcheck/printlist.jpg" /></a><br /><br />
           <table cellpadding="5" cellspacing="0" border="0" class="item_table" width="100%">
@@ -206,7 +203,6 @@ function switchTo(str,subpage) {
         <h3>Your Account</h3>
         <p id="sidebar_step3c" style="display:none;">Fines: <span id="acct_fines"></span><br /><a href="javascript:;" id='oils-selfck-view-fines-link'>View Details</a></p>
         <p id="sidebar_step3d">(<span id="oils-selfck-circ-account-total">0) Items</span> Checked Out<br /><a href="javascript:;" id='oils-selfck-items-out-details-link'>View Details</a></p>
-        <p id="sidebar_step3e">(<span id="oils-selfck-holds-ready">0) Items</span> Ready for Pick-Up<br /><a href="javascript:;" onclick="selfCheckMgr.drawHoldsPage();">View Details</a></p>
         <p id="sidebar_step3f">(<span id="oils-selfck-holds-total">0) Items</span> on Hold<br /><a href="javascript:;" id='oils-selfck-hold-details-link'>View Details</a></p>
 
                <div style="padding-left:40px;padding-top:10px;">
index 168a755..a64e88a 100644 (file)
@@ -5,7 +5,7 @@
     "TOTAL_HOLDS" : "You have ${0} total holds.",
     "TOTAL_FINES_ACCOUNT" : "Total fines on account: $${0}.",
     "HOLD_STATUS_READY" : "Ready for pickup",
-    "HOLD_STATUS_WAITING" : "#${0} in line with ${1} copies",
+    "HOLD_STATUS_WAITING" : "#${0} in line",
     "CHECKOUT_SUCCESS" : "Checkout of item ${0} succeeded",
     "RENEW_SUCCESS" : "Renewal of item ${0} succeeded",
     "ALREADY_OUT" : "Item ${0} is already checked out",
index 6b9fcb0..9297caa 100644 (file)
@@ -26,6 +26,8 @@ var selfCheckMgr;
 var itemsOutCirc = [];
 var itemsOutMod = [];
 var itemsOutCopy = [];
+var readyHolds = false;
+var holdsCounter = 0
 
 const SET_BARCODE_REGEX = 'opac.barcode_regex';
 const SET_PATRON_TIMEOUT = 'circ.selfcheck.patron_login_timeout';
@@ -124,6 +126,7 @@ function SelfCheckManager() {
 
     this.checkouts = [];
     this.itemsOut = [];
+    this.holdsArray = [];
 
     // During renewals, keep track of the ID of the previous circulation. 
     // Previous circ is used for tracking failed renewals (for receipts).
@@ -185,7 +188,7 @@ SelfCheckManager.prototype.init = function() {
     var self = this;
     // connect onclick handlers to the various navigation links
     var linkHandlers = {
-        'oils-selfck-hold-details-link' : function() { self.drawHoldsPage(true); },
+        'oils-selfck-hold-details-link' : function() { self.drawHoldsPage(); },
         'oils-selfck-view-fines-link' : function() { self.drawFinesPage(); openils.Util.show('oils-selfck-fines-tbody'); openils.Util.hide('pay_fines'); },
         'oils-selfck-pay-fines-link' : function() {
             switchTo('step3','step3c');
@@ -718,6 +721,11 @@ SelfCheckManager.prototype.printList = function(which) {
         case 'holds':
             this.printHoldsReceipt();
             break;
+        case 'rdyHolds':
+            readyHolds = true;
+            this.printHoldsReceipt();
+            readyHolds = false;
+            break;
         case 'fines':
             this.printFinesReceipt();
             break;
@@ -740,7 +748,6 @@ SelfCheckManager.prototype.updateHoldsSummary = function() {
     }
 
     dojo.byId('oils-selfck-holds-total').innerHTML =dojo.string.substitute("${0}) Item"+(this.holdsSummary.total==1?"":"s"),[this.holdsSummary.total]);
-    dojo.byId('oils-selfck-holds-ready').innerHTML =dojo.string.substitute("${0}) Item"+(this.holdsSummary.ready==1?"":"s"),[this.holdsSummary.ready]);
 }
 
 
@@ -777,23 +784,23 @@ SelfCheckManager.prototype.updateCircSummary = function(increment) {
 }
 
 
-SelfCheckManager.prototype.drawHoldsPage = function(bool) {
-       if(bool) switchTo('step3','step3f'); else switchTo('step3','step3e');
-
+SelfCheckManager.prototype.drawHoldsPage = function() {
+    switchTo('step3','step3f');
     this.holdTbody = dojo.byId('oils-selfck-hold-tbody');
-       this.readyTbody = dojo.byId('oils-selfck-rdy-tbody');
-       if(!this.readyTemplate)
+    this.readyTbody = dojo.byId('oils-selfck-rdy-tbody');
+    if(!this.readyTemplate)
         this.readyTemplate = this.readyTbody.removeChild(dojo.byId('oils-selfck-rdy-row'));
     if(!this.holdTemplate)
         this.holdTemplate = this.holdTbody.removeChild(dojo.byId('oils-selfck-hold-row'));
     while(this.holdTbody.childNodes[0])
         this.holdTbody.removeChild(this.holdTbody.childNodes[0]);
-       while(this.readyTbody.childNodes[0])
+    while(this.readyTbody.childNodes[0])
         this.readyTbody.removeChild(this.readyTbody.childNodes[0]);
 
     progressDialog.show(true);
 
     var self = this;
+    self.holdsArray = [];
     fieldmapper.standardRequest( // fetch the hold IDs
 
         ['open-ils.circ', 'open-ils.circ.holds.id_list.retrieve'],
@@ -814,13 +821,16 @@ SelfCheckManager.prototype.drawHoldsPage = function(bool) {
 
                         onresponse : function(rr) {
                                                        progressDialog.hide(); 
-                            self.drawHolds(openils.Util.readResponse(rr));
+                            self.holdsArray.push(openils.Util.readResponse(rr));
+                            self.drawHolds(self.holdsArray[holdsCounter]);
+                            holdsCounter++;
                         }
                     }
                 );
             }
         }
     );
+    holdsCounter = 0;
 }
 
 /**
@@ -834,7 +844,6 @@ SelfCheckManager.prototype.drawHolds = function(holds) {
        if(!data) return;
        var row = this.holdTemplate.cloneNode(true);
        var row2 = this.readyTemplate.cloneNode(true);
-
        //if(data.mvr.isbn()) {
        //    this.byName(row, 'jacket').setAttribute('src', '/opac/extras/ac/jacket/small/' + data.mvr.isbn());
        //}
@@ -1490,14 +1499,30 @@ SelfCheckManager.prototype.emailSessionReceipt = function(callback) {
  * Print a receipt for this user's items out
  */
 SelfCheckManager.prototype.printHoldsReceipt = function(callback) {
-    if(!this.holds.length) return;
+    if(!this.holdsArray.length) return;
 
     progressDialog.show(true);
 
     var holdIds = [];
     var holdData = [];
+    var rdyForPickup = false;
+
+  if(readyHolds){
+    dojo.forEach(this.holdsArray,
+        function(data) {
+            if(data.status == 4) {
+                holdIds.push(data.hold.id());
+                holdData.push({ready : true});
+                rdyForPickup = true;
+            }
+        }
 
-    dojo.forEach(this.holds,
+    );
+      if (!rdyForPickup){
+            progressDialog.hide();
+            return};
+  } else {
+      dojo.forEach(this.holdsArray,
         function(data) {
             holdIds.push(data.hold.id());
             if(data.status == 4) {
@@ -1509,8 +1534,8 @@ SelfCheckManager.prototype.printHoldsReceipt = function(callback) {
                 });
             }
         }
-    );
-
+      );
+    };
     var params = [
         this.authtoken, 
         this.staff.ws_ou(),
@@ -1532,7 +1557,7 @@ SelfCheckManager.prototype.printHoldsReceipt = function(callback) {
                 var resp = openils.Util.readResponse(r);
                 var output = resp.template_output();
                 if(output) {
-                    self.printData(output.data(), self.holds.length, callback); 
+                    self.printData(output.data(), self.holdsArray.length, callback);
                 } else {
                     var error = resp.error_output();
                     if(error) {