plugged in mark-po-received action
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Apr 2009 16:28:02 +0000 (16:28 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Apr 2009 16:28:02 +0000 (16:28 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12800 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/templates/default/acq/common/li_table.tt2

index 6145196..e04faad 100644 (file)
@@ -447,19 +447,22 @@ function AcqLiTable() {
             case 'print_po':
                 this.printPO();
                 break;
+
+            case 'receive_po':
+                this.receivePO();
+                break;
         }
     }
 
     this.printPO = function() {
         if(!this.isPO) return;
-        progressDialog.show();
-        console.log("printing PO " + this.isPO);
+        progressDialogInd.show();
         fieldmapper.standardRequest(
             ['open-ils.acq', 'open-ils.acq.purchase_order.format'],
             {   async: true,
                 params: [this.authtoken, this.isPO, 'html'],
                 oncomplete: function(r) {
-                    progressDialog.hide();
+                    progressDialogInd.hide();
                     var evt = openils.Util.readResponse(r);
                     if(evt && evt.template_output()) {
                         win = window.open('','', 'resizable,width=700,height=500,scrollbars=1');
@@ -470,6 +473,35 @@ function AcqLiTable() {
         );
     }
 
+
+    this.receivePO = function() {
+        if(!this.isPO) return;
+        progressDialog.show();
+        var maximum = 1;
+        dojo.forEach(this.liCache, function(){maximum += 1; });
+        dojo.forEach(this.copyCache, function(){maximum += 1; });
+        fieldmapper.standardRequest(
+            ['open-ils.acq', 'open-ils.acq.purchase_order.receive'],
+            {   async: true,
+                params: [this.authtoken, this.isPO],
+                onresponse : function(r) {
+                    var stat = openils.Util.readResponse(r);
+                    
+                    // we don't know the total amount of items to be processed
+                    // since we only have 1 page of data
+                    if(stat.progress > maximum) maximum *= 2;
+
+                    progressDialog.update({maximum:maximum, progress:stat.progress});
+                    if(stat.complete) {
+                        // XXX
+                        location.href = location.href;
+                    }
+                },
+            }
+        );
+    }
+
+
     this._createPO = function(fields) {
         this.show('acq-lit-create-po-progress');
         var po = new fieldmapper.acqpo();
index f03a536..5bad449 100644 (file)
@@ -19,6 +19,7 @@
                                             <option value='order_ready'>Mark Ready for Order</option>
                                             <option value='create_order'>Create Purchase Order</option>
                                             <option value='print_po'>Print Purchase Order</option>
+                                            <option value='receive_po'>Mark Purchase Order as Received</option>
                                         </select>
                                     </span>
                                     <span id='acq-lit-generic-progress' class='hidden'>
         </table>
     </div>
 
-    <div class='hidden'><div dojoType='openils.widget.ProgressDialog' jsId='progressDialog' indeterminate='true'/></div>
+    <div class='hidden'>
+        <div dojoType='openils.widget.ProgressDialog' jsId='progressDialog'/>
+        <div dojoType='openils.widget.ProgressDialog' jsId='progressDialogInd' indeterminate='true'/>
+    </div>
 
 </div>