plugged in paging for viewing fund propagation results. added context org and org...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Mar 2010 15:38:43 +0000 (15:38 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Mar 2010 15:38:43 +0000 (15:38 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16034 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/css/skin/default/acq.css
Open-ILS/web/js/ui/default/acq/financial/list_funds.js
Open-ILS/web/templates/default/acq/financial/list_funds.tt2

index 2016931..ea8eaa5 100644 (file)
@@ -177,3 +177,17 @@ span[name="notes_alert_flag"] {color: #c00;font-weight: bold;font-size: 110%;mar
 
 #acq-related-info-tbody td {padding:5px;}
 #acq-related-mini ul { list-style-type: square; }
+
+/* fiscal rollover ui */
+#oils-acq-rollover-tooltip-table td { border-bottom: 2px solid #888 }
+#acq-fund-list-rollover-summary-wrapper {
+    width:98%; 
+    margin-top:20px
+}
+#acq-fund-list-rollover-summary {
+    width:50%; 
+    margin-left:auto; 
+    margin-right:auto;
+    text-align:center;
+    border:1px solid #888;
+}
index 73ee432..dd1e9b9 100644 (file)
@@ -11,13 +11,17 @@ dojo.require('openils.acq.CurrencyType');
 dojo.require('openils.Event');
 dojo.require('openils.Util');
 dojo.require('openils.User');
+dojo.require('openils.CGI');
 dojo.require('openils.acq.Fund');
 dojo.require('openils.widget.AutoGrid');
 dojo.require('openils.widget.ProgressDialog');
+dojo.require('fieldmapper.OrgUtils');
 dojo.requireLocalization('openils.acq', 'acq');
 var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
 
 var contextOrg;
+var rolloverResponses;
+var rolloverMode = false;
 
 function getBalanceInfo(rowIndex, item) {
     if(!item) return '';
@@ -30,34 +34,53 @@ function getBalanceInfo(rowIndex, item) {
 
 function initPage() {
 
+    contextOrg = openils.User.user.ws_ou();
+
     var connect = function() {
         dojo.connect(contextOrgSelector, 'onChange',
             function() {
                 contextOrg = this.attr('value');
-                lfGrid.resetStore();
-                loadFundGrid(fundFilterYearSelect.attr('value'));
+                dojo.byId('oils-acq-rollover-ctxt-org').innerHTML = 
+                    fieldmapper.aou.findOrgUnit(contextOrg).shortname();
+                rolloverMode = false;
+                gridDataLoader();
             }
         );
     };
 
+    dojo.connect(refreshButton, 'onClick', function() { rolloverMode = false; gridDataLoader(); });
+
     new openils.User().buildPermOrgSelector(
-        'ADMIN_ACQ_FUND', contextOrgSelector, null, connect);
+        'ADMIN_ACQ_FUND', contextOrgSelector, contextOrg, connect);
+
+    dojo.byId('oils-acq-rollover-ctxt-org').innerHTML = 
+        fieldmapper.aou.findOrgUnit(contextOrg).shortname();
 
     loadYearSelector();
-    loadFundGrid();
+    lfGrid.dataLoader = gridDataLoader;
+    loadFundGrid(new openils.CGI().param('year') || new Date().getFullYear().toString());
 
     tagManager = new TagManager(lfGrid);
 }
 
+function gridDataLoader() {
+    lfGrid.resetStore();
+    if(rolloverMode) {
+        var offset = lfGrid.displayOffset;
+        for(var i = offset; i < (offset + lfGrid.displayLimit - 1); i++) {
+            var fund = rolloverResponses[i];
+            if(!fund) break;
+            lfGrid.store.newItem(fieldmapper.acqf.toStoreItem(fund));
+        }
+    } else {
+        loadFundGrid();
+    }
+}
+
 function loadFundGrid(year) {
 
     openils.Util.hide('acq-fund-list-rollover-summary');
-    lfGrid.resetStore();
-    year = year || new Date().getFullYear().toString();
-    lfGrid.dataLoader = function() { loadFundGrid(year); };
-
-    if(contextOrg == null)
-        contextOrg = openils.User.user.ws_ou();
+    year = year || fundFilterYearSelect.attr('value');
 
     fieldmapper.standardRequest(
        [ 'open-ils.acq', 'open-ils.acq.fund.org.retrieve'],
@@ -101,7 +124,7 @@ function loadYearSelector() {
 
                 var yearStore = {identifier:'year', name:'year', items:yearList};
                 yearStore.items = yearStore.items.sort().reverse();
-                fundFilterYearSelect.store = new dojo.data.ItemFileReadStore({data:yearStore});
+                fundFilterYearSelect.store = new dojo.data.ItemFileWriteStore({data:yearStore});
 
                 // default to this year
                 fundFilterYearSelect.setValue(new Date().getFullYear().toString());
@@ -109,8 +132,9 @@ function loadYearSelector() {
                 dojo.connect(
                     fundFilterYearSelect, 
                     'onChange', 
-                    function() {
-                        loadFundGrid(fundFilterYearSelect.attr('value'));
+                    function() { 
+                        rolloverMode = false;
+                        gridDataLoader();
                     }
                 );
             }
@@ -120,8 +144,9 @@ function loadYearSelector() {
 
 function performRollover(args) {
 
-    lfGrid.resetStore();
+    rolloverMode = true;
     progressDialog.show(true, "Processing...");
+    rolloverResponses = [];
 
     var method = 'open-ils.acq.fiscal_rollover';
 
@@ -131,12 +156,13 @@ function performRollover(args) {
         method += '.propagate';
     }
         
-    if(args.dry_run[0] == 'on')
-        method += '.dry_run';
+    var dryRun = args.dry_run[0] == 'on';
+    if(dryRun) method += '.dry_run';
 
     var count = 0;
     var amount_rolled = 0;
     var year = fundFilterYearSelect.attr('value'); // TODO alternate selector?
+    
     fieldmapper.standardRequest(
         ['open-ils.acq', method],
         {
@@ -146,19 +172,26 @@ function performRollover(args) {
                 openils.User.authtoken, 
                 year,
                 contextOrg,
-                false, // TODO: checkbox in dialog
+                (args.child_orgs[0] == 'on')
             ],
 
             onresponse : function(r) {
                 var resp = openils.Util.readResponse(r);
+                rolloverResponses.push(resp.fund);
                 count += 1;
                 amount_rolled += resp.rollover_amount;
-                lfGrid.store.newItem(fieldmapper.acqf.toStoreItem(resp.fund));
             }, 
 
             oncomplete : function() {
                 
                 var nextYear = Number(year) + 1;
+                rolloverResponses = rolloverResponses.sort(
+                    function(a, b) {
+                        if(a.code() > b.code())
+                            return 1;
+                        return -1;
+                    }
+                )
 
                 dojo.byId('acq-fund-list-rollover-summary-header').innerHTML = 
                     dojo.string.substitute(
@@ -178,13 +211,23 @@ function performRollover(args) {
                         [nextYear, amount_rolled]
                     );
 
-                if(!args.dry_run) {
+                if(!dryRun) {
                     openils.Util.hide('acq-fund-list-rollover-summary-dry-run');
+                    
+                    // add the new year to the year selector if it's not already there
+                    fundFilterYearSelect.store.fetch({
+                        query : {year : nextYear}, 
+                        onComplete:
+                            function(list) {
+                                if(list && list.length > 0) return;
+                                fundFilterYearSelect.store.newItem({year : nextYear});
+                            }
+                    });
                 }
-                openils.Util.show('acq-fund-list-rollover-summary');
-
 
+                openils.Util.show('acq-fund-list-rollover-summary');
                 progressDialog.hide();
+                gridDataLoader();
             }
         }
     );
index 536d77e..4622fa1 100644 (file)
             <div dojoType="dijit.form.DropDownButton">
                 <span>Fund Propagation &amp; Rollover</span>
                 <div dojoType="dijit.TooltipDialog" execute="performRollover(arguments[0]);">
-                    <table class='dijitTooltipTable'>
+                    <table class='dijitTooltipTable' id='oils-acq-rollover-tooltip-table'>
                         <tr>
                             <td colspan='2'>
-                                <div style='width:400px;border-bottom:2px solid #888'>
+                                <div style='width:400px;'>
                                 Propagation creates new funds for the sugsequent fiscal year based on the
                                 funds for the selected fiscal year.  Only funds with the propagate setting
                                 enabled will be affected.  No money or encumbrances are altered
@@ -56,7 +56,7 @@
                         </tr>
                         <tr>
                             <td colspan='2'>
-                                <div style='width:400px;border-bottom:2px solid #888'>
+                                <div style='width:400px;'>
                                 The year end close out operation moves encumbrances from the selected fiscal
                                 year to the analogous funds in the subsequent fiscal year and it deactivates
                                 funds for the selected fiscal year.  Additionally, for all funds that have
                             </td>
                         </tr>
                         <tr>
+                            <td>Context Org Unit:</td>
+                            <td><span id='oils-acq-rollover-ctxt-org'></span></td>
+                        </tr>
+                        <tr>
+                            <td>Include Funds for Descendant Org Units:</td>
+                            <td><input dojoType=dijit.form.CheckBox name='child_orgs'/></td>
+                        </tr>
+                        <tr>
                             <td><label for="dry_run">Dry Run: </label></td>
                             <td>
                                 <input dojoType="dijit.form.CheckBox" name="dry_run" checked='checked'> </input>
@@ -73,7 +81,7 @@
                         </tr>
                         <tr>
                             <td colspan='2'>
-                                <div style='width:400px;border-bottom:2px solid #888'>
+                                <div style='width:400px;'>
                                 When Dry Run is selected, the system will generate a summary of
                                 the changes that would occur during the selected operation(s).
                                 No data will be changed.
         labelAttr="year"
         searchAttr="year">
     </select>
+
+    <div dojoType='dijit.form.Button' jsId='refreshButton'>Refresh</div>
 </div>
 
 <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
-    <div style='width:98%; margin-top:20px;'>
-        <div id='acq-fund-list-rollover-summary' class='hidden' style='width:50%; margin-left:auto; margin-right:auto;text-align:center;border:1px solid #888;'>
+    <div id='acq-fund-list-rollover-summary-wrapper'>
+        <div id='acq-fund-list-rollover-summary' class='hidden'>
             <div id='acq-fund-list-rollover-summary-header'> </div>
             <ul>
                 <li id='acq-fund-list-rollover-summary-dry-run'>These changes have <span class='oils-notify-text'>not</span> been committed yet.</li>