my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
+ my $override = 1 if $self->api_name =~ /override/;
+
my $holds = (ref($holds[0] eq 'ARRAY')) ? $holds[0] : [@holds];
for my $hold (@$holds) {
next unless $hold;
+ my @events;
my $requestor = $e->requestor;
my $recipient = $requestor;
$sargs->{holdable_formats} = $hold->holdable_formats if $t eq 'M';
- # XXX Put multi-hold-per-title perm here for staff
my $existing = $e->search_action_hold_request($sargs);
- my $eevt = OpenILS::Event->new('HOLD_EXISTS') if @$existing;
+ push( @events, OpenILS::Event->new('HOLD_EXISTS')) if @$existing;
if( $t eq 'M' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'MR_HOLDS'); }
if( $t eq 'T' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'TITLE_HOLDS'); }
if( $t eq 'V' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'VOLUME_HOLDS'); }
if( $t eq 'C' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'COPY_HOLDS'); }
+ return $pevt if $pevt;
- # COPY/VOLUME holds are allowed for staff, not overridable
- # XXX We need overridable events for staff XXX
-
- if( $pevt ) {
- if( $self->api_name =~ /override/ ) {
- # The recipient is not allowed to receive the requested hold
- # and the requestor has elected to override -
- # let's see if the requestor is allowed
- return $e->event unless $e->allowed('REQUEST_HOLDS_OVERRIDE', $porg);
+ if( @events ) {
+ if( $override ) {
+ for my $evt (@events) {
+ next unless $evt;
+ my $name = $evt->{textcode};
+ return $e->event unless $e->allowed("$name.override", $porg);
+ }
} else {
- return $pevt;
+ return \@events;
}
}
- if( $eevt ) {
- if( $self->api_name =~ /override/ ) {
- return $e->event unless $e->allowed('CREATE_DUPLICATE_HOLDS', $porg);
- } else {
- return $eevt;
- }
- }
+
+# if( $eevt ) {
+# if( $override ) {
+# return $e->event unless $e->allowed('CREATE_DUPLICATE_HOLDS', $porg);
+# } else {
+# return $eevt;
+# }
+# }
$hold->requestor($e->requestor->id);
$e->create_action_hold_request($hold) or return $e->event;
}
+ $e->commit;
return 1;
}
var FETCH_CROSSREF = "open-ils.search:open-ils.search.authority.crossref";
var FETCH_CROSSREF_BATCH = "open-ils.search:open-ils.search.authority.crossref.batch";
var CREATE_HOLD = "open-ils.circ:open-ils.circ.holds.create";
+var CREATE_HOLD_OVERRIDE = "open-ils.circ:open-ils.circ.holds.create.override";
var CANCEL_HOLD = "open-ils.circ:open-ils.circ.hold.cancel";
var UPDATE_USERNAME = "open-ils.actor:open-ils.actor.user.username.update";
var UPDATE_PASSWORD = "open-ils.actor:open-ils.actor.user.password.update";
var CHECK_USERNAME = 'open-ils.actor:open-ils.actor.username.exists';
var FETCH_CIRC_BY_ID = 'open-ils.circ:open-ils.circ.retrieve';
var FETCH_MR_DESCRIPTORS = 'open-ils.search:open-ils.search.metabib.record_to_descriptors';
+var FETCH_HIGHEST_PERM_ORG = 'open-ils.actor:open-ils.actor.user.perm.highest_org.batch';
/* ---------------------------------------------------------------------------- */
}
}
+ if(!$('holds_phone').value)
+ $('holds_enable_phone').checked = false;
+
appendClear($('holds_physical_desc'), text(rec.physical_description()));
if(holdArgs.type == 'M') hideMe($('hold_physical_desc_row'));
return hold;
}
-function holdsPlaceHold(hold) {
+function holdsPlaceHold(hold, recurse) {
if(!hold) return;
}
}
- var req = new Request( CREATE_HOLD, holdArgs.requestor.session, hold );
+ var method = CREATE_HOLD;
+ if(recurse) method = CREATE_HOLD_OVERRIDE;
+
+ var req = new Request( method, holdArgs.requestor.session, hold );
+ req.request.alertEvent = false;
req.send(true);
var res = req.result();
-
- if( res == '1' ) alert($('holds_success').innerHTML);
- else alert($('holds_failure').innerHTML);
+ holdProcessResult(hold, res, recurse);
showCanvas();
runEvt('common', 'holdUpdated');
}
+function holdProcessResult( hold, res, recurse ) {
+
+ if( res == '1' ) {
+ alert($('holds_success').innerHTML);
+
+ } else {
+
+ if( recurse ) {
+ alert($('holds_failure').innerHTML);
+ return;
+ }
+
+ if( grep(res, function(e) { return (e.textcode == 'HOLD_EXISTS'); }) ) {
+
+ /* see if the requestor has the ability to create duplicate holds */
+ var preq = new Request(FETCH_HIGHEST_PERM_ORG,
+ G.user.session, G.user.id(), ['CREATE_DUPLICATE_HOLDS']);
+ preq.send(true);
+ var org = preq.result()[0];
+
+ if( org ) {
+ if( confirm($('hold_dup_exists_override').innerHTML) ) {
+ holdsPlaceHold(hold, true);
+ }
+
+ } else {
+ alert($('hold_dup_exists').innerHTML);
+ return;
+ }
+ }
+ }
+}
+
+
function holdsCancel(holdid, user) {
if(!user) user = G.user;
var req = new Request(CANCEL_HOLD, user.session, holdid);
Please select a physical location where your hold can be delivered.
</span>
+ <span class='hide_me' id='hold_dup_exists'>
+ A hold already exists on the requested item
+ </span>
+
+ <span class='hide_me' id='hold_dup_exists_override'>
+ A hold already exists on the requested item. Would you like to create the hold anyway?
+ </span>
+
+
</div>