$ratio = @{$exchange_rate}[0]->{ratio};
}
$dfund_amount = $ofund_amount * $ratio;
+ } else {
+ return $e->die_event unless $e->allowed("ACQ_XFER_MANUAL_DFUND_AMOUNT");
}
$e->json_query({
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0220); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0221'); -- senator
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
(385, 'CREATE_TRIGGER_VALIDATOR', oils_i18n_gettext(385, 'Allow a user to create trigger validators', 'ppl', 'description')),
(386, 'DELETE_TRIGGER_VALIDATOR', oils_i18n_gettext(386, 'Allow a user to delete trigger validators', 'ppl', 'description')),
(387, 'UPDATE_TRIGGER_VALIDATOR', oils_i18n_gettext(387, 'Allow a user to update trigger validators', 'ppl', 'description')),
- (388, 'UPDATE_ORG_UNIT_SETTING.circ.block_renews_for_holds', oils_i18n_gettext(388, 'Allow a user to enable blocking of renews on items that could fulfill holds', 'ppl', 'description'))
+ (388, 'UPDATE_ORG_UNIT_SETTING.circ.block_renews_for_holds', oils_i18n_gettext(388, 'Allow a user to enable blocking of renews on items that could fulfill holds', 'ppl', 'description')),
+ (389, 'ACQ_XFER_MANUAL_DFUND_AMOUNT', oils_i18n_gettext(389, 'Allow a user to transfer different amounts of money out of one fund and into another', 'ppl', 'description'))
;
SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0221'); -- senator
+
+INSERT INTO permission.perm_list (id, code, description)
+ VALUES (389, 'ACQ_XFER_MANUAL_DFUND_AMOUNT',
+ oils_i18n_gettext( 389, 'Allow a user to transfer different amounts of money out of one fund and into another', 'ppl', 'description' ));
+
+COMMIT;
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-table th { border-right: 1px solid #999; border-top: 1px solid #999; border-bottom: 1px solid #999; padding: 4px; }
+#oils-acq-fund-xfer-table td { padding: 4px 4px 4px 24px; }
#oils-acq-fund-xfer-submit-row { text-align: center; }
/* li search page */
dojo.require('dijit.layout.ContentPane');
dojo.require('dojox.grid.DataGrid');
dojo.require('dijit.form.CurrencyTextBox');
+dojo.require("dijit.form.CheckBox");
dojo.require('dojo.data.ItemFileReadStore');
dojo.require("fieldmapper.OrgUtils");
dojo.require('openils.acq.Fund');
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._init = function() {
+ 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": {
+ "onChange": function() {
+ openils.Util[
+ this.item.currency_type == fund.currency_type() ?
+ "hide" : "show"
+ ]("oils-acq-fund-xfer-dest-amount", "table-row");
+ }
+ },
+ "forceSync": true
+ }).build(function(w, ww) { self.fundSelector = w; });
+
+ dijit.byId("oils-acq-fund-xfer-same-o-d").onChange = function() {
+ dijit.byId("oils-acq-fund-xfer-d-amount").attr(
+ "disabled", this.attr("checked")
+ );
+ }
+ };
+
+ this._init();
this.clearFundSelector = function() {
- if (!this.fundSelector.attr("value"))
+ if (this.fundSelector.attr("value"))
this.fundSelector.attr("value", "");
};
this.submit = function() {
var values = xferDialog.getValues();
- if (values.d_fund == fund.id()) {
+ var dfund = this.fundSelector.item;
+ var dfund_id = typeof(dfund.id) == "object" ? dfund.id[0] : dfund.id;
+
+ if (dfund_id == fund.id()) {
alert(localeStrings.FUND_XFER_SAME_SOURCE_AND_DEST);
return false;
}
["open-ils.acq", "open-ils.acq.funds.transfer_money"], {
"params": [
openils.User.authtoken,
- fund.id(), values.o_amount,
- values.d_fund, null,
+ fund.id(),
+ values.o_amount,
+ dfund_id,
+ (dfund.currency_type != fund.currency_type() &&
+ values.same_o_d.length) ? null : values.d_amount,
values.note
],
"async": true,
}
);
}
- return true;
};
}
<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
+ /* If a fund 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();
<tr>
<th>
<label for="oils-acq-fund-xfer-o-amount">
- Amount to transfer from<br />
- <span id="oils-acq-fund-xfer-name-fund"></span>
+ Source amount<br />
+ <em>Amount to transfer from<br />
+ <span id="oils-acq-fund-xfer-name-fund"></span>
+ </em>
</label>
</th>
<td>
<span id="oils-acq-fund-xfer-d-selector"></span>
</td>
</tr>
+ <tr id="oils-acq-fund-xfer-dest-amount" class="hidden">
+ <th>
+ <label for="oils-acq-fund-xfer-d-selector">
+ Destination amount
+ </label>
+ </th>
+ <td>
+ <div class="oils-acq-basic-roomy">
+ <input id="oils-acq-fund-xfer-same-o-d"
+ dojoType="dijit.form.CheckBox" checked="checked"
+ value="1" name="same_o_d" />
+ <label for="oils-acq-fund-xfer-same-o-d">
+ Same as source amount?
+ </label>
+ </div>
+ <div class="oils-acq-basic-roomy">
+ <input id="oils-acq-fund-xfer-d-amount"
+ dojoType="dijit.form.CurrencyTextBox"
+ name="d_amount" disabled="disabled" />
+ </div>
+ </td>
+ </tr>
<tr>
<th>
<label for="oils-acq-fund-xfer-note">Note</label>