);
sub retrieve_org_funds {
- my($self, $conn, $auth, $org_id_list, $options) = @_;
+ my($self, $conn, $auth, $filter, $options) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
+ $filter ||= {};
$options ||= {};
my $limit_perm = ($$options{limit_perm}) ? $$options{limit_perm} : 'ADMIN_FUND';
return OpenILS::Event->new('BAD_PARAMS')
unless $limit_perm =~ /(ADMIN|MANAGE|VIEW)_FUND/;
- my $org_ids = ($org_id_list and @$org_id_list) ? $org_id_list :
+ $filter->{org} = $filter->{org} ||
$U->user_has_work_perm_at($e, $limit_perm, {descendants =>1});
- return undef unless @$org_ids;
- my $funds = $e->search_acq_fund({org => $org_ids});
+ return undef unless @{$filter->{org}};
+
+
+ my $query = [
+ $filter,
+ {
+ limit => $$options{limit} || 50,
+ offset => $$options{offset} || 0,
+ order_by => $$options{order_by} || {acqf => 'name'}
+ }
+ ];
+
+ my $funds = $e->search_acq_fund($query);
for my $fund (@$funds) {
$fund->summary(retrieve_fund_summary_impl($e, $fund))
this.initAutoEnv();
this.attr('structure', this._compileStructure());
this.setStore(this.buildAutoStore());
+ this.cachedQueryOpts = {};
if(this.showColumnPicker) {
if(!this.columnPickerPrefix) {
onclick : function() {
self.resetStore();
self.cachedQueryOpts.offset = self.displayOffset -= self.displayLimit;
- self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
+ if(self.dataLoader)
+ self.dataLoader()
+ else
+ self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
}
});
onclick : function() {
self.resetStore();
self.cachedQueryOpts.offset = self.displayOffset += self.displayLimit;
- self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
+ if(self.dataLoader)
+ self.dataLoader()
+ else
+ self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
}
});
}
},
+ hideLoadProgressIndicator : function() {
+ dojo.style(this.loadProgressIndicator, 'visibility', 'hidden');
+ },
+
+ showLoadProgressIndicator : function() {
+ dojo.style(this.loadProgressIndicator, 'visibility', 'visible');
+ },
+
/* Don't allow sorting on the selector column */
canSort : function(rowIdx) {
if(rowIdx == 1 && !this.hideSelector)
return 0;
}
-function loadFundGrid() {
+function loadFundGrid(year) {
var yearStore = {identifier:'year', name:'year', items:[]};
var yearsAdded = {}; /* don't duplicate the years in the selector */
+ lfGrid.resetStore();
+
+ if(!year) year = new Date().getFullYear().toString();
+
+ lfGrid.dataLoader = function() { loadFundGrid(year); };
fieldmapper.standardRequest(
[ 'open-ils.acq', 'open-ils.acq.fund.org.retrieve'],
{ async: true,
- params: [openils.User.authtoken, null, {flesh_summary:1}],
+
+ params: [
+ openils.User.authtoken,
+ {year:year},
+ {
+ flesh_summary:1,
+ limit: lfGrid.displayLimit,
+ offset: lfGrid.displayOffset
+ }
+ ],
+
onresponse : function(r) {
if(lf = openils.Util.readResponse(r)) {
openils.acq.Fund.cache[lf.id()] = lf;
}
}
},
+
oncomplete : function(r) {
- // sort the unique list of years and set the selector to "now" if possible
yearStore.items = yearStore.items.sort().reverse();
fundFilterYearSelect.store = new dojo.data.ItemFileReadStore({data:yearStore});
var today = new Date().getFullYear().toString();
+
if(today in yearsAdded)
fundFilterYearSelect.setValue(today);
+
+ lfGrid.hideLoadProgressIndicator();
+
+ dojo.connect(
+ fundFilterYearSelect,
+ 'onChange',
+ function() {
+ loadFundGrid(fundFilterYearSelect.getValue());
+ }
+ );
}
}
);
}
-function filterGrid() {
- var year = fundFilterYearSelect.getValue();
- console.log(year);
- if(year)
- lfGrid.setQuery({year:year});
- else
- lfGrid.setQuery({id:'*'});
-
- lfGrid.update();
-}
openils.Util.addOnLoad(loadFundGrid);
<!-- load the page-specific JS -->
<script src='[% ctx.media_prefix %]/js/ui/default/acq/financial/list_funds.js'> </script>
-<script type="text/javascript">
- function createFund(fields) {
- /** Creates a new fund source */
- openils.acq.Fund.create(
- fields,
- function(fundId) {
- var evt = openils.Event.parse(fundId);
- if(evt) {
- alert(evt); /* XXX */
- return;
- } else {
- location.href = /* go to the details page for this fund */
- '[% ctx.base_path %]/acq/fund/view/'+fundId;
- }
- }
- );
- }
-
- function getName(rowIndex, item) {
- if(!item) return;
- var name = this.grid.store.getValue(item, 'name');
- var id = this.grid.store.getValue(item, 'id');
- return '<a href="[% ctx.base_path %]/acq/fund/view/'+id+'">'+name+'</a>';
- }
-</script>
-
-
-<div class='oils-header-panel' dojoType="dijit.layout.ContentPane" layoutAlign="client">
- <div>Funds</div>
- <div>
- <button dojoType='dijit.form.Button' onClick='lfGrid.showCreateDialog()'>New Fund</button>
- <button dojoType='dijit.form.Button' onClick='lfGrid.deleteSelected()'>Delete Selected</button>
- </div>
-</div>
-
-<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
- Year <select dojoType='dijit.form.FilteringSelect' onchange='filterGrid();'
- jsId='fundFilterYearSelect' labelAttr='year' searchAttr='year'> </select>
-</div>
+<table style='width:100%;'>
+ <tr>
+ <!-- TODO CSS -->
+ <td style='text-align:left;font-size:130%;font-weight: bold;'>Funds</td>
+ <td style='text-align:right;width:90%;'>
+ Year <select dojoType='dijit.form.FilteringSelect'
+ jsId='fundFilterYearSelect' labelAttr='year' searchAttr='year'> </select>
+ <button dojoType='dijit.form.Button' onClick='lfGrid.showCreateDialog()'>New Fund</button>
+ <button dojoType='dijit.form.Button' onClick='lfGrid.deleteSelected()'>Delete Selected</button>
+ </td>
+ </tr>
+</table>
<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
<table jsId="lfGrid"
query="{id: '*'}"
defaultCellWidth='"auto"'
fmClass='acqf'
+ showPaginator='true'
editOnEnter='true'>
<thead>
<tr>