1 dojo.require("dijit.Dialog");
2 dojo.require('dijit.form.FilteringSelect');
3 dojo.require('dijit.layout.TabContainer');
4 dojo.require('dijit.layout.ContentPane');
5 dojo.require('dojox.grid.Grid');
7 dojo.require("fieldmapper.OrgUtils");
8 dojo.require('openils.acq.Fund');
9 dojo.require('openils.acq.FundingSource');
10 dojo.require('openils.Event');
11 dojo.require('openils.User');
12 dojo.require('openils.Util');
16 function getSummaryInfo(rowIndex) {
17 return new String(fund.summary()[this.field]);
20 function createAllocation(fields) {
22 if(isNaN(fields.percent)) fields.percent = null;
23 if(isNaN(fields.amount)) fields.amount = null;
24 //openils.acq.Fund.createAllocation(fields, resetPage);
25 openils.acq.Fund.createAllocation(fields,
26 function(r){location.href = location.href;});
29 function getOrgInfo(rowIndex) {
30 data = fundGrid.model.getRow(rowIndex);
32 return fieldmapper.aou.findOrgUnit(data.org).shortname();
35 function getXferDest(rowIndex) {
36 data = this.grid.model.getRow(rowIndex);
37 if(!(data && data.xfer_destination)) return '';
38 return data.xfer_destination;
41 function loadFundGrid() {
42 var store = new dojo.data.ItemFileReadStore({data:acqf.toStoreData([fund])});
43 var model = new dojox.grid.data.DojoData(
44 null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
45 fundGrid.setModel(model);
49 function loadAllocationGrid() {
50 if(fundAllocationGrid.isLoaded) return;
51 var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.allocations())});
52 var model = new dojox.grid.data.DojoData(
53 null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
54 fundAllocationGrid.setModel(model);
55 fundAllocationGrid.update();
56 fundAllocationGrid.isLoaded = true;
59 function loadDebitGrid() {
60 if(fundDebitGrid.isLoaded) return;
61 var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.debits())});
62 var model = new dojox.grid.data.DojoData(
63 null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
64 fundDebitGrid.setModel(model);
65 fundDebitGrid.update();
66 fundDebitGrid.isLoaded = true;
69 function fetchFund() {
70 fieldmapper.standardRequest(
71 ['open-ils.acq', 'open-ils.acq.fund.retrieve'],
74 openils.User.authtoken, fundID,
75 {flesh_summary:1, flesh_allocations:1, flesh_debits:1}
76 /* TODO grab allocations and debits only on as-needed basis */
78 oncomplete: function(r) {
79 fund = r.recv().content();
86 openils.Util.addOnLoad(fetchFund);