moved fund js to external file
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 May 2008 20:14:13 +0000 (20:14 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 12 May 2008 20:14:13 +0000 (20:14 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9559 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/financial/view_fund.js [new file with mode: 0644]
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html

diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/financial/view_fund.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/ui_js/oils/default/acq/financial/view_fund.js
new file mode 100644 (file)
index 0000000..d03f54a
--- /dev/null
@@ -0,0 +1,77 @@
+dojo.require("dijit.Dialog");
+dojo.require('dijit.layout.TabContainer');
+dojo.require('dijit.layout.ContentPane');
+dojo.require('dojox.grid.Grid');
+
+dojo.require("fieldmapper.OrgUtils");
+dojo.require('openils.acq.Fund');
+dojo.require('openils.acq.FundingSource');
+dojo.require('openils.Event');
+dojo.require('openils.User');
+
+var fund = null;
+
+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();
+}
+
+
+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 loadAllocationGrid() {
+    if(fundAllocationGrid.isLoaded) return;
+    var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.allocations())});
+    var model = new dojox.grid.data.DojoData(
+        null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
+    fundAllocationGrid.setModel(model);
+    fundAllocationGrid.update();
+    fundAllocationGrid.isLoaded = true;
+}
+
+function loadDebitGrid() {
+    if(fundDebitGrid.isLoaded) return;
+    var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.debits())});
+    var model = new dojox.grid.data.DojoData(
+        null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
+    fundDebitGrid.setModel(model);
+    fundDebitGrid.update();
+    fundDebitGrid.isLoaded = true;
+}
+
+function fetchFund() {
+    fieldmapper.standardRequest(
+        ['open-ils.acq', 'open-ils.acq.fund.retrieve'],
+        {   async: true,
+            params: [
+                openils.User.authtoken, fundID, 
+                {flesh_summary:1, flesh_allocations:1, flesh_debits:1} 
+                /* TODO grab allocations and debits only on as-needed basis */
+            ],
+            oncomplete: function(r) {
+                fund = r.recv().content();
+                loadFundGrid(fund);
+            }
+        }
+    );
+}
+
+dojo.addOnLoad(fetchFund);
index d9fec41..fdd0993 100644 (file)
@@ -4,37 +4,7 @@
 <%def name="block_content()">
 
 <script>
-    dojo.require("dijit.Dialog");
-    dojo.require('dijit.layout.TabContainer');
-    dojo.require('dijit.layout.ContentPane');
-    dojo.require('dojox.grid.Grid');
-
-    dojo.require("fieldmapper.OrgUtils");
-    dojo.require('openils.acq.Fund');
-    dojo.require('openils.acq.FundingSource');
-    dojo.require('openils.Event');
-    dojo.require('openils.User');
-
     var fundID = ${c.oils.acq.fund_id};
-    var fund = null;
-
-    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();
-    }
-
     function getFundingSource(rowIndex) {
         data = fundAllocationGrid.model.getRow(rowIndex);
         if(data) {
             return '<a href="${c.oils.acq.prefix.value}/funding_source/view/'+fs.id()+'">'+fs.name()+'</a>';
         }
     }
+</script>
 
-    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 loadAllocationGrid() {
-        if(fundAllocationGrid.isLoaded) return;
-        var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.allocations())});
-        var model = new dojox.grid.data.DojoData(
-            null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
-        fundAllocationGrid.setModel(model);
-        fundAllocationGrid.update();
-        fundAllocationGrid.isLoaded = true;
-    }
-
-    function loadDebitGrid() {
-        if(fundDebitGrid.isLoaded) return;
-        var store = new dojo.data.ItemFileReadStore({data:acqfa.toStoreData(fund.debits())});
-        var model = new dojox.grid.data.DojoData(
-            null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
-        fundDebitGrid.setModel(model);
-        fundDebitGrid.update();
-        fundDebitGrid.isLoaded = true;
-    }
-
-    function fetchFund() {
-        fieldmapper.standardRequest(
-            ['open-ils.acq', 'open-ils.acq.fund.retrieve'],
-            {   async: true,
-                params: [
-                    openils.User.authtoken, fundID, 
-                    {flesh_summary:1, flesh_allocations:1, flesh_debits:1} 
-                    /* TODO grab allocations and debits only on as-needed basis */
-                ],
-                oncomplete: function(r) {
-                    fund = r.recv().content();
-                    loadFundGrid(fund);
-                }
-            }
-        );
-    }
+<!-- load the page-specific JS -->
+<script src='${c.oils.core.media_prefix.value}/ui_js/oils/default/acq/financial/view_fund.js'> </script>
 
-    dojo.addOnLoad(fetchFund);
-</script>
-    
 <div id='oils-acq-list-header' class='container'>
     <div id='oils-acq-list-header-label'>${_('Fund Details')}</div>
 </div>