'COULD_NOT_DELETE_MAPPING': "Error removing tag from fund.",
'FUND_LIST_ROLLOVER_SUMMARY' : 'Fund Propagation & 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?"
}
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'';
);
}
+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();
}
</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>