Invoice link dialog supports multiple lineitems/POs
authorBill Erickson <berick@esilibrary.com>
Mon, 9 Jul 2012 18:45:15 +0000 (14:45 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 24 Jul 2012 17:12:52 +0000 (13:12 -0400)
Adds support to the invoice linking dialog for linking sets of lineitems
or POs instead of just one.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/acq/common/inv_dialog.js

index b76aa97..7a5789e 100644 (file)
@@ -4,8 +4,14 @@ function InvoiceLinkDialogManager(which, target) {
 
     this.linkFoundInvoice = function(r) {
         self.inv = openils.Util.readResponse(r);
-        location.href = oilsBasePath + "/acq/invoice/view/" + self.inv.id() +
-            "?attach_" + self.which + "=" + self.target.id();
+        var path = oilsBasePath + "/acq/invoice/view/" + self.inv.id();
+        if (!dojo.isArray(self.target)) self.target = [self.target];
+        dojo.forEach(self.target, function(target, idx) { 
+            id = (typeof target != 'object') ? target : target.id();
+            var join = (idx == 0) ? '?' : '&';
+            path += join + "attach_" + self.which + "=" + id;
+        });
+        location.href = path;
     };
 
     this.which = which;