'available at the library where the user is placing the hold (or, alternatively, '.
'at the pickup library) to encourage bypassing the hold placement and just ' .
'checking out the item.' ,
- params => {
+ params => [
{ desc => 'Authentication Token', type => 'string' },
{ desc => 'Method Arguments. Options include: hold_type, hold_target, org_unit. '
. 'hold_type is the hold type code (T, V, C, M, ...). '
. 'hold_target is the identifier of the hold target object. '
. 'org_unit is org unit ID.',
type => 'object'
- },
- },
+ }
+ ],
return => {
desc => q/Result hash like { "copy" : copy_id, "location" : location_name }, empty hash on misses, event on error./,
type => 'object'
use OpenILS::Application::AppUtils;
use OpenILS::Event;
use OpenSRF::Utils::JSON;
+use Data::Dumper;
+$Data::Dumper::Indent = 0;
use DateTime;
my $U = 'OpenILS::Application::AppUtils';
# Find out whether we care that local copies are available
sub local_avail_concern {
- my ($self, $allowed, $request_lib) = @_;
-
- my ($block, $alert);
- if ($allowed->{"success"} and $allowed->{"local_avail"}) {
- $block = $self->ctx->{get_org_setting}->
- ($request_lib, "circ.holds.hold_has_copy_at.block");
- $alert = (
- $self->ctx->{get_org_setting}->
- ($request_lib, "circ.holds.hold_has_copy_at.alert")
- and not $self->cgi->param("override")
+ my ($self, $allowed, $hold_target, $hold_type, $pickup_lib) = @_;
+
+ my $would_block = $self->ctx->{get_org_setting}->
+ ($pickup_lib, "circ.holds.hold_has_copy_at.block");
+ my $would_alert = (
+ $self->ctx->{get_org_setting}->
+ ($pickup_lib, "circ.holds.hold_has_copy_at.alert") and
+ not $self->cgi->param("override")
+ ) unless $would_block;
+
+ if ($allowed->{"success"} and ($would_block or $would_alert)) {
+ my $args = {
+ "hold_target" => $hold_target,
+ "hold_type" => $hold_type,
+ "org_unit" => $pickup_lib
+ };
+ my $local_avail = $U->simplereq(
+ "open-ils.circ",
+ "open-ils.circ.hold.has_copy_at", $self->editor->authtoken, $args
+ );
+ $logger->info(
+ "copy availability information for " . Dumper($args) .
+ " is " . Dumper($local_avail)
);
+ if (%$local_avail) { # if hash not empty
+ $self->ctx->{hold_copy_available} = $local_avail;
+ return ($would_block, $would_alert);
+ }
}
- return ($block, $alert);
+
+ return (0, 0);
}
# context additions:
$logger->info('hold permit result ' . OpenSRF::Utils::JSON->perl2JSON($allowed));
- my ($local_block, $local_alert) =
- $self->local_avail_concern($allowed, $request_lib);
+ my ($local_block, $local_alert) = $self->local_avail_concern(
+ $allowed, $args->{$target_field}, $args->{hold_type}, $pickup_lib
+ );
+
+ # Give the original CGI params back to the user in case they
+ # want to try to override something.
+ $ctx->{orig_params} = $cgi->Vars;
if ($local_block) {
$ctx->{hold_failed} = 1;
} else {
$ctx->{hold_failed} = 1;
- # Give the original CGI params back to the user in case they
- # want to try to override something.
- $ctx->{orig_params} = $cgi->Vars;
delete $ctx->{orig_params}{submit};
if (ref $stat eq 'ARRAY') {
<div><big><strong>[% l("Hold was successfully placed"); %]</strong></big></div>
[% ELSIF ctx.hold_failed %]
<div><big><strong>[% l("Hold was not successfully placed"); %]</strong></big></div>
- [% IF ctx.hold_failed_event || ctx.hold_local_alert %]
+ [% IF ctx.hold_local_block %]
+ <div>[% l("There is already a copy available at your local library.") %]</div>
+ [% ELSIF ctx.hold_failed_event || ctx.hold_local_alert %]
<div>
<strong>[% l('Problem:') %]</strong>
<span title="[% ctx.hold_failed_event.textcode %]">
ctx.hold_failed_event.payload.fail_part ||
ctx.hold_failed_event.textcode ||
(ctx.hold_local_alert ?
- l("There is already a copy available at your local library") :
- l("Unknown problem")) %]
+ l("There is already a copy available at your local library.") :
+ l("Unknown problem")) %]</em>
</span>
- [% IF ctx.could_override %]
+
+ [% IF ctx.hold_copy_available %]<p>
+ [% l('Find a copy in the shelving location, "[_1]."',
+ ctx.hold_copy_available.location) %]
+ </p>[% END %]
+
+ [% IF ctx.could_override || ctx.hold_local_alert %]
<p>
<big>[% l("You have permission to place this hold anyway.") %]</big>
<br />
</tr>
</tbody>
</table>
- <div class='hide_me' id='holds_success'>[% l("Hold was successfully placed") %]</div>
- <div class='hide_me' id='holds_failure'>[% l("Hold was not successfully placed") %]</div>
<span class='hide_me' id='holds_bad_phone'>
[% l("The phone number does not have the correct format. The expected format is XXX-YYY-ZZZZ") %]
</span>