LP#1350371 PO name on create w/ dupe detect
[working/Evergreen.git] / Open-ILS / web / js / ui / default / acq / financial / list_funding_sources.js
1 dojo.require("dijit.Dialog");
2 dojo.require("dijit.form.FilteringSelect");
3 dojo.require('openils.acq.FundingSource');
4 dojo.require('openils.acq.CurrencyType');
5 dojo.require('openils.widget.OrgUnitFilteringSelect');
6 dojo.require('dijit.form.Button');
7 dojo.require('dojo.data.ItemFileWriteStore');
8 dojo.require('dojox.grid.DataGrid');
9 dojo.require('openils.Event');
10 dojo.require('openils.Util');
11 dojo.require('openils.widget.AutoGrid');
12
13 function getOrgInfo(rowIndex, item) {
14     if(!item) return ''; 
15     var owner = this.grid.store.getValue(item, 'owner'); 
16     return fieldmapper.aou.findOrgUnit(owner).shortname();
17
18 }
19
20 function getBalanceInfo(rowIndex, item) {
21     if(!item) return '';
22     var id = this.grid.store.getValue( item, 'id');   
23     var fs = openils.acq.FundingSource.cache[id];
24     if(fs && fs.summary())
25         return fs.summary().balance;
26     return 0;
27 }
28
29 function loadFSGrid() {
30     fieldmapper.standardRequest(
31         ['open-ils.acq', 'open-ils.acq.funding_source.org.retrieve'], {
32             async: true,
33             params: [openils.User.authtoken, null, {flesh_summary:1, limit_perm : 'VIEW_FUNDING_SOURCE'}],
34             onresponse: function(r) { /* request object*/
35                 if(fs = openils.Util.readResponse(r)) {
36                     openils.acq.FundingSource.cache[fs.id()] = fs;
37                     fsGrid.store.newItem(acqfs.toStoreItem(fs));
38                 }
39             },
40             oncomplete: function() {
41                 fsGrid.hideLoadProgressIndicator();
42             }
43         }
44     );
45 }
46
47 openils.Util.addOnLoad(loadFSGrid);
48