[open-ils-commits] r9416 - in
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb:
controllers/acq templates/oils/default/acq/financial
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Apr 21 17:50:25 EDT 2008
Author: erickson
Date: 2008-04-21 17:11:25 -0400 (Mon, 21 Apr 2008)
New Revision: 9416
Modified:
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html
branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html
Log:
began dojo-ification of fund view page. updated fund list page to use some new widgets and to match the funding_source page more closely
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py 2008-04-21 20:32:34 UTC (rev 9415)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py 2008-04-21 21:11:25 UTC (rev 9416)
@@ -22,19 +22,7 @@
def view(self, **kwargs):
r = RequestMgr()
- r.ctx.core.org_tree.value = OrgUtil.fetch_org_tree()
- fund_id = kwargs['id']
- ses = ClientSession(oils.const.OILS_APP_ACQ)
-
- fund = ses.request('open-ils.acq.fund.retrieve',
- r.ctx.core.authtoken.value, fund_id,
- {"flesh_summary":1, 'flesh_allocations':1, 'flesh_allocation_sources':1}).recv().content()
- Event.parse_and_raise(fund)
-
- org_unit = OrgUtil.get_org_unit(fund.org())
- fund.org(org_unit)
-
- r.ctx.acq.fund.value = fund
+ r.ctx.acq.fund_id = kwargs['id']
return r.render('acq/financial/view_fund.html')
def list(self):
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html 2008-04-21 20:32:34 UTC (rev 9415)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html 2008-04-21 21:11:25 UTC (rev 9416)
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
<%inherit file='../base.html'/>
-<%namespace file='../../common/widgets.html' name='widget'/>
<%def name="page_title()">${_('Funding Sources')}</%def>
<%def name="block_content()">
@@ -8,8 +7,6 @@
<div id='oils-acq-list-header-label'>${_('Funding Sources')}</div>
</div>
-<script src='list_funding_sources.js'> </script>
-
<script type="text/javascript">
dojo.require("dijit.Dialog");
dojo.require("dijit.form.FilteringSelect");
@@ -113,16 +110,16 @@
var gridStructure = [{
cells : [[
{name: '${_("ID")}', field: 'id'},
- {name: '${_("Name")}', field: "name", width:'auto', get:getName},
- {name: '${_("Owner")}', field: "owner", width:'auto', get:getOrgInfo},
+ {name: '${_("Name")}', width:'auto', get:getName},
+ {name: '${_("Owner")}', width:'auto', get:getOrgInfo},
{name: '${_("Currency Type")}', field: "currency_type"},
- {name: '${_("Balance")}', field: "balance", get:getBalanceInfo}
+ {name: '${_("Balance")}', get:getBalanceInfo}
]]
}];
openils.acq.FundingSource.createStore(
function(storeData) {
- var store = new dojo.data.ItemFileWriteStore({data:storeData});
+ var store = new dojo.data.ItemFileReadStore({data:storeData});
var model = new dojox.grid.data.DojoData(null, store,
{rowsPerPage: 20, clientSort: true, query:{id:'*'}});
fundingSourceListGrid.setStructure(gridStructure);
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html 2008-04-21 20:32:34 UTC (rev 9415)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funds.html 2008-04-21 21:11:25 UTC (rev 9416)
@@ -1,31 +1,140 @@
# -*- coding: utf-8 -*-
<%inherit file='../base.html'/>
-<%namespace file='../../common/widgets.html' name='widget'/>
<%def name="page_title()">${_('Funds')}</%def>
<%def name="block_content()">
<div id='oils-acq-list-header' class='container'>
<div id='oils-acq-list-header-label'>${_('Funds')}</div>
- <div id='oils-acq-list-header-actions'>
- <a href='${c.oils.acq.prefix.value}/fund/create'>${_('New Fund')}</a>
- </div>
</div>
-<div id='oils-acq-fund-grid'> </div>
-<script>
+<script type="text/javascript">
+ dojo.require("dijit.Dialog");
+ dojo.require("dijit.form.FilteringSelect");
dojo.require('openils.acq.Fund');
+ dojo.require('openils.Event');
+ dojo.require('openils.acq.CurrencyType');
+ dojo.require('openils.widget.OrgUnitFilteringSelect');
- /* define the layout columns */
- var cols = [
- {name: '${_("ID")}', field: 'id'},
- {name: '${_("Name")}', field: "name"},
- {name: '${_("Owner")}', field: "org"},
- {name: '${_("Year")}', field: "year"},
- {name: '${_("Currency Type")}', field: "currency_type"},
- {name: '${_("Balance")}', field: "combined_balance"}
- ];
+ 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 */
+ '${c.oils.acq.prefix.value}/fund/view/'+fundId;
+ }
+ }
+ );
+ }
+</script>
- /* build the fund grid on page load */
- dojo.addOnLoad(function(){openils.acq.Fund.loadGrid('oils-acq-fund-grid', cols)});
+<div class='oils-acq-actions-div'>
+ <div dojoType="dijit.form.DropDownButton">
+ <span>${('New Fund')}</span>
+
+ <div dojoType="dijit.TooltipDialog" execute="createFund(arguments[0]);">
+ <script type='dojo/connect' event='onOpen'>
+ openils.acq.CurrencyType.loadSelectWidget(fundCurrencySelector);
+ openils.User.buildPermOrgSelector('ADMIN_FUND', fundOwnerSelect);
+ </script>
+
+ <table class='dijitTooltipTable'>
+ <tr>
+ <td><label for="name">${_('Name:')} </label></td>
+ <td><input dojoType="dijit.form.TextBox" name="name"></td>
+ </tr>
+ <tr>
+ <td><label for="year">${_('Year:')} </label></td>
+ <td><input dojoType="dijit.form.TextBox" name="year"></td>
+ </tr>
+ <tr>
+ <td><label for="currency_type">${_('Currency Type:')}</label></td>
+ <td>
+ <input jsId='fundCurrencySelector' name="currency_type"
+ dojoType="dijit.form.FilteringSelect" searchAttr='code' labelAttr='code'>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td valign='top'><label for="org">${_('Owning Location:')}</label></td>
+ <td>
+ <input dojoType="openils.widget.OrgUnitFilteringSelect" jsId='fundOwnerSelect'
+ searchAttr="shortname" name="org" autocomplete="true" labelAttr='shortname'> </input>
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2' align='center'>
+ <button dojoType=dijit.form.Button type="submit">${_('Create')}</button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ <button dojoType="dijit.form.Button"
+ onclick="openils.acq.Fund.deleteFromGrid(
+ fundListGrid, function(){location.href = location.href})">
+ ${_('Delete Selected')}
+ </button>
+</div>
+
+<!-- The main grid lives here -->
+<div jsId='fundListGrid' dojoType="dojox.Grid"></div>
+
+<script>
+
+ function loadFundGrid() {
+ openils.User.getBySession();
+
+ /** define how the primary grid is rendered */
+
+ function getOrgInfo(rowIndex) {
+ data = fundListGrid.model.getRow(rowIndex);
+ if(!data) return;
+ return fieldmapper.aou.findOrgUnit(data.org).shortname();
+ }
+
+ function getBalanceInfo(rowIndex) {
+ data = fundListGrid.model.getRow(rowIndex);
+ if(!data) return;
+ return new String(openils.acq.Fund.cache[data.id].summary().combined_balance);
+ }
+
+ function getName(rowIndex) {
+ data = fundListGrid.model.getRow(rowIndex);
+ if(!data) return;
+ return '<a href="${c.oils.acq.prefix.value}/fund/view/'+data.id+'">'+data.name+'</a>';
+ }
+
+ var gridStructure = [{
+ cells : [[
+ {name: '${_("ID")}', field: 'id'},
+ {name: '${_("Name")}', width:'auto', get:getName},
+ {name: '${_("Year")}', field: "year"},
+ {name: '${_("Location")}', get:getOrgInfo},
+ {name: '${_("Currency Type")}', field: "currency_type"},
+ {name: '${_("Combined Balance")}', get:getBalanceInfo}
+ ]]
+ }];
+
+ openils.acq.Fund.createStore(
+ function(storeData) {
+ var store = new dojo.data.ItemFileReadStore({data:storeData});
+ var model = new dojox.grid.data.DojoData(null, store,
+ {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
+ fundListGrid.setStructure(gridStructure);
+ fundListGrid.setModel(model);
+ fundListGrid.update();
+ }
+ );
+ }
+
+ dojo.addOnLoad(loadFundGrid);
</script>
+
</%def>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html 2008-04-21 20:32:34 UTC (rev 9415)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html 2008-04-21 21:11:25 UTC (rev 9416)
@@ -1,80 +1,96 @@
# -*- coding: utf-8 -*-
<%inherit file='../base.html'/>
-<%namespace file='../../common/widgets.html' name='widget'/>
<%def name="page_title()">${_('View Fund')}</%def>
<%def name="block_content()">
-<% fund = c.oils.acq.fund.value %>
+<script>
+ dojo.require("dijit.Dialog");
+ dojo.require('dijit.layout.TabContainer');
+ dojo.require('dijit.layout.ContentPane');
+ dojo.require('openils.acq.Fund');
+ dojo.require('openils.Event');
+ dojo.require('fieldmapper.Fieldmapper');
+ dojo.require('openils.User');
+ function getSummaryInfo(rowIndex) {
+ switch(this.index) {
+ case 4: return new String(fund.summary().combined_balance);
+ case 5: return new String(fund.summary().allocation_total);
+ case 6: return new String(fund.summary().spent_balance);
+ case 7: return new String(fund.summary().debit_total);
+ case 8: return new String(fund.summary().spent_total);
+ case 9: return new String(fund.summary().encumberance_total);
+ }
+ }
+
+ function getOrgInfo(rowIndex) {
+ data = fundGrid.model.getRow(rowIndex);
+ if(!data) return;
+ return fieldmapper.aou.findOrgUnit(data.org).shortname();
+ }
+
+ var fundID = ${c.oils.acq.fund_id};
+ var fund = null;
+
+ function loadFundGrid() {
+ var store = new dojo.data.ItemFileReadStore({data:acqf.toStoreData([fund])});
+ var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
+ fundGrid.setModel(model);
+ fundGrid.update();
+ }
+
+ function fetchFund() {
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.fund.retrieve'],
+ { async: true,
+ params: [openils.User.authtoken, fundID, {flesh_summary:1}],
+ oncomplete: function(r) {
+ fund = r.recv().content();
+ loadFundGrid(fund);
+ }
+ }
+ );
+ }
+
+ dojo.addOnLoad(fetchFund);
+</script>
+
<div id='oils-acq-list-header' class='container'>
- <div id='oils-acq-list-header-label'>${fund.name()}</div>
- <div id='oils-acq-list-header-actions'>
- <a href='${c.oils.acq.prefix.value}/fund/allocate?${c.oils.acq.fund_id.cgi_name}=${fund.id()}'>${_('Allocate Money')}</a>
- </div>
+ <div id='oils-acq-list-header-label'>${_('Fund Details')}</div>
</div>
-<table class='oils-admin-table'>
- <tbody>
- <tr>
- <td class='oils-admin-label'>${_('Owner')}</td>
- <td>${fund.org().name()}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Currency')}</td>
- <td>${fund.currency_type()}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Year')}</td>
- <td>${fund.year()}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Amount Allocated to this Fund')}</td>
- <td>${fund.summary()['allocation_total']}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Balance (Total - (Spent + Encumberances))')}</td>
- <td>${fund.summary()['combined_balance']}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Spent Balance (Total - Spent)')}</td>
- <td>${fund.summary()['spent_balance']}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Total Debits (Spent + Encumbered)')}</td>
- <td>${fund.summary()['debit_total']}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Total Spent')}</td>
- <td>${fund.summary()['spent_total']}</td>
- </tr>
- <tr>
- <td class='oils-admin-label'>${_('Total Encumbered')}</td>
- <td>${fund.summary()['encumberance_total']}</td>
- </tr>
- </tbody>
-</table>
+<style>
+ .oils-acq-detail-content-pane {height:500px;width:100%}
+</style>
-<h3>${_('Fund Allocations')}</h3>
-<table class='oils-admin-table'>
- <thead>
- <tr>
- <td>${_('Funding Source')}</td>
- <td>${_('Amount/Percent')}</td>
- </tr>
- </thead>
- <tbody>
- % for alloc in fund.allocations():
- <tr>
- <td>${alloc.funding_source().name()}</td>
- % if alloc.amount() != 0 and alloc.amount() is not None:
- <td>${alloc.amount()}</td>
- % else:
- <% percent = _('%(p)s%%') % {'p':alloc.percent()} %>
- <td>${percent}</td>
- % endif
- </tr>
- % endfor
- </tbody>
-</table>
-
+<div dojoType="dijit.layout.ContentPane" layoutAlign="top">
+ <div dojoType="dijit.layout.TabContainer">
+ <div dojoType="dijit.layout.ContentPane" class='oils-acq-detail-content-pane' title="${_('Summary')}" selected='true'>
+ <script>
+ /** Define the columns for the fund grid ----- */
+ var fundGridLayout = [{
+ cells : [[
+ {name: '${_("ID")}', field: 'id'},
+ {name: '${_("Name")}', field: "name", width:'auto'},
+ {name: '${_("Currency Type")}', field: "currency_type"},
+ {name: '${_("Owner")}', get:getOrgInfo},
+ /*
+ {name: '${_("Balance (Total - (Spent + Encumberances))")}', get:getSummaryInfo},
+ {name: '${_("Amount Allocated to this Fund")}', get:getSummaryInfo},
+ {name: '${_("Spent Balance (Total - Spent)")}', get:getSummaryInfo},
+ {name: '${_("Total Debits (Spent + Encumbered)")}', get:getSummaryInfo},
+ */
+ {name: '${_("Balance")}', get:getSummaryInfo},
+ {name: '${_("Total Allocated")}', get:getSummaryInfo},
+ {name: '${_("Spent Balance")}', get:getSummaryInfo},
+ {name: '${_("Total Debits")}', get:getSummaryInfo},
+ {name: '${_("Total Spent")}', get:getSummaryInfo},
+ {name: '${_("Total Encumbered")}', get:getSummaryInfo}
+ ]]
+ }];
+ </script>
+ <div jsId='fundGrid' dojoType="dojox.Grid" structure='fundGridLayout'> </div>
+ </div>
+ </div>
+</div>
</%def>
Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html 2008-04-21 20:32:34 UTC (rev 9415)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html 2008-04-21 21:11:25 UTC (rev 9416)
@@ -83,7 +83,6 @@
function loadFSGrid() {
var store = new dojo.data.ItemFileReadStore({data:acqfs.toStoreData([fundingSource])});
var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
- model.query = {id:'*'};
fundingSourceGrid.setModel(model);
fundingSourceGrid.update();
}
@@ -128,7 +127,7 @@
<tr>
<td><label for="amount">${_('Amount:')} </label></td>
<td>
- <!-- XXX get currency from from funding source ... -->
+ <!-- XXX get currency from funding source ... -->
<input dojoType="dijit.form.CurrencyTextBox" name="amount" currency='USD'> </input>
</td>
</tr>
More information about the open-ils-commits
mailing list