Acq: fund transfer UI
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Mar 2010 16:41:08 +0000 (16:41 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Mar 2010 16:41:08 +0000 (16:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16036 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index ea8eaa5..78e2bd1 100644 (file)
     padding: 4px;
 }
 .oils-acq-fund-tag A { margin-left: 10px; }
+#oils-acq-fund-xfer-table th { vertical-align: top; border-right: 1px solid #999; border-top: 1px solid #999; border-bottom: 1px solid #999; padding: 4px; }
+#oils-acq-fund-xfer-table td { padding-left: 24px; }
+#oils-acq-fund-xfer-name-fund { font-style: italic; }
+#oils-acq-fund-xfer-submit-row { text-align: center; }
 
 /* li search page */
 h1.oils-acq-li-search { font-size: 150%;font-weight: bold;margin-bottom: 12px; }
index 739b6c1..af3c777 100644 (file)
@@ -46,5 +46,7 @@
     'COULD_NOT_DELETE_MAPPING': "Error removing tag from fund.",
     'FUND_LIST_ROLLOVER_SUMMARY' : 'Fund Propagation &amp; Rollover Summary for Fiscal Year ${0}',
     'FUND_LIST_ROLLOVER_SUMMARY_FUNDS' : '<b>${1}</b> funds propagated for fiscal year ${0} for the selected locations',
-    'FUND_LIST_ROLLOVER_SUMMARY_ROLLOVER_AMOUNT' : '<b>$${1}</b> unspent money rolled over to fiscal year ${0} for the selected locations'
+    'FUND_LIST_ROLLOVER_SUMMARY_ROLLOVER_AMOUNT' : '<b>$${1}</b> unspent money rolled over to fiscal year ${0} for the selected locations',
+    'FUND_XFER_SAME_SOURCE_AND_DEST': "Cannot transfer. The source and destination funds are the same.",
+    'FUND_XFER_CONFIRM': "Are you sure you're ready to commit this transfer?"
 }
index eb0f0bd..5a0a779 100644 (file)
@@ -11,9 +11,11 @@ dojo.require('openils.acq.FundingSource');
 dojo.require('openils.Event');
 dojo.require('openils.User');
 dojo.require('openils.Util');
+dojo.require("openils.widget.AutoFieldWidget");
 
 var fund = null;
 var tagManager;
+var xferManager;
 
 function getSummaryInfo(rowIndex, item) {
     if(!item) return'';
@@ -80,9 +82,68 @@ function fetchFund() {
     );
 }
 
+function TransferManager() {
+    var self = this;
+
+    new openils.widget.AutoFieldWidget({
+        "fmField": "fund",
+        /* We're not really using LIDs here, we just need some class that has
+         * a fund field to take advantage of AutoFieldWidget's magic.
+         */
+        "fmClass": "acqlid",
+        "labelFormat": ["${0} (${1})", "code", "year"],
+        "searchFormat": ["${0} (${1})", "code", "year"],
+        "searchFilter": {"active": "t"}, /* consider making it possible to select inactive? */
+        "parentNode": dojo.byId("oils-acq-fund-xfer-d-selector"),
+        "orgLimitPerms": ["ADMIN_ACQ_FUND"], /* XXX is there a more appropriate permission for this? */
+        "dijitArgs": {"name": "d_fund"},
+        "forceSync": true
+    }).build(function(w, ww) { self.fundSelector = w; });
+
+    this.clearFundSelector = function() {
+        if (!this.fundSelector.attr("value"))
+            this.fundSelector.attr("value", "");
+    };
+
+    this.setFundName = function(fund) {
+        dojo.byId("oils-acq-fund-xfer-name-fund").innerHTML =
+            fund.code() + " (" + fund.year() + ") / " + fund.name();
+    };
+
+    this.submit = function() {
+        var values = xferDialog.getValues();
+        if (values.d_fund == fund.id()) {
+            alert(localeStrings.FUND_XFER_SAME_SOURCE_AND_DEST);
+            return false;
+        }
+        if (confirm(localeStrings.FUND_XFER_CONFIRM)) {
+            fieldmapper.standardRequest(
+                ["open-ils.acq", "open-ils.acq.funds.transfer_money"], {
+                    "params": [
+                        openils.User.authtoken,
+                        fund.id(), values.o_amount,
+                        values.d_fund, null,
+                        values.note
+                    ],
+                    "async": true,
+                    "oncomplete": function(r) {
+                        if (openils.Util.readResponse(r) == 1) {
+                            location.href = location.href;
+                        }
+                    }
+                }
+            );
+        }
+        return true;
+    };
+}
+
 function load() {
     tagManager = new TagManager(dojo.byId("oils-acq-tag-manager-display"));
     tagManager.prepareTagSelector(tagSelector);
+
+    xferManager = new TransferManager();
+
     fetchFund();
 }
 
index 4622fa1..937c277 100644 (file)
@@ -13,7 +13,7 @@
     }
 
     function formatName(value) {
-        if (!value) return "XXX"; // XXX
+        if (!value) return ""; // XXX
 
         var link = "<a href='/eg/acq/financial/view_fund/" +
             value.id + "'>" +
index 6945128..f98c385 100644 (file)
             </table>
         </div>
     </div> 
+    <div dojoType="dijit.form.DropDownButton">
+        <span>Transfer Money</span>
+        <div jsId="xferDialog" dojoType="dijit.TooltipDialog">
+            <script type="dojo/connect" event="onOpen">
+                /* If something is selected (from a previous time that the
+                user popped open this dialog), unselect it. Wouldn't want to
+                accidentally encourage a transfer that the user didn't mean. */
+                xferManager.clearFundSelector();
+                xferManager.setFundName(fund);
+            </script>
+            <table id="oils-acq-fund-xfer-table">
+                <tr>
+                    <th>
+                        <label for="oils-acq-fund-xfer-o-amount">
+                            Amount to transfer from<br />
+                            <span id="oils-acq-fund-xfer-name-fund"></span>
+                        </label>
+                    </th>
+                    <td>
+                        <input dojoType="dijit.form.CurrencyTextBox"
+                            id="oils-acq-fund-xfer-o-amount"
+                            name="o_amount" />
+                    </td>
+                </tr>
+                <tr>
+                    <th>
+                        <label for="oils-acq-fund-xfer-d-selector">
+                            Destination fund
+                        </label>
+                    </th>
+                    <td>
+                        <span id="oils-acq-fund-xfer-d-selector"></span>
+                    </td>
+                </tr>
+                <tr>
+                    <th>
+                        <label for="oils-acq-fund-xfer-note">Note</label>
+                    </th>
+                    <td>
+                        <input dojoType="dijit.form.TextBox" name="note"
+                            id="oils-acq-fund-xfer-note" />
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan="2" id="oils-acq-fund-xfer-submit-row">
+                        <button onclick="xferManager.submit();"
+                            dojoType="dijit.form.Button" type="submit">
+                            Transfer
+                        </button>
+                    </td>
+                </tr>
+            </table>
+        </div>
+    </div>
 </div>