1 dojo.require('dojo.date.locale');
2 dojo.require('dojo.date.stamp');
3 dojo.require('dijit.form.Button');
4 dojo.require('dijit.form.TextBox');
5 dojo.require('dijit.form.FilteringSelect');
6 dojo.require('dijit.form.Textarea');
7 dojo.require('dijit.ProgressBar');
8 dojo.require('openils.User');
9 dojo.require('openils.Util');
10 dojo.require('openils.acq.Lineitem');
11 dojo.require('openils.acq.PO');
12 dojo.require('openils.acq.Picklist');
13 dojo.require('openils.widget.AutoFieldWidget');
14 dojo.require('dojo.data.ItemFileReadStore');
15 dojo.require('openils.widget.ProgressDialog');
16 dojo.require('openils.PermaCrud');
17 dojo.require('openils.XUL');
19 dojo.requireLocalization('openils.acq', 'acq');
20 var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
21 const XUL_OPAC_WRAPPER = 'chrome://open_ils_staff_client/content/cat/opac.xul';
23 function AcqLiTable() {
27 this.toggleState = false;
28 this.tbody = dojo.byId('acq-lit-tbody');
30 this.authtoken = openils.User.authtoken;
31 this.rowTemplate = this.tbody.removeChild(dojo.byId('acq-lit-row'));
32 this.copyTbody = dojo.byId('acq-lit-li-details-tbody');
33 this.copyRow = this.copyTbody.removeChild(dojo.byId('acq-lit-li-details-row'));
34 this.copyBatchRow = dojo.byId('acq-lit-li-details-batch-row');
35 this.copyBatchWidgets = {};
36 this.liNotesTbody = dojo.byId('acq-lit-notes-tbody');
37 this.liNotesRow = this.liNotesTbody.removeChild(dojo.byId('acq-lit-notes-row'));
39 dojo.connect(acqLitLiActionsSelector, 'onChange',
41 self.applySelectedLiAction(this.attr('value'))
42 acqLitLiActionsSelector.attr('value', '_');
45 acqLitCreatePoSubmit.onClick = function() {
46 acqLitPoCreateDialog.hide();
47 self._createPO(acqLitPoCreateDialog.getValues());
50 acqLitSavePlButton.onClick = function() {
51 acqLitSavePlDialog.hide();
52 self._savePl(acqLitSavePlDialog.getValues());
55 //dojo.byId('acq-lit-notes-new-button').onclick = function(){acqLitCreateLiNoteDialog.show();}
57 dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()};
58 dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')};
59 dojo.byId('acq-lit-copies-back-button').onclick = function(){self.show('list')};
60 dojo.byId('acq-lit-notes-back-button').onclick = function(){self.show('list')};
62 this.reset = function() {
63 while(self.tbody.childNodes[0])
64 self.tbody.removeChild(self.tbody.childNodes[0]);
68 this.setNext = function(handler) {
69 var link = dojo.byId('acq-lit-next');
71 dojo.style(link, 'visibility', 'visible');
72 link.onclick = handler;
74 dojo.style(link, 'visibility', 'hidden');
78 this.setPrev = function(handler) {
79 var link = dojo.byId('acq-lit-prev');
81 dojo.style(link, 'visibility', 'visible');
82 link.onclick = handler;
84 dojo.style(link, 'visibility', 'hidden');
88 this.show = function(div) {
89 openils.Util.hide('acq-lit-table-div');
90 openils.Util.hide('acq-lit-info-div');
91 openils.Util.hide('acq-lit-li-details');
92 openils.Util.hide('acq-lit-notes-div');
95 openils.Util.show('acq-lit-table-div');
98 openils.Util.show('acq-lit-info-div');
101 openils.Util.show('acq-lit-li-details');
104 openils.Util.show('acq-lit-notes-div');
108 openils.Util.show(div);
112 this.hide = function() {
116 this.toggleSelect = function() {
118 dojo.forEach(self.selectors, function(i){i.checked = false});
120 dojo.forEach(self.selectors, function(i){i.checked = true});
121 self.toggleState = !self.toggleState;
125 /** @param all If true, assume all are selected */
126 this.getSelected = function(all) {
128 dojo.forEach(self.selectors,
131 selected.push(self.liCache[i.parentNode.parentNode.getAttribute('li')]);
137 this.setRowAttr = function(td, liWrapper, field, type) {
138 var val = liWrapper.findAttr(field, type || 'lineitem_marc_attr_definition') || '';
139 td.appendChild(document.createTextNode(val));
142 this.addLineitem = function(li) {
143 this.liCache[li.id()] = li;
145 // sort the lineitem notes on edit_time
146 if(!li.lineitem_notes()) li.lineitem_notes([]);
148 var liWrapper = new openils.acq.Lineitem({lineitem:li});
149 var row = self.rowTemplate.cloneNode(true);
150 row.setAttribute('li', li.id());
151 var tds = dojo.query('[attr]', row);
152 dojo.forEach(tds, function(td) {self.setRowAttr(td, liWrapper, td.getAttribute('attr'), td.getAttribute('attr_type'));});
153 dojo.query('[name=source_label]', row)[0].appendChild(document.createTextNode(li.source_label()));
155 var isbn = liWrapper.findAttr('isbn', 'lineitem_marc_attr_definition');
157 // XXX media prefix for added content
158 dojo.query('[name=jacket]', row)[0].setAttribute('src', '/opac/extras/ac/jacket/small/' + isbn);
161 dojo.query('[attr=title]', row)[0].onclick = function() {self.drawInfo(li.id())};
162 dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())};
163 dojo.query('[name=count]', row)[0].innerHTML = li.item_count() || 0;
164 dojo.query('[name=notes_count]', row)[0].innerHTML = li.lineitem_notes().length;
165 dojo.query('[name=noteslink]', row)[0].onclick = function() {self.drawLiNotes(li)};
167 var priceInput = dojo.query('[name=price]', row)[0];
168 var priceData = liWrapper.getPrice();
169 priceInput.value = (priceData) ? priceData.price : '';
170 priceInput.onchange = function() { self.updateLiPrice(priceInput, li) };
172 var recv_link = dojo.query('[name=receive_link]', row)[0];
173 if(li.state() == 'received') {
174 openils.Util.hide(recv_link)
176 recv_link.onclick = function() {
178 openils.Util.hide(recv_link)
182 self.tbody.appendChild(row);
183 self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
186 this.drawLiNotes = function(li) {
190 li.lineitem_notes().sort(
192 if(a.edit_time() < b.edit_time()) return 1;
198 while(this.liNotesTbody.childNodes[0])
199 this.liNotesTbody.removeChild(this.liNotesTbody.childNodes[0]);
202 acqLitCreateLiNoteSubmit.onClick = function() {
203 var value = acqLitCreateNoteText.attr('value');
205 var note = new fieldmapper.acqlin();
208 note.lineitem(li.id());
209 self.updateLiNotes(li, note);
212 dojo.byId('acq-lit-notes-save-button').onclick = function() {
213 self.updateLiNotes(li);
216 dojo.forEach(li.lineitem_notes(), function(note) { self.addLiNote(li, note) });
219 this.addLiNote = function(li, note) {
220 if(note.isdeleted()) return;
222 var row = self.liNotesRow.cloneNode(true);
223 dojo.query('[name=value]', row)[0].innerHTML = note.value();
225 dojo.query('[name=delete]', row)[0].onclick = function() {
226 note.isdeleted(true);
227 self.liNotesTbody.removeChild(row);
230 if(note.edit_time()) {
231 dojo.query('[name=edit_time]', row)[0].innerHTML =
232 dojo.date.locale.format(
233 dojo.date.stamp.fromISOString(note.edit_time()),
234 {formatLength:'short'});
237 self.liNotesTbody.appendChild(row);
240 this.updateLiNotes = function(li, newNote) {
246 notes = li.lineitem_notes().filter(
248 if(note.ischanged() || note.isnew() || note.isdeleted())
254 if(notes.length == 0) return;
255 progressDialog.show();
257 fieldmapper.standardRequest(
258 ['open-ils.acq', 'open-ils.acq.lineitem_note.cud.batch'],
260 params : [this.authtoken, notes],
261 onresponse : function(r) {
262 var resp = openils.Util.readResponse(r);
267 // remove the old changed notes
269 dojo.forEach(li.lineitem_notes(),
271 if(!(note.ischanged() || note.isnew() || note.isdeleted()))
275 li.lineitem_notes(list);
278 progressDialog.hide();
279 self.drawLiNotes(li);
283 progressDialog.update(resp);
284 var newnote = resp.note;
286 if(!newnote.isdeleted()) {
287 newnote.isnew(false);
288 newnote.ischanged(false);
289 li.lineitem_notes().push(newnote);
296 this.updateLiPrice = function(input, li) {
298 var price = input.value;
299 var liWrapper = new openils.acq.Lineitem({lineitem:li});
300 var oldPrice = liWrapper.getPrice() || null;
302 if(oldPrice) oldPrice = oldPrice.price;
303 if(price == oldPrice) return;
305 fieldmapper.standardRequest(
306 ['open-ils.acq', 'open-ils.acq.lineitem.price.set'],
308 params : [this.authtoken, li.id(), price],
309 oncomplete : function(r) {
310 openils.Util.readResponse(r);
316 this.removeLineitem = function(liId) {
317 this.tbody.removeChild(dojo.query('[li='+liId+']', this.tbody)[0]);
318 delete this.liCache[liId];
321 this.drawInfo = function(liId) {
323 openils.acq.Lineitem.fetchAttrDefs(
325 self._fetchLineitem(liId, function(li){self._drawInfo(li);});
330 this._fetchLineitem = function(liId, handler) {
332 var li = this.liCache[liId];
333 if(li && li.marc() && li.lineitem_details())
336 fieldmapper.standardRequest(
337 ['open-ils.acq', 'open-ils.acq.lineitem.retrieve'],
340 params: [self.authtoken, liId, {
342 flesh_li_details: true,
343 flesh_fund_debit: true }],
345 oncomplete: function(r) {
346 var li = openils.Util.readResponse(r);
353 this._drawInfo = function(li) {
355 acqLitEditOrderMarc.onClick = function() { self.editOrderMarc(li); }
356 acqLitEditILSMarc.onClick = function() { self.editILSMarc(li); }
359 openils.Util.hide('acq-lit-marc-order-record-label');
360 openils.Util.hide(acqLitEditOrderMarc.domNode);
361 openils.Util.show('acq-lit-marc-real-record-label');
362 openils.Util.show(acqLitEditILSMarc.domNode);
364 openils.Util.show('acq-lit-marc-order-record-label');
365 openils.Util.show(acqLitEditOrderMarc.domNode);
366 openils.Util.hide('acq-lit-marc-real-record-label');
367 openils.Util.hide(acqLitEditILSMarc.domNode);
370 this.drawMarcHTML(li);
371 this.infoTbody = dojo.byId('acq-lit-info-tbody');
374 this.infoRow = this.infoTbody.removeChild(dojo.byId('acq-lit-info-row'));
375 while(this.infoTbody.childNodes[0])
376 this.infoTbody.removeChild(this.infoTbody.childNodes[0]);
378 for(var i = 0; i < li.attributes().length; i++) {
379 var attr = li.attributes()[i];
380 var row = this.infoRow.cloneNode(true);
382 var type = attr.attr_type().replace(/lineitem_(.*)_attr_definition/, '$1');
383 var name = openils.acq.Lineitem.attrDefs[type].filter(
385 return (a.code() == attr.attr_name());
387 ).pop().description();
389 dojo.query('[name=label]', row)[0].appendChild(document.createTextNode(name));
390 dojo.query('[name=value]', row)[0].appendChild(document.createTextNode(attr.attr_value()));
391 this.infoTbody.appendChild(row);
395 openils.Util.show('acq-lit-info-cat-link');
396 var link = dojo.byId('acq-lit-info-cat-link').getElementsByTagName('a')[0];
398 if(openils.XUL.isXUL()) {
400 var makeRecTab = function() {
403 {tab_name: localeStrings.XUL_RECORD_DETAIL_PAGE, browser:false},
406 show_nav_buttons : true,
407 show_print_button : true,
408 opac_url : xulG.url_prefix(xulG.urls.opac_rdetail + '?r=' + li.eg_bib_id())
412 link.setAttribute('href', 'javascript:void(0);');
413 link.onclick = makeRecTab;
416 var href = link.getAttribute('href');
418 link.setAttribute('href', href + li.eg_bib_id());
421 openils.Util.hide('acq-lit-info-cat-link');
425 this.drawMarcHTML = function(li) {
426 var params = [null, true, li.marc()];
428 params = [li.eg_bib_id(), true];
430 fieldmapper.standardRequest(
431 ['open-ils.search', 'open-ils.search.biblio.record.html'],
434 oncomplete: function(r) {
435 dojo.byId('acq-lit-marc-div').innerHTML =
436 openils.Util.readResponse(r);
442 if(this.canEditILSMarc === true) {
443 acqLitEditILSMarc.attr('disabled', false);
445 if(this.canEditILSMarc === false) {
446 acqLitEditILSMarc.attr('disabled', true);
449 new openils.User().getPermOrgList('UPDATE_RECORD',
451 if(list.length > 0) {
452 self.canEditILSMarc = true;
453 acqLitEditILSMarc.attr('disabled', false);
455 self.canEditILSMarc = false;
456 acqLitEditILSMarc.attr('disabled', true);
465 this.drawCopies = function(liId) {
469 this.copyWidgetCache = {};
471 acqLitSaveCopies.onClick = function() { self.saveCopyChanges(liId) };
472 acqLitBatchUpdateCopies.onClick = function() { self.batchCopyUpdate() };
474 while(this.copyTbody.childNodes[0])
475 this.copyTbody.removeChild(this.copyTbody.childNodes[0]);
477 this._drawBatchCopyWidgets();
479 this._fetchDistribFormulas(
481 openils.acq.Lineitem.fetchAttrDefs(
483 self._fetchLineitem(liId, function(li){self._drawCopies(li);});
490 this._fetchDistribFormulas = function(onload) {
491 if(this.distribForms) {
495 fieldmapper.standardRequest(
496 ['open-ils.acq', 'open-ils.acq.distribution_formula.ranged.retrieve.atomic'],
498 params: [openils.User.authtoken],
499 oncomplete: function(r) {
500 self.distribForms = openils.Util.readResponse(r);
501 self.distribFormulaStore =
502 new dojo.data.ItemFileReadStore(
503 {data:acqdf.toStoreData(self.distribForms)});
511 this._drawBatchCopyWidgets = function() {
512 var row = this.copyBatchRow;
513 dojo.forEach(['fund', 'owning_lib', 'location', 'circ_modifier', 'cn_label'],
515 if(self.copyBatchRowDrawn) {
516 self.copyBatchWidgets[field].attr('value', null);
518 var widget = new openils.widget.AutoFieldWidget({
521 parentNode : dojo.query('[name='+field+']', row)[0],
522 orgLimitPerms : ['CREATE_PICKLIST'],
523 dijitArgs : {required:false}
526 self.copyBatchWidgets[field] = widget.widget;
530 this.copyBatchRowDrawn = true;
533 this.batchCopyUpdate = function() {
535 var fields = ['fund', 'owning_lib', 'location', 'circ_modifier', 'cn_label'];
536 for(var k in this.copyWidgetCache) {
537 var cache = this.copyWidgetCache[k];
538 dojo.forEach(fields, function(f) {
539 var newval = self.copyBatchWidgets[f].attr('value');
540 if(newval) cache[f].attr('value', newval);
545 this._drawCopies = function(li) {
546 acqLitAddCopyCount.onClick = function() {
547 var count = acqLitCopyCountInput.attr('value');
548 for(var i = 0; i < count; i++)
551 if(li.lineitem_details().length > 0) {
552 dojo.forEach(li.lineitem_details(),
554 self.addCopy(li, copy);
562 this.virtCopyId = -1;
563 this.addCopy = function(li, copy) {
564 var row = this.copyRow.cloneNode(true);
565 this.copyTbody.appendChild(row);
569 copy = new fieldmapper.acqlid();
571 copy.id(this.virtCopyId--);
572 copy.lineitem(li.id());
575 this.copyCache[copy.id()] = copy;
576 row.setAttribute('copy_id', copy.id());
577 self.copyWidgetCache[copy.id()] = {};
579 dojo.forEach(['fund', 'owning_lib', 'location', 'barcode', 'cn_label', 'circ_modifier', 'note'],
581 var widget = new openils.widget.AutoFieldWidget({
585 parentNode : dojo.query('[name='+field+']', row)[0],
586 orgLimitPerms : ['CREATE_PICKLIST'],
590 // make sure we capture the value from any async widgets
591 function(w, ww) { copy[field](ww.getFormattedValue()) }
593 dojo.connect(widget.widget, 'onChange',
595 if(copy.isnew() || val != copy[field]()) {
596 // prevent setting ischanged() automatically on widget load for existing copies
597 copy[field](widget.getFormattedValue())
598 copy.ischanged(true);
602 self.copyWidgetCache[copy.id()][field] = widget.widget;
606 var recv_link = dojo.query('[name=receive]', row)[0];
607 if(copy.recv_time()) {
608 openils.Util.hide(recv_link);
610 recv_link.onclick = function() {
611 self.receiveLid(copy);
612 openils.Util.hide(recv_link);
617 openils.Util.hide(dojo.query('[name=delete]', row)[0].parentNode);
619 dojo.query('[name=delete]', row)[0].onclick =
620 function() { self.deleteCopy(row) };
624 this.deleteCopy = function(row) {
625 var copy = this.copyCache[row.getAttribute('copy_id')];
626 copy.isdeleted(true);
628 delete this.copyCache[copy.id()];
629 this.copyTbody.removeChild(row);
632 this.saveCopyChanges = function(liId) {
636 openils.Util.show('acq-lit-update-copies-progress');
638 for(var id in this.copyCache) {
639 var c = this.copyCache[id];
640 if(c.isnew() || c.ischanged() || c.isdeleted()) {
641 if(c.id() < 0) c.id(null);
646 if(copies.length == 0)
649 fieldmapper.standardRequest(
650 ['open-ils.acq', 'open-ils.acq.lineitem_detail.cud.batch'],
652 params: [openils.User.authtoken, copies],
653 onresponse: function(r) {
654 var res = openils.Util.readResponse(r);
655 litUpdateCopiesProgress.update(res);
657 oncomplete: function() {
658 openils.Util.hide('acq-lit-update-copies-progress');
659 self.drawCopies(liId);
665 this.applySelectedLiAction = function(action) {
669 case 'delete_selected':
670 this._deleteLiList(self.getSelected());
675 if(!this.createPoProviderSelector) {
676 var widget = new openils.widget.AutoFieldWidget({
677 fmField : 'provider',
679 parentNode : dojo.byId('acq-lit-po-provider'),
680 orgLimitPerms : ['CREATE_PURCHASE_ORDER'],
683 function(w) { self.createPoProviderSelector = w; }
687 acqLitPoCreateDialog.show();
690 case 'save_picklist':
691 this._loadPLSelect();
692 acqLitSavePlDialog.show();
703 case 'rollback_receive_po':
704 this.rollbackPoReceive();
707 case 'create_assets':
713 this.createAssets = function() {
714 if(!this.isPO) return;
715 if(!confirm(localeStrings.CREATE_PO_ASSETS_CONFIRM)) return;
716 this.show('acq-lit-progress-numbers');
718 fieldmapper.standardRequest(
719 ['open-ils.acq', 'open-ils.acq.purchase_order.assets.create'],
721 params: [this.authtoken, this.isPO],
722 onresponse: function(r) {
723 var resp = openils.Util.readResponse(r);
724 self._updateProgressNumbers(resp, true);
730 this.printPO = function() {
731 if(!this.isPO) return;
732 progressDialog.show(true);
733 fieldmapper.standardRequest(
734 ['open-ils.acq', 'open-ils.acq.purchase_order.format'],
736 params: [this.authtoken, this.isPO, 'html'],
737 oncomplete: function(r) {
738 progressDialog.hide();
739 var evt = openils.Util.readResponse(r);
740 if(evt && evt.template_output()) {
741 win = window.open('','', 'resizable,width=800,height=600,scrollbars=1');
742 win.document.body.innerHTML = evt.template_output().data();
750 this.receivePO = function() {
751 if(!this.isPO) return;
752 this.show('acq-lit-progress-numbers');
754 fieldmapper.standardRequest(
755 ['open-ils.acq', 'open-ils.acq.purchase_order.receive'],
757 params: [this.authtoken, this.isPO],
758 onresponse : function(r) {
759 var resp = openils.Util.readResponse(r);
760 self._updateProgressNumbers(resp, true);
766 this.receiveLi = function(li) {
767 if(!this.isPO) return;
768 progressDialog.show(true);
769 fieldmapper.standardRequest(
770 ['open-ils.acq', 'open-ils.acq.lineitem.receive'],
772 params: [this.authtoken, li.id()],
773 onresponse : function(r) {
774 var resp = openils.Util.readResponse(r);
775 progressDialog.hide();
781 this.receiveLid = function(li) {
782 if(!this.isPO) return;
783 progressDialog.show(true);
784 fieldmapper.standardRequest(
785 ['open-ils.acq', 'open-ils.acq.lineitem_detail.receive'],
787 params: [this.authtoken, li.id()],
788 onresponse : function(r) {
789 var resp = openils.Util.readResponse(r);
790 progressDialog.hide();
796 this.rollbackPoReceive = function() {
797 if(!this.isPO) return;
798 if(!confirm(localeStrings.ROLLBACK_PO_RECEIVE_CONFIRM)) return;
799 this.show('acq-lit-progress-numbers');
801 fieldmapper.standardRequest(
802 ['open-ils.acq', 'open-ils.acq.purchase_order.receive.rollback'],
804 params: [this.authtoken, this.isPO],
805 onresponse : function(r) {
806 var resp = openils.Util.readResponse(r);
807 self._updateProgressNumbers(resp, true);
813 this._updateProgressNumbers = function(resp, reloadOnComplete) {
815 dojo.byId('acq-pl-lit-li-processed').innerHTML = resp.li;
816 dojo.byId('acq-pl-lit-lid-processed').innerHTML = resp.lid;
817 dojo.byId('acq-pl-lit-debits-processed').innerHTML = resp.debits_accrued;
818 dojo.byId('acq-pl-lit-bibs-processed').innerHTML = resp.bibs;
819 dojo.byId('acq-pl-lit-indexed-processed').innerHTML = resp.indexed;
820 dojo.byId('acq-pl-lit-copies-processed').innerHTML = resp.copies;
821 if(resp.complete && reloadOnComplete)
822 location.href = location.href;
826 this._createPO = function(fields) {
827 this.show('acq-lit-progress-numbers');
828 var po = new fieldmapper.acqpo();
829 po.provider(this.createPoProviderSelector.attr('value'));
831 var selected = this.getSelected( (fields.create_from == 'all') );
832 if(selected.length == 0) return;
834 var max = selected.length * 3;
837 fieldmapper.standardRequest(
838 ['open-ils.acq', 'open-ils.acq.purchase_order.create'],
841 openils.User.authtoken,
844 lineitems : selected.map(function(li) { return li.id() }),
845 create_assets : fields.create_assets[0],
849 onresponse : function(r) {
850 var resp = openils.Util.readResponse(r);
851 self._updateProgressNumbers(resp);
853 location.href = oilsBasePath + '/eg/acq/po/view/' + resp.purchase_order.id();
859 this._deleteLiList = function(list, idx) {
860 if(idx == null) idx = 0;
861 if(idx >= list.length) return;
862 var liId = list[idx].id();
863 fieldmapper.standardRequest(
864 ['open-ils.acq', 'open-ils.acq.lineitem.delete'],
866 params: [openils.User.authtoken, liId],
867 oncomplete: function(r) {
868 self.removeLineitem(liId);
869 self._deleteLiList(list, ++idx);
875 this.editOrderMarc = function(li) {
877 /* To run in Firefox directly, must set signed.applets.codebase_principal_support
878 to true in about:config */
880 if(!openils.XUL.enableXPConnect()) return;
881 win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
885 record : {marc : li.marc()},
887 label: 'Save Record', // XXX I18N
888 func: function(xmlString) {
890 fieldmapper.standardRequest(
891 ['open-ils.acq', 'open-ils.acq.lineitem.update'],
893 params: [openils.User.authtoken, li],
894 oncomplete: function(r) {
895 openils.Util.readResponse(r);
897 self.drawInfo(li.id())
907 this.editILSMarc = function(li) {
909 /* To run in Firefox directly, must set signed.applets.codebase_principal_support
910 to true in about:config */
912 if(!openils.XUL.enableXPConnect()) return;
913 win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
915 var bib = new openils.PermaCrud().retrieve('bre', li.eg_bib_id());
919 record : {marc : li.marc()},
921 label: 'Save Record', // XXX I18N
922 func: function(xmlString) {
924 fieldmapper.standardRequest(
925 ['open-ils.cat', 'open-ils.cat.biblio.record_entry.update'],
927 params: [openils.User.authtoken, bib],
928 oncomplete: function(r) {
929 openils.Util.readResponse(r);
931 self.drawInfo(li.id())
940 this._savePl = function(values) {
942 var selected = this.getSelected( (values.which == 'all') );
943 openils.Util.show('acq-lit-generic-progress');
945 if(values.new_name) {
946 openils.acq.Picklist.create(
947 {name: values.new_name},
949 self._updateLiList(id, selected, 0,
951 location.href = oilsBasePath + '/eg/acq/picklist/view/' + id;
955 } else if(values.existing_pl) {
956 // update lineitems to use an existing picklist
957 self._updateLiList(values.existing_pl, selected, 0,
959 location.href = oilsBasePath + '/eg/acq/picklist/view/' + values.existing_pl;
964 this._updateLiList = function(pl, list, idx, oncomplete) {
965 if(idx >= list.length) return oncomplete();
968 litGenericProgress.update({maximum: list.length, progress: idx});
969 new openils.acq.Lineitem({lineitem:li}).update(
971 self._updateLiList(pl, list, ++idx, oncomplete);
976 this._loadPLSelect = function() {
977 if(this._plSelectLoaded) return;
979 function handleResponse(r) {
980 plList.push(r.recv().content());
982 var method = 'open-ils.acq.picklist.user.retrieve';
983 fieldmapper.standardRequest(
984 ['open-ils.acq', method],
986 params: [this.authtoken],
987 onresponse: handleResponse,
988 oncomplete: function() {
989 self._plSelectLoaded = true;
990 acqLitAddExistingSelect.store =
991 new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
992 acqLitAddExistingSelect.setValue();