]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/acq/common/inv_dialog.js
Acq: Improved invoice-linking and -viewing features in LI, PO interfaces
[working/Evergreen.git] / Open-ILS / web / js / ui / default / acq / common / inv_dialog.js
1 function InvoiceLinkDialogManager(which, target) {
2     var self = this;
3     this.inv = null;
4
5     this.linkFoundInvoice = function(r) {
6         self.inv = openils.Util.readResponse(r);
7         location.href = oilsBasePath + "/acq/invoice/view/" + self.inv.id() +
8             "?attach_" + self.which + "=" + self.target.id();
9     };
10
11     this.which = which;
12     if (target)
13         this.target = target;
14
15     new openils.widget.AutoFieldWidget({
16         "fmField": "provider",
17         "fmClass": "acqinv",
18         "parentNode": dojo.byId("acq-" + this.which + "-link-invoice-provider"),
19         "orgLimitPerms": ["VIEW_INVOICE"],
20         "forceSync": true
21     }).build();
22
23     dijit.byId("acq-" + this.which + "-link-invoice-link").onClick =
24         function() {
25             self.inv = null;
26             pcrud.search(
27                 "acqinv", {
28                     "provider": dijit.byId(
29                             "acq-" + self.which + "-link-invoice-provider"
30                         ).attr("value"),
31                     "inv_ident":
32                         dijit.byId(
33                             "acq-" + self.which + "-link-invoice-inv_ident"
34                         ).attr("value")
35                 }, {
36                     "async": true,
37                     "streaming": true,
38                     "onresponse": self.linkFoundInvoice,
39                     "oncomplete": function() {
40                         if (!self.inv)
41                             alert(localeStrings.NO_FIND_INVOICE);
42                     }
43                 }
44             );
45         };
46 }