From 9da7fa1f23e7bb7e3adf47eded6b1299491487e6 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 20 Sep 2011 10:27:51 -0400 Subject: [PATCH] Allow choice of placing hold despite age protect This alters the backend to watch when so much as one copy failed only due to age protection. If so, a flag is set and returned back up the calling tree for examination. In JSPac when the flag is set an alternate confirm message is shown. In TTPac when the flag is set the failure message is changed and override is always allowed for the hold in question. Signed-off-by: Thomas Berezansky --- .../perlmods/lib/OpenILS/Application/Circ/Holds.pm | 23 ++++++++-- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 7 ++- .../src/templates/opac/parts/place_hold_result.tt2 | 18 ++++---- Open-ILS/web/opac/locale/en-US/opac.dtd | 1 + Open-ILS/web/opac/skin/default/js/holds.js | 50 ++++++++++++++-------- .../web/opac/skin/default/xml/common/holds.xml | 1 + 6 files changed, 69 insertions(+), 31 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 6705d617de..9e64270b4b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -2193,9 +2193,9 @@ sub check_title_hold { }; } elsif ($status[2]) { my $n = scalar @{$status[2]}; - return {"success" => 0, "last_event" => $status[2]->[$n - 1]}; + return {"success" => 0, "last_event" => $status[2]->[$n - 1], "age_protected_copy" => $status[3]}; } else { - return {"success" => 0}; + return {"success" => 0, "age_protected_copy" => $status[3]}; } } @@ -2409,6 +2409,7 @@ sub _check_title_hold_is_possible { my $title; my %seen; my @status; + my $age_protect_only = 0; OUTER: for my $key (@keys) { my @cps = @{$buckets{$key}}; @@ -2430,10 +2431,12 @@ sub _check_title_hold_is_possible { @status = verify_copy_for_hold( $patron, $requestor, $title, $copy, $pickup_lib, $request_lib); + $age_protect_only ||= $status[3]; last OUTER if $status[0]; } } + $status[3] = $age_protect_only; return @status; } @@ -2535,6 +2538,7 @@ sub _check_issuance_hold_is_possible { my $title; my %seen; my @status; + my $age_protect_only = 0; OUTER: for my $key (@keys) { my @cps = @{$buckets{$key}}; @@ -2556,6 +2560,7 @@ sub _check_issuance_hold_is_possible { @status = verify_copy_for_hold( $patron, $requestor, $title, $copy, $pickup_lib, $request_lib); + $age_protect_only ||= $status[3]; last OUTER if $status[0]; } } @@ -2568,6 +2573,7 @@ sub _check_issuance_hold_is_possible { return (1,0) if ($empty_ok); } + $status[3] = $age_protect_only; return @status; } @@ -2669,6 +2675,7 @@ sub _check_monopart_hold_is_possible { my $title; my %seen; my @status; + my $age_protect_only = 0; OUTER: for my $key (@keys) { my @cps = @{$buckets{$key}}; @@ -2690,6 +2697,7 @@ sub _check_monopart_hold_is_possible { @status = verify_copy_for_hold( $patron, $requestor, $title, $copy, $pickup_lib, $request_lib); + $age_protect_only ||= $status[3]; last OUTER if $status[0]; } } @@ -2702,6 +2710,7 @@ sub _check_monopart_hold_is_possible { return (1,0) if ($empty_ok); } + $status[3] = $age_protect_only; return @status; } @@ -2730,11 +2739,14 @@ sub _check_volume_hold_is_possible { ) unless @$copies; my @status; + my $age_protect_only = 0; for my $copy ( @$copies ) { @status = verify_copy_for_hold( $patron, $requestor, $title, $copy, $pickup_lib, $request_lib ); + $age_protect_only ||= $status[3]; last if $status[0]; } + $status[3] = $age_protect_only; return @status; } @@ -2755,6 +2767,10 @@ sub verify_copy_for_hold { show_event_list => 1 } ); + my $age_protect_only = 0; + if (@$permitted == 1 && @$permitted[0]->{textcode} eq 'ITEM_AGE_PROTECTED') { + $age_protect_only = 1; + } return ( (not scalar @$permitted), # true if permitted is an empty arrayref @@ -2763,7 +2779,8 @@ sub verify_copy_for_hold { ($copy->circ_lib == $pickup_lib) and ($copy->status == OILS_COPY_STATUS_AVAILABLE) ), - $permitted + $permitted, + $age_protect_only ); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 116f8c5e28..578a0219d6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -800,7 +800,12 @@ sub attempt_hold_placement { $hdata->{hold_failed_event} = pop @$result; } - $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event}); + if($result->{age_protected_copy}) { + $hdata->{could_override} = 1; + $hdata->{age_protect} = 1; + } else { + $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event}); + } } } } diff --git a/Open-ILS/src/templates/opac/parts/place_hold_result.tt2 b/Open-ILS/src/templates/opac/parts/place_hold_result.tt2 index 87e2d40340..6504906b21 100644 --- a/Open-ILS/src/templates/opac/parts/place_hold_result.tt2 +++ b/Open-ILS/src/templates/opac/parts/place_hold_result.tt2 @@ -68,14 +68,16 @@ event_key = hdata.hold_failed_event.textcode; # display: - FAIL_PART_MSG_MAP.$fail_part_key || - EVENT_MSG_MAP.$event_key || - l(hdata.hold_failed_event.desc) || - hdata.hold_failed_event.payload.fail_part || - hdata.hold_failed_event.textcode || - (hdata.hold_local_alert ? - l("There is already a copy available at your local library.") : - l("Unknown problem")) | html + (hdata.age_protect ? + l("All available copies are temporarily unavailable at your pickup library. Placing this hold could result in longer wait times.") : + FAIL_PART_MSG_MAP.$fail_part_key || + EVENT_MSG_MAP.$event_key || + l(hdata.hold_failed_event.desc) || + hdata.hold_failed_event.payload.fail_part || + hdata.hold_failed_event.textcode || + (hdata.hold_local_alert ? + l("There is already a copy available at your local library.") : + l("Unknown problem"))) | html %] [% IF event_key == 'PERM_FAILURE' %]
[% l('Permission: "[_1]"', hdata.hold_failed_event.ilsperm) | html %]
diff --git a/Open-ILS/web/opac/locale/en-US/opac.dtd b/Open-ILS/web/opac/locale/en-US/opac.dtd index 545085a9ad..7bcf044f6b 100644 --- a/Open-ILS/web/opac/locale/en-US/opac.dtd +++ b/Open-ILS/web/opac/locale/en-US/opac.dtd @@ -619,6 +619,7 @@ We recommend that you remove this title from any bookbags it may have been added + &common.hold.exists.override; &common.hold.checked_out.override; + &common.hold.age_protect.override; &common.hold.barred; -- 2.11.0