Initial dev repository
[kcls-web.git] / js / ui / default / acq / search / invoice.js
diff --git a/js/ui/default/acq/search/invoice.js b/js/ui/default/acq/search/invoice.js
new file mode 100644 (file)
index 0000000..a5dc460
--- /dev/null
@@ -0,0 +1,50 @@
+dojo.require('openils.widget.ProgressDialog');
+
+function getInvIdent(rowIndex, item) {
+    if (item) {
+        return {
+            "inv_ident": this.grid.store.getValue(item, "inv_ident") ||
+                this.grid.store.getValue(item, "id"),
+            "id": this.grid.store.getValue(item, "id")
+        };
+    }
+}
+
+function formatInvIdent(inv) {
+    if (inv) {
+        return "<a href='" + oilsBasePath + "/acq/invoice/view/" +
+            inv.id + "'>" + inv.inv_ident + "</a>";
+    }
+}
+
+function printInvoiceVouchers() {
+    var inv_ids = dijit.byId("acq-unified-inv-grid").
+        getSelectedItems().map(function(o) {return o.id[0];});
+
+    progressDialog.show(true);
+
+    var html;
+    if (inv_ids.length) {
+        var win = null;
+        fieldmapper.standardRequest(
+            ["open-ils.acq", "open-ils.acq.invoice.print.html"], {
+                "params": [openils.User.authtoken, inv_ids],
+                "async": true,
+                "onresponse": function(r) {
+                    if (r = openils.Util.readResponse(r)) {
+                        if(!html) {
+                            html = "<style type='text/css'>.acq-invoice-" +
+                                "voucher {page-break-after:always;}" +
+                                "</style>\n";
+                        }
+                        html += r.template_output().data();
+                    }
+                },
+                "oncomplete": function() { 
+                    progressDialog.hide();
+                    openils.Util.printHtmlString(html);
+                }
+            }
+        );
+    }
+}