From a663dfed41126ba4607e500ccda85dd9fa113789 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 Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Circ/Holds.pm | 23 +++++++-- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 7 ++- .../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 ++++++++++++------- .../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 d083747114..fe1b93075c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -2256,9 +2256,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]}; } } @@ -2473,6 +2473,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}}; @@ -2494,10 +2495,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; } @@ -2599,6 +2602,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}}; @@ -2620,6 +2624,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]; } } @@ -2632,6 +2637,7 @@ sub _check_issuance_hold_is_possible { return (1,0) if ($empty_ok); } + $status[3] = $age_protect_only; return @status; } @@ -2733,6 +2739,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}}; @@ -2754,6 +2761,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]; } } @@ -2766,6 +2774,7 @@ sub _check_monopart_hold_is_possible { return (1,0) if ($empty_ok); } + $status[3] = $age_protect_only; return @status; } @@ -2794,11 +2803,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; } @@ -2819,6 +2831,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 @@ -2827,7 +2843,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 5c95809853..7f00cb6f07 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -892,7 +892,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.43.2