'<span class="fund_${0}">${1} (${2})</span>', 'id', 'code', 'year'
];
var fundSearchFormat = ['${0} (${1})', 'code', 'year'];
+var fundSearchFilter = {active : 't'};
function nodeByName(name, context) {
return dojo.query('[name='+name+']', context)[0];
dojo.byId('acq-lit-notes-back-button').onclick = function(){self.show('list')};
dojo.byId('acq-lit-real-copies-back-button').onclick = function(){self.show('list')};
+ this.setFundSearchFilter = function(callback) {
+ new openils.User().getPermOrgList(
+ ['CREATE_PURCHASE_ORDER', 'MANAGE_FUND'],
+ function(orgs) {
+ fundSearchFilter.org = orgs;
+ if (callback) callback();
+ },
+ true, true // descendants, id_list
+ );
+ }
+
this.afwCopyFieldArgs = function(field, perms) {
return {
"fmField" : field,
"fmClass": 'acqlid',
"labelFormat": (field == 'fund') ? fundLabelFormat : null,
"searchFormat": (field == 'fund') ? fundSearchFormat : null,
- "searchFilter": (field == 'fund') ? {"active": "t"} : null,
+ "searchFilter": (field == 'fund') ? fundSearchFilter : null,
"orgLimitPerms": [perms],
"dijitArgs": {
"required": false,
// The list of funds can be huge. Before fetching
// funds for PO modification, see where the user has
// perms and limit the retreived funds accordingly.
- // Note: this code only runs once per page load, so
- // no caching is required.
- new openils.User().getPermOrgList(
- ['CREATE_PURCHASE_ORDER', 'MANAGE_FUND'],
- function(orgs) {
- args.searchFilter.org = orgs;
- buildOneBatchWidget(field, args);
- },
- true, true // descendants, id_list
- );
+ // Note: This is the first instance of fund list
+ // retrieval. All future fund list retrievals will
+ // benefit directly from having applied the fund
+ // search filter org units here.
+ self.setFundSearchFilter(function() {
+ buildOneBatchWidget(field, args);
+ });
return;
}
searchFilter = (copy.fund() ?
{"-or": {"active": "t", "id": copy.fund()}} :
{"active" : "t"});
+ searchFilter.org = fundSearchFilter.org;
} else {
searchFilter = null;
}
selfReference : true,
labelFormat : fundLabelFormat,
searchFormat : fundSearchFormat,
- searchFilter : {"active": "t"},
+ searchFilter : fundSearchFilter,
parentNode : dojo.byId('acq-lit-batch-fund-selector'),
orgLimitPerms : ['CREATE_PICKLIST', 'CREATE_PURCHASE_ORDER'],
dijitArgs : { "required": true, "labelType": "html" },
var fundLabelFormat = ['${0} (${1})', 'code', 'year'];
var fundSearchFormat = ['${0} (${1})', 'code', 'year'];
+var fundSearchFilter = {};
var cgi = new openils.CGI();
var pcrud = new openils.PermaCrud();
}
function init() {
+ // before rendering any fund selectors, limit the funds to
+ // attempt to retrieve to those the user can actually use.
+ new openils.User().getPermOrgList(
+ ['ADMIN_INVOICE','CREATE_INVOICE','MANAGE_FUND'],
+ function(orgs) {
+ fundSearchFilter.org = orgs;
+ init2();
+ },
+ true, true // descendants, id_list
+ );
+}
+
+function init2() {
attachLi = cgi.param('attach_li') || [];
if (!dojo.isArray(attachLi))
searchFilter : {active : 't'},
labelFormat : fundLabelFormat,
searchFormat : fundSearchFormat,
+ searchFilter : fundSearchFilter,
dijitArgs : {required : true},
parentNode : dojo.byId('acq-invoice-extra-copies-fund')
});
fmField : 'fund',
labelFormat : fundLabelFormat,
searchFormat : fundSearchFormat,
+ searchFilter : fundSearchFilter,
readOnly : invoice && openils.Util.isTrue(invoice.complete()),
dijitArgs : {required : true},
parentNode : nodeByName('fund', row)
var pcrud;
var _collection_code_textboxes = [];
var _collection_code_kludge_active = false;
+var fundSearchFilter = {active : 't'};
function gridDataLoader() {
fListGrid.resetStore();
);
}
+function setFundSearchFilter(callback) {
+ new openils.User().getPermOrgList(
+ ['ADMIN_ACQ_DISTRIB_FORMULA'],
+ function(orgs) {
+ fundSearchFilter.org = orgs;
+ if (callback) callback();
+ },
+ true, true // descendants, id_list
+ );
+}
+
function draw() {
pcrud = new openils.PermaCrud();
if(formulaId) {
openils.Util.hide('formula-list-div');
- drawFormulaSummary();
+ setFundSearchFilter(drawFormulaSummary);
} else {
openils.Util.hide('formula-entry-div');
fmField : field,
fmObject : entry,
fmClass : 'acqdfe',
+ searchFilter : (field == 'fund') ? fundSearchFilter : null,
parentNode : byName(row, field),
orgDefaultsToWs : true,
orgLimitPerms : ['ADMIN_ACQ_DISTRIB_FORMULA'],