testing commit, please ignore
[kcls-web.git] / js / ui / default / acq / search / invoice.js
1 dojo.require('openils.widget.ProgressDialog');
2
3 function getInvIdent(rowIndex, item) {
4     if (item) {
5         return {
6             "inv_ident": this.grid.store.getValue(item, "inv_ident") ||
7                 this.grid.store.getValue(item, "id"),
8             "id": this.grid.store.getValue(item, "id")
9         };
10     }
11 }
12
13 function formatInvIdent(inv) {
14     if (inv) {
15         return "<a href='" + oilsBasePath + "/acq/invoice/view/" +
16             inv.id + "'>" + inv.inv_ident + "</a>";
17     }
18 }
19
20 function printInvoiceVouchers() {
21     var inv_ids = dijit.byId("acq-unified-inv-grid").
22         getSelectedItems().map(function(o) {return o.id[0];});
23
24     progressDialog.show(true);
25
26     var html;
27     if (inv_ids.length) {
28         var win = null;
29         fieldmapper.standardRequest(
30             ["open-ils.acq", "open-ils.acq.invoice.print.html"], {
31                 "params": [openils.User.authtoken, inv_ids],
32                 "async": true,
33                 "onresponse": function(r) {
34                     if (r = openils.Util.readResponse(r)) {
35                         if(!html) {
36                             html = "<style type='text/css'>.acq-invoice-" +
37                                 "voucher {page-break-after:always;}" +
38                                 "</style>\n";
39                         }
40                         html += r.template_output().data();
41                     }
42                 },
43                 "oncomplete": function() { 
44                     progressDialog.hide();
45                     openils.Util.printHtmlString(html);
46                 }
47             }
48         );
49     }
50 }