plugged in holds list printing and progress dialog while waiting for template generation
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Dec 2009 21:21:03 +0000 (21:21 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Dec 2009 21:21:03 +0000 (21:21 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15107 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js

index f6b91a5..96e4a80 100644 (file)
@@ -397,7 +397,7 @@ SelfCheckManager.prototype.goToTab = function(name) {
 
     openils.Util.hide('oils-selfck-payment-page');
     openils.Util.hide('oils-selfck-holds-page');
-    openils.Util.show('oils-selfck-circ-page');
+    openils.Util.hide('oils-selfck-circ-page');
     
     switch(name) {
         case 'checkout':
@@ -558,6 +558,8 @@ SelfCheckManager.prototype.drawHolds = function(holds) {
         }
     );
 
+    this.holds = holds;
+
     progressDialog.hide();
 
     for(var i in holds) {
@@ -963,6 +965,8 @@ SelfCheckManager.prototype.printItemsOutReceipt = function(callback) {
 
     if(!this.itemsOut.length) return;
 
+    progressDialog.show(true);
+
     var params = [
         this.authtoken, 
         this.staff.ws_ou(),
@@ -979,6 +983,7 @@ SelfCheckManager.prototype.printItemsOutReceipt = function(callback) {
             async : true,
             params : params,
             oncomplete : function(r) {
+                progressDialog.hide();
                 var resp = openils.Util.readResponse(r);
                 var output = resp.template_output();
                 if(output) {
@@ -996,6 +1001,67 @@ SelfCheckManager.prototype.printItemsOutReceipt = function(callback) {
     );
 }
 
+/**
+ * Print a receipt for this user's items out
+ */
+SelfCheckManager.prototype.printHoldsReceipt = function(callback) {
+
+    if(!this.holds.length) return;
+
+    progressDialog.show(true);
+
+    var holdIds = [];
+    var holdData = [];
+
+    dojo.forEach(this.holds,
+        function(data) {
+            holdIds.push(data.hold.id());
+            if(data.status == 4) {
+                holdData.push({ready : true});
+            } else {
+                holdData.push({
+                    queue_position : data.queue_position, 
+                    potential_copies : data.potential_copies
+                });
+            }
+        }
+    );
+
+    var params = [
+        this.authtoken, 
+        this.staff.ws_ou(),
+        null,
+        'format.selfcheck.holds',
+        'print-on-demand',
+        holdIds,
+        holdData
+    ];
+
+    var self = this;
+    fieldmapper.standardRequest(
+        ['open-ils.circ', 'open-ils.circ.fire_hold_trigger_events'],
+        {   
+            async : true,
+            params : params,
+            oncomplete : function(r) {
+                progressDialog.hide();
+                var resp = openils.Util.readResponse(r);
+                var output = resp.template_output();
+                if(output) {
+                    self.printData(output.data(), self.holds.length, callback); 
+                } else {
+                    var error = resp.error_output();
+                    if(error) {
+                        throw new Error("Error creating receipt: " + error.data());
+                    } else {
+                        throw new Error("No receipt data returned from server");
+                    }
+                }
+            }
+        }
+    );
+}
+