1 dojo.require("dijit.Dialog");
2 dojo.require("dijit.form.FilteringSelect");
3 dojo.require('dijit.form.Button');
4 dojo.require('dojox.grid.DataGrid');
5 dojo.require('dojo.data.ItemFileWriteStore');
6 dojo.require('openils.widget.OrgUnitFilteringSelect');
7 dojo.require('openils.acq.CurrencyType');
8 dojo.require('openils.Event');
9 dojo.require('openils.Util');
10 dojo.require('openils.acq.Fund');
12 function getOrgInfo(rowIndex, item) {
15 var owner = this.grid.store.getValue(item, 'org');
16 return fieldmapper.aou.findOrgUnit(owner).shortname();
20 function getBalanceInfo(rowIndex, item) {
22 var data = this.grid.store.getValue( item, 'id');
23 return new String(openils.acq.Fund.cache[data].summary().combined_balance);
26 function loadFundGrid() {
27 var store = new dojo.data.ItemFileWriteStore({data:acqf.initStoreData()});
28 fundListGrid.setStore(store);
29 fundListGrid.render();
30 var yearStore = {identifier:'year', name:'year', items:[]};
31 var yearsAdded = {}; /* don't duplicate the years in the selector */
33 fieldmapper.standardRequest(
34 [ 'open-ils.acq', 'open-ils.acq.fund.org.retrieve'],
36 params: [openils.User.authtoken, null, {flesh_summary:1}],
37 onresponse : function(r) {
38 if(lf = openils.Util.readResponse(r)) {
39 openils.acq.Fund.cache[lf.id()] = lf;
40 store.newItem(acqf.toStoreItem(lf));
42 if(!(year in yearsAdded)) {
43 yearStore.items.push({year:year});
48 oncomplete : function(r) {
49 // sort the unique list of years and set the selector to "now" if possible
50 yearStore.items = yearStore.items.sort().reverse();
51 fundFilterYearSelect.store = new dojo.data.ItemFileReadStore({data:yearStore});
52 var today = new Date().getFullYear().toString();
53 if(today in yearsAdded)
54 fundFilterYearSelect.setValue(today);
60 function filterGrid() {
61 var year = fundFilterYearSelect.getValue();
63 fundListGrid.query = {year:year};
65 fundListGrid.query = {id:'*'};
66 fundListGrid.update();
69 openils.Util.addOnLoad(loadFundGrid);