--- /dev/null
+<div dojoType="dijit.Dialog" jsId='oilsFSOverAllocateDialog' style='display:none;'>
+ <p>[% l('You are attempting to allocate more money than is available in the funding source.') %]</p>
+ <td>
+ <button jsId='oilsFSOverAllocateContinue'
+ dojoType='dijit.form.Button'>[% l('Ok') %]</button>
+ </td>
+ <td>
+ <button jsId='oilsFSOverAllocateOverride'
+ dojoType='dijit.form.Button'>[% l('Override') %]</button>
+ </td>
+ </tr></table>
+</div>
+
function applyFSAllocation(fields) {
fields.funding_source = fundingSourceID;
+ //fs = openils.acq.FundingSource.retrieve(fundingSourceID, {flesh_summary:1});
+ var req = ses.request(
+ 'open-ils.acq.funding_source.retrieve',
+ openils.User.authtoken, fundingSourceID,
+ {flesh_summary:1}
+ );
+
+ req.oncomplete = function(r) {
+ var msg = req.recv();
+ fundingSource = msg.content();
+ }
+
+ req.send();
+
+ var balance = fundingSource.summary().balance;
+
if(isNaN(fields.amount)) fields.amount = null;
- openils.acq.Fund.createAllocation(
- fields, function() { resetPage(loadAllocationGrid); }
+
+ dojo.connect(oilsFSOverAllocateContinue, 'onClick',
+ function() {
+ oilsFSOverAllocateDialog.hide();
+ }
);
+
+ dojo.connect(oilsFSOverAllocateOverride, 'onClick',
+ function() {
+ oilsFSOverAllocateDialog.hide();
+ doAllocation(fields);
+ }
+ );
+
+ if(fields.amount > balance) {
+ oilsFSOverAllocateDialog.show();
+ } else {
+ doAllocation(fields);
+ }
+
+ function doAllocation(fields) {
+ openils.acq.Fund.createAllocation(
+ fields, function() { resetPage(loadAllocationGrid); }
+ );
+ }
}
/** fetch the fleshed funding source ----- */