method => 'update_user_request',
api_name => 'open-ils.acq.user_request.cancel.batch',
stream => 1,
+ signature => q/
+ If given a cancel reason, will update the request with that reason, otherwise, this will delete the request altogether. The intention
+ is for staff interfaces or processes to provide cancel reasons, and for patron interfaces to just delete the requests.
+ @param authtoken Login session key
+ @param ids Id or array of id's for the user requests to cancel.
+ @param cancel_reason Optional Cancel Reason Id.
+ /
);
__PACKAGE__->register_method (
method => 'update_user_request',
);
sub update_user_request {
- my($self, $conn, $auth, $aur_ids) = @_;
+ my($self, $conn, $auth, $aur_ids, $cancel_reason) = @_;
my $e = new_editor(xact => 1, authtoken => $auth);
return $e->die_event unless $e->checkauth;
my $rid = $e->requestor->id;
}
if($self->api_name =~ /cancel/) {
- $e->delete_acq_user_request($aur_obj);
+ if ( $cancel_reason ) {
+ $aur_obj->cancel_reason( $cancel_reason );
+ $e->update_acq_user_request($aur_obj) or return $e->die_event;
+ } else {
+ $e->delete_acq_user_request($aur_obj);
+ }
}
$conn->respond({maximum => scalar(@$aur_ids), progress => $x++});
'PO_CANCEL_CONFIRM': "Are you SURE you want to cancel this purchase order?",
'LI_CANCEL_CONFIRM': "Are you SURE you want to cancel this line item?",
'LID_CANCEL_CONFIRM': "Are you SURE you want to cancel this copy?",
+ 'UR_CANCEL_CONFIRM': "Are you SURE you want to cancel this user request?",
'CANCEL_REASON': "Cancel reason",
'CANCEL': "Cancel",
'YES': "Yes",
dojo.require('openils.widget.EditPane');
dojo.require("dijit.layout.StackContainer");
dojo.require('openils.PermaCrud');
+dojo.requireLocalization("openils.acq", "acq");
var contextOrg;
var aur_obj;
+var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
function setup() {
-
if(reqId) {
drawRequest();
} else {
drawList();
- rGrid.cancelSelected = function() { doSelected('open-ils.acq.user_request.cancel.batch') };
- rGrid.setNoHoldSelected = function() { doSelected('open-ils.acq.user_request.set_no_hold.batch') };
}
}
// toggle the View Picklist/Add to Picklist button label
if (aur_obj.lineitem()) {
- openils.Util.addCSSClass( document.getElementById('add_to_picklist'), 'hidden' );
- openils.Util.removeCSSClass( document.getElementById('view_picklist'), 'hidden' );
+ openils.Util.show( 'add_to_picklist' );
+ openils.Util.hide( 'view_picklist' );
} else {
- openils.Util.addCSSClass( document.getElementById('view_picklist'), 'hidden' );
- openils.Util.removeCSSClass( document.getElementById('add_to_picklist'), 'hidden' );
+ openils.Util.show( 'view_picklist' );
+ openils.Util.hide( 'add_to_picklist' );
}
// draw a detail page for a particular request
// including ability to add request to a picklist
// and to "reject" it (aka apply a cancel reason)
+
+ dojo.byId("acq-ur-cancel-reason").innerHTML = '';
+ var widget = new openils.widget.AutoFieldWidget({
+ "fmField": "cancel_reason",
+ "fmClass": "aur",
+ "parentNode": dojo.byId("acq-ur-cancel-reason"),
+ "orgLimitPerms": ["CREATE_PURCHASE_REQUEST"],
+ "forceSync": true
+ });
+
+ widget.build(
+ function(w, ww) {
+ acqUrCancelReasonSubmit.onClick = function() {
+ if (w.attr("value")) {
+ if (confirm( localeStrings.UR_CANCEL_CONFIRM )) {
+ fieldmapper.standardRequest(
+ [ 'open-ils.acq', 'open-ils.acq.user_request.cancel.batch' ],
+ { async: true,
+ params: [openils.User.authtoken, [reqId], w.attr("value")],
+ oncomplete: function(r) {
+ location.href = location.href; // kludge to reload the interface
+ }
+ }
+ );
+ }
+ }
+ };
+ }
+ );
+}
+
+function fooPicklist() {
+ if (aur_obj.lineitem()) {
+ viewPicklist();
+ } else {
+ addToPicklist();
+ }
+}
+
+function viewPicklist() {
+ var lineitem = fieldmapper.standardRequest(
+ [ 'open-ils.acq', 'open-ils.acq.lineitem.retrieve' ],
+ {
+ params: [openils.User.authtoken, aur_obj.lineitem()]
+ }
+ );
+ location.href = oilsBasePath + "/acq/picklist/view/" + lineitem.picklist();
}
function fooPicklist() {
);
}
-function cancelRequest() {
- // reqId, from detail view
- fieldmapper.standardRequest(
- [ 'open-ils.acq', 'open-ils.acq.user_request.cancel.batch' ],
- { async: true,
- params: [openils.User.authtoken, [reqId]],
- oncomplete: function(r) {
- drawRequest();
- }
- }
- );
-}
-
// format the title data as id:title
function getTitle(idx, item) {
if(item) {
);
}
-function doSelected(method) {
- try {
- var ids = [];
- dojo.forEach(
- rGrid.getSelectedItems(),
- function(item) {
- ids.push( rGrid.store.getValue(item,'id') );
- }
- );
- fieldmapper.standardRequest(
- [ 'open-ils.acq', method ],
- { async: true,
- params: [openils.User.authtoken, ids],
- onresponse: function(r) {
- try {
- var result = openils.Util.readResponse(r);
- if (typeof result.ilsevent != 'undefined') { throw(result); }
- } catch(E) {
- //dump('Error in acq/events.js, doSelected(), onresponse(): ' + E);
- throw(E);
- }
- },
- onerror: function(r) {
- try {
- var result = openils.Util.readResponse(r);
- throw(result);
- } catch(E) {
- //dump('Error in acq/events.js, doSelected(), onerror(): ' + E);
- throw(E);
- }
- },
- oncomplete: function(r) {
- try {
- var result = openils.Util.readResponse(r);
- rGrid.resetStore();
- buildGrid();
- } catch(E) {
- //dump('Error in acq/events.js, doSelected(), oncomplete(): ' + E);
- throw(E);
- }
- }
- }
- );
- } catch(E) {
- //dump('Error in acq/events.js, doSelected(): ' + E);
- throw(E);
- }
-}
-
openils.Util.addOnLoad(setup);
<!ENTITY staff.main.menu.acq.po.accesskey "P">
<!ENTITY staff.main.menu.acq.po_events.label "Purchase Order Events">
<!ENTITY staff.main.menu.acq.po_events.accesskey "E">
+<!ENTITY staff.main.menu.acq.user_requests.label "User Requests">
+<!ENTITY staff.main.menu.acq.user_requests.accesskey "R">
<!ENTITY staff.main.menu.acq.fund.label "Funds">
<!ENTITY staff.main.menu.acq.fund.accesskey "F">
<!ENTITY staff.main.menu.acq.funding_source.label "Funding Sources">
<div dojoType="dijit.layout.ContentPane">
<div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
<div>[% ctx.page_title %]</div>
- <div>
- <button dojoType="dijit.form.Button" onClick="rGrid.setNoHoldSelected()">Set No Hold on Selected</button>
- <button dojoType="dijit.form.Button" onClick="rGrid.cancelSelected()">Cancel Selected</button>
- </div>
</div>
<div>
<span>Context Org Unit</span>
<button dojoType="dijit.form.Button" onClick="location.href=oilsBasePath+'/acq/picklist/user_request'">[% ctx.page_title %]</button>
<button dojoType="dijit.form.Button" onClick="fooPicklist()"><span id="add_to_picklist">Add to Picklist</span><span id="view_picklist">View Picklist</span></button>
<button dojoType="dijit.form.Button" onClick="setNoHold()">Set No Hold</button>
- <button dojoType="dijit.form.Button" onClick="cancelRequest()">Cancel Request with Reason</button>
+ <span dojoType="dijit.form.DropDownButton">
+ <span>Cancel Request</span>
+ <span dojoType="dijit.TooltipDialog">
+ <label for="acq-ur-cancel-reason">
+ Reason:
+ </label>
+ <span id="acq-ur-cancel-reason"></span>
+ <button jsId="acqUrCancelReasonSubmit"
+ dojoType="dijit.form.Button"
+ type="submit">Cancel Request</button>
+ </span>
+ </span>
</div>
</div>
<div id="detail_content_pane" />
['oncommand'],
function() { open_eg_web_page('acq/po/events', 'menu.cmd_acq_view_po_events.tab'); }
],
+ 'cmd_acq_user_requests' : [
+ ['oncommand'],
+ function() { open_eg_web_page('acq/picklist/user_request', 'menu.cmd_acq_user_requests.tab'); }
+ ],
'cmd_acq_upload' : [
['oncommand'],
function() { open_eg_web_page('acq/picklist/upload', 'menu.cmd_acq_upload.tab'); }
<command id="cmd_acq_upload" />
<command id="cmd_acq_view_po" />
<command id="cmd_acq_view_po_events" />
+ <command id="cmd_acq_user_requests" />
<command id="cmd_acq_bib_search" />
<command id="cmd_acq_li_search" />
<command id="cmd_acq_new_brief_record" />
<menuseparator />
<menuitem label="&staff.main.menu.acq.po.label;" accesskey="&staff.main.menu.acq.po.accesskey;" command="cmd_acq_view_po" />
<menuitem label="&staff.main.menu.acq.po_events.label;" accesskey="&staff.main.menu.acq.po_events.accesskey;" command="cmd_acq_view_po_events" />
+ <menuitem label="&staff.main.menu.acq.user_requests.label;" accesskey="&staff.main.menu.acq.user_requests.accesskey;" command="cmd_acq_user_requests" />
<menuseparator />
<menuitem label="&staff.main.menu.acq.fund.label;" accesskey="&staff.main.menu.acq.fund.accesskey;" command="cmd_acq_view_fund" />
<menuitem label="&staff.main.menu.acq.funding_source.label;" accesskey="&staff.main.menu.acq.funding_source.accesskey;" command="cmd_acq_view_funding_source" />
menu.cmd_acq_new_brief_record.tab=New Brief Record
menu.cmd_acq_view_po.tab=Purchase Orders
menu.cmd_acq_view_po_events.tab=Purchase Order Events
+menu.cmd_acq_user_requests.tab=User Requests
menu.cmd_acq_view_fund.tab=Funds
menu.cmd_acq_view_funding_source.tab=Funding Sources
menu.cmd_acq_view_provider.tab=Providers