From: erickson Date: Mon, 12 May 2008 20:09:58 +0000 (+0000) Subject: added the UI js directory for page-specific javascript. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ac26e955cb153c33beddfc950b10d5f04a6ea7f1;p=Evergreen.git added the UI js directory for page-specific javascript. created the view_funding_source Js page and moved JS over git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9558 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/financial/view_funding_source.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/financial/view_funding_source.js new file mode 100644 index 0000000000..4b457a745f --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/financial/view_funding_source.js @@ -0,0 +1,103 @@ +dojo.require("dijit.Dialog"); +dojo.require('dijit.layout.TabContainer'); +dojo.require('dijit.layout.ContentPane'); +dojo.require("dijit.form.FilteringSelect"); +dojo.require("dijit.form.Textarea"); +dojo.require("dijit.form.CurrencyTextBox"); +dojo.require('dojox.grid.Grid'); + +dojo.require("fieldmapper.OrgUtils"); +dojo.require('openils.acq.FundingSource'); +dojo.require('openils.acq.Fund'); +dojo.require('openils.Event'); + +var ses = new OpenSRF.ClientSession('open-ils.acq'); +var fundingSource = null; + +function resetPage() { + fundingSource = null; + fsCreditGrid.isLoaded = false; + fsAllocationGrid.isLoaded = false; + loadFS(); +} + +/** creates a new funding_source_credit from the dialog ----- */ +function applyFSCredit(fields) { + fields.funding_source = fundingSourceID; + openils.acq.FundingSource.createCredit(fields, resetPage); +} + +function applyFSAllocation(fields) { + fields.funding_source = fundingSourceID; + if(isNaN(fields.percent)) fields.percent = null; + if(isNaN(fields.amount)) fields.amount = null; + openils.acq.Fund.createAllocation(fields, resetPage); +} + +/** fetch the fleshed funding source ----- */ +function loadFS() { + var req = ses.request( + 'open-ils.acq.funding_source.retrieve', + openils.User.authtoken, fundingSourceID, + {flesh_summary:1, flesh_credits:1,flesh_allocations:1} + ); + + req.oncomplete = function(r) { + var msg = req.recv(); + fundingSource = msg.content(); + var evt = openils.Event.parse(fundingSource); + if(evt) { + alert(evt); + return; + } + loadFSGrid(); + } + req.send(); +} + +/** Some grid rendering accessor functions ----- */ +function getOrgInfo(rowIndex) { + data = fundingSourceGrid.model.getRow(rowIndex); + if(!data) return; + return fieldmapper.aou.findOrgUnit(data.owner).shortname(); +} + +function getSummaryInfo(rowIndex) { + switch(this.index) { + case 2: return new String(fundingSource.summary().balance); + case 3: return new String(fundingSource.summary().credit_total); + case 4: return new String(fundingSource.summary().allocation_total); + } +} + +/** builds the credits grid ----- */ +function loadFSGrid() { + if(!fundingSource) return; + 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:'*'}}); + fundingSourceGrid.setModel(model); + fundingSourceGrid.update(); +} + + +/** builds the credits grid ----- */ +function loadCreditGrid() { + if(fsCreditGrid.isLoaded) return; + var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fundingSource.credits())}); + var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}}); + fsCreditGrid.setModel(model); + fsCreditGrid.update(); + fsCreditGrid.isLoaded = true; +} + +/** builds the allocations grid ----- */ +function loadAllocationGrid() { + if(fsAllocationGrid.isLoaded) return; + var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fundingSource.allocations())}); + var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}}); + fsAllocationGrid.setModel(model); + fsAllocationGrid.update(); + fsAllocationGrid.isLoaded = true; +} + +dojo.addOnLoad(loadFS); diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html index 62d2894728..70bf047b15 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_funding_source.html @@ -5,79 +5,7 @@ <%def name="block_content()"> - + +
${_('Funding Source Details')}