Batch lineitem create / link-to invoice action
authorBill Erickson <berick@esilibrary.com>
Mon, 9 Jul 2012 18:46:41 +0000 (14:46 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 24 Jul 2012 17:12:52 +0000 (13:12 -0400)
In the PO lineitem list page and lineitem search restuls page,  there
are two new actions in the top-level actions selector: "Create Invoice
from Selected Lineitems" and "Link To Invoice for Selected Lineitems".
Both behave the same as create/link invoice for single lineitems, but
now it's possible to select multiple lineitems for invoicing.

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

index 9eb8d35..00c2727 100644 (file)
@@ -32,6 +32,8 @@
                                             <option mask='po' value='rollback_receive_po'>Un-Receive Purchase Order</option>
                                             <option mask='po' value='print_po'>Print Purchase Order</option>
                                             <option mask='po' value='po_history'>View PO History</option>
+                                            <option mask='po' value='batch_create_invoice'>[% l('Create Invoice From Selected Lineitems') %]</option>
+                                            <option mask='po' value='batch_link_invoice'>[% l('Link To Invoice for Selected Lineitems') %]</option>
                                         </select>
                                         <span id="acq-lit-export-attr-holder" class="hidden">
                                             <input dojoType="dijit.form.FilteringSelect" id="acq-lit-export-attr" jsId="acqLitExportAttrSelector" labelAttr="description" searchAttr="description" />
index d0a9d84..6495c87 100644 (file)
@@ -2121,6 +2121,14 @@ function AcqLiTable() {
                 location.href = oilsBasePath + '/acq/po/history/' + this.isPO;
                 break;
 
+            case 'batch_create_invoice':
+                this.batchCreateInvoice();
+                break;
+
+            case 'batch_link_invoice':
+                this.batchLinkInvoice();
+                break;
+
             case 'receive_po':
                 this.receivePO();
                 break;
@@ -2368,8 +2376,26 @@ function AcqLiTable() {
                 }
             }
         );
-    }
+    };
+
+    this.batchCreateInvoice = function() {
+        var liIds = this.getSelected(false, null, true /* id_list */)
+        if (!liIds.length) return;
+        var path = oilsBasePath + '/acq/invoice/view?create=1';
+        dojo.forEach(liIds, function(li, idx) { path += '&attach_li=' + li });
+        location.href = path;
+    };
 
+    this.batchLinkInvoice = function(create) {
+        var liIds = this.getSelected(false, null, true /* id_list */)
+        if (!liIds.length) return;
+        if (!self.invoiceLinkDialogManager) {
+            self.invoiceLinkDialogManager =
+                new InvoiceLinkDialogManager("li");
+        }
+        self.invoiceLinkDialogManager.target = liIds;
+        acqLitLinkInvoiceDialog.show();
+    };
 
     this.receivePO = function() {
         if (!this.isPO) return;