1 dojo.require("openils.acq.Lineitem");
2 dojo.require("openils.Util");
3 dojo.require("openils.XUL");
4 dojo.require("openils.CGI");
5 dojo.require("openils.PermaCrud");
6 dojo.require('openils.BibTemplate');
7 dojo.require('fieldmapper.OrgUtils');
16 fieldmapper.standardRequest(
17 ["open-ils.acq", "open-ils.acq.lineitem.retrieve.authoritative"], {
19 "params": [openils.User.authtoken, targetId, {
21 "flesh_li_details": true,
22 "flesh_fund_debit": true,
23 "flesh_cancel_reason": true
25 "oncomplete": function(r) {
26 var li = openils.Util.readResponse(r);
27 fetchBib(li.eg_bib_id());
34 function fetchRelated() {
35 var method = 'open-ils.acq.lineitems_for_bib.by_lineitem_id';
36 if(identTarget == 'bib')
37 var method = 'open-ils.acq.lineitems_for_bib.by_bib_id';
40 fieldmapper.standardRequest(
41 ["open-ils.acq", method], {
43 "params": [openils.User.authtoken, targetId, {
46 "flesh_cancel_reason": true
48 "onresponse": function(r) {
49 var resp = openils.Util.readResponse(r);
53 liTable.addLineitem(resp);
60 function fetchBib(bibId) {
61 bibId = bibId || targetId;
62 new openils.BibTemplate({
64 org_unit : fieldmapper.aou.findOrgUnit(openils.User.user.ws_ou()).shortname()
67 new openils.PermaCrud().retrieve('bre', bibId, {
68 oncomplete : function(r) {
69 bibRecord = openils.Util.readResponse(r);
71 // perhaps we just pull these from the beating heart of bibtemplate
76 function createLi(oncomplete) {
78 progressDialog.show();
80 fieldmapper.standardRequest(
81 ["open-ils.acq", "open-ils.acq.biblio.create_by_id"], {
83 openils.User.authtoken, [bibRecord.id()], {
85 "flesh_cancel_reason": true,
90 "onresponse": function(r) {
91 var li = openils.Util.readResponse(r);
92 if (typeof(li) == "object") {
94 liTable.addLineitem(li);
96 "input[name='selectbox']", liTable._findLiRow(li)
100 "oncomplete": function() {
101 progressDialog.hide();
109 function prepareButtons() {
110 addToPlButton.onClick = createLi(
111 function() { /* oncomplete */
112 acqLitSavePlDialog.show();
115 createPoButton.onClick = createLi(
116 function() { /* oncomplete */
117 liTable._loadPOSelect();
118 acqLitPoCreateDialog.show();
124 var cgi = new openils.CGI();
126 identTarget = cgi.param('target');
127 paramPL = cgi.param('pl');
128 // paramPO = cgi.param('po');
130 if (identTarget == 'bib') {
136 liTable = new AcqLiTable();
138 liTable._isRelatedViewer = true;
144 openils.Util.addOnLoad(load);